00001
00002
00003
00004
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 ParabolaPy::Type = {
00021 PyObject_HEAD_INIT(&PyType_Type)
00022 0,
00023 "Part.GeomParabola",
00024 sizeof(ParabolaPy),
00025 0,
00026
00027 PyDestructor,
00028 0,
00029 __getattr,
00030 __setattr,
00031 0,
00032 __repr,
00033 0,
00034 0,
00035 0,
00036 0,
00037 0,
00038 0,
00039 0,
00040 0,
00041
00042 0,
00043
00044 Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_CLASS,
00045 "Describes a parabola in 3D space",
00046 0,
00047 0,
00048 0,
00049 0,
00050 0,
00051 0,
00052 Part::ParabolaPy::Methods,
00053 0,
00054 Part::ParabolaPy::GetterSetter,
00055 &Part::GeometryCurvePy::Type,
00056 0,
00057 0,
00058 0,
00059 0,
00060 __PyInit,
00061 0,
00062 Part::ParabolaPy::PyMake,
00063 0,
00064 0,
00065 0,
00066 0,
00067 0,
00068 0,
00069 0,
00070 0
00071 };
00072
00074 PyMethodDef ParabolaPy::Methods[] = {
00075 {NULL, NULL, 0, NULL}
00076 };
00077
00078
00079
00081 PyGetSetDef ParabolaPy::GetterSetter[] = {
00082 {"Eccentricity",
00083 (getter) staticCallback_getEccentricity,
00084 (setter) staticCallback_setEccentricity,
00085 "Returns 1. (which is the eccentricity of any parabola).",
00086 NULL
00087 },
00088 {"Focal",
00089 (getter) staticCallback_getFocal,
00090 (setter) staticCallback_setFocal,
00091 "The focal distance is the distance between\nthe apex and the focus of the parabola.",
00092 NULL
00093 },
00094 {"Focus",
00095 (getter) staticCallback_getFocus,
00096 (setter) staticCallback_setFocus,
00097 "The focus is on the positive side of the\n'X Axis' of the local coordinate system of the parabola.",
00098 NULL
00099 },
00100 {"Parameter",
00101 (getter) staticCallback_getParameter,
00102 (setter) staticCallback_setParameter,
00103 "Compute the parameter of this parabola\nwhich is the distance between its focus\nand its directrix. This distance is twice the focal length.\n ",
00104 NULL
00105 },
00106 {"Location",
00107 (getter) staticCallback_getLocation,
00108 (setter) staticCallback_setLocation,
00109 "Location of the parabola",
00110 NULL
00111 },
00112 {"Axis",
00113 (getter) staticCallback_getAxis,
00114 (setter) staticCallback_setAxis,
00115 "The axis direction of the parabola",
00116 NULL
00117 },
00118 {NULL, NULL, NULL, NULL, NULL}
00119 };
00120
00121
00122
00123
00124 PyObject * ParabolaPy::staticCallback_getEccentricity (PyObject *self, void * )
00125 {
00126 if (!((PyObjectBase*) self)->isValid()){
00127 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00128 return NULL;
00129 }
00130
00131 try {
00132 return Py::new_reference_to(((ParabolaPy*)self)->getEccentricity());
00133 } catch (const Py::Exception&) {
00134
00135 return NULL;
00136 } catch (...) {
00137 PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Eccentricity' of object 'GeomParabola'");
00138 return NULL;
00139 }
00140 }
00141
00142 int ParabolaPy::staticCallback_setEccentricity (PyObject *self, PyObject * , void * )
00143 {
00144 if (!((PyObjectBase*) self)->isValid()){
00145 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00146 return -1;
00147 }
00148
00149 PyErr_SetString(PyExc_AttributeError, "Attribute 'Eccentricity' of object 'GeomParabola' is read-only");
00150 return -1;
00151 }
00152
00153
00154
00155
00156 PyObject * ParabolaPy::staticCallback_getFocal (PyObject *self, void * )
00157 {
00158 if (!((PyObjectBase*) self)->isValid()){
00159 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00160 return NULL;
00161 }
00162
00163 try {
00164 return Py::new_reference_to(((ParabolaPy*)self)->getFocal());
00165 } catch (const Py::Exception&) {
00166
00167 return NULL;
00168 } catch (...) {
00169 PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Focal' of object 'GeomParabola'");
00170 return NULL;
00171 }
00172 }
00173
00174 int ParabolaPy::staticCallback_setFocal (PyObject *self, PyObject *value, void * )
00175 {
00176 if (!((PyObjectBase*) self)->isValid()){
00177 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00178 return -1;
00179 }
00180 if (((PyObjectBase*) self)->isConst()){
00181 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00182 return -1;
00183 }
00184
00185 try {
00186 ((ParabolaPy*)self)->setFocal(Py::Float(value,false));
00187 return 0;
00188 } catch (const Py::Exception&) {
00189
00190 return -1;
00191 } catch (...) {
00192 PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Focal' of object 'GeomParabola'");
00193 return -1;
00194 }
00195 }
00196
00197
00198
00199
00200 PyObject * ParabolaPy::staticCallback_getFocus (PyObject *self, void * )
00201 {
00202 if (!((PyObjectBase*) self)->isValid()){
00203 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00204 return NULL;
00205 }
00206
00207 try {
00208 return Py::new_reference_to(((ParabolaPy*)self)->getFocus());
00209 } catch (const Py::Exception&) {
00210
00211 return NULL;
00212 } catch (...) {
00213 PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Focus' of object 'GeomParabola'");
00214 return NULL;
00215 }
00216 }
00217
00218 int ParabolaPy::staticCallback_setFocus (PyObject *self, PyObject * , void * )
00219 {
00220 if (!((PyObjectBase*) self)->isValid()){
00221 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00222 return -1;
00223 }
00224
00225 PyErr_SetString(PyExc_AttributeError, "Attribute 'Focus' of object 'GeomParabola' is read-only");
00226 return -1;
00227 }
00228
00229
00230
00231
00232 PyObject * ParabolaPy::staticCallback_getParameter (PyObject *self, void * )
00233 {
00234 if (!((PyObjectBase*) self)->isValid()){
00235 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00236 return NULL;
00237 }
00238
00239 try {
00240 return Py::new_reference_to(((ParabolaPy*)self)->getParameter());
00241 } catch (const Py::Exception&) {
00242
00243 return NULL;
00244 } catch (...) {
00245 PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Parameter' of object 'GeomParabola'");
00246 return NULL;
00247 }
00248 }
00249
00250 int ParabolaPy::staticCallback_setParameter (PyObject *self, PyObject * , void * )
00251 {
00252 if (!((PyObjectBase*) self)->isValid()){
00253 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00254 return -1;
00255 }
00256
00257 PyErr_SetString(PyExc_AttributeError, "Attribute 'Parameter' of object 'GeomParabola' is read-only");
00258 return -1;
00259 }
00260
00261
00262
00263
00264 PyObject * ParabolaPy::staticCallback_getLocation (PyObject *self, void * )
00265 {
00266 if (!((PyObjectBase*) self)->isValid()){
00267 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00268 return NULL;
00269 }
00270
00271 try {
00272 return Py::new_reference_to(((ParabolaPy*)self)->getLocation());
00273 } catch (const Py::Exception&) {
00274
00275 return NULL;
00276 } catch (...) {
00277 PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Location' of object 'GeomParabola'");
00278 return NULL;
00279 }
00280 }
00281
00282 int ParabolaPy::staticCallback_setLocation (PyObject *self, PyObject *value, void * )
00283 {
00284 if (!((PyObjectBase*) self)->isValid()){
00285 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00286 return -1;
00287 }
00288 if (((PyObjectBase*) self)->isConst()){
00289 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00290 return -1;
00291 }
00292
00293 try {
00294 ((ParabolaPy*)self)->setLocation(Py::Object(value,false));
00295 return 0;
00296 } catch (const Py::Exception&) {
00297
00298 return -1;
00299 } catch (...) {
00300 PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Location' of object 'GeomParabola'");
00301 return -1;
00302 }
00303 }
00304
00305
00306
00307
00308 PyObject * ParabolaPy::staticCallback_getAxis (PyObject *self, void * )
00309 {
00310 if (!((PyObjectBase*) self)->isValid()){
00311 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00312 return NULL;
00313 }
00314
00315 try {
00316 return Py::new_reference_to(((ParabolaPy*)self)->getAxis());
00317 } catch (const Py::Exception&) {
00318
00319 return NULL;
00320 } catch (...) {
00321 PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Axis' of object 'GeomParabola'");
00322 return NULL;
00323 }
00324 }
00325
00326 int ParabolaPy::staticCallback_setAxis (PyObject *self, PyObject *value, void * )
00327 {
00328 if (!((PyObjectBase*) self)->isValid()){
00329 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00330 return -1;
00331 }
00332 if (((PyObjectBase*) self)->isConst()){
00333 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00334 return -1;
00335 }
00336
00337 try {
00338 ((ParabolaPy*)self)->setAxis(Py::Object(value,false));
00339 return 0;
00340 } catch (const Py::Exception&) {
00341
00342 return -1;
00343 } catch (...) {
00344 PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Axis' of object 'GeomParabola'");
00345 return -1;
00346 }
00347 }
00348
00349
00350
00351
00352
00353
00354 PyParentObject ParabolaPy::Parents[] = { PARENTSPartParabolaPy };
00355
00356
00357
00358
00359 ParabolaPy::ParabolaPy(GeomParabola *pcObject, PyTypeObject *T)
00360 : GeometryCurvePy(reinterpret_cast<GeometryCurvePy::PointerType>(pcObject), T)
00361 {
00362 }
00363
00364
00365
00366
00367
00368 ParabolaPy::~ParabolaPy()
00369 {
00370 }
00371
00372
00373
00374
00375 PyObject *ParabolaPy::_repr(void)
00376 {
00377 return Py_BuildValue("s", representation().c_str());
00378 }
00379
00380
00381
00382
00383 PyObject *ParabolaPy::_getattr(char *attr)
00384 {
00385 try {
00386
00387 PyObject *r = getCustomAttributes(attr);
00388 if(r) return r;
00389 }
00390 #ifndef DONT_CATCH_CXX_EXCEPTIONS
00391 catch(const Base::Exception& e)
00392 {
00393 std::string str;
00394 str += "FreeCAD exception thrown (";
00395 str += e.what();
00396 str += ")";
00397 e.ReportException();
00398 PyErr_SetString(PyExc_Exception,str.c_str());
00399 return NULL;
00400 }
00401 catch(const std::exception& e)
00402 {
00403 std::string str;
00404 str += "FC++ exception thrown (";
00405 str += e.what();
00406 str += ")";
00407 Base::Console().Error(str.c_str());
00408 PyErr_SetString(PyExc_Exception,str.c_str());
00409 return NULL;
00410 }
00411 catch(const Py::Exception&)
00412 {
00413
00414 return NULL;
00415 }
00416 catch(...)
00417 {
00418 PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00419 return NULL;
00420 }
00421 #else // DONT_CATCH_CXX_EXCEPTIONS
00422 catch(const Base::Exception& e)
00423 {
00424 std::string str;
00425 str += "FreeCAD exception thrown (";
00426 str += e.what();
00427 str += ")";
00428 e.ReportException();
00429 PyErr_SetString(PyExc_Exception,str.c_str());
00430 return NULL;
00431 }
00432 catch(const Py::Exception&)
00433 {
00434
00435 return NULL;
00436 }
00437 #endif // DONT_CATCH_CXX_EXCEPTIONS
00438
00439 PyObject *rvalue = Py_FindMethod(Methods, this, attr);
00440 if (rvalue == NULL)
00441 {
00442 PyErr_Clear();
00443 return GeometryCurvePy::_getattr(attr);
00444 }
00445 else
00446 {
00447 return rvalue;
00448 }
00449 }
00450
00451 int ParabolaPy::_setattr(char *attr, PyObject *value)
00452 {
00453 try {
00454
00455 int r = setCustomAttributes(attr, value);
00456 if(r==1) return 0;
00457 }
00458 #ifndef DONT_CATCH_CXX_EXCEPTIONS
00459 catch(const Base::Exception& e)
00460 {
00461 std::string str;
00462 str += "FreeCAD exception thrown (";
00463 str += e.what();
00464 str += ")";
00465 e.ReportException();
00466 PyErr_SetString(PyExc_Exception,str.c_str());
00467 return -1;
00468 }
00469 catch(const std::exception& e)
00470 {
00471 std::string str;
00472 str += "FC++ exception thrown (";
00473 str += e.what();
00474 str += ")";
00475 Base::Console().Error(str.c_str());
00476 PyErr_SetString(PyExc_Exception,str.c_str());
00477 return -1;
00478 }
00479 catch(const Py::Exception&)
00480 {
00481
00482 return -1;
00483 }
00484 catch(...)
00485 {
00486 PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00487 return -1;
00488 }
00489 #else // DONT_CATCH_CXX_EXCEPTIONS
00490 catch(const Base::Exception& e)
00491 {
00492 std::string str;
00493 str += "FreeCAD exception thrown (";
00494 str += e.what();
00495 str += ")";
00496 e.ReportException();
00497 PyErr_SetString(PyExc_Exception,str.c_str());
00498 return -1;
00499 }
00500 catch(const Py::Exception&)
00501 {
00502
00503 return -1;
00504 }
00505 #endif // DONT_CATCH_CXX_EXCEPTIONS
00506
00507 return GeometryCurvePy::_setattr(attr, value);
00508 }
00509
00510 GeomParabola *ParabolaPy::getGeomParabolaPtr(void) const
00511 {
00512 return static_cast<GeomParabola *>(_pcTwinPointer);
00513 }
00514
00515 #if 0
00516
00517
00518
00519
00520 PyObject *ParabolaPy::PyMake(struct _typeobject *, PyObject *, PyObject *)
00521 {
00522
00523 return new ParabolaPy(new GeomParabola);
00524 }
00525
00526
00527 int ParabolaPy::PyInit(PyObject* , PyObject* )
00528 {
00529 return 0;
00530 }
00531
00532
00533 std::string ParabolaPy::representation(void) const
00534 {
00535 return std::string("<GeomParabola object>");
00536 }
00537
00538
00539
00540 Py::Float ParabolaPy::getEccentricity(void) const
00541 {
00542
00543 throw Py::AttributeError("Not yet implemented");
00544 }
00545
00546 Py::Float ParabolaPy::getFocal(void) const
00547 {
00548
00549 throw Py::AttributeError("Not yet implemented");
00550 }
00551
00552 void ParabolaPy::setFocal(Py::Float arg)
00553 {
00554 throw Py::AttributeError("Not yet implemented");
00555 }
00556
00557 Py::Object ParabolaPy::getFocus(void) const
00558 {
00559
00560 throw Py::AttributeError("Not yet implemented");
00561 }
00562
00563 Py::Float ParabolaPy::getParameter(void) const
00564 {
00565
00566 throw Py::AttributeError("Not yet implemented");
00567 }
00568
00569 Py::Object ParabolaPy::getLocation(void) const
00570 {
00571
00572 throw Py::AttributeError("Not yet implemented");
00573 }
00574
00575 void ParabolaPy::setLocation(Py::Object arg)
00576 {
00577 throw Py::AttributeError("Not yet implemented");
00578 }
00579
00580 Py::Object ParabolaPy::getAxis(void) const
00581 {
00582
00583 throw Py::AttributeError("Not yet implemented");
00584 }
00585
00586 void ParabolaPy::setAxis(Py::Object arg)
00587 {
00588 throw Py::AttributeError("Not yet implemented");
00589 }
00590
00591 PyObject *ParabolaPy::getCustomAttributes(const char* attr) const
00592 {
00593 return 0;
00594 }
00595
00596 int ParabolaPy::setCustomAttributes(const char* attr, PyObject *obj)
00597 {
00598 return 0;
00599 }
00600 #endif
00601
00602
00603