RectangularTrimmedSurfacePy.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 RectangularTrimmedSurfacePyImp.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 RectangularTrimmedSurfacePy::Type = {
00021     PyObject_HEAD_INIT(&PyType_Type)
00022     0,                                                /*ob_size*/
00023     "Part.GeomTrimmedSurface",     /*tp_name*/
00024     sizeof(RectangularTrimmedSurfacePy),                       /*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     "Describes a portion of a surface (a patch) limited by two values of the\n"
00046     "u parameter in the u parametric direction, and two values of the v parameter in the v parametric\n"
00047     "direction. The domain of the trimmed surface must be within the domain of the surface being trimmed.\n"
00048     "\n"
00049     "The trimmed surface is defined by:\n"
00050     "- the basis surface, and\n"
00051     "- the values (umin, umax) and (vmin, vmax) which limit it in the u and v parametric directions.\n"
00052     "\n"
00053     "The trimmed surface is built from a copy of the basis surface. Therefore, when the basis surface\n"
00054     "is modified the trimmed surface is not changed. Consequently, the trimmed surface does not\n"
00055     "necessarily have the same orientation as the basis surface.",           /*tp_doc */
00056     0,                                                /*tp_traverse */
00057     0,                                                /*tp_clear */
00058     0,                                                /*tp_richcompare */
00059     0,                                                /*tp_weaklistoffset */
00060     0,                                                /*tp_iter */
00061     0,                                                /*tp_iternext */
00062     Part::RectangularTrimmedSurfacePy::Methods,                     /*tp_methods */
00063     0,                                                /*tp_members */
00064     Part::RectangularTrimmedSurfacePy::GetterSetter,                     /*tp_getset */
00065     &Part::GeometrySurfacePy::Type,                        /*tp_base */
00066     0,                                                /*tp_dict */
00067     0,                                                /*tp_descr_get */
00068     0,                                                /*tp_descr_set */
00069     0,                                                /*tp_dictoffset */
00070     __PyInit,                                         /*tp_init */
00071     0,                                                /*tp_alloc */
00072     Part::RectangularTrimmedSurfacePy::PyMake,/*tp_new */
00073     0,                                                /*tp_free   Low-level free-memory routine */
00074     0,                                                /*tp_is_gc  For PyObject_IS_GC */
00075     0,                                                /*tp_bases */
00076     0,                                                /*tp_mro    method resolution order */
00077     0,                                                /*tp_cache */
00078     0,                                                /*tp_subclasses */
00079     0,                                                /*tp_weaklist */
00080     0                                                 /*tp_del */
00081 };
00082 
00084 PyMethodDef RectangularTrimmedSurfacePy::Methods[] = {
00085     {"uIso",
00086         (PyCFunction) staticCallback_uIso,
00087         METH_VARARGS,
00088         "Builds the U isoparametric curve"
00089     },
00090     {"vIso",
00091         (PyCFunction) staticCallback_vIso,
00092         METH_VARARGS,
00093         "Builds the V isoparametric curve"
00094     },
00095     {NULL, NULL, 0, NULL}               /* Sentinel */
00096 };
00097 
00098 
00099 
00101 PyGetSetDef RectangularTrimmedSurfacePy::GetterSetter[] = {
00102     {NULL, NULL, NULL, NULL, NULL}              /* Sentinel */
00103 };
00104 
00105 // uIso() callback and implementer
00106 // PyObject*  RectangularTrimmedSurfacePy::uIso(PyObject *args){};
00107 // has to be implemented in RectangularTrimmedSurfacePyImp.cpp
00108 PyObject * RectangularTrimmedSurfacePy::staticCallback_uIso (PyObject *self, PyObject *args)
00109 {
00110     // test if twin object not allready deleted
00111     if (!((PyObjectBase*) self)->isValid()){
00112         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00113         return NULL;
00114     }
00115 
00116     // test if object is set Const
00117     if (((PyObjectBase*) self)->isConst()){
00118         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00119         return NULL;
00120     }
00121 
00122     try { // catches all exceptions coming up from c++ and generate a python exception
00123         PyObject* ret = ((RectangularTrimmedSurfacePy*)self)->uIso(args);
00124         if (ret != 0)
00125             ((RectangularTrimmedSurfacePy*)self)->startNotify();
00126         return ret;
00127     }
00128     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00129     {
00130         std::string str;
00131         str += "FreeCAD exception thrown (";
00132         str += e.what();
00133         str += ")";
00134         e.ReportException();
00135         PyErr_SetString(PyExc_Exception,str.c_str());
00136         return NULL;
00137     }
00138     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00139     {
00140         std::string str;
00141         str += "File system exception thrown (";
00142         //str += e.who();
00143         //str += ", ";
00144         str += e.what();
00145         str += ")\n";
00146         Base::Console().Error(str.c_str());
00147         PyErr_SetString(PyExc_Exception,str.c_str());
00148         return NULL;
00149     }
00150     catch(const Py::Exception&)
00151     {
00152         // The exception text is already set
00153         return NULL;
00154     }
00155     catch(const char* e) // catch simple string exceptions
00156     {
00157         Base::Console().Error(e);
00158         PyErr_SetString(PyExc_Exception,e);
00159         return NULL;
00160     }
00161     // in debug not all exceptions will be catched to get the attention of the developer!
00162 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00163     catch(const std::exception& e) // catch other c++ exceptions
00164     {
00165         std::string str;
00166         str += "FC++ exception thrown (";
00167         str += e.what();
00168         str += ")";
00169         Base::Console().Error(str.c_str());
00170         PyErr_SetString(PyExc_Exception,str.c_str());
00171         return NULL;
00172     }
00173     catch(...)  // catch the rest!
00174     {
00175         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00176         return NULL;
00177     }
00178 #endif
00179 }
00180 
00181 // vIso() callback and implementer
00182 // PyObject*  RectangularTrimmedSurfacePy::vIso(PyObject *args){};
00183 // has to be implemented in RectangularTrimmedSurfacePyImp.cpp
00184 PyObject * RectangularTrimmedSurfacePy::staticCallback_vIso (PyObject *self, PyObject *args)
00185 {
00186     // test if twin object not allready deleted
00187     if (!((PyObjectBase*) self)->isValid()){
00188         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00189         return NULL;
00190     }
00191 
00192     // test if object is set Const
00193     if (((PyObjectBase*) self)->isConst()){
00194         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00195         return NULL;
00196     }
00197 
00198     try { // catches all exceptions coming up from c++ and generate a python exception
00199         PyObject* ret = ((RectangularTrimmedSurfacePy*)self)->vIso(args);
00200         if (ret != 0)
00201             ((RectangularTrimmedSurfacePy*)self)->startNotify();
00202         return ret;
00203     }
00204     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00205     {
00206         std::string str;
00207         str += "FreeCAD exception thrown (";
00208         str += e.what();
00209         str += ")";
00210         e.ReportException();
00211         PyErr_SetString(PyExc_Exception,str.c_str());
00212         return NULL;
00213     }
00214     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00215     {
00216         std::string str;
00217         str += "File system exception thrown (";
00218         //str += e.who();
00219         //str += ", ";
00220         str += e.what();
00221         str += ")\n";
00222         Base::Console().Error(str.c_str());
00223         PyErr_SetString(PyExc_Exception,str.c_str());
00224         return NULL;
00225     }
00226     catch(const Py::Exception&)
00227     {
00228         // The exception text is already set
00229         return NULL;
00230     }
00231     catch(const char* e) // catch simple string exceptions
00232     {
00233         Base::Console().Error(e);
00234         PyErr_SetString(PyExc_Exception,e);
00235         return NULL;
00236     }
00237     // in debug not all exceptions will be catched to get the attention of the developer!
00238 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00239     catch(const std::exception& e) // catch other c++ exceptions
00240     {
00241         std::string str;
00242         str += "FC++ exception thrown (";
00243         str += e.what();
00244         str += ")";
00245         Base::Console().Error(str.c_str());
00246         PyErr_SetString(PyExc_Exception,str.c_str());
00247         return NULL;
00248     }
00249     catch(...)  // catch the rest!
00250     {
00251         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00252         return NULL;
00253     }
00254 #endif
00255 }
00256 
00257 
00258 
00259 //--------------------------------------------------------------------------
00260 // Parents structure
00261 //--------------------------------------------------------------------------
00262 PyParentObject RectangularTrimmedSurfacePy::Parents[] = { PARENTSPartRectangularTrimmedSurfacePy };
00263 
00264 //--------------------------------------------------------------------------
00265 // Constructor
00266 //--------------------------------------------------------------------------
00267 RectangularTrimmedSurfacePy::RectangularTrimmedSurfacePy(GeomTrimmedSurface *pcObject, PyTypeObject *T)
00268     : GeometrySurfacePy(reinterpret_cast<GeometrySurfacePy::PointerType>(pcObject), T)
00269 {
00270 }
00271 
00272 
00273 //--------------------------------------------------------------------------
00274 // destructor
00275 //--------------------------------------------------------------------------
00276 RectangularTrimmedSurfacePy::~RectangularTrimmedSurfacePy()                                // Everything handled in parent
00277 {
00278 }
00279 
00280 //--------------------------------------------------------------------------
00281 // RectangularTrimmedSurfacePy representation
00282 //--------------------------------------------------------------------------
00283 PyObject *RectangularTrimmedSurfacePy::_repr(void)
00284 {
00285     return Py_BuildValue("s", representation().c_str());
00286 }
00287 
00288 //--------------------------------------------------------------------------
00289 // RectangularTrimmedSurfacePy Attributes
00290 //--------------------------------------------------------------------------
00291 PyObject *RectangularTrimmedSurfacePy::_getattr(char *attr)                             // __getattr__ function: note only need to handle new state
00292 {
00293     try {
00294         // getter method for special Attributes (e.g. dynamic ones)
00295         PyObject *r = getCustomAttributes(attr);
00296         if(r) return r;
00297     }
00298 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00299     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00300     {
00301         std::string str;
00302         str += "FreeCAD exception thrown (";
00303         str += e.what();
00304         str += ")";
00305         e.ReportException();
00306         PyErr_SetString(PyExc_Exception,str.c_str());
00307         return NULL;
00308     }
00309     catch(const std::exception& e) // catch other c++ exceptions
00310     {
00311         std::string str;
00312         str += "FC++ exception thrown (";
00313         str += e.what();
00314         str += ")";
00315         Base::Console().Error(str.c_str());
00316         PyErr_SetString(PyExc_Exception,str.c_str());
00317         return NULL;
00318     }
00319     catch(const Py::Exception&)
00320     {
00321         // The exception text is already set
00322         return NULL;
00323     }
00324     catch(...)  // catch the rest!
00325     {
00326         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00327         return NULL;
00328     }
00329 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00330     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00331     {
00332         std::string str;
00333         str += "FreeCAD exception thrown (";
00334         str += e.what();
00335         str += ")";
00336         e.ReportException();
00337         PyErr_SetString(PyExc_Exception,str.c_str());
00338         return NULL;
00339     }
00340     catch(const Py::Exception&)
00341     {
00342         // The exception text is already set
00343         return NULL;
00344     }
00345 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00346 
00347     PyObject *rvalue = Py_FindMethod(Methods, this, attr);
00348     if (rvalue == NULL)
00349     {
00350         PyErr_Clear();
00351         return GeometrySurfacePy::_getattr(attr);
00352     }
00353     else
00354     {
00355         return rvalue;
00356     }
00357 }
00358 
00359 int RectangularTrimmedSurfacePy::_setattr(char *attr, PyObject *value)  // __setattr__ function: note only need to handle new state
00360 {
00361     try {
00362         // setter for  special Attributes (e.g. dynamic ones)
00363         int r = setCustomAttributes(attr, value);
00364         if(r==1) return 0;
00365     }
00366 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00367     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00368     {
00369         std::string str;
00370         str += "FreeCAD exception thrown (";
00371         str += e.what();
00372         str += ")";
00373         e.ReportException();
00374         PyErr_SetString(PyExc_Exception,str.c_str());
00375         return -1;
00376     }
00377     catch(const std::exception& e) // catch other c++ exceptions
00378     {
00379         std::string str;
00380         str += "FC++ exception thrown (";
00381         str += e.what();
00382         str += ")";
00383         Base::Console().Error(str.c_str());
00384         PyErr_SetString(PyExc_Exception,str.c_str());
00385         return -1;
00386     }
00387     catch(const Py::Exception&)
00388     {
00389         // The exception text is already set
00390         return -1;
00391     }
00392     catch(...)  // catch the rest!
00393     {
00394         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00395         return -1;
00396     }
00397 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00398     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00399     {
00400         std::string str;
00401         str += "FreeCAD exception thrown (";
00402         str += e.what();
00403         str += ")";
00404         e.ReportException();
00405         PyErr_SetString(PyExc_Exception,str.c_str());
00406         return -1;
00407     }
00408     catch(const Py::Exception&)
00409     {
00410         // The exception text is already set
00411         return -1;
00412     }
00413 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00414 
00415     return GeometrySurfacePy::_setattr(attr, value);
00416 }
00417 
00418 GeomTrimmedSurface *RectangularTrimmedSurfacePy::getGeomTrimmedSurfacePtr(void) const
00419 {
00420     return static_cast<GeomTrimmedSurface *>(_pcTwinPointer);
00421 }
00422 
00423 #if 0
00424 /* From here on come the methods you have to implement, but NOT in this module. Implement in RectangularTrimmedSurfacePyImp.cpp! This prototypes 
00425  * are just for convenience when you add a new method.
00426  */
00427 
00428 PyObject *RectangularTrimmedSurfacePy::PyMake(struct _typeobject *, PyObject *, PyObject *)  // Python wrapper
00429 {
00430     // create a new instance of RectangularTrimmedSurfacePy and the Twin object 
00431     return new RectangularTrimmedSurfacePy(new GeomTrimmedSurface);
00432 }
00433 
00434 // constructor method
00435 int RectangularTrimmedSurfacePy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
00436 {
00437     return 0;
00438 }
00439 
00440 // returns a string which represents the object e.g. when printed in python
00441 std::string RectangularTrimmedSurfacePy::representation(void) const
00442 {
00443     return std::string("<GeomTrimmedSurface object>");
00444 }
00445 
00446 PyObject* RectangularTrimmedSurfacePy::uIso(PyObject *args)
00447 {
00448     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00449     return 0;
00450 }
00451 
00452 PyObject* RectangularTrimmedSurfacePy::vIso(PyObject *args)
00453 {
00454     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00455     return 0;
00456 }
00457 
00458 
00459 
00460 PyObject *RectangularTrimmedSurfacePy::getCustomAttributes(const char* attr) const
00461 {
00462     return 0;
00463 }
00464 
00465 int RectangularTrimmedSurfacePy::setCustomAttributes(const char* attr, PyObject *obj)
00466 {
00467     return 0; 
00468 }
00469 #endif
00470 
00471 
00472 

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