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

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