TopoShapeWirePy.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 TopoShapeWirePyImp.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 TopoShapeWirePy::Type = {
00021     PyObject_HEAD_INIT(&PyType_Type)
00022     0,                                                /*ob_size*/
00023     "Part.TopoShape",     /*tp_name*/
00024     sizeof(TopoShapeWirePy),                       /*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     "TopoShapeWire is the OpenCasCade topological wire wrapper",           /*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::TopoShapeWirePy::Methods,                     /*tp_methods */
00053     0,                                                /*tp_members */
00054     Part::TopoShapeWirePy::GetterSetter,                     /*tp_getset */
00055     &Part::TopoShapePy::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::TopoShapeWirePy::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 TopoShapeWirePy::Methods[] = {
00075     {"makeOffset",
00076         (PyCFunction) staticCallback_makeOffset,
00077         METH_VARARGS,
00078         "Offset the shape by a given ammount"
00079     },
00080     {"makeHomogenousWires",
00081         (PyCFunction) staticCallback_makeHomogenousWires,
00082         METH_VARARGS,
00083         "Make this and the given wire homogenous to have the same number of edges"
00084     },
00085     {"makePipe",
00086         (PyCFunction) staticCallback_makePipe,
00087         METH_VARARGS,
00088         "Make a pipe by sweeping along a wire."
00089     },
00090     {"makePipeShell",
00091         (PyCFunction) staticCallback_makePipeShell,
00092         METH_VARARGS,
00093         "Make a loft defined by profiles along a wire."
00094     },
00095     {"approximate",
00096         (PyCFunction) staticCallback_approximate,
00097         METH_VARARGS,
00098         "Approximate B-Spline-curve from this wire"
00099     },
00100     {NULL, NULL, 0, NULL}               /* Sentinel */
00101 };
00102 
00103 
00104 
00106 PyGetSetDef TopoShapeWirePy::GetterSetter[] = {
00107     {"CenterOfMass",
00108         (getter) staticCallback_getCenterOfMass,
00109         (setter) staticCallback_setCenterOfMass, 
00110         "Returns the center of mass of the current system.\nIf the gravitational field is uniform, it is the center of gravity.\nThe coordinates returned for the center of mass are expressed in the\nabsolute Cartesian coordinate system.",
00111         NULL
00112     },
00113     {NULL, NULL, NULL, NULL, NULL}              /* Sentinel */
00114 };
00115 
00116 // makeOffset() callback and implementer
00117 // PyObject*  TopoShapeWirePy::makeOffset(PyObject *args){};
00118 // has to be implemented in TopoShapeWirePyImp.cpp
00119 PyObject * TopoShapeWirePy::staticCallback_makeOffset (PyObject *self, PyObject *args)
00120 {
00121     // test if twin object not allready deleted
00122     if (!((PyObjectBase*) self)->isValid()){
00123         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00124         return NULL;
00125     }
00126 
00127     // test if object is set Const
00128     if (((PyObjectBase*) self)->isConst()){
00129         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00130         return NULL;
00131     }
00132 
00133     try { // catches all exceptions coming up from c++ and generate a python exception
00134         PyObject* ret = ((TopoShapeWirePy*)self)->makeOffset(args);
00135         if (ret != 0)
00136             ((TopoShapeWirePy*)self)->startNotify();
00137         return ret;
00138     }
00139     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00140     {
00141         std::string str;
00142         str += "FreeCAD exception thrown (";
00143         str += e.what();
00144         str += ")";
00145         e.ReportException();
00146         PyErr_SetString(PyExc_Exception,str.c_str());
00147         return NULL;
00148     }
00149     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00150     {
00151         std::string str;
00152         str += "File system exception thrown (";
00153         //str += e.who();
00154         //str += ", ";
00155         str += e.what();
00156         str += ")\n";
00157         Base::Console().Error(str.c_str());
00158         PyErr_SetString(PyExc_Exception,str.c_str());
00159         return NULL;
00160     }
00161     catch(const Py::Exception&)
00162     {
00163         // The exception text is already set
00164         return NULL;
00165     }
00166     catch(const char* e) // catch simple string exceptions
00167     {
00168         Base::Console().Error(e);
00169         PyErr_SetString(PyExc_Exception,e);
00170         return NULL;
00171     }
00172     // in debug not all exceptions will be catched to get the attention of the developer!
00173 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00174     catch(const std::exception& e) // catch other c++ exceptions
00175     {
00176         std::string str;
00177         str += "FC++ exception thrown (";
00178         str += e.what();
00179         str += ")";
00180         Base::Console().Error(str.c_str());
00181         PyErr_SetString(PyExc_Exception,str.c_str());
00182         return NULL;
00183     }
00184     catch(...)  // catch the rest!
00185     {
00186         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00187         return NULL;
00188     }
00189 #endif
00190 }
00191 
00192 // makeHomogenousWires() callback and implementer
00193 // PyObject*  TopoShapeWirePy::makeHomogenousWires(PyObject *args){};
00194 // has to be implemented in TopoShapeWirePyImp.cpp
00195 PyObject * TopoShapeWirePy::staticCallback_makeHomogenousWires (PyObject *self, PyObject *args)
00196 {
00197     // test if twin object not allready deleted
00198     if (!((PyObjectBase*) self)->isValid()){
00199         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00200         return NULL;
00201     }
00202 
00203     // test if object is set Const
00204     if (((PyObjectBase*) self)->isConst()){
00205         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00206         return NULL;
00207     }
00208 
00209     try { // catches all exceptions coming up from c++ and generate a python exception
00210         PyObject* ret = ((TopoShapeWirePy*)self)->makeHomogenousWires(args);
00211         if (ret != 0)
00212             ((TopoShapeWirePy*)self)->startNotify();
00213         return ret;
00214     }
00215     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00216     {
00217         std::string str;
00218         str += "FreeCAD exception thrown (";
00219         str += e.what();
00220         str += ")";
00221         e.ReportException();
00222         PyErr_SetString(PyExc_Exception,str.c_str());
00223         return NULL;
00224     }
00225     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00226     {
00227         std::string str;
00228         str += "File system exception thrown (";
00229         //str += e.who();
00230         //str += ", ";
00231         str += e.what();
00232         str += ")\n";
00233         Base::Console().Error(str.c_str());
00234         PyErr_SetString(PyExc_Exception,str.c_str());
00235         return NULL;
00236     }
00237     catch(const Py::Exception&)
00238     {
00239         // The exception text is already set
00240         return NULL;
00241     }
00242     catch(const char* e) // catch simple string exceptions
00243     {
00244         Base::Console().Error(e);
00245         PyErr_SetString(PyExc_Exception,e);
00246         return NULL;
00247     }
00248     // in debug not all exceptions will be catched to get the attention of the developer!
00249 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00250     catch(const std::exception& e) // catch other c++ exceptions
00251     {
00252         std::string str;
00253         str += "FC++ exception thrown (";
00254         str += e.what();
00255         str += ")";
00256         Base::Console().Error(str.c_str());
00257         PyErr_SetString(PyExc_Exception,str.c_str());
00258         return NULL;
00259     }
00260     catch(...)  // catch the rest!
00261     {
00262         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00263         return NULL;
00264     }
00265 #endif
00266 }
00267 
00268 // makePipe() callback and implementer
00269 // PyObject*  TopoShapeWirePy::makePipe(PyObject *args){};
00270 // has to be implemented in TopoShapeWirePyImp.cpp
00271 PyObject * TopoShapeWirePy::staticCallback_makePipe (PyObject *self, PyObject *args)
00272 {
00273     // test if twin object not allready deleted
00274     if (!((PyObjectBase*) self)->isValid()){
00275         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00276         return NULL;
00277     }
00278 
00279     // test if object is set Const
00280     if (((PyObjectBase*) self)->isConst()){
00281         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00282         return NULL;
00283     }
00284 
00285     try { // catches all exceptions coming up from c++ and generate a python exception
00286         PyObject* ret = ((TopoShapeWirePy*)self)->makePipe(args);
00287         if (ret != 0)
00288             ((TopoShapeWirePy*)self)->startNotify();
00289         return ret;
00290     }
00291     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00292     {
00293         std::string str;
00294         str += "FreeCAD exception thrown (";
00295         str += e.what();
00296         str += ")";
00297         e.ReportException();
00298         PyErr_SetString(PyExc_Exception,str.c_str());
00299         return NULL;
00300     }
00301     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00302     {
00303         std::string str;
00304         str += "File system exception thrown (";
00305         //str += e.who();
00306         //str += ", ";
00307         str += e.what();
00308         str += ")\n";
00309         Base::Console().Error(str.c_str());
00310         PyErr_SetString(PyExc_Exception,str.c_str());
00311         return NULL;
00312     }
00313     catch(const Py::Exception&)
00314     {
00315         // The exception text is already set
00316         return NULL;
00317     }
00318     catch(const char* e) // catch simple string exceptions
00319     {
00320         Base::Console().Error(e);
00321         PyErr_SetString(PyExc_Exception,e);
00322         return NULL;
00323     }
00324     // in debug not all exceptions will be catched to get the attention of the developer!
00325 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00326     catch(const std::exception& e) // catch other c++ exceptions
00327     {
00328         std::string str;
00329         str += "FC++ exception thrown (";
00330         str += e.what();
00331         str += ")";
00332         Base::Console().Error(str.c_str());
00333         PyErr_SetString(PyExc_Exception,str.c_str());
00334         return NULL;
00335     }
00336     catch(...)  // catch the rest!
00337     {
00338         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00339         return NULL;
00340     }
00341 #endif
00342 }
00343 
00344 // makePipeShell() callback and implementer
00345 // PyObject*  TopoShapeWirePy::makePipeShell(PyObject *args){};
00346 // has to be implemented in TopoShapeWirePyImp.cpp
00347 PyObject * TopoShapeWirePy::staticCallback_makePipeShell (PyObject *self, PyObject *args)
00348 {
00349     // test if twin object not allready deleted
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 NULL;
00353     }
00354 
00355     // test if object is set Const
00356     if (((PyObjectBase*) self)->isConst()){
00357         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00358         return NULL;
00359     }
00360 
00361     try { // catches all exceptions coming up from c++ and generate a python exception
00362         PyObject* ret = ((TopoShapeWirePy*)self)->makePipeShell(args);
00363         if (ret != 0)
00364             ((TopoShapeWirePy*)self)->startNotify();
00365         return ret;
00366     }
00367     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00368     {
00369         std::string str;
00370         str += "FreeCAD exception thrown (";
00371         str += e.what();
00372         str += ")";
00373         e.ReportException();
00374         PyErr_SetString(PyExc_Exception,str.c_str());
00375         return NULL;
00376     }
00377     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00378     {
00379         std::string str;
00380         str += "File system exception thrown (";
00381         //str += e.who();
00382         //str += ", ";
00383         str += e.what();
00384         str += ")\n";
00385         Base::Console().Error(str.c_str());
00386         PyErr_SetString(PyExc_Exception,str.c_str());
00387         return NULL;
00388     }
00389     catch(const Py::Exception&)
00390     {
00391         // The exception text is already set
00392         return NULL;
00393     }
00394     catch(const char* e) // catch simple string exceptions
00395     {
00396         Base::Console().Error(e);
00397         PyErr_SetString(PyExc_Exception,e);
00398         return NULL;
00399     }
00400     // in debug not all exceptions will be catched to get the attention of the developer!
00401 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00402     catch(const std::exception& e) // catch other c++ exceptions
00403     {
00404         std::string str;
00405         str += "FC++ exception thrown (";
00406         str += e.what();
00407         str += ")";
00408         Base::Console().Error(str.c_str());
00409         PyErr_SetString(PyExc_Exception,str.c_str());
00410         return NULL;
00411     }
00412     catch(...)  // catch the rest!
00413     {
00414         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00415         return NULL;
00416     }
00417 #endif
00418 }
00419 
00420 // approximate() callback and implementer
00421 // PyObject*  TopoShapeWirePy::approximate(PyObject *args){};
00422 // has to be implemented in TopoShapeWirePyImp.cpp
00423 PyObject * TopoShapeWirePy::staticCallback_approximate (PyObject *self, PyObject *args)
00424 {
00425     // test if twin object not allready deleted
00426     if (!((PyObjectBase*) self)->isValid()){
00427         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00428         return NULL;
00429     }
00430 
00431     // test if object is set Const
00432     if (((PyObjectBase*) self)->isConst()){
00433         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00434         return NULL;
00435     }
00436 
00437     try { // catches all exceptions coming up from c++ and generate a python exception
00438         PyObject* ret = ((TopoShapeWirePy*)self)->approximate(args);
00439         if (ret != 0)
00440             ((TopoShapeWirePy*)self)->startNotify();
00441         return ret;
00442     }
00443     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00444     {
00445         std::string str;
00446         str += "FreeCAD exception thrown (";
00447         str += e.what();
00448         str += ")";
00449         e.ReportException();
00450         PyErr_SetString(PyExc_Exception,str.c_str());
00451         return NULL;
00452     }
00453     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00454     {
00455         std::string str;
00456         str += "File system exception thrown (";
00457         //str += e.who();
00458         //str += ", ";
00459         str += e.what();
00460         str += ")\n";
00461         Base::Console().Error(str.c_str());
00462         PyErr_SetString(PyExc_Exception,str.c_str());
00463         return NULL;
00464     }
00465     catch(const Py::Exception&)
00466     {
00467         // The exception text is already set
00468         return NULL;
00469     }
00470     catch(const char* e) // catch simple string exceptions
00471     {
00472         Base::Console().Error(e);
00473         PyErr_SetString(PyExc_Exception,e);
00474         return NULL;
00475     }
00476     // in debug not all exceptions will be catched to get the attention of the developer!
00477 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00478     catch(const std::exception& e) // catch other c++ exceptions
00479     {
00480         std::string str;
00481         str += "FC++ exception thrown (";
00482         str += e.what();
00483         str += ")";
00484         Base::Console().Error(str.c_str());
00485         PyErr_SetString(PyExc_Exception,str.c_str());
00486         return NULL;
00487     }
00488     catch(...)  // catch the rest!
00489     {
00490         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00491         return NULL;
00492     }
00493 #endif
00494 }
00495 
00496 // CenterOfMass() callback and implementer
00497 // PyObject*  TopoShapeWirePy::CenterOfMass(PyObject *args){};
00498 // has to be implemented in TopoShapeWirePyImp.cpp
00499 PyObject * TopoShapeWirePy::staticCallback_getCenterOfMass (PyObject *self, void * /*closure*/)
00500 {
00501     if (!((PyObjectBase*) self)->isValid()){
00502         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00503         return NULL;
00504     }
00505 
00506     try {
00507         return Py::new_reference_to(((TopoShapeWirePy*)self)->getCenterOfMass());
00508     } catch (const Py::Exception&) {
00509         // The exception text is already set
00510         return NULL;
00511     } catch (...) {
00512         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'CenterOfMass' of object 'TopoShape'");
00513         return NULL;
00514     }
00515 }
00516 
00517 int TopoShapeWirePy::staticCallback_setCenterOfMass (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00518 {
00519     if (!((PyObjectBase*) self)->isValid()){
00520         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00521         return -1;
00522     }
00523 
00524     PyErr_SetString(PyExc_AttributeError, "Attribute 'CenterOfMass' of object 'TopoShape' is read-only");
00525     return -1;
00526 }
00527 
00528 
00529 
00530 //--------------------------------------------------------------------------
00531 // Parents structure
00532 //--------------------------------------------------------------------------
00533 PyParentObject TopoShapeWirePy::Parents[] = { PARENTSPartTopoShapeWirePy };
00534 
00535 //--------------------------------------------------------------------------
00536 // Constructor
00537 //--------------------------------------------------------------------------
00538 TopoShapeWirePy::TopoShapeWirePy(TopoShape *pcObject, PyTypeObject *T)
00539     : TopoShapePy(reinterpret_cast<TopoShapePy::PointerType>(pcObject), T)
00540 {
00541 }
00542 
00543 
00544 //--------------------------------------------------------------------------
00545 // destructor
00546 //--------------------------------------------------------------------------
00547 TopoShapeWirePy::~TopoShapeWirePy()                                // Everything handled in parent
00548 {
00549 }
00550 
00551 //--------------------------------------------------------------------------
00552 // TopoShapeWirePy representation
00553 //--------------------------------------------------------------------------
00554 PyObject *TopoShapeWirePy::_repr(void)
00555 {
00556     return Py_BuildValue("s", representation().c_str());
00557 }
00558 
00559 //--------------------------------------------------------------------------
00560 // TopoShapeWirePy Attributes
00561 //--------------------------------------------------------------------------
00562 PyObject *TopoShapeWirePy::_getattr(char *attr)                         // __getattr__ function: note only need to handle new state
00563 {
00564     try {
00565         // getter method for special Attributes (e.g. dynamic ones)
00566         PyObject *r = getCustomAttributes(attr);
00567         if(r) return r;
00568     }
00569 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00570     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00571     {
00572         std::string str;
00573         str += "FreeCAD exception thrown (";
00574         str += e.what();
00575         str += ")";
00576         e.ReportException();
00577         PyErr_SetString(PyExc_Exception,str.c_str());
00578         return NULL;
00579     }
00580     catch(const std::exception& e) // catch other c++ exceptions
00581     {
00582         std::string str;
00583         str += "FC++ exception thrown (";
00584         str += e.what();
00585         str += ")";
00586         Base::Console().Error(str.c_str());
00587         PyErr_SetString(PyExc_Exception,str.c_str());
00588         return NULL;
00589     }
00590     catch(const Py::Exception&)
00591     {
00592         // The exception text is already set
00593         return NULL;
00594     }
00595     catch(...)  // catch the rest!
00596     {
00597         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00598         return NULL;
00599     }
00600 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00601     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00602     {
00603         std::string str;
00604         str += "FreeCAD exception thrown (";
00605         str += e.what();
00606         str += ")";
00607         e.ReportException();
00608         PyErr_SetString(PyExc_Exception,str.c_str());
00609         return NULL;
00610     }
00611     catch(const Py::Exception&)
00612     {
00613         // The exception text is already set
00614         return NULL;
00615     }
00616 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00617 
00618     PyObject *rvalue = Py_FindMethod(Methods, this, attr);
00619     if (rvalue == NULL)
00620     {
00621         PyErr_Clear();
00622         return TopoShapePy::_getattr(attr);
00623     }
00624     else
00625     {
00626         return rvalue;
00627     }
00628 }
00629 
00630 int TopoShapeWirePy::_setattr(char *attr, PyObject *value)      // __setattr__ function: note only need to handle new state
00631 {
00632     try {
00633         // setter for  special Attributes (e.g. dynamic ones)
00634         int r = setCustomAttributes(attr, value);
00635         if(r==1) return 0;
00636     }
00637 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00638     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00639     {
00640         std::string str;
00641         str += "FreeCAD exception thrown (";
00642         str += e.what();
00643         str += ")";
00644         e.ReportException();
00645         PyErr_SetString(PyExc_Exception,str.c_str());
00646         return -1;
00647     }
00648     catch(const std::exception& e) // catch other c++ exceptions
00649     {
00650         std::string str;
00651         str += "FC++ exception thrown (";
00652         str += e.what();
00653         str += ")";
00654         Base::Console().Error(str.c_str());
00655         PyErr_SetString(PyExc_Exception,str.c_str());
00656         return -1;
00657     }
00658     catch(const Py::Exception&)
00659     {
00660         // The exception text is already set
00661         return -1;
00662     }
00663     catch(...)  // catch the rest!
00664     {
00665         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00666         return -1;
00667     }
00668 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00669     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00670     {
00671         std::string str;
00672         str += "FreeCAD exception thrown (";
00673         str += e.what();
00674         str += ")";
00675         e.ReportException();
00676         PyErr_SetString(PyExc_Exception,str.c_str());
00677         return -1;
00678     }
00679     catch(const Py::Exception&)
00680     {
00681         // The exception text is already set
00682         return -1;
00683     }
00684 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00685 
00686     return TopoShapePy::_setattr(attr, value);
00687 }
00688 
00689 TopoShape *TopoShapeWirePy::getTopoShapePtr(void) const
00690 {
00691     return static_cast<TopoShape *>(_pcTwinPointer);
00692 }
00693 
00694 #if 0
00695 /* From here on come the methods you have to implement, but NOT in this module. Implement in TopoShapeWirePyImp.cpp! This prototypes 
00696  * are just for convenience when you add a new method.
00697  */
00698 
00699 PyObject *TopoShapeWirePy::PyMake(struct _typeobject *, PyObject *, PyObject *)  // Python wrapper
00700 {
00701     // create a new instance of TopoShapeWirePy and the Twin object 
00702     return new TopoShapeWirePy(new TopoShape);
00703 }
00704 
00705 // constructor method
00706 int TopoShapeWirePy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
00707 {
00708     return 0;
00709 }
00710 
00711 // returns a string which represents the object e.g. when printed in python
00712 std::string TopoShapeWirePy::representation(void) const
00713 {
00714     return std::string("<TopoShape object>");
00715 }
00716 
00717 PyObject* TopoShapeWirePy::makeOffset(PyObject *args)
00718 {
00719     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00720     return 0;
00721 }
00722 
00723 PyObject* TopoShapeWirePy::makeHomogenousWires(PyObject *args)
00724 {
00725     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00726     return 0;
00727 }
00728 
00729 PyObject* TopoShapeWirePy::makePipe(PyObject *args)
00730 {
00731     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00732     return 0;
00733 }
00734 
00735 PyObject* TopoShapeWirePy::makePipeShell(PyObject *args)
00736 {
00737     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00738     return 0;
00739 }
00740 
00741 PyObject* TopoShapeWirePy::approximate(PyObject *args)
00742 {
00743     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00744     return 0;
00745 }
00746 
00747 
00748 
00749 Py::Object TopoShapeWirePy::getCenterOfMass(void) const
00750 {
00751     //return Py::Object();
00752     throw Py::AttributeError("Not yet implemented");
00753 }
00754 
00755 PyObject *TopoShapeWirePy::getCustomAttributes(const char* attr) const
00756 {
00757     return 0;
00758 }
00759 
00760 int TopoShapeWirePy::setCustomAttributes(const char* attr, PyObject *obj)
00761 {
00762     return 0; 
00763 }
00764 #endif
00765 
00766 
00767 

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