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

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