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

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