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