ToroidPy.cpp

Go to the documentation of this file.
00001 
00002 // This file is generated by src/Tools/generateTemaplates/templateClassPyExport.py out of the .XML file
00003 // Every change you make here get lost at the next full rebuild!
00004 // This File is normaly build as an include in ToroidPyImp.cpp! Its not intended to be in a project!
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 ToroidPy::Type = {
00021     PyObject_HEAD_INIT(&PyType_Type)
00022     0,                                                /*ob_size*/
00023     "Part.GeomToroid",     /*tp_name*/
00024     sizeof(ToroidPy),                       /*tp_basicsize*/
00025     0,                                                /*tp_itemsize*/
00026     /* methods */
00027     PyDestructor,                                     /*tp_dealloc*/
00028     0,                                                /*tp_print*/
00029     __getattr,                                        /*tp_getattr*/
00030     __setattr,                                        /*tp_setattr*/
00031     0,                                                /*tp_compare*/
00032     __repr,                                           /*tp_repr*/
00033     0,                                                /*tp_as_number*/
00034     0,                                                /*tp_as_sequence*/
00035     0,                                                /*tp_as_mapping*/
00036     0,                                                /*tp_hash*/
00037     0,                                                /*tp_call */
00038     0,                                                /*tp_str  */
00039     0,                                                /*tp_getattro*/
00040     0,                                                /*tp_setattro*/
00041     /* --- Functions to access object as input/output buffer ---------*/
00042     0,                                                /* tp_as_buffer */
00043     /* --- Flags to define presence of optional/expanded features */
00044     Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_CLASS,        /*tp_flags */
00045     "Describes a toroid in 3D space",           /*tp_doc */
00046     0,                                                /*tp_traverse */
00047     0,                                                /*tp_clear */
00048     0,                                                /*tp_richcompare */
00049     0,                                                /*tp_weaklistoffset */
00050     0,                                                /*tp_iter */
00051     0,                                                /*tp_iternext */
00052     Part::ToroidPy::Methods,                     /*tp_methods */
00053     0,                                                /*tp_members */
00054     Part::ToroidPy::GetterSetter,                     /*tp_getset */
00055     &Part::GeometrySurfacePy::Type,                        /*tp_base */
00056     0,                                                /*tp_dict */
00057     0,                                                /*tp_descr_get */
00058     0,                                                /*tp_descr_set */
00059     0,                                                /*tp_dictoffset */
00060     __PyInit,                                         /*tp_init */
00061     0,                                                /*tp_alloc */
00062     Part::ToroidPy::PyMake,/*tp_new */
00063     0,                                                /*tp_free   Low-level free-memory routine */
00064     0,                                                /*tp_is_gc  For PyObject_IS_GC */
00065     0,                                                /*tp_bases */
00066     0,                                                /*tp_mro    method resolution order */
00067     0,                                                /*tp_cache */
00068     0,                                                /*tp_subclasses */
00069     0,                                                /*tp_weaklist */
00070     0                                                 /*tp_del */
00071 };
00072 
00074 PyMethodDef ToroidPy::Methods[] = {
00075     {"uIso",
00076         (PyCFunction) staticCallback_uIso,
00077         METH_VARARGS,
00078         "Builds the U isoparametric circle of this toroid"
00079     },
00080     {"vIso",
00081         (PyCFunction) staticCallback_vIso,
00082         METH_VARARGS,
00083         "Builds the V isoparametric circle of this toroid"
00084     },
00085     {NULL, NULL, 0, NULL}               /* Sentinel */
00086 };
00087 
00088 
00089 
00091 PyGetSetDef ToroidPy::GetterSetter[] = {
00092     {"MajorRadius",
00093         (getter) staticCallback_getMajorRadius,
00094         (setter) staticCallback_setMajorRadius, 
00095         "The major radius of the toroid.",
00096         NULL
00097     },
00098     {"MinorRadius",
00099         (getter) staticCallback_getMinorRadius,
00100         (setter) staticCallback_setMinorRadius, 
00101         "The minor radius of the toroid.",
00102         NULL
00103     },
00104     {"Center",
00105         (getter) staticCallback_getCenter,
00106         (setter) staticCallback_setCenter, 
00107         "Center of the toroid.",
00108         NULL
00109     },
00110     {"Axis",
00111         (getter) staticCallback_getAxis,
00112         (setter) staticCallback_setAxis, 
00113         "The axis direction of the toroid",
00114         NULL
00115     },
00116     {"Area",
00117         (getter) staticCallback_getArea,
00118         (setter) staticCallback_setArea, 
00119         "Compute the area of the toroid.",
00120         NULL
00121     },
00122     {"Volume",
00123         (getter) staticCallback_getVolume,
00124         (setter) staticCallback_setVolume, 
00125         "Compute the volume of the toroid.",
00126         NULL
00127     },
00128     {NULL, NULL, NULL, NULL, NULL}              /* Sentinel */
00129 };
00130 
00131 // uIso() callback and implementer
00132 // PyObject*  ToroidPy::uIso(PyObject *args){};
00133 // has to be implemented in ToroidPyImp.cpp
00134 PyObject * ToroidPy::staticCallback_uIso (PyObject *self, PyObject *args)
00135 {
00136     // test if twin object not allready deleted
00137     if (!((PyObjectBase*) self)->isValid()){
00138         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00139         return NULL;
00140     }
00141 
00142     // test if object is set Const
00143     if (((PyObjectBase*) self)->isConst()){
00144         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00145         return NULL;
00146     }
00147 
00148     try { // catches all exceptions coming up from c++ and generate a python exception
00149         PyObject* ret = ((ToroidPy*)self)->uIso(args);
00150         if (ret != 0)
00151             ((ToroidPy*)self)->startNotify();
00152         return ret;
00153     }
00154     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00155     {
00156         std::string str;
00157         str += "FreeCAD exception thrown (";
00158         str += e.what();
00159         str += ")";
00160         e.ReportException();
00161         PyErr_SetString(PyExc_Exception,str.c_str());
00162         return NULL;
00163     }
00164     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00165     {
00166         std::string str;
00167         str += "File system exception thrown (";
00168         //str += e.who();
00169         //str += ", ";
00170         str += e.what();
00171         str += ")\n";
00172         Base::Console().Error(str.c_str());
00173         PyErr_SetString(PyExc_Exception,str.c_str());
00174         return NULL;
00175     }
00176     catch(const Py::Exception&)
00177     {
00178         // The exception text is already set
00179         return NULL;
00180     }
00181     catch(const char* e) // catch simple string exceptions
00182     {
00183         Base::Console().Error(e);
00184         PyErr_SetString(PyExc_Exception,e);
00185         return NULL;
00186     }
00187     // in debug not all exceptions will be catched to get the attention of the developer!
00188 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00189     catch(const std::exception& e) // catch other c++ exceptions
00190     {
00191         std::string str;
00192         str += "FC++ exception thrown (";
00193         str += e.what();
00194         str += ")";
00195         Base::Console().Error(str.c_str());
00196         PyErr_SetString(PyExc_Exception,str.c_str());
00197         return NULL;
00198     }
00199     catch(...)  // catch the rest!
00200     {
00201         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00202         return NULL;
00203     }
00204 #endif
00205 }
00206 
00207 // vIso() callback and implementer
00208 // PyObject*  ToroidPy::vIso(PyObject *args){};
00209 // has to be implemented in ToroidPyImp.cpp
00210 PyObject * ToroidPy::staticCallback_vIso (PyObject *self, PyObject *args)
00211 {
00212     // test if twin object not allready deleted
00213     if (!((PyObjectBase*) self)->isValid()){
00214         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00215         return NULL;
00216     }
00217 
00218     // test if object is set Const
00219     if (((PyObjectBase*) self)->isConst()){
00220         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00221         return NULL;
00222     }
00223 
00224     try { // catches all exceptions coming up from c++ and generate a python exception
00225         PyObject* ret = ((ToroidPy*)self)->vIso(args);
00226         if (ret != 0)
00227             ((ToroidPy*)self)->startNotify();
00228         return ret;
00229     }
00230     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00231     {
00232         std::string str;
00233         str += "FreeCAD exception thrown (";
00234         str += e.what();
00235         str += ")";
00236         e.ReportException();
00237         PyErr_SetString(PyExc_Exception,str.c_str());
00238         return NULL;
00239     }
00240     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00241     {
00242         std::string str;
00243         str += "File system exception thrown (";
00244         //str += e.who();
00245         //str += ", ";
00246         str += e.what();
00247         str += ")\n";
00248         Base::Console().Error(str.c_str());
00249         PyErr_SetString(PyExc_Exception,str.c_str());
00250         return NULL;
00251     }
00252     catch(const Py::Exception&)
00253     {
00254         // The exception text is already set
00255         return NULL;
00256     }
00257     catch(const char* e) // catch simple string exceptions
00258     {
00259         Base::Console().Error(e);
00260         PyErr_SetString(PyExc_Exception,e);
00261         return NULL;
00262     }
00263     // in debug not all exceptions will be catched to get the attention of the developer!
00264 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00265     catch(const std::exception& e) // catch other c++ exceptions
00266     {
00267         std::string str;
00268         str += "FC++ exception thrown (";
00269         str += e.what();
00270         str += ")";
00271         Base::Console().Error(str.c_str());
00272         PyErr_SetString(PyExc_Exception,str.c_str());
00273         return NULL;
00274     }
00275     catch(...)  // catch the rest!
00276     {
00277         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00278         return NULL;
00279     }
00280 #endif
00281 }
00282 
00283 // MajorRadius() callback and implementer
00284 // PyObject*  ToroidPy::MajorRadius(PyObject *args){};
00285 // has to be implemented in ToroidPyImp.cpp
00286 PyObject * ToroidPy::staticCallback_getMajorRadius (PyObject *self, void * /*closure*/)
00287 {
00288     if (!((PyObjectBase*) self)->isValid()){
00289         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00290         return NULL;
00291     }
00292 
00293     try {
00294         return Py::new_reference_to(((ToroidPy*)self)->getMajorRadius());
00295     } catch (const Py::Exception&) {
00296         // The exception text is already set
00297         return NULL;
00298     } catch (...) {
00299         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'MajorRadius' of object 'GeomToroid'");
00300         return NULL;
00301     }
00302 }
00303 
00304 int ToroidPy::staticCallback_setMajorRadius (PyObject *self, PyObject *value, void * /*closure*/)
00305 {    
00306     if (!((PyObjectBase*) self)->isValid()){
00307         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00308         return -1;
00309     }
00310     if (((PyObjectBase*) self)->isConst()){
00311         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00312         return -1;
00313     }
00314 
00315     try {
00316         ((ToroidPy*)self)->setMajorRadius(Py::Float(value,false));
00317         return 0;
00318     } catch (const Py::Exception&) {
00319         // The exception text is already set
00320         return -1;
00321     } catch (...) {
00322         PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'MajorRadius' of object 'GeomToroid'");
00323         return -1;
00324     }
00325 }
00326 
00327 // MinorRadius() callback and implementer
00328 // PyObject*  ToroidPy::MinorRadius(PyObject *args){};
00329 // has to be implemented in ToroidPyImp.cpp
00330 PyObject * ToroidPy::staticCallback_getMinorRadius (PyObject *self, void * /*closure*/)
00331 {
00332     if (!((PyObjectBase*) self)->isValid()){
00333         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00334         return NULL;
00335     }
00336 
00337     try {
00338         return Py::new_reference_to(((ToroidPy*)self)->getMinorRadius());
00339     } catch (const Py::Exception&) {
00340         // The exception text is already set
00341         return NULL;
00342     } catch (...) {
00343         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'MinorRadius' of object 'GeomToroid'");
00344         return NULL;
00345     }
00346 }
00347 
00348 int ToroidPy::staticCallback_setMinorRadius (PyObject *self, PyObject *value, void * /*closure*/)
00349 {    
00350     if (!((PyObjectBase*) self)->isValid()){
00351         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00352         return -1;
00353     }
00354     if (((PyObjectBase*) self)->isConst()){
00355         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00356         return -1;
00357     }
00358 
00359     try {
00360         ((ToroidPy*)self)->setMinorRadius(Py::Float(value,false));
00361         return 0;
00362     } catch (const Py::Exception&) {
00363         // The exception text is already set
00364         return -1;
00365     } catch (...) {
00366         PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'MinorRadius' of object 'GeomToroid'");
00367         return -1;
00368     }
00369 }
00370 
00371 // Center() callback and implementer
00372 // PyObject*  ToroidPy::Center(PyObject *args){};
00373 // has to be implemented in ToroidPyImp.cpp
00374 PyObject * ToroidPy::staticCallback_getCenter (PyObject *self, void * /*closure*/)
00375 {
00376     if (!((PyObjectBase*) self)->isValid()){
00377         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00378         return NULL;
00379     }
00380 
00381     try {
00382         return Py::new_reference_to(((ToroidPy*)self)->getCenter());
00383     } catch (const Py::Exception&) {
00384         // The exception text is already set
00385         return NULL;
00386     } catch (...) {
00387         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Center' of object 'GeomToroid'");
00388         return NULL;
00389     }
00390 }
00391 
00392 int ToroidPy::staticCallback_setCenter (PyObject *self, PyObject *value, void * /*closure*/)
00393 {    
00394     if (!((PyObjectBase*) self)->isValid()){
00395         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00396         return -1;
00397     }
00398     if (((PyObjectBase*) self)->isConst()){
00399         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00400         return -1;
00401     }
00402 
00403     try {
00404         ((ToroidPy*)self)->setCenter(Py::Object(value,false));
00405         return 0;
00406     } catch (const Py::Exception&) {
00407         // The exception text is already set
00408         return -1;
00409     } catch (...) {
00410         PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Center' of object 'GeomToroid'");
00411         return -1;
00412     }
00413 }
00414 
00415 // Axis() callback and implementer
00416 // PyObject*  ToroidPy::Axis(PyObject *args){};
00417 // has to be implemented in ToroidPyImp.cpp
00418 PyObject * ToroidPy::staticCallback_getAxis (PyObject *self, void * /*closure*/)
00419 {
00420     if (!((PyObjectBase*) self)->isValid()){
00421         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00422         return NULL;
00423     }
00424 
00425     try {
00426         return Py::new_reference_to(((ToroidPy*)self)->getAxis());
00427     } catch (const Py::Exception&) {
00428         // The exception text is already set
00429         return NULL;
00430     } catch (...) {
00431         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Axis' of object 'GeomToroid'");
00432         return NULL;
00433     }
00434 }
00435 
00436 int ToroidPy::staticCallback_setAxis (PyObject *self, PyObject *value, void * /*closure*/)
00437 {    
00438     if (!((PyObjectBase*) self)->isValid()){
00439         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00440         return -1;
00441     }
00442     if (((PyObjectBase*) self)->isConst()){
00443         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00444         return -1;
00445     }
00446 
00447     try {
00448         ((ToroidPy*)self)->setAxis(Py::Object(value,false));
00449         return 0;
00450     } catch (const Py::Exception&) {
00451         // The exception text is already set
00452         return -1;
00453     } catch (...) {
00454         PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Axis' of object 'GeomToroid'");
00455         return -1;
00456     }
00457 }
00458 
00459 // Area() callback and implementer
00460 // PyObject*  ToroidPy::Area(PyObject *args){};
00461 // has to be implemented in ToroidPyImp.cpp
00462 PyObject * ToroidPy::staticCallback_getArea (PyObject *self, void * /*closure*/)
00463 {
00464     if (!((PyObjectBase*) self)->isValid()){
00465         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00466         return NULL;
00467     }
00468 
00469     try {
00470         return Py::new_reference_to(((ToroidPy*)self)->getArea());
00471     } catch (const Py::Exception&) {
00472         // The exception text is already set
00473         return NULL;
00474     } catch (...) {
00475         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Area' of object 'GeomToroid'");
00476         return NULL;
00477     }
00478 }
00479 
00480 int ToroidPy::staticCallback_setArea (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00481 {
00482     if (!((PyObjectBase*) self)->isValid()){
00483         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00484         return -1;
00485     }
00486 
00487     PyErr_SetString(PyExc_AttributeError, "Attribute 'Area' of object 'GeomToroid' is read-only");
00488     return -1;
00489 }
00490 
00491 // Volume() callback and implementer
00492 // PyObject*  ToroidPy::Volume(PyObject *args){};
00493 // has to be implemented in ToroidPyImp.cpp
00494 PyObject * ToroidPy::staticCallback_getVolume (PyObject *self, void * /*closure*/)
00495 {
00496     if (!((PyObjectBase*) self)->isValid()){
00497         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00498         return NULL;
00499     }
00500 
00501     try {
00502         return Py::new_reference_to(((ToroidPy*)self)->getVolume());
00503     } catch (const Py::Exception&) {
00504         // The exception text is already set
00505         return NULL;
00506     } catch (...) {
00507         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Volume' of object 'GeomToroid'");
00508         return NULL;
00509     }
00510 }
00511 
00512 int ToroidPy::staticCallback_setVolume (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00513 {
00514     if (!((PyObjectBase*) self)->isValid()){
00515         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00516         return -1;
00517     }
00518 
00519     PyErr_SetString(PyExc_AttributeError, "Attribute 'Volume' of object 'GeomToroid' is read-only");
00520     return -1;
00521 }
00522 
00523 
00524 
00525 //--------------------------------------------------------------------------
00526 // Parents structure
00527 //--------------------------------------------------------------------------
00528 PyParentObject ToroidPy::Parents[] = { PARENTSPartToroidPy };
00529 
00530 //--------------------------------------------------------------------------
00531 // Constructor
00532 //--------------------------------------------------------------------------
00533 ToroidPy::ToroidPy(GeomToroid *pcObject, PyTypeObject *T)
00534     : GeometrySurfacePy(reinterpret_cast<GeometrySurfacePy::PointerType>(pcObject), T)
00535 {
00536 }
00537 
00538 
00539 //--------------------------------------------------------------------------
00540 // destructor
00541 //--------------------------------------------------------------------------
00542 ToroidPy::~ToroidPy()                                // Everything handled in parent
00543 {
00544 }
00545 
00546 //--------------------------------------------------------------------------
00547 // ToroidPy representation
00548 //--------------------------------------------------------------------------
00549 PyObject *ToroidPy::_repr(void)
00550 {
00551     return Py_BuildValue("s", representation().c_str());
00552 }
00553 
00554 //--------------------------------------------------------------------------
00555 // ToroidPy Attributes
00556 //--------------------------------------------------------------------------
00557 PyObject *ToroidPy::_getattr(char *attr)                                // __getattr__ function: note only need to handle new state
00558 {
00559     try {
00560         // getter method for special Attributes (e.g. dynamic ones)
00561         PyObject *r = getCustomAttributes(attr);
00562         if(r) return r;
00563     }
00564 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00565     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00566     {
00567         std::string str;
00568         str += "FreeCAD exception thrown (";
00569         str += e.what();
00570         str += ")";
00571         e.ReportException();
00572         PyErr_SetString(PyExc_Exception,str.c_str());
00573         return NULL;
00574     }
00575     catch(const std::exception& e) // catch other c++ exceptions
00576     {
00577         std::string str;
00578         str += "FC++ exception thrown (";
00579         str += e.what();
00580         str += ")";
00581         Base::Console().Error(str.c_str());
00582         PyErr_SetString(PyExc_Exception,str.c_str());
00583         return NULL;
00584     }
00585     catch(const Py::Exception&)
00586     {
00587         // The exception text is already set
00588         return NULL;
00589     }
00590     catch(...)  // catch the rest!
00591     {
00592         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00593         return NULL;
00594     }
00595 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00596     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00597     {
00598         std::string str;
00599         str += "FreeCAD exception thrown (";
00600         str += e.what();
00601         str += ")";
00602         e.ReportException();
00603         PyErr_SetString(PyExc_Exception,str.c_str());
00604         return NULL;
00605     }
00606     catch(const Py::Exception&)
00607     {
00608         // The exception text is already set
00609         return NULL;
00610     }
00611 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00612 
00613     PyObject *rvalue = Py_FindMethod(Methods, this, attr);
00614     if (rvalue == NULL)
00615     {
00616         PyErr_Clear();
00617         return GeometrySurfacePy::_getattr(attr);
00618     }
00619     else
00620     {
00621         return rvalue;
00622     }
00623 }
00624 
00625 int ToroidPy::_setattr(char *attr, PyObject *value)     // __setattr__ function: note only need to handle new state
00626 {
00627     try {
00628         // setter for  special Attributes (e.g. dynamic ones)
00629         int r = setCustomAttributes(attr, value);
00630         if(r==1) return 0;
00631     }
00632 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00633     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00634     {
00635         std::string str;
00636         str += "FreeCAD exception thrown (";
00637         str += e.what();
00638         str += ")";
00639         e.ReportException();
00640         PyErr_SetString(PyExc_Exception,str.c_str());
00641         return -1;
00642     }
00643     catch(const std::exception& e) // catch other c++ exceptions
00644     {
00645         std::string str;
00646         str += "FC++ exception thrown (";
00647         str += e.what();
00648         str += ")";
00649         Base::Console().Error(str.c_str());
00650         PyErr_SetString(PyExc_Exception,str.c_str());
00651         return -1;
00652     }
00653     catch(const Py::Exception&)
00654     {
00655         // The exception text is already set
00656         return -1;
00657     }
00658     catch(...)  // catch the rest!
00659     {
00660         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00661         return -1;
00662     }
00663 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00664     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00665     {
00666         std::string str;
00667         str += "FreeCAD exception thrown (";
00668         str += e.what();
00669         str += ")";
00670         e.ReportException();
00671         PyErr_SetString(PyExc_Exception,str.c_str());
00672         return -1;
00673     }
00674     catch(const Py::Exception&)
00675     {
00676         // The exception text is already set
00677         return -1;
00678     }
00679 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00680 
00681     return GeometrySurfacePy::_setattr(attr, value);
00682 }
00683 
00684 GeomToroid *ToroidPy::getGeomToroidPtr(void) const
00685 {
00686     return static_cast<GeomToroid *>(_pcTwinPointer);
00687 }
00688 
00689 #if 0
00690 /* From here on come the methods you have to implement, but NOT in this module. Implement in ToroidPyImp.cpp! This prototypes 
00691  * are just for convenience when you add a new method.
00692  */
00693 
00694 PyObject *ToroidPy::PyMake(struct _typeobject *, PyObject *, PyObject *)  // Python wrapper
00695 {
00696     // create a new instance of ToroidPy and the Twin object 
00697     return new ToroidPy(new GeomToroid);
00698 }
00699 
00700 // constructor method
00701 int ToroidPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
00702 {
00703     return 0;
00704 }
00705 
00706 // returns a string which represents the object e.g. when printed in python
00707 std::string ToroidPy::representation(void) const
00708 {
00709     return std::string("<GeomToroid object>");
00710 }
00711 
00712 PyObject* ToroidPy::uIso(PyObject *args)
00713 {
00714     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00715     return 0;
00716 }
00717 
00718 PyObject* ToroidPy::vIso(PyObject *args)
00719 {
00720     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00721     return 0;
00722 }
00723 
00724 
00725 
00726 Py::Float ToroidPy::getMajorRadius(void) const
00727 {
00728     //return Py::Float();
00729     throw Py::AttributeError("Not yet implemented");
00730 }
00731 
00732 void  ToroidPy::setMajorRadius(Py::Float arg)
00733 {
00734     throw Py::AttributeError("Not yet implemented");
00735 }
00736 
00737 Py::Float ToroidPy::getMinorRadius(void) const
00738 {
00739     //return Py::Float();
00740     throw Py::AttributeError("Not yet implemented");
00741 }
00742 
00743 void  ToroidPy::setMinorRadius(Py::Float arg)
00744 {
00745     throw Py::AttributeError("Not yet implemented");
00746 }
00747 
00748 Py::Object ToroidPy::getCenter(void) const
00749 {
00750     //return Py::Object();
00751     throw Py::AttributeError("Not yet implemented");
00752 }
00753 
00754 void  ToroidPy::setCenter(Py::Object arg)
00755 {
00756     throw Py::AttributeError("Not yet implemented");
00757 }
00758 
00759 Py::Object ToroidPy::getAxis(void) const
00760 {
00761     //return Py::Object();
00762     throw Py::AttributeError("Not yet implemented");
00763 }
00764 
00765 void  ToroidPy::setAxis(Py::Object arg)
00766 {
00767     throw Py::AttributeError("Not yet implemented");
00768 }
00769 
00770 Py::Float ToroidPy::getArea(void) const
00771 {
00772     //return Py::Float();
00773     throw Py::AttributeError("Not yet implemented");
00774 }
00775 
00776 Py::Float ToroidPy::getVolume(void) const
00777 {
00778     //return Py::Float();
00779     throw Py::AttributeError("Not yet implemented");
00780 }
00781 
00782 PyObject *ToroidPy::getCustomAttributes(const char* attr) const
00783 {
00784     return 0;
00785 }
00786 
00787 int ToroidPy::setCustomAttributes(const char* attr, PyObject *obj)
00788 {
00789     return 0; 
00790 }
00791 #endif
00792 
00793 
00794 

Generated on Wed Nov 23 19:00:49 2011 for FreeCAD by  doxygen 1.6.1