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

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