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