VectorPy.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 VectorPyImp.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 Base;
00018 
00020 PyTypeObject VectorPy::Type = {
00021     PyObject_HEAD_INIT(&PyType_Type)
00022     0,                                                /*ob_size*/
00023     "Base.Vector",     /*tp_name*/
00024     sizeof(VectorPy),                       /*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     Base::VectorPy::Number,      /*tp_as_number*/
00034     Base::VectorPy::Sequence,      /*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|Py_TPFLAGS_HAVE_RICHCOMPARE,        /*tp_flags */
00045     "This class represents a 3D float vector",           /*tp_doc */
00046     0,                                                /*tp_traverse */
00047     0,                                                /*tp_clear */
00048     Base::VectorPy::richCompare,      /*tp_richcompare*/
00049     0,                                                /*tp_weaklistoffset */
00050     0,                                                /*tp_iter */
00051     0,                                                /*tp_iternext */
00052     Base::VectorPy::Methods,                     /*tp_methods */
00053     0,                                                /*tp_members */
00054     Base::VectorPy::GetterSetter,                     /*tp_getset */
00055     &Base::PyObjectBase::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     Base::VectorPy::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 VectorPy::Methods[] = {
00075     {"add",
00076         (PyCFunction) staticCallback_add,
00077         METH_VARARGS,
00078         "add(Vector) - return the sum of the two vectors"
00079     },
00080     {"sub",
00081         (PyCFunction) staticCallback_sub,
00082         METH_VARARGS,
00083         "sub(Vector) - return the difference of the two vectors"
00084     },
00085     {"scale",
00086         (PyCFunction) staticCallback_scale,
00087         METH_VARARGS,
00088         "scale(Float,Float,Float) - scale (multiplies) this vector by a factor"
00089     },
00090     {"multiply",
00091         (PyCFunction) staticCallback_multiply,
00092         METH_VARARGS,
00093         "multiply(Float) - multiplies (scales) this vector by a single factor"
00094     },
00095     {"dot",
00096         (PyCFunction) staticCallback_dot,
00097         METH_VARARGS,
00098         "dot(Vector) - return the dot product of the two vectors"
00099     },
00100     {"cross",
00101         (PyCFunction) staticCallback_cross,
00102         METH_VARARGS,
00103         "cross(Vector) - return the cross product of the two vectors"
00104     },
00105     {"getAngle",
00106         (PyCFunction) staticCallback_getAngle,
00107         METH_VARARGS,
00108         "getAngle(Vector) - return the angle in radians between the two vectors"
00109     },
00110     {"normalize",
00111         (PyCFunction) staticCallback_normalize,
00112         METH_VARARGS,
00113         "Normalize the vector to the length of 1.0"
00114     },
00115     {"projectToLine",
00116         (PyCFunction) staticCallback_projectToLine,
00117         METH_VARARGS,
00118         "Deliver the projection point to a given line"
00119     },
00120     {"projectToPlane",
00121         (PyCFunction) staticCallback_projectToPlane,
00122         METH_VARARGS,
00123         "Deliver the projection point to a given plane"
00124     },
00125     {"distanceToLine",
00126         (PyCFunction) staticCallback_distanceToLine,
00127         METH_VARARGS,
00128         "Deliver the distance of the point to a given line"
00129     },
00130     {"distanceToPlane",
00131         (PyCFunction) staticCallback_distanceToPlane,
00132         METH_VARARGS,
00133         "Deliver the distance of the point to a given plane"
00134     },
00135     {NULL, NULL, 0, NULL}               /* Sentinel */
00136 };
00137 
00138 PyNumberMethods VectorPy::Number[] = { {
00139     number_add_handler,
00140     number_subtract_handler,
00141     number_multiply_handler,
00142     NULL
00143 } };
00144 
00145 PySequenceMethods VectorPy::Sequence[] = { {
00146     sequence_length,
00147     0,
00148     0,
00149     sequence_item,
00150     0,
00151     sequence_ass_item,
00152     0,
00153     0,
00154     0,
00155     0
00156 } };
00157 
00159 PyGetSetDef VectorPy::GetterSetter[] = {
00160     {"Length",
00161         (getter) staticCallback_getLength,
00162         (setter) staticCallback_setLength, 
00163         "To read or modifiy the length of the vector",
00164         NULL
00165     },
00166     {"x",
00167         (getter) staticCallback_getx,
00168         (setter) staticCallback_setx, 
00169         "The X component of the vector",
00170         NULL
00171     },
00172     {"y",
00173         (getter) staticCallback_gety,
00174         (setter) staticCallback_sety, 
00175         "The Y component of the vector",
00176         NULL
00177     },
00178     {"z",
00179         (getter) staticCallback_getz,
00180         (setter) staticCallback_setz, 
00181         "The Z component of the vector",
00182         NULL
00183     },
00184     {NULL, NULL, NULL, NULL, NULL}              /* Sentinel */
00185 };
00186 
00187 // add() callback and implementer
00188 // PyObject*  VectorPy::add(PyObject *args){};
00189 // has to be implemented in VectorPyImp.cpp
00190 PyObject * VectorPy::staticCallback_add (PyObject *self, PyObject *args)
00191 {
00192     // test if twin object not allready deleted
00193     if (!((PyObjectBase*) self)->isValid()){
00194         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00195         return NULL;
00196     }
00197 
00198 
00199     try { // catches all exceptions coming up from c++ and generate a python exception
00200         PyObject* ret = ((VectorPy*)self)->add(args);
00201         return ret;
00202     }
00203     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00204     {
00205         std::string str;
00206         str += "FreeCAD exception thrown (";
00207         str += e.what();
00208         str += ")";
00209         e.ReportException();
00210         PyErr_SetString(PyExc_Exception,str.c_str());
00211         return NULL;
00212     }
00213     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00214     {
00215         std::string str;
00216         str += "File system exception thrown (";
00217         //str += e.who();
00218         //str += ", ";
00219         str += e.what();
00220         str += ")\n";
00221         Base::Console().Error(str.c_str());
00222         PyErr_SetString(PyExc_Exception,str.c_str());
00223         return NULL;
00224     }
00225     catch(const Py::Exception&)
00226     {
00227         // The exception text is already set
00228         return NULL;
00229     }
00230     catch(const char* e) // catch simple string exceptions
00231     {
00232         Base::Console().Error(e);
00233         PyErr_SetString(PyExc_Exception,e);
00234         return NULL;
00235     }
00236     // in debug not all exceptions will be catched to get the attention of the developer!
00237 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00238     catch(const std::exception& e) // catch other c++ exceptions
00239     {
00240         std::string str;
00241         str += "FC++ exception thrown (";
00242         str += e.what();
00243         str += ")";
00244         Base::Console().Error(str.c_str());
00245         PyErr_SetString(PyExc_Exception,str.c_str());
00246         return NULL;
00247     }
00248     catch(...)  // catch the rest!
00249     {
00250         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00251         return NULL;
00252     }
00253 #endif
00254 }
00255 
00256 // sub() callback and implementer
00257 // PyObject*  VectorPy::sub(PyObject *args){};
00258 // has to be implemented in VectorPyImp.cpp
00259 PyObject * VectorPy::staticCallback_sub (PyObject *self, PyObject *args)
00260 {
00261     // test if twin object not allready deleted
00262     if (!((PyObjectBase*) self)->isValid()){
00263         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00264         return NULL;
00265     }
00266 
00267 
00268     try { // catches all exceptions coming up from c++ and generate a python exception
00269         PyObject* ret = ((VectorPy*)self)->sub(args);
00270         return ret;
00271     }
00272     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00273     {
00274         std::string str;
00275         str += "FreeCAD exception thrown (";
00276         str += e.what();
00277         str += ")";
00278         e.ReportException();
00279         PyErr_SetString(PyExc_Exception,str.c_str());
00280         return NULL;
00281     }
00282     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00283     {
00284         std::string str;
00285         str += "File system exception thrown (";
00286         //str += e.who();
00287         //str += ", ";
00288         str += e.what();
00289         str += ")\n";
00290         Base::Console().Error(str.c_str());
00291         PyErr_SetString(PyExc_Exception,str.c_str());
00292         return NULL;
00293     }
00294     catch(const Py::Exception&)
00295     {
00296         // The exception text is already set
00297         return NULL;
00298     }
00299     catch(const char* e) // catch simple string exceptions
00300     {
00301         Base::Console().Error(e);
00302         PyErr_SetString(PyExc_Exception,e);
00303         return NULL;
00304     }
00305     // in debug not all exceptions will be catched to get the attention of the developer!
00306 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00307     catch(const std::exception& e) // catch other c++ exceptions
00308     {
00309         std::string str;
00310         str += "FC++ exception thrown (";
00311         str += e.what();
00312         str += ")";
00313         Base::Console().Error(str.c_str());
00314         PyErr_SetString(PyExc_Exception,str.c_str());
00315         return NULL;
00316     }
00317     catch(...)  // catch the rest!
00318     {
00319         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00320         return NULL;
00321     }
00322 #endif
00323 }
00324 
00325 // scale() callback and implementer
00326 // PyObject*  VectorPy::scale(PyObject *args){};
00327 // has to be implemented in VectorPyImp.cpp
00328 PyObject * VectorPy::staticCallback_scale (PyObject *self, PyObject *args)
00329 {
00330     // test if twin object not allready deleted
00331     if (!((PyObjectBase*) self)->isValid()){
00332         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00333         return NULL;
00334     }
00335 
00336     // test if object is set Const
00337     if (((PyObjectBase*) self)->isConst()){
00338         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00339         return NULL;
00340     }
00341 
00342     try { // catches all exceptions coming up from c++ and generate a python exception
00343         PyObject* ret = ((VectorPy*)self)->scale(args);
00344         if (ret != 0)
00345             ((VectorPy*)self)->startNotify();
00346         return ret;
00347     }
00348     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00349     {
00350         std::string str;
00351         str += "FreeCAD exception thrown (";
00352         str += e.what();
00353         str += ")";
00354         e.ReportException();
00355         PyErr_SetString(PyExc_Exception,str.c_str());
00356         return NULL;
00357     }
00358     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00359     {
00360         std::string str;
00361         str += "File system exception thrown (";
00362         //str += e.who();
00363         //str += ", ";
00364         str += e.what();
00365         str += ")\n";
00366         Base::Console().Error(str.c_str());
00367         PyErr_SetString(PyExc_Exception,str.c_str());
00368         return NULL;
00369     }
00370     catch(const Py::Exception&)
00371     {
00372         // The exception text is already set
00373         return NULL;
00374     }
00375     catch(const char* e) // catch simple string exceptions
00376     {
00377         Base::Console().Error(e);
00378         PyErr_SetString(PyExc_Exception,e);
00379         return NULL;
00380     }
00381     // in debug not all exceptions will be catched to get the attention of the developer!
00382 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00383     catch(const std::exception& e) // catch other c++ exceptions
00384     {
00385         std::string str;
00386         str += "FC++ exception thrown (";
00387         str += e.what();
00388         str += ")";
00389         Base::Console().Error(str.c_str());
00390         PyErr_SetString(PyExc_Exception,str.c_str());
00391         return NULL;
00392     }
00393     catch(...)  // catch the rest!
00394     {
00395         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00396         return NULL;
00397     }
00398 #endif
00399 }
00400 
00401 // multiply() callback and implementer
00402 // PyObject*  VectorPy::multiply(PyObject *args){};
00403 // has to be implemented in VectorPyImp.cpp
00404 PyObject * VectorPy::staticCallback_multiply (PyObject *self, PyObject *args)
00405 {
00406     // test if twin object not allready deleted
00407     if (!((PyObjectBase*) self)->isValid()){
00408         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00409         return NULL;
00410     }
00411 
00412     // test if object is set Const
00413     if (((PyObjectBase*) self)->isConst()){
00414         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00415         return NULL;
00416     }
00417 
00418     try { // catches all exceptions coming up from c++ and generate a python exception
00419         PyObject* ret = ((VectorPy*)self)->multiply(args);
00420         if (ret != 0)
00421             ((VectorPy*)self)->startNotify();
00422         return ret;
00423     }
00424     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00425     {
00426         std::string str;
00427         str += "FreeCAD exception thrown (";
00428         str += e.what();
00429         str += ")";
00430         e.ReportException();
00431         PyErr_SetString(PyExc_Exception,str.c_str());
00432         return NULL;
00433     }
00434     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00435     {
00436         std::string str;
00437         str += "File system exception thrown (";
00438         //str += e.who();
00439         //str += ", ";
00440         str += e.what();
00441         str += ")\n";
00442         Base::Console().Error(str.c_str());
00443         PyErr_SetString(PyExc_Exception,str.c_str());
00444         return NULL;
00445     }
00446     catch(const Py::Exception&)
00447     {
00448         // The exception text is already set
00449         return NULL;
00450     }
00451     catch(const char* e) // catch simple string exceptions
00452     {
00453         Base::Console().Error(e);
00454         PyErr_SetString(PyExc_Exception,e);
00455         return NULL;
00456     }
00457     // in debug not all exceptions will be catched to get the attention of the developer!
00458 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00459     catch(const std::exception& e) // catch other c++ exceptions
00460     {
00461         std::string str;
00462         str += "FC++ exception thrown (";
00463         str += e.what();
00464         str += ")";
00465         Base::Console().Error(str.c_str());
00466         PyErr_SetString(PyExc_Exception,str.c_str());
00467         return NULL;
00468     }
00469     catch(...)  // catch the rest!
00470     {
00471         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00472         return NULL;
00473     }
00474 #endif
00475 }
00476 
00477 // dot() callback and implementer
00478 // PyObject*  VectorPy::dot(PyObject *args){};
00479 // has to be implemented in VectorPyImp.cpp
00480 PyObject * VectorPy::staticCallback_dot (PyObject *self, PyObject *args)
00481 {
00482     // test if twin object not allready deleted
00483     if (!((PyObjectBase*) self)->isValid()){
00484         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00485         return NULL;
00486     }
00487 
00488 
00489     try { // catches all exceptions coming up from c++ and generate a python exception
00490         PyObject* ret = ((VectorPy*)self)->dot(args);
00491         return ret;
00492     }
00493     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00494     {
00495         std::string str;
00496         str += "FreeCAD exception thrown (";
00497         str += e.what();
00498         str += ")";
00499         e.ReportException();
00500         PyErr_SetString(PyExc_Exception,str.c_str());
00501         return NULL;
00502     }
00503     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00504     {
00505         std::string str;
00506         str += "File system exception thrown (";
00507         //str += e.who();
00508         //str += ", ";
00509         str += e.what();
00510         str += ")\n";
00511         Base::Console().Error(str.c_str());
00512         PyErr_SetString(PyExc_Exception,str.c_str());
00513         return NULL;
00514     }
00515     catch(const Py::Exception&)
00516     {
00517         // The exception text is already set
00518         return NULL;
00519     }
00520     catch(const char* e) // catch simple string exceptions
00521     {
00522         Base::Console().Error(e);
00523         PyErr_SetString(PyExc_Exception,e);
00524         return NULL;
00525     }
00526     // in debug not all exceptions will be catched to get the attention of the developer!
00527 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00528     catch(const std::exception& e) // catch other c++ exceptions
00529     {
00530         std::string str;
00531         str += "FC++ exception thrown (";
00532         str += e.what();
00533         str += ")";
00534         Base::Console().Error(str.c_str());
00535         PyErr_SetString(PyExc_Exception,str.c_str());
00536         return NULL;
00537     }
00538     catch(...)  // catch the rest!
00539     {
00540         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00541         return NULL;
00542     }
00543 #endif
00544 }
00545 
00546 // cross() callback and implementer
00547 // PyObject*  VectorPy::cross(PyObject *args){};
00548 // has to be implemented in VectorPyImp.cpp
00549 PyObject * VectorPy::staticCallback_cross (PyObject *self, PyObject *args)
00550 {
00551     // test if twin object not allready deleted
00552     if (!((PyObjectBase*) self)->isValid()){
00553         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00554         return NULL;
00555     }
00556 
00557 
00558     try { // catches all exceptions coming up from c++ and generate a python exception
00559         PyObject* ret = ((VectorPy*)self)->cross(args);
00560         return ret;
00561     }
00562     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00563     {
00564         std::string str;
00565         str += "FreeCAD exception thrown (";
00566         str += e.what();
00567         str += ")";
00568         e.ReportException();
00569         PyErr_SetString(PyExc_Exception,str.c_str());
00570         return NULL;
00571     }
00572     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00573     {
00574         std::string str;
00575         str += "File system exception thrown (";
00576         //str += e.who();
00577         //str += ", ";
00578         str += e.what();
00579         str += ")\n";
00580         Base::Console().Error(str.c_str());
00581         PyErr_SetString(PyExc_Exception,str.c_str());
00582         return NULL;
00583     }
00584     catch(const Py::Exception&)
00585     {
00586         // The exception text is already set
00587         return NULL;
00588     }
00589     catch(const char* e) // catch simple string exceptions
00590     {
00591         Base::Console().Error(e);
00592         PyErr_SetString(PyExc_Exception,e);
00593         return NULL;
00594     }
00595     // in debug not all exceptions will be catched to get the attention of the developer!
00596 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00597     catch(const std::exception& e) // catch other c++ exceptions
00598     {
00599         std::string str;
00600         str += "FC++ exception thrown (";
00601         str += e.what();
00602         str += ")";
00603         Base::Console().Error(str.c_str());
00604         PyErr_SetString(PyExc_Exception,str.c_str());
00605         return NULL;
00606     }
00607     catch(...)  // catch the rest!
00608     {
00609         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00610         return NULL;
00611     }
00612 #endif
00613 }
00614 
00615 // getAngle() callback and implementer
00616 // PyObject*  VectorPy::getAngle(PyObject *args){};
00617 // has to be implemented in VectorPyImp.cpp
00618 PyObject * VectorPy::staticCallback_getAngle (PyObject *self, PyObject *args)
00619 {
00620     // test if twin object not allready deleted
00621     if (!((PyObjectBase*) self)->isValid()){
00622         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00623         return NULL;
00624     }
00625 
00626 
00627     try { // catches all exceptions coming up from c++ and generate a python exception
00628         PyObject* ret = ((VectorPy*)self)->getAngle(args);
00629         return ret;
00630     }
00631     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00632     {
00633         std::string str;
00634         str += "FreeCAD exception thrown (";
00635         str += e.what();
00636         str += ")";
00637         e.ReportException();
00638         PyErr_SetString(PyExc_Exception,str.c_str());
00639         return NULL;
00640     }
00641     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00642     {
00643         std::string str;
00644         str += "File system exception thrown (";
00645         //str += e.who();
00646         //str += ", ";
00647         str += e.what();
00648         str += ")\n";
00649         Base::Console().Error(str.c_str());
00650         PyErr_SetString(PyExc_Exception,str.c_str());
00651         return NULL;
00652     }
00653     catch(const Py::Exception&)
00654     {
00655         // The exception text is already set
00656         return NULL;
00657     }
00658     catch(const char* e) // catch simple string exceptions
00659     {
00660         Base::Console().Error(e);
00661         PyErr_SetString(PyExc_Exception,e);
00662         return NULL;
00663     }
00664     // in debug not all exceptions will be catched to get the attention of the developer!
00665 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00666     catch(const std::exception& e) // catch other c++ exceptions
00667     {
00668         std::string str;
00669         str += "FC++ exception thrown (";
00670         str += e.what();
00671         str += ")";
00672         Base::Console().Error(str.c_str());
00673         PyErr_SetString(PyExc_Exception,str.c_str());
00674         return NULL;
00675     }
00676     catch(...)  // catch the rest!
00677     {
00678         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00679         return NULL;
00680     }
00681 #endif
00682 }
00683 
00684 // normalize() callback and implementer
00685 // PyObject*  VectorPy::normalize(PyObject *args){};
00686 // has to be implemented in VectorPyImp.cpp
00687 PyObject * VectorPy::staticCallback_normalize (PyObject *self, PyObject *args)
00688 {
00689     // test if twin object not allready deleted
00690     if (!((PyObjectBase*) self)->isValid()){
00691         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00692         return NULL;
00693     }
00694 
00695     // test if object is set Const
00696     if (((PyObjectBase*) self)->isConst()){
00697         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00698         return NULL;
00699     }
00700 
00701     try { // catches all exceptions coming up from c++ and generate a python exception
00702         PyObject* ret = ((VectorPy*)self)->normalize(args);
00703         if (ret != 0)
00704             ((VectorPy*)self)->startNotify();
00705         return ret;
00706     }
00707     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00708     {
00709         std::string str;
00710         str += "FreeCAD exception thrown (";
00711         str += e.what();
00712         str += ")";
00713         e.ReportException();
00714         PyErr_SetString(PyExc_Exception,str.c_str());
00715         return NULL;
00716     }
00717     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00718     {
00719         std::string str;
00720         str += "File system exception thrown (";
00721         //str += e.who();
00722         //str += ", ";
00723         str += e.what();
00724         str += ")\n";
00725         Base::Console().Error(str.c_str());
00726         PyErr_SetString(PyExc_Exception,str.c_str());
00727         return NULL;
00728     }
00729     catch(const Py::Exception&)
00730     {
00731         // The exception text is already set
00732         return NULL;
00733     }
00734     catch(const char* e) // catch simple string exceptions
00735     {
00736         Base::Console().Error(e);
00737         PyErr_SetString(PyExc_Exception,e);
00738         return NULL;
00739     }
00740     // in debug not all exceptions will be catched to get the attention of the developer!
00741 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00742     catch(const std::exception& e) // catch other c++ exceptions
00743     {
00744         std::string str;
00745         str += "FC++ exception thrown (";
00746         str += e.what();
00747         str += ")";
00748         Base::Console().Error(str.c_str());
00749         PyErr_SetString(PyExc_Exception,str.c_str());
00750         return NULL;
00751     }
00752     catch(...)  // catch the rest!
00753     {
00754         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00755         return NULL;
00756     }
00757 #endif
00758 }
00759 
00760 // projectToLine() callback and implementer
00761 // PyObject*  VectorPy::projectToLine(PyObject *args){};
00762 // has to be implemented in VectorPyImp.cpp
00763 PyObject * VectorPy::staticCallback_projectToLine (PyObject *self, PyObject *args)
00764 {
00765     // test if twin object not allready deleted
00766     if (!((PyObjectBase*) self)->isValid()){
00767         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00768         return NULL;
00769     }
00770 
00771     // test if object is set Const
00772     if (((PyObjectBase*) self)->isConst()){
00773         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00774         return NULL;
00775     }
00776 
00777     try { // catches all exceptions coming up from c++ and generate a python exception
00778         PyObject* ret = ((VectorPy*)self)->projectToLine(args);
00779         if (ret != 0)
00780             ((VectorPy*)self)->startNotify();
00781         return ret;
00782     }
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 NULL;
00792     }
00793     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00794     {
00795         std::string str;
00796         str += "File system exception thrown (";
00797         //str += e.who();
00798         //str += ", ";
00799         str += e.what();
00800         str += ")\n";
00801         Base::Console().Error(str.c_str());
00802         PyErr_SetString(PyExc_Exception,str.c_str());
00803         return NULL;
00804     }
00805     catch(const Py::Exception&)
00806     {
00807         // The exception text is already set
00808         return NULL;
00809     }
00810     catch(const char* e) // catch simple string exceptions
00811     {
00812         Base::Console().Error(e);
00813         PyErr_SetString(PyExc_Exception,e);
00814         return NULL;
00815     }
00816     // in debug not all exceptions will be catched to get the attention of the developer!
00817 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00818     catch(const std::exception& e) // catch other c++ exceptions
00819     {
00820         std::string str;
00821         str += "FC++ exception thrown (";
00822         str += e.what();
00823         str += ")";
00824         Base::Console().Error(str.c_str());
00825         PyErr_SetString(PyExc_Exception,str.c_str());
00826         return NULL;
00827     }
00828     catch(...)  // catch the rest!
00829     {
00830         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00831         return NULL;
00832     }
00833 #endif
00834 }
00835 
00836 // projectToPlane() callback and implementer
00837 // PyObject*  VectorPy::projectToPlane(PyObject *args){};
00838 // has to be implemented in VectorPyImp.cpp
00839 PyObject * VectorPy::staticCallback_projectToPlane (PyObject *self, PyObject *args)
00840 {
00841     // test if twin object not allready deleted
00842     if (!((PyObjectBase*) self)->isValid()){
00843         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00844         return NULL;
00845     }
00846 
00847     // test if object is set Const
00848     if (((PyObjectBase*) self)->isConst()){
00849         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00850         return NULL;
00851     }
00852 
00853     try { // catches all exceptions coming up from c++ and generate a python exception
00854         PyObject* ret = ((VectorPy*)self)->projectToPlane(args);
00855         if (ret != 0)
00856             ((VectorPy*)self)->startNotify();
00857         return ret;
00858     }
00859     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00860     {
00861         std::string str;
00862         str += "FreeCAD exception thrown (";
00863         str += e.what();
00864         str += ")";
00865         e.ReportException();
00866         PyErr_SetString(PyExc_Exception,str.c_str());
00867         return NULL;
00868     }
00869     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00870     {
00871         std::string str;
00872         str += "File system exception thrown (";
00873         //str += e.who();
00874         //str += ", ";
00875         str += e.what();
00876         str += ")\n";
00877         Base::Console().Error(str.c_str());
00878         PyErr_SetString(PyExc_Exception,str.c_str());
00879         return NULL;
00880     }
00881     catch(const Py::Exception&)
00882     {
00883         // The exception text is already set
00884         return NULL;
00885     }
00886     catch(const char* e) // catch simple string exceptions
00887     {
00888         Base::Console().Error(e);
00889         PyErr_SetString(PyExc_Exception,e);
00890         return NULL;
00891     }
00892     // in debug not all exceptions will be catched to get the attention of the developer!
00893 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00894     catch(const std::exception& e) // catch other c++ exceptions
00895     {
00896         std::string str;
00897         str += "FC++ exception thrown (";
00898         str += e.what();
00899         str += ")";
00900         Base::Console().Error(str.c_str());
00901         PyErr_SetString(PyExc_Exception,str.c_str());
00902         return NULL;
00903     }
00904     catch(...)  // catch the rest!
00905     {
00906         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00907         return NULL;
00908     }
00909 #endif
00910 }
00911 
00912 // distanceToLine() callback and implementer
00913 // PyObject*  VectorPy::distanceToLine(PyObject *args){};
00914 // has to be implemented in VectorPyImp.cpp
00915 PyObject * VectorPy::staticCallback_distanceToLine (PyObject *self, PyObject *args)
00916 {
00917     // test if twin object not allready deleted
00918     if (!((PyObjectBase*) self)->isValid()){
00919         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00920         return NULL;
00921     }
00922 
00923 
00924     try { // catches all exceptions coming up from c++ and generate a python exception
00925         PyObject* ret = ((VectorPy*)self)->distanceToLine(args);
00926         return ret;
00927     }
00928     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00929     {
00930         std::string str;
00931         str += "FreeCAD exception thrown (";
00932         str += e.what();
00933         str += ")";
00934         e.ReportException();
00935         PyErr_SetString(PyExc_Exception,str.c_str());
00936         return NULL;
00937     }
00938     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00939     {
00940         std::string str;
00941         str += "File system exception thrown (";
00942         //str += e.who();
00943         //str += ", ";
00944         str += e.what();
00945         str += ")\n";
00946         Base::Console().Error(str.c_str());
00947         PyErr_SetString(PyExc_Exception,str.c_str());
00948         return NULL;
00949     }
00950     catch(const Py::Exception&)
00951     {
00952         // The exception text is already set
00953         return NULL;
00954     }
00955     catch(const char* e) // catch simple string exceptions
00956     {
00957         Base::Console().Error(e);
00958         PyErr_SetString(PyExc_Exception,e);
00959         return NULL;
00960     }
00961     // in debug not all exceptions will be catched to get the attention of the developer!
00962 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00963     catch(const std::exception& e) // catch other c++ exceptions
00964     {
00965         std::string str;
00966         str += "FC++ exception thrown (";
00967         str += e.what();
00968         str += ")";
00969         Base::Console().Error(str.c_str());
00970         PyErr_SetString(PyExc_Exception,str.c_str());
00971         return NULL;
00972     }
00973     catch(...)  // catch the rest!
00974     {
00975         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00976         return NULL;
00977     }
00978 #endif
00979 }
00980 
00981 // distanceToPlane() callback and implementer
00982 // PyObject*  VectorPy::distanceToPlane(PyObject *args){};
00983 // has to be implemented in VectorPyImp.cpp
00984 PyObject * VectorPy::staticCallback_distanceToPlane (PyObject *self, PyObject *args)
00985 {
00986     // test if twin object not allready deleted
00987     if (!((PyObjectBase*) self)->isValid()){
00988         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00989         return NULL;
00990     }
00991 
00992 
00993     try { // catches all exceptions coming up from c++ and generate a python exception
00994         PyObject* ret = ((VectorPy*)self)->distanceToPlane(args);
00995         return ret;
00996     }
00997     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00998     {
00999         std::string str;
01000         str += "FreeCAD exception thrown (";
01001         str += e.what();
01002         str += ")";
01003         e.ReportException();
01004         PyErr_SetString(PyExc_Exception,str.c_str());
01005         return NULL;
01006     }
01007     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
01008     {
01009         std::string str;
01010         str += "File system exception thrown (";
01011         //str += e.who();
01012         //str += ", ";
01013         str += e.what();
01014         str += ")\n";
01015         Base::Console().Error(str.c_str());
01016         PyErr_SetString(PyExc_Exception,str.c_str());
01017         return NULL;
01018     }
01019     catch(const Py::Exception&)
01020     {
01021         // The exception text is already set
01022         return NULL;
01023     }
01024     catch(const char* e) // catch simple string exceptions
01025     {
01026         Base::Console().Error(e);
01027         PyErr_SetString(PyExc_Exception,e);
01028         return NULL;
01029     }
01030     // in debug not all exceptions will be catched to get the attention of the developer!
01031 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
01032     catch(const std::exception& e) // catch other c++ exceptions
01033     {
01034         std::string str;
01035         str += "FC++ exception thrown (";
01036         str += e.what();
01037         str += ")";
01038         Base::Console().Error(str.c_str());
01039         PyErr_SetString(PyExc_Exception,str.c_str());
01040         return NULL;
01041     }
01042     catch(...)  // catch the rest!
01043     {
01044         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
01045         return NULL;
01046     }
01047 #endif
01048 }
01049 
01050 // Length() callback and implementer
01051 // PyObject*  VectorPy::Length(PyObject *args){};
01052 // has to be implemented in VectorPyImp.cpp
01053 PyObject * VectorPy::staticCallback_getLength (PyObject *self, void * /*closure*/)
01054 {
01055     if (!((PyObjectBase*) self)->isValid()){
01056         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01057         return NULL;
01058     }
01059 
01060     try {
01061         return Py::new_reference_to(((VectorPy*)self)->getLength());
01062     } catch (const Py::Exception&) {
01063         // The exception text is already set
01064         return NULL;
01065     } catch (...) {
01066         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Length' of object 'Vector'");
01067         return NULL;
01068     }
01069 }
01070 
01071 int VectorPy::staticCallback_setLength (PyObject *self, PyObject *value, void * /*closure*/)
01072 {    
01073     if (!((PyObjectBase*) self)->isValid()){
01074         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01075         return -1;
01076     }
01077     if (((PyObjectBase*) self)->isConst()){
01078         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
01079         return -1;
01080     }
01081 
01082     try {
01083         ((VectorPy*)self)->setLength(Py::Float(value,false));
01084         return 0;
01085     } catch (const Py::Exception&) {
01086         // The exception text is already set
01087         return -1;
01088     } catch (...) {
01089         PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Length' of object 'Vector'");
01090         return -1;
01091     }
01092 }
01093 
01094 // x() callback and implementer
01095 // PyObject*  VectorPy::x(PyObject *args){};
01096 // has to be implemented in VectorPyImp.cpp
01097 PyObject * VectorPy::staticCallback_getx (PyObject *self, void * /*closure*/)
01098 {
01099     if (!((PyObjectBase*) self)->isValid()){
01100         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01101         return NULL;
01102     }
01103 
01104     try {
01105         return Py::new_reference_to(((VectorPy*)self)->getx());
01106     } catch (const Py::Exception&) {
01107         // The exception text is already set
01108         return NULL;
01109     } catch (...) {
01110         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'x' of object 'Vector'");
01111         return NULL;
01112     }
01113 }
01114 
01115 int VectorPy::staticCallback_setx (PyObject *self, PyObject *value, void * /*closure*/)
01116 {    
01117     if (!((PyObjectBase*) self)->isValid()){
01118         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01119         return -1;
01120     }
01121     if (((PyObjectBase*) self)->isConst()){
01122         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
01123         return -1;
01124     }
01125 
01126     try {
01127         ((VectorPy*)self)->setx(Py::Float(value,false));
01128         return 0;
01129     } catch (const Py::Exception&) {
01130         // The exception text is already set
01131         return -1;
01132     } catch (...) {
01133         PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'x' of object 'Vector'");
01134         return -1;
01135     }
01136 }
01137 
01138 // y() callback and implementer
01139 // PyObject*  VectorPy::y(PyObject *args){};
01140 // has to be implemented in VectorPyImp.cpp
01141 PyObject * VectorPy::staticCallback_gety (PyObject *self, void * /*closure*/)
01142 {
01143     if (!((PyObjectBase*) self)->isValid()){
01144         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01145         return NULL;
01146     }
01147 
01148     try {
01149         return Py::new_reference_to(((VectorPy*)self)->gety());
01150     } catch (const Py::Exception&) {
01151         // The exception text is already set
01152         return NULL;
01153     } catch (...) {
01154         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'y' of object 'Vector'");
01155         return NULL;
01156     }
01157 }
01158 
01159 int VectorPy::staticCallback_sety (PyObject *self, PyObject *value, void * /*closure*/)
01160 {    
01161     if (!((PyObjectBase*) self)->isValid()){
01162         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01163         return -1;
01164     }
01165     if (((PyObjectBase*) self)->isConst()){
01166         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
01167         return -1;
01168     }
01169 
01170     try {
01171         ((VectorPy*)self)->sety(Py::Float(value,false));
01172         return 0;
01173     } catch (const Py::Exception&) {
01174         // The exception text is already set
01175         return -1;
01176     } catch (...) {
01177         PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'y' of object 'Vector'");
01178         return -1;
01179     }
01180 }
01181 
01182 // z() callback and implementer
01183 // PyObject*  VectorPy::z(PyObject *args){};
01184 // has to be implemented in VectorPyImp.cpp
01185 PyObject * VectorPy::staticCallback_getz (PyObject *self, void * /*closure*/)
01186 {
01187     if (!((PyObjectBase*) self)->isValid()){
01188         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01189         return NULL;
01190     }
01191 
01192     try {
01193         return Py::new_reference_to(((VectorPy*)self)->getz());
01194     } catch (const Py::Exception&) {
01195         // The exception text is already set
01196         return NULL;
01197     } catch (...) {
01198         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'z' of object 'Vector'");
01199         return NULL;
01200     }
01201 }
01202 
01203 int VectorPy::staticCallback_setz (PyObject *self, PyObject *value, void * /*closure*/)
01204 {    
01205     if (!((PyObjectBase*) self)->isValid()){
01206         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01207         return -1;
01208     }
01209     if (((PyObjectBase*) self)->isConst()){
01210         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
01211         return -1;
01212     }
01213 
01214     try {
01215         ((VectorPy*)self)->setz(Py::Float(value,false));
01216         return 0;
01217     } catch (const Py::Exception&) {
01218         // The exception text is already set
01219         return -1;
01220     } catch (...) {
01221         PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'z' of object 'Vector'");
01222         return -1;
01223     }
01224 }
01225 
01226 
01227 
01228 //--------------------------------------------------------------------------
01229 // Parents structure
01230 //--------------------------------------------------------------------------
01231 PyParentObject VectorPy::Parents[] = { PARENTSBaseVectorPy };
01232 
01233 //--------------------------------------------------------------------------
01234 // Constructor
01235 //--------------------------------------------------------------------------
01236 VectorPy::VectorPy(Vector3d *pcObject, PyTypeObject *T)
01237     : PyObjectBase(reinterpret_cast<PyObjectBase::PointerType>(pcObject), T)
01238 {
01239 }
01240 
01241 
01242 //--------------------------------------------------------------------------
01243 // destructor
01244 //--------------------------------------------------------------------------
01245 VectorPy::~VectorPy()                                // Everything handled in parent
01246 {
01247     // delete the handled object when the PyObject dies
01248     VectorPy::PointerType ptr = reinterpret_cast<VectorPy::PointerType>(_pcTwinPointer);
01249     delete ptr;
01250 }
01251 
01252 //--------------------------------------------------------------------------
01253 // VectorPy representation
01254 //--------------------------------------------------------------------------
01255 PyObject *VectorPy::_repr(void)
01256 {
01257     return Py_BuildValue("s", representation().c_str());
01258 }
01259 
01260 //--------------------------------------------------------------------------
01261 // VectorPy Attributes
01262 //--------------------------------------------------------------------------
01263 PyObject *VectorPy::_getattr(char *attr)                                // __getattr__ function: note only need to handle new state
01264 {
01265     try {
01266         // getter method for special Attributes (e.g. dynamic ones)
01267         PyObject *r = getCustomAttributes(attr);
01268         if(r) return r;
01269     }
01270 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
01271     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01272     {
01273         std::string str;
01274         str += "FreeCAD exception thrown (";
01275         str += e.what();
01276         str += ")";
01277         e.ReportException();
01278         PyErr_SetString(PyExc_Exception,str.c_str());
01279         return NULL;
01280     }
01281     catch(const std::exception& e) // catch other c++ exceptions
01282     {
01283         std::string str;
01284         str += "FC++ exception thrown (";
01285         str += e.what();
01286         str += ")";
01287         Base::Console().Error(str.c_str());
01288         PyErr_SetString(PyExc_Exception,str.c_str());
01289         return NULL;
01290     }
01291     catch(const Py::Exception&)
01292     {
01293         // The exception text is already set
01294         return NULL;
01295     }
01296     catch(...)  // catch the rest!
01297     {
01298         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
01299         return NULL;
01300     }
01301 #else  // DONT_CATCH_CXX_EXCEPTIONS  
01302     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01303     {
01304         std::string str;
01305         str += "FreeCAD exception thrown (";
01306         str += e.what();
01307         str += ")";
01308         e.ReportException();
01309         PyErr_SetString(PyExc_Exception,str.c_str());
01310         return NULL;
01311     }
01312     catch(const Py::Exception&)
01313     {
01314         // The exception text is already set
01315         return NULL;
01316     }
01317 #endif  // DONT_CATCH_CXX_EXCEPTIONS
01318 
01319     PyObject *rvalue = Py_FindMethod(Methods, this, attr);
01320     if (rvalue == NULL)
01321     {
01322         PyErr_Clear();
01323         return PyObjectBase::_getattr(attr);
01324     }
01325     else
01326     {
01327         return rvalue;
01328     }
01329 }
01330 
01331 int VectorPy::_setattr(char *attr, PyObject *value)     // __setattr__ function: note only need to handle new state
01332 {
01333     try {
01334         // setter for  special Attributes (e.g. dynamic ones)
01335         int r = setCustomAttributes(attr, value);
01336         if(r==1) return 0;
01337     }
01338 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
01339     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01340     {
01341         std::string str;
01342         str += "FreeCAD exception thrown (";
01343         str += e.what();
01344         str += ")";
01345         e.ReportException();
01346         PyErr_SetString(PyExc_Exception,str.c_str());
01347         return -1;
01348     }
01349     catch(const std::exception& e) // catch other c++ exceptions
01350     {
01351         std::string str;
01352         str += "FC++ exception thrown (";
01353         str += e.what();
01354         str += ")";
01355         Base::Console().Error(str.c_str());
01356         PyErr_SetString(PyExc_Exception,str.c_str());
01357         return -1;
01358     }
01359     catch(const Py::Exception&)
01360     {
01361         // The exception text is already set
01362         return -1;
01363     }
01364     catch(...)  // catch the rest!
01365     {
01366         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
01367         return -1;
01368     }
01369 #else  // DONT_CATCH_CXX_EXCEPTIONS  
01370     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01371     {
01372         std::string str;
01373         str += "FreeCAD exception thrown (";
01374         str += e.what();
01375         str += ")";
01376         e.ReportException();
01377         PyErr_SetString(PyExc_Exception,str.c_str());
01378         return -1;
01379     }
01380     catch(const Py::Exception&)
01381     {
01382         // The exception text is already set
01383         return -1;
01384     }
01385 #endif  // DONT_CATCH_CXX_EXCEPTIONS
01386 
01387     return PyObjectBase::_setattr(attr, value);
01388 }
01389 
01390 Vector3d *VectorPy::getVectorPtr(void) const
01391 {
01392     return static_cast<Vector3d *>(_pcTwinPointer);
01393 }
01394 
01395 #if 0
01396 /* From here on come the methods you have to implement, but NOT in this module. Implement in VectorPyImp.cpp! This prototypes 
01397  * are just for convenience when you add a new method.
01398  */
01399 
01400 PyObject *VectorPy::PyMake(struct _typeobject *, PyObject *, PyObject *)  // Python wrapper
01401 {
01402     // create a new instance of VectorPy and the Twin object 
01403     return new VectorPy(new Vector3d);
01404 }
01405 
01406 // constructor method
01407 int VectorPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
01408 {
01409     return 0;
01410 }
01411 
01412 // returns a string which represents the object e.g. when printed in python
01413 std::string VectorPy::representation(void) const
01414 {
01415     return std::string("<Vector object>");
01416 }
01417 
01418 PyObject* VectorPy::add(PyObject *args)
01419 {
01420     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01421     return 0;
01422 }
01423 
01424 PyObject* VectorPy::sub(PyObject *args)
01425 {
01426     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01427     return 0;
01428 }
01429 
01430 PyObject* VectorPy::scale(PyObject *args)
01431 {
01432     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01433     return 0;
01434 }
01435 
01436 PyObject* VectorPy::multiply(PyObject *args)
01437 {
01438     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01439     return 0;
01440 }
01441 
01442 PyObject* VectorPy::dot(PyObject *args)
01443 {
01444     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01445     return 0;
01446 }
01447 
01448 PyObject* VectorPy::cross(PyObject *args)
01449 {
01450     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01451     return 0;
01452 }
01453 
01454 PyObject* VectorPy::getAngle(PyObject *args)
01455 {
01456     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01457     return 0;
01458 }
01459 
01460 PyObject* VectorPy::normalize(PyObject *args)
01461 {
01462     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01463     return 0;
01464 }
01465 
01466 PyObject* VectorPy::projectToLine(PyObject *args)
01467 {
01468     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01469     return 0;
01470 }
01471 
01472 PyObject* VectorPy::projectToPlane(PyObject *args)
01473 {
01474     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01475     return 0;
01476 }
01477 
01478 PyObject* VectorPy::distanceToLine(PyObject *args)
01479 {
01480     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01481     return 0;
01482 }
01483 
01484 PyObject* VectorPy::distanceToPlane(PyObject *args)
01485 {
01486     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01487     return 0;
01488 }
01489 
01490 PyObject* VectorPy::number_add_handler(PyObject *self, PyObject *other)
01491 {
01492     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01493     return 0;
01494 }
01495 
01496 PyObject* VectorPy::number_subtract_handler(PyObject *self, PyObject *other)
01497 {
01498     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01499     return 0;
01500 }
01501 
01502 PyObject* VectorPy::number_multiply_handler(PyObject *self, PyObject *other)
01503 {
01504     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01505     return 0;
01506 }
01507 
01508 Py_ssize_t VectorPy::sequence_length(PyObject *)
01509 {
01510     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01511     return -1;
01512 }
01513 
01514 PyObject * VectorPy::sequence_item(PyObject *, Py_ssize_t)
01515 {
01516     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01517     return 0;
01518 }
01519 
01520 int VectorPy::sequence_ass_item(PyObject *, Py_ssize_t, PyObject *)
01521 {
01522     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01523     return -1;
01524 }
01525 
01526 PyObject* VectorPy::richCompare(PyObject *v, PyObject *w, int op)
01527 {
01528     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01529     return 0;
01530 }
01531 
01532 Py::Float VectorPy::getLength(void) const
01533 {
01534     //return Py::Float();
01535     throw Py::AttributeError("Not yet implemented");
01536 }
01537 
01538 void  VectorPy::setLength(Py::Float arg)
01539 {
01540     throw Py::AttributeError("Not yet implemented");
01541 }
01542 
01543 Py::Float VectorPy::getx(void) const
01544 {
01545     //return Py::Float();
01546     throw Py::AttributeError("Not yet implemented");
01547 }
01548 
01549 void  VectorPy::setx(Py::Float arg)
01550 {
01551     throw Py::AttributeError("Not yet implemented");
01552 }
01553 
01554 Py::Float VectorPy::gety(void) const
01555 {
01556     //return Py::Float();
01557     throw Py::AttributeError("Not yet implemented");
01558 }
01559 
01560 void  VectorPy::sety(Py::Float arg)
01561 {
01562     throw Py::AttributeError("Not yet implemented");
01563 }
01564 
01565 Py::Float VectorPy::getz(void) const
01566 {
01567     //return Py::Float();
01568     throw Py::AttributeError("Not yet implemented");
01569 }
01570 
01571 void  VectorPy::setz(Py::Float arg)
01572 {
01573     throw Py::AttributeError("Not yet implemented");
01574 }
01575 
01576 PyObject *VectorPy::getCustomAttributes(const char* attr) const
01577 {
01578     return 0;
01579 }
01580 
01581 int VectorPy::setCustomAttributes(const char* attr, PyObject *obj)
01582 {
01583     return 0; 
01584 }
01585 #endif
01586 
01587 
01588 

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