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 SurfaceOfRevolutionPy::Type = {
00021 PyObject_HEAD_INIT(&PyType_Type)
00022 0,
00023 "Part.GeomSurfaceOfRevolution",
00024 sizeof(SurfaceOfRevolutionPy),
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 surface of revolution",
00046 0,
00047 0,
00048 0,
00049 0,
00050 0,
00051 0,
00052 Part::SurfaceOfRevolutionPy::Methods,
00053 0,
00054 Part::SurfaceOfRevolutionPy::GetterSetter,
00055 &Part::GeometrySurfacePy::Type,
00056 0,
00057 0,
00058 0,
00059 0,
00060 __PyInit,
00061 0,
00062 Part::SurfaceOfRevolutionPy::PyMake,
00063 0,
00064 0,
00065 0,
00066 0,
00067 0,
00068 0,
00069 0,
00070 0
00071 };
00072
00074 PyMethodDef SurfaceOfRevolutionPy::Methods[] = {
00075 {NULL, NULL, 0, NULL}
00076 };
00077
00078
00079
00081 PyGetSetDef SurfaceOfRevolutionPy::GetterSetter[] = {
00082 {"Location",
00083 (getter) staticCallback_getLocation,
00084 (setter) staticCallback_setLocation,
00085 "\n Sets or gets the location of revolution.\n ",
00086 NULL
00087 },
00088 {"Direction",
00089 (getter) staticCallback_getDirection,
00090 (setter) staticCallback_setDirection,
00091 "\n Sets or gets the direction of revolution.\n ",
00092 NULL
00093 },
00094 {"BasisCurve",
00095 (getter) staticCallback_getBasisCurve,
00096 (setter) staticCallback_setBasisCurve,
00097 "\n Sets or gets the basic curve.\n ",
00098 NULL
00099 },
00100 {NULL, NULL, NULL, NULL, NULL}
00101 };
00102
00103
00104
00105
00106 PyObject * SurfaceOfRevolutionPy::staticCallback_getLocation (PyObject *self, void * )
00107 {
00108 if (!((PyObjectBase*) self)->isValid()){
00109 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00110 return NULL;
00111 }
00112
00113 try {
00114 return Py::new_reference_to(((SurfaceOfRevolutionPy*)self)->getLocation());
00115 } catch (const Py::Exception&) {
00116
00117 return NULL;
00118 } catch (...) {
00119 PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Location' of object 'GeomSurfaceOfRevolution'");
00120 return NULL;
00121 }
00122 }
00123
00124 int SurfaceOfRevolutionPy::staticCallback_setLocation (PyObject *self, PyObject *value, 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 -1;
00129 }
00130 if (((PyObjectBase*) self)->isConst()){
00131 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00132 return -1;
00133 }
00134
00135 try {
00136 ((SurfaceOfRevolutionPy*)self)->setLocation(Py::Object(value,false));
00137 return 0;
00138 } catch (const Py::Exception&) {
00139
00140 return -1;
00141 } catch (...) {
00142 PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Location' of object 'GeomSurfaceOfRevolution'");
00143 return -1;
00144 }
00145 }
00146
00147
00148
00149
00150 PyObject * SurfaceOfRevolutionPy::staticCallback_getDirection (PyObject *self, void * )
00151 {
00152 if (!((PyObjectBase*) self)->isValid()){
00153 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00154 return NULL;
00155 }
00156
00157 try {
00158 return Py::new_reference_to(((SurfaceOfRevolutionPy*)self)->getDirection());
00159 } catch (const Py::Exception&) {
00160
00161 return NULL;
00162 } catch (...) {
00163 PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Direction' of object 'GeomSurfaceOfRevolution'");
00164 return NULL;
00165 }
00166 }
00167
00168 int SurfaceOfRevolutionPy::staticCallback_setDirection (PyObject *self, PyObject *value, void * )
00169 {
00170 if (!((PyObjectBase*) self)->isValid()){
00171 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00172 return -1;
00173 }
00174 if (((PyObjectBase*) self)->isConst()){
00175 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00176 return -1;
00177 }
00178
00179 try {
00180 ((SurfaceOfRevolutionPy*)self)->setDirection(Py::Object(value,false));
00181 return 0;
00182 } catch (const Py::Exception&) {
00183
00184 return -1;
00185 } catch (...) {
00186 PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Direction' of object 'GeomSurfaceOfRevolution'");
00187 return -1;
00188 }
00189 }
00190
00191
00192
00193
00194 PyObject * SurfaceOfRevolutionPy::staticCallback_getBasisCurve (PyObject *self, void * )
00195 {
00196 if (!((PyObjectBase*) self)->isValid()){
00197 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00198 return NULL;
00199 }
00200
00201 try {
00202 return Py::new_reference_to(((SurfaceOfRevolutionPy*)self)->getBasisCurve());
00203 } catch (const Py::Exception&) {
00204
00205 return NULL;
00206 } catch (...) {
00207 PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'BasisCurve' of object 'GeomSurfaceOfRevolution'");
00208 return NULL;
00209 }
00210 }
00211
00212 int SurfaceOfRevolutionPy::staticCallback_setBasisCurve (PyObject *self, PyObject *value, void * )
00213 {
00214 if (!((PyObjectBase*) self)->isValid()){
00215 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00216 return -1;
00217 }
00218 if (((PyObjectBase*) self)->isConst()){
00219 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00220 return -1;
00221 }
00222
00223 try {
00224 ((SurfaceOfRevolutionPy*)self)->setBasisCurve(Py::Object(value,false));
00225 return 0;
00226 } catch (const Py::Exception&) {
00227
00228 return -1;
00229 } catch (...) {
00230 PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'BasisCurve' of object 'GeomSurfaceOfRevolution'");
00231 return -1;
00232 }
00233 }
00234
00235
00236
00237
00238
00239
00240 PyParentObject SurfaceOfRevolutionPy::Parents[] = { PARENTSPartSurfaceOfRevolutionPy };
00241
00242
00243
00244
00245 SurfaceOfRevolutionPy::SurfaceOfRevolutionPy(GeomSurfaceOfRevolution *pcObject, PyTypeObject *T)
00246 : GeometrySurfacePy(reinterpret_cast<GeometrySurfacePy::PointerType>(pcObject), T)
00247 {
00248 }
00249
00250
00251
00252
00253
00254 SurfaceOfRevolutionPy::~SurfaceOfRevolutionPy()
00255 {
00256 }
00257
00258
00259
00260
00261 PyObject *SurfaceOfRevolutionPy::_repr(void)
00262 {
00263 return Py_BuildValue("s", representation().c_str());
00264 }
00265
00266
00267
00268
00269 PyObject *SurfaceOfRevolutionPy::_getattr(char *attr)
00270 {
00271 try {
00272
00273 PyObject *r = getCustomAttributes(attr);
00274 if(r) return r;
00275 }
00276 #ifndef DONT_CATCH_CXX_EXCEPTIONS
00277 catch(const Base::Exception& e)
00278 {
00279 std::string str;
00280 str += "FreeCAD exception thrown (";
00281 str += e.what();
00282 str += ")";
00283 e.ReportException();
00284 PyErr_SetString(PyExc_Exception,str.c_str());
00285 return NULL;
00286 }
00287 catch(const std::exception& e)
00288 {
00289 std::string str;
00290 str += "FC++ exception thrown (";
00291 str += e.what();
00292 str += ")";
00293 Base::Console().Error(str.c_str());
00294 PyErr_SetString(PyExc_Exception,str.c_str());
00295 return NULL;
00296 }
00297 catch(const Py::Exception&)
00298 {
00299
00300 return NULL;
00301 }
00302 catch(...)
00303 {
00304 PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00305 return NULL;
00306 }
00307 #else // DONT_CATCH_CXX_EXCEPTIONS
00308 catch(const Base::Exception& e)
00309 {
00310 std::string str;
00311 str += "FreeCAD exception thrown (";
00312 str += e.what();
00313 str += ")";
00314 e.ReportException();
00315 PyErr_SetString(PyExc_Exception,str.c_str());
00316 return NULL;
00317 }
00318 catch(const Py::Exception&)
00319 {
00320
00321 return NULL;
00322 }
00323 #endif // DONT_CATCH_CXX_EXCEPTIONS
00324
00325 PyObject *rvalue = Py_FindMethod(Methods, this, attr);
00326 if (rvalue == NULL)
00327 {
00328 PyErr_Clear();
00329 return GeometrySurfacePy::_getattr(attr);
00330 }
00331 else
00332 {
00333 return rvalue;
00334 }
00335 }
00336
00337 int SurfaceOfRevolutionPy::_setattr(char *attr, PyObject *value)
00338 {
00339 try {
00340
00341 int r = setCustomAttributes(attr, value);
00342 if(r==1) return 0;
00343 }
00344 #ifndef DONT_CATCH_CXX_EXCEPTIONS
00345 catch(const Base::Exception& e)
00346 {
00347 std::string str;
00348 str += "FreeCAD exception thrown (";
00349 str += e.what();
00350 str += ")";
00351 e.ReportException();
00352 PyErr_SetString(PyExc_Exception,str.c_str());
00353 return -1;
00354 }
00355 catch(const std::exception& e)
00356 {
00357 std::string str;
00358 str += "FC++ exception thrown (";
00359 str += e.what();
00360 str += ")";
00361 Base::Console().Error(str.c_str());
00362 PyErr_SetString(PyExc_Exception,str.c_str());
00363 return -1;
00364 }
00365 catch(const Py::Exception&)
00366 {
00367
00368 return -1;
00369 }
00370 catch(...)
00371 {
00372 PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00373 return -1;
00374 }
00375 #else // DONT_CATCH_CXX_EXCEPTIONS
00376 catch(const Base::Exception& e)
00377 {
00378 std::string str;
00379 str += "FreeCAD exception thrown (";
00380 str += e.what();
00381 str += ")";
00382 e.ReportException();
00383 PyErr_SetString(PyExc_Exception,str.c_str());
00384 return -1;
00385 }
00386 catch(const Py::Exception&)
00387 {
00388
00389 return -1;
00390 }
00391 #endif // DONT_CATCH_CXX_EXCEPTIONS
00392
00393 return GeometrySurfacePy::_setattr(attr, value);
00394 }
00395
00396 GeomSurfaceOfRevolution *SurfaceOfRevolutionPy::getGeomSurfaceOfRevolutionPtr(void) const
00397 {
00398 return static_cast<GeomSurfaceOfRevolution *>(_pcTwinPointer);
00399 }
00400
00401 #if 0
00402
00403
00404
00405
00406 PyObject *SurfaceOfRevolutionPy::PyMake(struct _typeobject *, PyObject *, PyObject *)
00407 {
00408
00409 return new SurfaceOfRevolutionPy(new GeomSurfaceOfRevolution);
00410 }
00411
00412
00413 int SurfaceOfRevolutionPy::PyInit(PyObject* , PyObject* )
00414 {
00415 return 0;
00416 }
00417
00418
00419 std::string SurfaceOfRevolutionPy::representation(void) const
00420 {
00421 return std::string("<GeomSurfaceOfRevolution object>");
00422 }
00423
00424
00425
00426 Py::Object SurfaceOfRevolutionPy::getLocation(void) const
00427 {
00428
00429 throw Py::AttributeError("Not yet implemented");
00430 }
00431
00432 void SurfaceOfRevolutionPy::setLocation(Py::Object arg)
00433 {
00434 throw Py::AttributeError("Not yet implemented");
00435 }
00436
00437 Py::Object SurfaceOfRevolutionPy::getDirection(void) const
00438 {
00439
00440 throw Py::AttributeError("Not yet implemented");
00441 }
00442
00443 void SurfaceOfRevolutionPy::setDirection(Py::Object arg)
00444 {
00445 throw Py::AttributeError("Not yet implemented");
00446 }
00447
00448 Py::Object SurfaceOfRevolutionPy::getBasisCurve(void) const
00449 {
00450
00451 throw Py::AttributeError("Not yet implemented");
00452 }
00453
00454 void SurfaceOfRevolutionPy::setBasisCurve(Py::Object arg)
00455 {
00456 throw Py::AttributeError("Not yet implemented");
00457 }
00458
00459 PyObject *SurfaceOfRevolutionPy::getCustomAttributes(const char* attr) const
00460 {
00461 return 0;
00462 }
00463
00464 int SurfaceOfRevolutionPy::setCustomAttributes(const char* attr, PyObject *obj)
00465 {
00466 return 0;
00467 }
00468 #endif
00469
00470
00471