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

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