00001
00002
00003
00004
00005
00006 #include <boost/filesystem/path.hpp>
00007 #include <boost/filesystem/operations.hpp>
00008 #include <boost/filesystem/exception.hpp>
00009 #include <Base/PyObjectBase.h>
00010 #include <Base/Console.h>
00011 #include <Base/Exception.h>
00012 #include <CXX/Objects.hxx>
00013
00014 #define new DEBUG_CLIENTBLOCK
00015
00016 using Base::streq;
00017 using namespace Part;
00018
00020 PyTypeObject ArcOfCirclePy::Type = {
00021 PyObject_HEAD_INIT(&PyType_Type)
00022 0,
00023 "Part.GeomArcOfCircle",
00024 sizeof(ArcOfCirclePy),
00025 0,
00026
00027 PyDestructor,
00028 0,
00029 __getattr,
00030 __setattr,
00031 0,
00032 __repr,
00033 0,
00034 0,
00035 0,
00036 0,
00037 0,
00038 0,
00039 0,
00040 0,
00041
00042 0,
00043
00044 Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_CLASS,
00045 "Describes a portion of a circle",
00046 0,
00047 0,
00048 0,
00049 0,
00050 0,
00051 0,
00052 Part::ArcOfCirclePy::Methods,
00053 0,
00054 Part::ArcOfCirclePy::GetterSetter,
00055 &Part::GeometryCurvePy::Type,
00056 0,
00057 0,
00058 0,
00059 0,
00060 __PyInit,
00061 0,
00062 Part::ArcOfCirclePy::PyMake,
00063 0,
00064 0,
00065 0,
00066 0,
00067 0,
00068 0,
00069 0,
00070 0
00071 };
00072
00074 PyMethodDef ArcOfCirclePy::Methods[] = {
00075 {NULL, NULL, 0, NULL}
00076 };
00077
00078
00079
00081 PyGetSetDef ArcOfCirclePy::GetterSetter[] = {
00082 {"Radius",
00083 (getter) staticCallback_getRadius,
00084 (setter) staticCallback_setRadius,
00085 "The radius of the circle.",
00086 NULL
00087 },
00088 {"Center",
00089 (getter) staticCallback_getCenter,
00090 (setter) staticCallback_setCenter,
00091 "Center of the circle.",
00092 NULL
00093 },
00094 {"Axis",
00095 (getter) staticCallback_getAxis,
00096 (setter) staticCallback_setAxis,
00097 "The axis direction of the circle",
00098 NULL
00099 },
00100 {"Circle",
00101 (getter) staticCallback_getCircle,
00102 (setter) staticCallback_setCircle,
00103 "The internal circle representation",
00104 NULL
00105 },
00106 {NULL, NULL, NULL, NULL, NULL}
00107 };
00108
00109
00110
00111
00112 PyObject * ArcOfCirclePy::staticCallback_getRadius (PyObject *self, void * )
00113 {
00114 if (!((PyObjectBase*) self)->isValid()){
00115 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00116 return NULL;
00117 }
00118
00119 try {
00120 return Py::new_reference_to(((ArcOfCirclePy*)self)->getRadius());
00121 } catch (const Py::Exception&) {
00122
00123 return NULL;
00124 } catch (...) {
00125 PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Radius' of object 'GeomArcOfCircle'");
00126 return NULL;
00127 }
00128 }
00129
00130 int ArcOfCirclePy::staticCallback_setRadius (PyObject *self, PyObject *value, void * )
00131 {
00132 if (!((PyObjectBase*) self)->isValid()){
00133 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00134 return -1;
00135 }
00136 if (((PyObjectBase*) self)->isConst()){
00137 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00138 return -1;
00139 }
00140
00141 try {
00142 ((ArcOfCirclePy*)self)->setRadius(Py::Float(value,false));
00143 return 0;
00144 } catch (const Py::Exception&) {
00145
00146 return -1;
00147 } catch (...) {
00148 PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Radius' of object 'GeomArcOfCircle'");
00149 return -1;
00150 }
00151 }
00152
00153
00154
00155
00156 PyObject * ArcOfCirclePy::staticCallback_getCenter (PyObject *self, void * )
00157 {
00158 if (!((PyObjectBase*) self)->isValid()){
00159 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00160 return NULL;
00161 }
00162
00163 try {
00164 return Py::new_reference_to(((ArcOfCirclePy*)self)->getCenter());
00165 } catch (const Py::Exception&) {
00166
00167 return NULL;
00168 } catch (...) {
00169 PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Center' of object 'GeomArcOfCircle'");
00170 return NULL;
00171 }
00172 }
00173
00174 int ArcOfCirclePy::staticCallback_setCenter (PyObject *self, PyObject *value, void * )
00175 {
00176 if (!((PyObjectBase*) self)->isValid()){
00177 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00178 return -1;
00179 }
00180 if (((PyObjectBase*) self)->isConst()){
00181 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00182 return -1;
00183 }
00184
00185 try {
00186 ((ArcOfCirclePy*)self)->setCenter(Py::Object(value,false));
00187 return 0;
00188 } catch (const Py::Exception&) {
00189
00190 return -1;
00191 } catch (...) {
00192 PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Center' of object 'GeomArcOfCircle'");
00193 return -1;
00194 }
00195 }
00196
00197
00198
00199
00200 PyObject * ArcOfCirclePy::staticCallback_getAxis (PyObject *self, void * )
00201 {
00202 if (!((PyObjectBase*) self)->isValid()){
00203 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00204 return NULL;
00205 }
00206
00207 try {
00208 return Py::new_reference_to(((ArcOfCirclePy*)self)->getAxis());
00209 } catch (const Py::Exception&) {
00210
00211 return NULL;
00212 } catch (...) {
00213 PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Axis' of object 'GeomArcOfCircle'");
00214 return NULL;
00215 }
00216 }
00217
00218 int ArcOfCirclePy::staticCallback_setAxis (PyObject *self, PyObject *value, void * )
00219 {
00220 if (!((PyObjectBase*) self)->isValid()){
00221 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00222 return -1;
00223 }
00224 if (((PyObjectBase*) self)->isConst()){
00225 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00226 return -1;
00227 }
00228
00229 try {
00230 ((ArcOfCirclePy*)self)->setAxis(Py::Object(value,false));
00231 return 0;
00232 } catch (const Py::Exception&) {
00233
00234 return -1;
00235 } catch (...) {
00236 PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Axis' of object 'GeomArcOfCircle'");
00237 return -1;
00238 }
00239 }
00240
00241
00242
00243
00244 PyObject * ArcOfCirclePy::staticCallback_getCircle (PyObject *self, void * )
00245 {
00246 if (!((PyObjectBase*) self)->isValid()){
00247 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00248 return NULL;
00249 }
00250
00251 try {
00252 return Py::new_reference_to(((ArcOfCirclePy*)self)->getCircle());
00253 } catch (const Py::Exception&) {
00254
00255 return NULL;
00256 } catch (...) {
00257 PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Circle' of object 'GeomArcOfCircle'");
00258 return NULL;
00259 }
00260 }
00261
00262 int ArcOfCirclePy::staticCallback_setCircle (PyObject *self, PyObject * , void * )
00263 {
00264 if (!((PyObjectBase*) self)->isValid()){
00265 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00266 return -1;
00267 }
00268
00269 PyErr_SetString(PyExc_AttributeError, "Attribute 'Circle' of object 'GeomArcOfCircle' is read-only");
00270 return -1;
00271 }
00272
00273
00274
00275
00276
00277
00278 PyParentObject ArcOfCirclePy::Parents[] = { PARENTSPartArcOfCirclePy };
00279
00280
00281
00282
00283 ArcOfCirclePy::ArcOfCirclePy(GeomArcOfCircle *pcObject, PyTypeObject *T)
00284 : GeometryCurvePy(reinterpret_cast<GeometryCurvePy::PointerType>(pcObject), T)
00285 {
00286 }
00287
00288
00289
00290
00291
00292 ArcOfCirclePy::~ArcOfCirclePy()
00293 {
00294 }
00295
00296
00297
00298
00299 PyObject *ArcOfCirclePy::_repr(void)
00300 {
00301 return Py_BuildValue("s", representation().c_str());
00302 }
00303
00304
00305
00306
00307 PyObject *ArcOfCirclePy::_getattr(char *attr)
00308 {
00309 try {
00310
00311 PyObject *r = getCustomAttributes(attr);
00312 if(r) return r;
00313 }
00314 #ifndef DONT_CATCH_CXX_EXCEPTIONS
00315 catch(const Base::Exception& e)
00316 {
00317 std::string str;
00318 str += "FreeCAD exception thrown (";
00319 str += e.what();
00320 str += ")";
00321 e.ReportException();
00322 PyErr_SetString(PyExc_Exception,str.c_str());
00323 return NULL;
00324 }
00325 catch(const std::exception& e)
00326 {
00327 std::string str;
00328 str += "FC++ exception thrown (";
00329 str += e.what();
00330 str += ")";
00331 Base::Console().Error(str.c_str());
00332 PyErr_SetString(PyExc_Exception,str.c_str());
00333 return NULL;
00334 }
00335 catch(const Py::Exception&)
00336 {
00337
00338 return NULL;
00339 }
00340 catch(...)
00341 {
00342 PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00343 return NULL;
00344 }
00345 #else // DONT_CATCH_CXX_EXCEPTIONS
00346 catch(const Base::Exception& e)
00347 {
00348 std::string str;
00349 str += "FreeCAD exception thrown (";
00350 str += e.what();
00351 str += ")";
00352 e.ReportException();
00353 PyErr_SetString(PyExc_Exception,str.c_str());
00354 return NULL;
00355 }
00356 catch(const Py::Exception&)
00357 {
00358
00359 return NULL;
00360 }
00361 #endif // DONT_CATCH_CXX_EXCEPTIONS
00362
00363 PyObject *rvalue = Py_FindMethod(Methods, this, attr);
00364 if (rvalue == NULL)
00365 {
00366 PyErr_Clear();
00367 return GeometryCurvePy::_getattr(attr);
00368 }
00369 else
00370 {
00371 return rvalue;
00372 }
00373 }
00374
00375 int ArcOfCirclePy::_setattr(char *attr, PyObject *value)
00376 {
00377 try {
00378
00379 int r = setCustomAttributes(attr, value);
00380 if(r==1) return 0;
00381 }
00382 #ifndef DONT_CATCH_CXX_EXCEPTIONS
00383 catch(const Base::Exception& e)
00384 {
00385 std::string str;
00386 str += "FreeCAD exception thrown (";
00387 str += e.what();
00388 str += ")";
00389 e.ReportException();
00390 PyErr_SetString(PyExc_Exception,str.c_str());
00391 return -1;
00392 }
00393 catch(const std::exception& e)
00394 {
00395 std::string str;
00396 str += "FC++ exception thrown (";
00397 str += e.what();
00398 str += ")";
00399 Base::Console().Error(str.c_str());
00400 PyErr_SetString(PyExc_Exception,str.c_str());
00401 return -1;
00402 }
00403 catch(const Py::Exception&)
00404 {
00405
00406 return -1;
00407 }
00408 catch(...)
00409 {
00410 PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00411 return -1;
00412 }
00413 #else // DONT_CATCH_CXX_EXCEPTIONS
00414 catch(const Base::Exception& e)
00415 {
00416 std::string str;
00417 str += "FreeCAD exception thrown (";
00418 str += e.what();
00419 str += ")";
00420 e.ReportException();
00421 PyErr_SetString(PyExc_Exception,str.c_str());
00422 return -1;
00423 }
00424 catch(const Py::Exception&)
00425 {
00426
00427 return -1;
00428 }
00429 #endif // DONT_CATCH_CXX_EXCEPTIONS
00430
00431 return GeometryCurvePy::_setattr(attr, value);
00432 }
00433
00434 GeomArcOfCircle *ArcOfCirclePy::getGeomArcOfCirclePtr(void) const
00435 {
00436 return static_cast<GeomArcOfCircle *>(_pcTwinPointer);
00437 }
00438
00439 #if 0
00440
00441
00442
00443
00444 PyObject *ArcOfCirclePy::PyMake(struct _typeobject *, PyObject *, PyObject *)
00445 {
00446
00447 return new ArcOfCirclePy(new GeomArcOfCircle);
00448 }
00449
00450
00451 int ArcOfCirclePy::PyInit(PyObject* , PyObject* )
00452 {
00453 return 0;
00454 }
00455
00456
00457 std::string ArcOfCirclePy::representation(void) const
00458 {
00459 return std::string("<GeomArcOfCircle object>");
00460 }
00461
00462
00463
00464 Py::Float ArcOfCirclePy::getRadius(void) const
00465 {
00466
00467 throw Py::AttributeError("Not yet implemented");
00468 }
00469
00470 void ArcOfCirclePy::setRadius(Py::Float arg)
00471 {
00472 throw Py::AttributeError("Not yet implemented");
00473 }
00474
00475 Py::Object ArcOfCirclePy::getCenter(void) const
00476 {
00477
00478 throw Py::AttributeError("Not yet implemented");
00479 }
00480
00481 void ArcOfCirclePy::setCenter(Py::Object arg)
00482 {
00483 throw Py::AttributeError("Not yet implemented");
00484 }
00485
00486 Py::Object ArcOfCirclePy::getAxis(void) const
00487 {
00488
00489 throw Py::AttributeError("Not yet implemented");
00490 }
00491
00492 void ArcOfCirclePy::setAxis(Py::Object arg)
00493 {
00494 throw Py::AttributeError("Not yet implemented");
00495 }
00496
00497 Py::Object ArcOfCirclePy::getCircle(void) const
00498 {
00499
00500 throw Py::AttributeError("Not yet implemented");
00501 }
00502
00503 PyObject *ArcOfCirclePy::getCustomAttributes(const char* attr) const
00504 {
00505 return 0;
00506 }
00507
00508 int ArcOfCirclePy::setCustomAttributes(const char* attr, PyObject *obj)
00509 {
00510 return 0;
00511 }
00512 #endif
00513
00514
00515