TopoShapeVertexPy.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 TopoShapeVertexPyImp.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 TopoShapeVertexPy::Type = {
00021     PyObject_HEAD_INIT(&PyType_Type)
00022     0,                                                /*ob_size*/
00023     "Part.TopoShape",     /*tp_name*/
00024     sizeof(TopoShapeVertexPy),                       /*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     "TopoShapeVertex is the OpenCasCade topological vertex 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::TopoShapeVertexPy::Methods,                     /*tp_methods */
00053     0,                                                /*tp_members */
00054     Part::TopoShapeVertexPy::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::TopoShapeVertexPy::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 TopoShapeVertexPy::Methods[] = {
00075     {"setTolerance",
00076         (PyCFunction) staticCallback_setTolerance,
00077         METH_VARARGS,
00078         "Set the tolerance for the vertex."
00079     },
00080     {NULL, NULL, 0, NULL}               /* Sentinel */
00081 };
00082 
00083 
00084 
00086 PyGetSetDef TopoShapeVertexPy::GetterSetter[] = {
00087     {"X",
00088         (getter) staticCallback_getX,
00089         (setter) staticCallback_setX, 
00090         "X component of this Vertex.",
00091         NULL
00092     },
00093     {"Y",
00094         (getter) staticCallback_getY,
00095         (setter) staticCallback_setY, 
00096         "Y component of this Vertex.",
00097         NULL
00098     },
00099     {"Z",
00100         (getter) staticCallback_getZ,
00101         (setter) staticCallback_setZ, 
00102         "Z component of this Vertex.",
00103         NULL
00104     },
00105     {"Point",
00106         (getter) staticCallback_getPoint,
00107         (setter) staticCallback_setPoint, 
00108         "Position of this Vertex as a Vector",
00109         NULL
00110     },
00111     {NULL, NULL, NULL, NULL, NULL}              /* Sentinel */
00112 };
00113 
00114 // setTolerance() callback and implementer
00115 // PyObject*  TopoShapeVertexPy::setTolerance(PyObject *args){};
00116 // has to be implemented in TopoShapeVertexPyImp.cpp
00117 PyObject * TopoShapeVertexPy::staticCallback_setTolerance (PyObject *self, PyObject *args)
00118 {
00119     // test if twin object not allready deleted
00120     if (!((PyObjectBase*) self)->isValid()){
00121         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00122         return NULL;
00123     }
00124 
00125     // test if object is set Const
00126     if (((PyObjectBase*) self)->isConst()){
00127         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00128         return NULL;
00129     }
00130 
00131     try { // catches all exceptions coming up from c++ and generate a python exception
00132         PyObject* ret = ((TopoShapeVertexPy*)self)->setTolerance(args);
00133         if (ret != 0)
00134             ((TopoShapeVertexPy*)self)->startNotify();
00135         return ret;
00136     }
00137     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00138     {
00139         std::string str;
00140         str += "FreeCAD exception thrown (";
00141         str += e.what();
00142         str += ")";
00143         e.ReportException();
00144         PyErr_SetString(PyExc_Exception,str.c_str());
00145         return NULL;
00146     }
00147     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00148     {
00149         std::string str;
00150         str += "File system exception thrown (";
00151         //str += e.who();
00152         //str += ", ";
00153         str += e.what();
00154         str += ")\n";
00155         Base::Console().Error(str.c_str());
00156         PyErr_SetString(PyExc_Exception,str.c_str());
00157         return NULL;
00158     }
00159     catch(const Py::Exception&)
00160     {
00161         // The exception text is already set
00162         return NULL;
00163     }
00164     catch(const char* e) // catch simple string exceptions
00165     {
00166         Base::Console().Error(e);
00167         PyErr_SetString(PyExc_Exception,e);
00168         return NULL;
00169     }
00170     // in debug not all exceptions will be catched to get the attention of the developer!
00171 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00172     catch(const std::exception& e) // catch other c++ exceptions
00173     {
00174         std::string str;
00175         str += "FC++ exception thrown (";
00176         str += e.what();
00177         str += ")";
00178         Base::Console().Error(str.c_str());
00179         PyErr_SetString(PyExc_Exception,str.c_str());
00180         return NULL;
00181     }
00182     catch(...)  // catch the rest!
00183     {
00184         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00185         return NULL;
00186     }
00187 #endif
00188 }
00189 
00190 // X() callback and implementer
00191 // PyObject*  TopoShapeVertexPy::X(PyObject *args){};
00192 // has to be implemented in TopoShapeVertexPyImp.cpp
00193 PyObject * TopoShapeVertexPy::staticCallback_getX (PyObject *self, void * /*closure*/)
00194 {
00195     if (!((PyObjectBase*) self)->isValid()){
00196         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00197         return NULL;
00198     }
00199 
00200     try {
00201         return Py::new_reference_to(((TopoShapeVertexPy*)self)->getX());
00202     } catch (const Py::Exception&) {
00203         // The exception text is already set
00204         return NULL;
00205     } catch (...) {
00206         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'X' of object 'TopoShape'");
00207         return NULL;
00208     }
00209 }
00210 
00211 int TopoShapeVertexPy::staticCallback_setX (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00212 {
00213     if (!((PyObjectBase*) self)->isValid()){
00214         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00215         return -1;
00216     }
00217 
00218     PyErr_SetString(PyExc_AttributeError, "Attribute 'X' of object 'TopoShape' is read-only");
00219     return -1;
00220 }
00221 
00222 // Y() callback and implementer
00223 // PyObject*  TopoShapeVertexPy::Y(PyObject *args){};
00224 // has to be implemented in TopoShapeVertexPyImp.cpp
00225 PyObject * TopoShapeVertexPy::staticCallback_getY (PyObject *self, void * /*closure*/)
00226 {
00227     if (!((PyObjectBase*) self)->isValid()){
00228         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00229         return NULL;
00230     }
00231 
00232     try {
00233         return Py::new_reference_to(((TopoShapeVertexPy*)self)->getY());
00234     } catch (const Py::Exception&) {
00235         // The exception text is already set
00236         return NULL;
00237     } catch (...) {
00238         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Y' of object 'TopoShape'");
00239         return NULL;
00240     }
00241 }
00242 
00243 int TopoShapeVertexPy::staticCallback_setY (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00244 {
00245     if (!((PyObjectBase*) self)->isValid()){
00246         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00247         return -1;
00248     }
00249 
00250     PyErr_SetString(PyExc_AttributeError, "Attribute 'Y' of object 'TopoShape' is read-only");
00251     return -1;
00252 }
00253 
00254 // Z() callback and implementer
00255 // PyObject*  TopoShapeVertexPy::Z(PyObject *args){};
00256 // has to be implemented in TopoShapeVertexPyImp.cpp
00257 PyObject * TopoShapeVertexPy::staticCallback_getZ (PyObject *self, void * /*closure*/)
00258 {
00259     if (!((PyObjectBase*) self)->isValid()){
00260         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00261         return NULL;
00262     }
00263 
00264     try {
00265         return Py::new_reference_to(((TopoShapeVertexPy*)self)->getZ());
00266     } catch (const Py::Exception&) {
00267         // The exception text is already set
00268         return NULL;
00269     } catch (...) {
00270         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Z' of object 'TopoShape'");
00271         return NULL;
00272     }
00273 }
00274 
00275 int TopoShapeVertexPy::staticCallback_setZ (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00276 {
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 -1;
00280     }
00281 
00282     PyErr_SetString(PyExc_AttributeError, "Attribute 'Z' of object 'TopoShape' is read-only");
00283     return -1;
00284 }
00285 
00286 // Point() callback and implementer
00287 // PyObject*  TopoShapeVertexPy::Point(PyObject *args){};
00288 // has to be implemented in TopoShapeVertexPyImp.cpp
00289 PyObject * TopoShapeVertexPy::staticCallback_getPoint (PyObject *self, void * /*closure*/)
00290 {
00291     if (!((PyObjectBase*) self)->isValid()){
00292         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00293         return NULL;
00294     }
00295 
00296     try {
00297         return Py::new_reference_to(((TopoShapeVertexPy*)self)->getPoint());
00298     } catch (const Py::Exception&) {
00299         // The exception text is already set
00300         return NULL;
00301     } catch (...) {
00302         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Point' of object 'TopoShape'");
00303         return NULL;
00304     }
00305 }
00306 
00307 int TopoShapeVertexPy::staticCallback_setPoint (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00308 {
00309     if (!((PyObjectBase*) self)->isValid()){
00310         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00311         return -1;
00312     }
00313 
00314     PyErr_SetString(PyExc_AttributeError, "Attribute 'Point' of object 'TopoShape' is read-only");
00315     return -1;
00316 }
00317 
00318 
00319 
00320 //--------------------------------------------------------------------------
00321 // Parents structure
00322 //--------------------------------------------------------------------------
00323 PyParentObject TopoShapeVertexPy::Parents[] = { PARENTSPartTopoShapeVertexPy };
00324 
00325 //--------------------------------------------------------------------------
00326 // Constructor
00327 //--------------------------------------------------------------------------
00328 TopoShapeVertexPy::TopoShapeVertexPy(TopoShape *pcObject, PyTypeObject *T)
00329     : TopoShapePy(reinterpret_cast<TopoShapePy::PointerType>(pcObject), T)
00330 {
00331 }
00332 
00333 
00334 //--------------------------------------------------------------------------
00335 // destructor
00336 //--------------------------------------------------------------------------
00337 TopoShapeVertexPy::~TopoShapeVertexPy()                                // Everything handled in parent
00338 {
00339 }
00340 
00341 //--------------------------------------------------------------------------
00342 // TopoShapeVertexPy representation
00343 //--------------------------------------------------------------------------
00344 PyObject *TopoShapeVertexPy::_repr(void)
00345 {
00346     return Py_BuildValue("s", representation().c_str());
00347 }
00348 
00349 //--------------------------------------------------------------------------
00350 // TopoShapeVertexPy Attributes
00351 //--------------------------------------------------------------------------
00352 PyObject *TopoShapeVertexPy::_getattr(char *attr)                               // __getattr__ function: note only need to handle new state
00353 {
00354     try {
00355         // getter method for special Attributes (e.g. dynamic ones)
00356         PyObject *r = getCustomAttributes(attr);
00357         if(r) return r;
00358     }
00359 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00360     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00361     {
00362         std::string str;
00363         str += "FreeCAD exception thrown (";
00364         str += e.what();
00365         str += ")";
00366         e.ReportException();
00367         PyErr_SetString(PyExc_Exception,str.c_str());
00368         return NULL;
00369     }
00370     catch(const std::exception& e) // catch other c++ exceptions
00371     {
00372         std::string str;
00373         str += "FC++ exception thrown (";
00374         str += e.what();
00375         str += ")";
00376         Base::Console().Error(str.c_str());
00377         PyErr_SetString(PyExc_Exception,str.c_str());
00378         return NULL;
00379     }
00380     catch(const Py::Exception&)
00381     {
00382         // The exception text is already set
00383         return NULL;
00384     }
00385     catch(...)  // catch the rest!
00386     {
00387         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00388         return NULL;
00389     }
00390 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00391     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00392     {
00393         std::string str;
00394         str += "FreeCAD exception thrown (";
00395         str += e.what();
00396         str += ")";
00397         e.ReportException();
00398         PyErr_SetString(PyExc_Exception,str.c_str());
00399         return NULL;
00400     }
00401     catch(const Py::Exception&)
00402     {
00403         // The exception text is already set
00404         return NULL;
00405     }
00406 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00407 
00408     PyObject *rvalue = Py_FindMethod(Methods, this, attr);
00409     if (rvalue == NULL)
00410     {
00411         PyErr_Clear();
00412         return TopoShapePy::_getattr(attr);
00413     }
00414     else
00415     {
00416         return rvalue;
00417     }
00418 }
00419 
00420 int TopoShapeVertexPy::_setattr(char *attr, PyObject *value)    // __setattr__ function: note only need to handle new state
00421 {
00422     try {
00423         // setter for  special Attributes (e.g. dynamic ones)
00424         int r = setCustomAttributes(attr, value);
00425         if(r==1) return 0;
00426     }
00427 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00428     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00429     {
00430         std::string str;
00431         str += "FreeCAD exception thrown (";
00432         str += e.what();
00433         str += ")";
00434         e.ReportException();
00435         PyErr_SetString(PyExc_Exception,str.c_str());
00436         return -1;
00437     }
00438     catch(const std::exception& e) // catch other c++ exceptions
00439     {
00440         std::string str;
00441         str += "FC++ exception thrown (";
00442         str += e.what();
00443         str += ")";
00444         Base::Console().Error(str.c_str());
00445         PyErr_SetString(PyExc_Exception,str.c_str());
00446         return -1;
00447     }
00448     catch(const Py::Exception&)
00449     {
00450         // The exception text is already set
00451         return -1;
00452     }
00453     catch(...)  // catch the rest!
00454     {
00455         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00456         return -1;
00457     }
00458 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00459     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00460     {
00461         std::string str;
00462         str += "FreeCAD exception thrown (";
00463         str += e.what();
00464         str += ")";
00465         e.ReportException();
00466         PyErr_SetString(PyExc_Exception,str.c_str());
00467         return -1;
00468     }
00469     catch(const Py::Exception&)
00470     {
00471         // The exception text is already set
00472         return -1;
00473     }
00474 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00475 
00476     return TopoShapePy::_setattr(attr, value);
00477 }
00478 
00479 TopoShape *TopoShapeVertexPy::getTopoShapePtr(void) const
00480 {
00481     return static_cast<TopoShape *>(_pcTwinPointer);
00482 }
00483 
00484 #if 0
00485 /* From here on come the methods you have to implement, but NOT in this module. Implement in TopoShapeVertexPyImp.cpp! This prototypes 
00486  * are just for convenience when you add a new method.
00487  */
00488 
00489 PyObject *TopoShapeVertexPy::PyMake(struct _typeobject *, PyObject *, PyObject *)  // Python wrapper
00490 {
00491     // create a new instance of TopoShapeVertexPy and the Twin object 
00492     return new TopoShapeVertexPy(new TopoShape);
00493 }
00494 
00495 // constructor method
00496 int TopoShapeVertexPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
00497 {
00498     return 0;
00499 }
00500 
00501 // returns a string which represents the object e.g. when printed in python
00502 std::string TopoShapeVertexPy::representation(void) const
00503 {
00504     return std::string("<TopoShape object>");
00505 }
00506 
00507 PyObject* TopoShapeVertexPy::setTolerance(PyObject *args)
00508 {
00509     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00510     return 0;
00511 }
00512 
00513 
00514 
00515 Py::Float TopoShapeVertexPy::getX(void) const
00516 {
00517     //return Py::Float();
00518     throw Py::AttributeError("Not yet implemented");
00519 }
00520 
00521 Py::Float TopoShapeVertexPy::getY(void) const
00522 {
00523     //return Py::Float();
00524     throw Py::AttributeError("Not yet implemented");
00525 }
00526 
00527 Py::Float TopoShapeVertexPy::getZ(void) const
00528 {
00529     //return Py::Float();
00530     throw Py::AttributeError("Not yet implemented");
00531 }
00532 
00533 Py::Object TopoShapeVertexPy::getPoint(void) const
00534 {
00535     //return Py::Object();
00536     throw Py::AttributeError("Not yet implemented");
00537 }
00538 
00539 PyObject *TopoShapeVertexPy::getCustomAttributes(const char* attr) const
00540 {
00541     return 0;
00542 }
00543 
00544 int TopoShapeVertexPy::setCustomAttributes(const char* attr, PyObject *obj)
00545 {
00546     return 0; 
00547 }
00548 #endif
00549 
00550 
00551 

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