MeshFeaturePy.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 MeshFeaturePyImp.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 MeshFeaturePy::Type = {
00021     PyObject_HEAD_INIT(&PyType_Type)
00022     0,                                                /*ob_size*/
00023     "Mesh.Feature",     /*tp_name*/
00024     sizeof(MeshFeaturePy),                       /*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 Mesh::Feature class handles meshes.\n"
00046     "The Mesh.MeshFeature() function is for internal use only and cannot be used to create instances of this class.\n"
00047     "Therefore you must have a reference to a document, e.g. 'd' then you can create an instance with\n"
00048     "d.addObject(\"Mesh::Feature\").\n"
00049     "                   ",           /*tp_doc */
00050     0,                                                /*tp_traverse */
00051     0,                                                /*tp_clear */
00052     0,                                                /*tp_richcompare */
00053     0,                                                /*tp_weaklistoffset */
00054     0,                                                /*tp_iter */
00055     0,                                                /*tp_iternext */
00056     Mesh::MeshFeaturePy::Methods,                     /*tp_methods */
00057     0,                                                /*tp_members */
00058     Mesh::MeshFeaturePy::GetterSetter,                     /*tp_getset */
00059     &App::DocumentObjectPy::Type,                        /*tp_base */
00060     0,                                                /*tp_dict */
00061     0,                                                /*tp_descr_get */
00062     0,                                                /*tp_descr_set */
00063     0,                                                /*tp_dictoffset */
00064     __PyInit,                                         /*tp_init */
00065     0,                                                /*tp_alloc */
00066     Mesh::MeshFeaturePy::PyMake,/*tp_new */
00067     0,                                                /*tp_free   Low-level free-memory routine */
00068     0,                                                /*tp_is_gc  For PyObject_IS_GC */
00069     0,                                                /*tp_bases */
00070     0,                                                /*tp_mro    method resolution order */
00071     0,                                                /*tp_cache */
00072     0,                                                /*tp_subclasses */
00073     0,                                                /*tp_weaklist */
00074     0                                                 /*tp_del */
00075 };
00076 
00078 PyMethodDef MeshFeaturePy::Methods[] = {
00079     {"countPoints",
00080         (PyCFunction) staticCallback_countPoints,
00081         METH_VARARGS,
00082         "Return the number of vertices of the mesh object"
00083     },
00084     {"countFacets",
00085         (PyCFunction) staticCallback_countFacets,
00086         METH_VARARGS,
00087         "Return the number of facets of the mesh object"
00088     },
00089     {"harmonizeNormals",
00090         (PyCFunction) staticCallback_harmonizeNormals,
00091         METH_VARARGS,
00092         "Adjust wrong oriented facets"
00093     },
00094     {"smooth",
00095         (PyCFunction) staticCallback_smooth,
00096         METH_VARARGS,
00097         "Smooth the mesh data"
00098     },
00099     {"removeNonManifolds",
00100         (PyCFunction) staticCallback_removeNonManifolds,
00101         METH_VARARGS,
00102         "Remove non-manifolds"
00103     },
00104     {"fixIndices",
00105         (PyCFunction) staticCallback_fixIndices,
00106         METH_VARARGS,
00107         "Repair any invalid indices"
00108     },
00109     {"fixDegenerations",
00110         (PyCFunction) staticCallback_fixDegenerations,
00111         METH_VARARGS,
00112         "Remove degenerated facets"
00113     },
00114     {"removeDuplicatedFacets",
00115         (PyCFunction) staticCallback_removeDuplicatedFacets,
00116         METH_VARARGS,
00117         "Remove duplicated facets"
00118     },
00119     {"removeDuplicatedPoints",
00120         (PyCFunction) staticCallback_removeDuplicatedPoints,
00121         METH_VARARGS,
00122         "Remove duplicated points"
00123     },
00124     {"fixSelfIntersections",
00125         (PyCFunction) staticCallback_fixSelfIntersections,
00126         METH_VARARGS,
00127         "Repair self-intersections"
00128     },
00129     {"removeFoldsOnSurface",
00130         (PyCFunction) staticCallback_removeFoldsOnSurface,
00131         METH_VARARGS,
00132         "Remove folds on surfaces"
00133     },
00134     {NULL, NULL, 0, NULL}               /* Sentinel */
00135 };
00136 
00137 
00138 
00140 PyGetSetDef MeshFeaturePy::GetterSetter[] = {
00141     {NULL, NULL, NULL, NULL, NULL}              /* Sentinel */
00142 };
00143 
00144 // countPoints() callback and implementer
00145 // PyObject*  MeshFeaturePy::countPoints(PyObject *args){};
00146 // has to be implemented in MeshFeaturePyImp.cpp
00147 PyObject * MeshFeaturePy::staticCallback_countPoints (PyObject *self, PyObject *args)
00148 {
00149     // test if twin object not allready deleted
00150     if (!((PyObjectBase*) self)->isValid()){
00151         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00152         return NULL;
00153     }
00154 
00155     // test if object is set Const
00156     if (((PyObjectBase*) self)->isConst()){
00157         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00158         return NULL;
00159     }
00160 
00161     try { // catches all exceptions coming up from c++ and generate a python exception
00162         PyObject* ret = ((MeshFeaturePy*)self)->countPoints(args);
00163         if (ret != 0)
00164             ((MeshFeaturePy*)self)->startNotify();
00165         return ret;
00166     }
00167     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00168     {
00169         std::string str;
00170         str += "FreeCAD exception thrown (";
00171         str += e.what();
00172         str += ")";
00173         e.ReportException();
00174         PyErr_SetString(PyExc_Exception,str.c_str());
00175         return NULL;
00176     }
00177     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00178     {
00179         std::string str;
00180         str += "File system exception thrown (";
00181         //str += e.who();
00182         //str += ", ";
00183         str += e.what();
00184         str += ")\n";
00185         Base::Console().Error(str.c_str());
00186         PyErr_SetString(PyExc_Exception,str.c_str());
00187         return NULL;
00188     }
00189     catch(const Py::Exception&)
00190     {
00191         // The exception text is already set
00192         return NULL;
00193     }
00194     catch(const char* e) // catch simple string exceptions
00195     {
00196         Base::Console().Error(e);
00197         PyErr_SetString(PyExc_Exception,e);
00198         return NULL;
00199     }
00200     // in debug not all exceptions will be catched to get the attention of the developer!
00201 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00202     catch(const std::exception& e) // catch other c++ exceptions
00203     {
00204         std::string str;
00205         str += "FC++ exception thrown (";
00206         str += e.what();
00207         str += ")";
00208         Base::Console().Error(str.c_str());
00209         PyErr_SetString(PyExc_Exception,str.c_str());
00210         return NULL;
00211     }
00212     catch(...)  // catch the rest!
00213     {
00214         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00215         return NULL;
00216     }
00217 #endif
00218 }
00219 
00220 // countFacets() callback and implementer
00221 // PyObject*  MeshFeaturePy::countFacets(PyObject *args){};
00222 // has to be implemented in MeshFeaturePyImp.cpp
00223 PyObject * MeshFeaturePy::staticCallback_countFacets (PyObject *self, PyObject *args)
00224 {
00225     // test if twin object not allready deleted
00226     if (!((PyObjectBase*) self)->isValid()){
00227         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00228         return NULL;
00229     }
00230 
00231     // test if object is set Const
00232     if (((PyObjectBase*) self)->isConst()){
00233         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00234         return NULL;
00235     }
00236 
00237     try { // catches all exceptions coming up from c++ and generate a python exception
00238         PyObject* ret = ((MeshFeaturePy*)self)->countFacets(args);
00239         if (ret != 0)
00240             ((MeshFeaturePy*)self)->startNotify();
00241         return ret;
00242     }
00243     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00244     {
00245         std::string str;
00246         str += "FreeCAD exception thrown (";
00247         str += e.what();
00248         str += ")";
00249         e.ReportException();
00250         PyErr_SetString(PyExc_Exception,str.c_str());
00251         return NULL;
00252     }
00253     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00254     {
00255         std::string str;
00256         str += "File system exception thrown (";
00257         //str += e.who();
00258         //str += ", ";
00259         str += e.what();
00260         str += ")\n";
00261         Base::Console().Error(str.c_str());
00262         PyErr_SetString(PyExc_Exception,str.c_str());
00263         return NULL;
00264     }
00265     catch(const Py::Exception&)
00266     {
00267         // The exception text is already set
00268         return NULL;
00269     }
00270     catch(const char* e) // catch simple string exceptions
00271     {
00272         Base::Console().Error(e);
00273         PyErr_SetString(PyExc_Exception,e);
00274         return NULL;
00275     }
00276     // in debug not all exceptions will be catched to get the attention of the developer!
00277 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00278     catch(const std::exception& e) // catch other c++ exceptions
00279     {
00280         std::string str;
00281         str += "FC++ exception thrown (";
00282         str += e.what();
00283         str += ")";
00284         Base::Console().Error(str.c_str());
00285         PyErr_SetString(PyExc_Exception,str.c_str());
00286         return NULL;
00287     }
00288     catch(...)  // catch the rest!
00289     {
00290         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00291         return NULL;
00292     }
00293 #endif
00294 }
00295 
00296 // harmonizeNormals() callback and implementer
00297 // PyObject*  MeshFeaturePy::harmonizeNormals(PyObject *args){};
00298 // has to be implemented in MeshFeaturePyImp.cpp
00299 PyObject * MeshFeaturePy::staticCallback_harmonizeNormals (PyObject *self, PyObject *args)
00300 {
00301     // test if twin object not allready deleted
00302     if (!((PyObjectBase*) self)->isValid()){
00303         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00304         return NULL;
00305     }
00306 
00307     // test if object is set Const
00308     if (((PyObjectBase*) self)->isConst()){
00309         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00310         return NULL;
00311     }
00312 
00313     try { // catches all exceptions coming up from c++ and generate a python exception
00314         PyObject* ret = ((MeshFeaturePy*)self)->harmonizeNormals(args);
00315         if (ret != 0)
00316             ((MeshFeaturePy*)self)->startNotify();
00317         return ret;
00318     }
00319     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00320     {
00321         std::string str;
00322         str += "FreeCAD exception thrown (";
00323         str += e.what();
00324         str += ")";
00325         e.ReportException();
00326         PyErr_SetString(PyExc_Exception,str.c_str());
00327         return NULL;
00328     }
00329     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00330     {
00331         std::string str;
00332         str += "File system exception thrown (";
00333         //str += e.who();
00334         //str += ", ";
00335         str += e.what();
00336         str += ")\n";
00337         Base::Console().Error(str.c_str());
00338         PyErr_SetString(PyExc_Exception,str.c_str());
00339         return NULL;
00340     }
00341     catch(const Py::Exception&)
00342     {
00343         // The exception text is already set
00344         return NULL;
00345     }
00346     catch(const char* e) // catch simple string exceptions
00347     {
00348         Base::Console().Error(e);
00349         PyErr_SetString(PyExc_Exception,e);
00350         return NULL;
00351     }
00352     // in debug not all exceptions will be catched to get the attention of the developer!
00353 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00354     catch(const std::exception& e) // catch other c++ exceptions
00355     {
00356         std::string str;
00357         str += "FC++ exception thrown (";
00358         str += e.what();
00359         str += ")";
00360         Base::Console().Error(str.c_str());
00361         PyErr_SetString(PyExc_Exception,str.c_str());
00362         return NULL;
00363     }
00364     catch(...)  // catch the rest!
00365     {
00366         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00367         return NULL;
00368     }
00369 #endif
00370 }
00371 
00372 // smooth() callback and implementer
00373 // PyObject*  MeshFeaturePy::smooth(PyObject *args){};
00374 // has to be implemented in MeshFeaturePyImp.cpp
00375 PyObject * MeshFeaturePy::staticCallback_smooth (PyObject *self, PyObject *args)
00376 {
00377     // test if twin object not allready deleted
00378     if (!((PyObjectBase*) self)->isValid()){
00379         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00380         return NULL;
00381     }
00382 
00383     // test if object is set Const
00384     if (((PyObjectBase*) self)->isConst()){
00385         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00386         return NULL;
00387     }
00388 
00389     try { // catches all exceptions coming up from c++ and generate a python exception
00390         PyObject* ret = ((MeshFeaturePy*)self)->smooth(args);
00391         if (ret != 0)
00392             ((MeshFeaturePy*)self)->startNotify();
00393         return ret;
00394     }
00395     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00396     {
00397         std::string str;
00398         str += "FreeCAD exception thrown (";
00399         str += e.what();
00400         str += ")";
00401         e.ReportException();
00402         PyErr_SetString(PyExc_Exception,str.c_str());
00403         return NULL;
00404     }
00405     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00406     {
00407         std::string str;
00408         str += "File system exception thrown (";
00409         //str += e.who();
00410         //str += ", ";
00411         str += e.what();
00412         str += ")\n";
00413         Base::Console().Error(str.c_str());
00414         PyErr_SetString(PyExc_Exception,str.c_str());
00415         return NULL;
00416     }
00417     catch(const Py::Exception&)
00418     {
00419         // The exception text is already set
00420         return NULL;
00421     }
00422     catch(const char* e) // catch simple string exceptions
00423     {
00424         Base::Console().Error(e);
00425         PyErr_SetString(PyExc_Exception,e);
00426         return NULL;
00427     }
00428     // in debug not all exceptions will be catched to get the attention of the developer!
00429 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00430     catch(const std::exception& e) // catch other c++ exceptions
00431     {
00432         std::string str;
00433         str += "FC++ exception thrown (";
00434         str += e.what();
00435         str += ")";
00436         Base::Console().Error(str.c_str());
00437         PyErr_SetString(PyExc_Exception,str.c_str());
00438         return NULL;
00439     }
00440     catch(...)  // catch the rest!
00441     {
00442         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00443         return NULL;
00444     }
00445 #endif
00446 }
00447 
00448 // removeNonManifolds() callback and implementer
00449 // PyObject*  MeshFeaturePy::removeNonManifolds(PyObject *args){};
00450 // has to be implemented in MeshFeaturePyImp.cpp
00451 PyObject * MeshFeaturePy::staticCallback_removeNonManifolds (PyObject *self, PyObject *args)
00452 {
00453     // test if twin object not allready deleted
00454     if (!((PyObjectBase*) self)->isValid()){
00455         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00456         return NULL;
00457     }
00458 
00459     // test if object is set Const
00460     if (((PyObjectBase*) self)->isConst()){
00461         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00462         return NULL;
00463     }
00464 
00465     try { // catches all exceptions coming up from c++ and generate a python exception
00466         PyObject* ret = ((MeshFeaturePy*)self)->removeNonManifolds(args);
00467         if (ret != 0)
00468             ((MeshFeaturePy*)self)->startNotify();
00469         return ret;
00470     }
00471     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00472     {
00473         std::string str;
00474         str += "FreeCAD exception thrown (";
00475         str += e.what();
00476         str += ")";
00477         e.ReportException();
00478         PyErr_SetString(PyExc_Exception,str.c_str());
00479         return NULL;
00480     }
00481     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00482     {
00483         std::string str;
00484         str += "File system exception thrown (";
00485         //str += e.who();
00486         //str += ", ";
00487         str += e.what();
00488         str += ")\n";
00489         Base::Console().Error(str.c_str());
00490         PyErr_SetString(PyExc_Exception,str.c_str());
00491         return NULL;
00492     }
00493     catch(const Py::Exception&)
00494     {
00495         // The exception text is already set
00496         return NULL;
00497     }
00498     catch(const char* e) // catch simple string exceptions
00499     {
00500         Base::Console().Error(e);
00501         PyErr_SetString(PyExc_Exception,e);
00502         return NULL;
00503     }
00504     // in debug not all exceptions will be catched to get the attention of the developer!
00505 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00506     catch(const std::exception& e) // catch other c++ exceptions
00507     {
00508         std::string str;
00509         str += "FC++ exception thrown (";
00510         str += e.what();
00511         str += ")";
00512         Base::Console().Error(str.c_str());
00513         PyErr_SetString(PyExc_Exception,str.c_str());
00514         return NULL;
00515     }
00516     catch(...)  // catch the rest!
00517     {
00518         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00519         return NULL;
00520     }
00521 #endif
00522 }
00523 
00524 // fixIndices() callback and implementer
00525 // PyObject*  MeshFeaturePy::fixIndices(PyObject *args){};
00526 // has to be implemented in MeshFeaturePyImp.cpp
00527 PyObject * MeshFeaturePy::staticCallback_fixIndices (PyObject *self, PyObject *args)
00528 {
00529     // test if twin object not allready deleted
00530     if (!((PyObjectBase*) self)->isValid()){
00531         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00532         return NULL;
00533     }
00534 
00535     // test if object is set Const
00536     if (((PyObjectBase*) self)->isConst()){
00537         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00538         return NULL;
00539     }
00540 
00541     try { // catches all exceptions coming up from c++ and generate a python exception
00542         PyObject* ret = ((MeshFeaturePy*)self)->fixIndices(args);
00543         if (ret != 0)
00544             ((MeshFeaturePy*)self)->startNotify();
00545         return ret;
00546     }
00547     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00548     {
00549         std::string str;
00550         str += "FreeCAD exception thrown (";
00551         str += e.what();
00552         str += ")";
00553         e.ReportException();
00554         PyErr_SetString(PyExc_Exception,str.c_str());
00555         return NULL;
00556     }
00557     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00558     {
00559         std::string str;
00560         str += "File system exception thrown (";
00561         //str += e.who();
00562         //str += ", ";
00563         str += e.what();
00564         str += ")\n";
00565         Base::Console().Error(str.c_str());
00566         PyErr_SetString(PyExc_Exception,str.c_str());
00567         return NULL;
00568     }
00569     catch(const Py::Exception&)
00570     {
00571         // The exception text is already set
00572         return NULL;
00573     }
00574     catch(const char* e) // catch simple string exceptions
00575     {
00576         Base::Console().Error(e);
00577         PyErr_SetString(PyExc_Exception,e);
00578         return NULL;
00579     }
00580     // in debug not all exceptions will be catched to get the attention of the developer!
00581 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00582     catch(const std::exception& e) // catch other c++ exceptions
00583     {
00584         std::string str;
00585         str += "FC++ exception thrown (";
00586         str += e.what();
00587         str += ")";
00588         Base::Console().Error(str.c_str());
00589         PyErr_SetString(PyExc_Exception,str.c_str());
00590         return NULL;
00591     }
00592     catch(...)  // catch the rest!
00593     {
00594         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00595         return NULL;
00596     }
00597 #endif
00598 }
00599 
00600 // fixDegenerations() callback and implementer
00601 // PyObject*  MeshFeaturePy::fixDegenerations(PyObject *args){};
00602 // has to be implemented in MeshFeaturePyImp.cpp
00603 PyObject * MeshFeaturePy::staticCallback_fixDegenerations (PyObject *self, PyObject *args)
00604 {
00605     // test if twin object not allready deleted
00606     if (!((PyObjectBase*) self)->isValid()){
00607         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00608         return NULL;
00609     }
00610 
00611     // test if object is set Const
00612     if (((PyObjectBase*) self)->isConst()){
00613         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00614         return NULL;
00615     }
00616 
00617     try { // catches all exceptions coming up from c++ and generate a python exception
00618         PyObject* ret = ((MeshFeaturePy*)self)->fixDegenerations(args);
00619         if (ret != 0)
00620             ((MeshFeaturePy*)self)->startNotify();
00621         return ret;
00622     }
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 boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00634     {
00635         std::string str;
00636         str += "File system exception thrown (";
00637         //str += e.who();
00638         //str += ", ";
00639         str += e.what();
00640         str += ")\n";
00641         Base::Console().Error(str.c_str());
00642         PyErr_SetString(PyExc_Exception,str.c_str());
00643         return NULL;
00644     }
00645     catch(const Py::Exception&)
00646     {
00647         // The exception text is already set
00648         return NULL;
00649     }
00650     catch(const char* e) // catch simple string exceptions
00651     {
00652         Base::Console().Error(e);
00653         PyErr_SetString(PyExc_Exception,e);
00654         return NULL;
00655     }
00656     // in debug not all exceptions will be catched to get the attention of the developer!
00657 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00658     catch(const std::exception& e) // catch other c++ exceptions
00659     {
00660         std::string str;
00661         str += "FC++ exception thrown (";
00662         str += e.what();
00663         str += ")";
00664         Base::Console().Error(str.c_str());
00665         PyErr_SetString(PyExc_Exception,str.c_str());
00666         return NULL;
00667     }
00668     catch(...)  // catch the rest!
00669     {
00670         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00671         return NULL;
00672     }
00673 #endif
00674 }
00675 
00676 // removeDuplicatedFacets() callback and implementer
00677 // PyObject*  MeshFeaturePy::removeDuplicatedFacets(PyObject *args){};
00678 // has to be implemented in MeshFeaturePyImp.cpp
00679 PyObject * MeshFeaturePy::staticCallback_removeDuplicatedFacets (PyObject *self, PyObject *args)
00680 {
00681     // test if twin object not allready deleted
00682     if (!((PyObjectBase*) self)->isValid()){
00683         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00684         return NULL;
00685     }
00686 
00687     // test if object is set Const
00688     if (((PyObjectBase*) self)->isConst()){
00689         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00690         return NULL;
00691     }
00692 
00693     try { // catches all exceptions coming up from c++ and generate a python exception
00694         PyObject* ret = ((MeshFeaturePy*)self)->removeDuplicatedFacets(args);
00695         if (ret != 0)
00696             ((MeshFeaturePy*)self)->startNotify();
00697         return ret;
00698     }
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 NULL;
00708     }
00709     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00710     {
00711         std::string str;
00712         str += "File system exception thrown (";
00713         //str += e.who();
00714         //str += ", ";
00715         str += e.what();
00716         str += ")\n";
00717         Base::Console().Error(str.c_str());
00718         PyErr_SetString(PyExc_Exception,str.c_str());
00719         return NULL;
00720     }
00721     catch(const Py::Exception&)
00722     {
00723         // The exception text is already set
00724         return NULL;
00725     }
00726     catch(const char* e) // catch simple string exceptions
00727     {
00728         Base::Console().Error(e);
00729         PyErr_SetString(PyExc_Exception,e);
00730         return NULL;
00731     }
00732     // in debug not all exceptions will be catched to get the attention of the developer!
00733 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00734     catch(const std::exception& e) // catch other c++ exceptions
00735     {
00736         std::string str;
00737         str += "FC++ exception thrown (";
00738         str += e.what();
00739         str += ")";
00740         Base::Console().Error(str.c_str());
00741         PyErr_SetString(PyExc_Exception,str.c_str());
00742         return NULL;
00743     }
00744     catch(...)  // catch the rest!
00745     {
00746         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00747         return NULL;
00748     }
00749 #endif
00750 }
00751 
00752 // removeDuplicatedPoints() callback and implementer
00753 // PyObject*  MeshFeaturePy::removeDuplicatedPoints(PyObject *args){};
00754 // has to be implemented in MeshFeaturePyImp.cpp
00755 PyObject * MeshFeaturePy::staticCallback_removeDuplicatedPoints (PyObject *self, PyObject *args)
00756 {
00757     // test if twin object not allready deleted
00758     if (!((PyObjectBase*) self)->isValid()){
00759         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00760         return NULL;
00761     }
00762 
00763     // test if object is set Const
00764     if (((PyObjectBase*) self)->isConst()){
00765         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00766         return NULL;
00767     }
00768 
00769     try { // catches all exceptions coming up from c++ and generate a python exception
00770         PyObject* ret = ((MeshFeaturePy*)self)->removeDuplicatedPoints(args);
00771         if (ret != 0)
00772             ((MeshFeaturePy*)self)->startNotify();
00773         return ret;
00774     }
00775     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00776     {
00777         std::string str;
00778         str += "FreeCAD exception thrown (";
00779         str += e.what();
00780         str += ")";
00781         e.ReportException();
00782         PyErr_SetString(PyExc_Exception,str.c_str());
00783         return NULL;
00784     }
00785     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00786     {
00787         std::string str;
00788         str += "File system exception thrown (";
00789         //str += e.who();
00790         //str += ", ";
00791         str += e.what();
00792         str += ")\n";
00793         Base::Console().Error(str.c_str());
00794         PyErr_SetString(PyExc_Exception,str.c_str());
00795         return NULL;
00796     }
00797     catch(const Py::Exception&)
00798     {
00799         // The exception text is already set
00800         return NULL;
00801     }
00802     catch(const char* e) // catch simple string exceptions
00803     {
00804         Base::Console().Error(e);
00805         PyErr_SetString(PyExc_Exception,e);
00806         return NULL;
00807     }
00808     // in debug not all exceptions will be catched to get the attention of the developer!
00809 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00810     catch(const std::exception& e) // catch other c++ exceptions
00811     {
00812         std::string str;
00813         str += "FC++ exception thrown (";
00814         str += e.what();
00815         str += ")";
00816         Base::Console().Error(str.c_str());
00817         PyErr_SetString(PyExc_Exception,str.c_str());
00818         return NULL;
00819     }
00820     catch(...)  // catch the rest!
00821     {
00822         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00823         return NULL;
00824     }
00825 #endif
00826 }
00827 
00828 // fixSelfIntersections() callback and implementer
00829 // PyObject*  MeshFeaturePy::fixSelfIntersections(PyObject *args){};
00830 // has to be implemented in MeshFeaturePyImp.cpp
00831 PyObject * MeshFeaturePy::staticCallback_fixSelfIntersections (PyObject *self, PyObject *args)
00832 {
00833     // test if twin object not allready deleted
00834     if (!((PyObjectBase*) self)->isValid()){
00835         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00836         return NULL;
00837     }
00838 
00839     // test if object is set Const
00840     if (((PyObjectBase*) self)->isConst()){
00841         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00842         return NULL;
00843     }
00844 
00845     try { // catches all exceptions coming up from c++ and generate a python exception
00846         PyObject* ret = ((MeshFeaturePy*)self)->fixSelfIntersections(args);
00847         if (ret != 0)
00848             ((MeshFeaturePy*)self)->startNotify();
00849         return ret;
00850     }
00851     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00852     {
00853         std::string str;
00854         str += "FreeCAD exception thrown (";
00855         str += e.what();
00856         str += ")";
00857         e.ReportException();
00858         PyErr_SetString(PyExc_Exception,str.c_str());
00859         return NULL;
00860     }
00861     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00862     {
00863         std::string str;
00864         str += "File system exception thrown (";
00865         //str += e.who();
00866         //str += ", ";
00867         str += e.what();
00868         str += ")\n";
00869         Base::Console().Error(str.c_str());
00870         PyErr_SetString(PyExc_Exception,str.c_str());
00871         return NULL;
00872     }
00873     catch(const Py::Exception&)
00874     {
00875         // The exception text is already set
00876         return NULL;
00877     }
00878     catch(const char* e) // catch simple string exceptions
00879     {
00880         Base::Console().Error(e);
00881         PyErr_SetString(PyExc_Exception,e);
00882         return NULL;
00883     }
00884     // in debug not all exceptions will be catched to get the attention of the developer!
00885 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00886     catch(const std::exception& e) // catch other c++ exceptions
00887     {
00888         std::string str;
00889         str += "FC++ exception thrown (";
00890         str += e.what();
00891         str += ")";
00892         Base::Console().Error(str.c_str());
00893         PyErr_SetString(PyExc_Exception,str.c_str());
00894         return NULL;
00895     }
00896     catch(...)  // catch the rest!
00897     {
00898         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00899         return NULL;
00900     }
00901 #endif
00902 }
00903 
00904 // removeFoldsOnSurface() callback and implementer
00905 // PyObject*  MeshFeaturePy::removeFoldsOnSurface(PyObject *args){};
00906 // has to be implemented in MeshFeaturePyImp.cpp
00907 PyObject * MeshFeaturePy::staticCallback_removeFoldsOnSurface (PyObject *self, PyObject *args)
00908 {
00909     // test if twin object not allready deleted
00910     if (!((PyObjectBase*) self)->isValid()){
00911         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00912         return NULL;
00913     }
00914 
00915     // test if object is set Const
00916     if (((PyObjectBase*) self)->isConst()){
00917         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00918         return NULL;
00919     }
00920 
00921     try { // catches all exceptions coming up from c++ and generate a python exception
00922         PyObject* ret = ((MeshFeaturePy*)self)->removeFoldsOnSurface(args);
00923         if (ret != 0)
00924             ((MeshFeaturePy*)self)->startNotify();
00925         return ret;
00926     }
00927     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00928     {
00929         std::string str;
00930         str += "FreeCAD exception thrown (";
00931         str += e.what();
00932         str += ")";
00933         e.ReportException();
00934         PyErr_SetString(PyExc_Exception,str.c_str());
00935         return NULL;
00936     }
00937     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00938     {
00939         std::string str;
00940         str += "File system exception thrown (";
00941         //str += e.who();
00942         //str += ", ";
00943         str += e.what();
00944         str += ")\n";
00945         Base::Console().Error(str.c_str());
00946         PyErr_SetString(PyExc_Exception,str.c_str());
00947         return NULL;
00948     }
00949     catch(const Py::Exception&)
00950     {
00951         // The exception text is already set
00952         return NULL;
00953     }
00954     catch(const char* e) // catch simple string exceptions
00955     {
00956         Base::Console().Error(e);
00957         PyErr_SetString(PyExc_Exception,e);
00958         return NULL;
00959     }
00960     // in debug not all exceptions will be catched to get the attention of the developer!
00961 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00962     catch(const std::exception& e) // catch other c++ exceptions
00963     {
00964         std::string str;
00965         str += "FC++ exception thrown (";
00966         str += e.what();
00967         str += ")";
00968         Base::Console().Error(str.c_str());
00969         PyErr_SetString(PyExc_Exception,str.c_str());
00970         return NULL;
00971     }
00972     catch(...)  // catch the rest!
00973     {
00974         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00975         return NULL;
00976     }
00977 #endif
00978 }
00979 
00980 
00981 
00982 //--------------------------------------------------------------------------
00983 // Parents structure
00984 //--------------------------------------------------------------------------
00985 PyParentObject MeshFeaturePy::Parents[] = { PARENTSMeshMeshFeaturePy };
00986 
00987 //--------------------------------------------------------------------------
00988 // Constructor
00989 //--------------------------------------------------------------------------
00990 MeshFeaturePy::MeshFeaturePy(Feature *pcObject, PyTypeObject *T)
00991     : DocumentObjectPy(reinterpret_cast<DocumentObjectPy::PointerType>(pcObject), T)
00992 {
00993 }
00994 
00995 PyObject *MeshFeaturePy::PyMake(struct _typeobject *, PyObject *, PyObject *)  // Python wrapper
00996 {
00997     // never create such objects with the constructor
00998     PyErr_SetString(PyExc_RuntimeError, "You cannot create directly an instance of 'MeshFeaturePy'.");
00999  
01000     return 0;
01001 }
01002 
01003 int MeshFeaturePy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
01004 {
01005     return 0;
01006 }
01007 
01008 //--------------------------------------------------------------------------
01009 // destructor
01010 //--------------------------------------------------------------------------
01011 MeshFeaturePy::~MeshFeaturePy()                                // Everything handled in parent
01012 {
01013 }
01014 
01015 //--------------------------------------------------------------------------
01016 // MeshFeaturePy representation
01017 //--------------------------------------------------------------------------
01018 PyObject *MeshFeaturePy::_repr(void)
01019 {
01020     return Py_BuildValue("s", representation().c_str());
01021 }
01022 
01023 //--------------------------------------------------------------------------
01024 // MeshFeaturePy Attributes
01025 //--------------------------------------------------------------------------
01026 PyObject *MeshFeaturePy::_getattr(char *attr)                           // __getattr__ function: note only need to handle new state
01027 {
01028     try {
01029         // getter method for special Attributes (e.g. dynamic ones)
01030         PyObject *r = getCustomAttributes(attr);
01031         if(r) return r;
01032     }
01033 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
01034     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01035     {
01036         std::string str;
01037         str += "FreeCAD exception thrown (";
01038         str += e.what();
01039         str += ")";
01040         e.ReportException();
01041         PyErr_SetString(PyExc_Exception,str.c_str());
01042         return NULL;
01043     }
01044     catch(const std::exception& e) // catch other c++ exceptions
01045     {
01046         std::string str;
01047         str += "FC++ exception thrown (";
01048         str += e.what();
01049         str += ")";
01050         Base::Console().Error(str.c_str());
01051         PyErr_SetString(PyExc_Exception,str.c_str());
01052         return NULL;
01053     }
01054     catch(const Py::Exception&)
01055     {
01056         // The exception text is already set
01057         return NULL;
01058     }
01059     catch(...)  // catch the rest!
01060     {
01061         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
01062         return NULL;
01063     }
01064 #else  // DONT_CATCH_CXX_EXCEPTIONS  
01065     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01066     {
01067         std::string str;
01068         str += "FreeCAD exception thrown (";
01069         str += e.what();
01070         str += ")";
01071         e.ReportException();
01072         PyErr_SetString(PyExc_Exception,str.c_str());
01073         return NULL;
01074     }
01075     catch(const Py::Exception&)
01076     {
01077         // The exception text is already set
01078         return NULL;
01079     }
01080 #endif  // DONT_CATCH_CXX_EXCEPTIONS
01081 
01082     PyObject *rvalue = Py_FindMethod(Methods, this, attr);
01083     if (rvalue == NULL)
01084     {
01085         PyErr_Clear();
01086         return DocumentObjectPy::_getattr(attr);
01087     }
01088     else
01089     {
01090         return rvalue;
01091     }
01092 }
01093 
01094 int MeshFeaturePy::_setattr(char *attr, PyObject *value)        // __setattr__ function: note only need to handle new state
01095 {
01096     try {
01097         // setter for  special Attributes (e.g. dynamic ones)
01098         int r = setCustomAttributes(attr, value);
01099         if(r==1) return 0;
01100     }
01101 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
01102     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01103     {
01104         std::string str;
01105         str += "FreeCAD exception thrown (";
01106         str += e.what();
01107         str += ")";
01108         e.ReportException();
01109         PyErr_SetString(PyExc_Exception,str.c_str());
01110         return -1;
01111     }
01112     catch(const std::exception& e) // catch other c++ exceptions
01113     {
01114         std::string str;
01115         str += "FC++ exception thrown (";
01116         str += e.what();
01117         str += ")";
01118         Base::Console().Error(str.c_str());
01119         PyErr_SetString(PyExc_Exception,str.c_str());
01120         return -1;
01121     }
01122     catch(const Py::Exception&)
01123     {
01124         // The exception text is already set
01125         return -1;
01126     }
01127     catch(...)  // catch the rest!
01128     {
01129         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
01130         return -1;
01131     }
01132 #else  // DONT_CATCH_CXX_EXCEPTIONS  
01133     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01134     {
01135         std::string str;
01136         str += "FreeCAD exception thrown (";
01137         str += e.what();
01138         str += ")";
01139         e.ReportException();
01140         PyErr_SetString(PyExc_Exception,str.c_str());
01141         return -1;
01142     }
01143     catch(const Py::Exception&)
01144     {
01145         // The exception text is already set
01146         return -1;
01147     }
01148 #endif  // DONT_CATCH_CXX_EXCEPTIONS
01149 
01150     return DocumentObjectPy::_setattr(attr, value);
01151 }
01152 
01153 Feature *MeshFeaturePy::getFeaturePtr(void) const
01154 {
01155     return static_cast<Feature *>(_pcTwinPointer);
01156 }
01157 
01158 #if 0
01159 /* From here on come the methods you have to implement, but NOT in this module. Implement in MeshFeaturePyImp.cpp! This prototypes 
01160  * are just for convenience when you add a new method.
01161  */
01162 
01163 
01164 // returns a string which represents the object e.g. when printed in python
01165 std::string MeshFeaturePy::representation(void) const
01166 {
01167     return std::string("<Feature object>");
01168 }
01169 
01170 PyObject* MeshFeaturePy::countPoints(PyObject *args)
01171 {
01172     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01173     return 0;
01174 }
01175 
01176 PyObject* MeshFeaturePy::countFacets(PyObject *args)
01177 {
01178     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01179     return 0;
01180 }
01181 
01182 PyObject* MeshFeaturePy::harmonizeNormals(PyObject *args)
01183 {
01184     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01185     return 0;
01186 }
01187 
01188 PyObject* MeshFeaturePy::smooth(PyObject *args)
01189 {
01190     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01191     return 0;
01192 }
01193 
01194 PyObject* MeshFeaturePy::removeNonManifolds(PyObject *args)
01195 {
01196     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01197     return 0;
01198 }
01199 
01200 PyObject* MeshFeaturePy::fixIndices(PyObject *args)
01201 {
01202     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01203     return 0;
01204 }
01205 
01206 PyObject* MeshFeaturePy::fixDegenerations(PyObject *args)
01207 {
01208     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01209     return 0;
01210 }
01211 
01212 PyObject* MeshFeaturePy::removeDuplicatedFacets(PyObject *args)
01213 {
01214     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01215     return 0;
01216 }
01217 
01218 PyObject* MeshFeaturePy::removeDuplicatedPoints(PyObject *args)
01219 {
01220     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01221     return 0;
01222 }
01223 
01224 PyObject* MeshFeaturePy::fixSelfIntersections(PyObject *args)
01225 {
01226     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01227     return 0;
01228 }
01229 
01230 PyObject* MeshFeaturePy::removeFoldsOnSurface(PyObject *args)
01231 {
01232     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01233     return 0;
01234 }
01235 
01236 
01237 
01238 PyObject *MeshFeaturePy::getCustomAttributes(const char* attr) const
01239 {
01240     return 0;
01241 }
01242 
01243 int MeshFeaturePy::setCustomAttributes(const char* attr, PyObject *obj)
01244 {
01245     return 0; 
01246 }
01247 #endif
01248 
01249 
01250 

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