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

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