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 ArcPy::Type = {
00021 PyObject_HEAD_INIT(&PyType_Type)
00022 0,
00023 "Part.GeomTrimmedCurve",
00024 sizeof(ArcPy),
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 curve",
00046 0,
00047 0,
00048 0,
00049 0,
00050 0,
00051 0,
00052 Part::ArcPy::Methods,
00053 0,
00054 Part::ArcPy::GetterSetter,
00055 &Part::GeometryCurvePy::Type,
00056 0,
00057 0,
00058 0,
00059 0,
00060 __PyInit,
00061 0,
00062 Part::ArcPy::PyMake,
00063 0,
00064 0,
00065 0,
00066 0,
00067 0,
00068 0,
00069 0,
00070 0
00071 };
00072
00074 PyMethodDef ArcPy::Methods[] = {
00075 {NULL, NULL, 0, NULL}
00076 };
00077
00078
00079
00081 PyGetSetDef ArcPy::GetterSetter[] = {
00082 {NULL, NULL, NULL, NULL, NULL}
00083 };
00084
00085
00086
00087
00088
00089
00090 PyParentObject ArcPy::Parents[] = { PARENTSPartArcPy };
00091
00092
00093
00094
00095 ArcPy::ArcPy(GeomTrimmedCurve *pcObject, PyTypeObject *T)
00096 : GeometryCurvePy(reinterpret_cast<GeometryCurvePy::PointerType>(pcObject), T)
00097 {
00098 }
00099
00100
00101
00102
00103
00104 ArcPy::~ArcPy()
00105 {
00106 }
00107
00108
00109
00110
00111 PyObject *ArcPy::_repr(void)
00112 {
00113 return Py_BuildValue("s", representation().c_str());
00114 }
00115
00116
00117
00118
00119 PyObject *ArcPy::_getattr(char *attr)
00120 {
00121 try {
00122
00123 PyObject *r = getCustomAttributes(attr);
00124 if(r) return r;
00125 }
00126 #ifndef DONT_CATCH_CXX_EXCEPTIONS
00127 catch(const Base::Exception& e)
00128 {
00129 std::string str;
00130 str += "FreeCAD exception thrown (";
00131 str += e.what();
00132 str += ")";
00133 e.ReportException();
00134 PyErr_SetString(PyExc_Exception,str.c_str());
00135 return NULL;
00136 }
00137 catch(const std::exception& e)
00138 {
00139 std::string str;
00140 str += "FC++ exception thrown (";
00141 str += e.what();
00142 str += ")";
00143 Base::Console().Error(str.c_str());
00144 PyErr_SetString(PyExc_Exception,str.c_str());
00145 return NULL;
00146 }
00147 catch(const Py::Exception&)
00148 {
00149
00150 return NULL;
00151 }
00152 catch(...)
00153 {
00154 PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00155 return NULL;
00156 }
00157 #else // DONT_CATCH_CXX_EXCEPTIONS
00158 catch(const Base::Exception& e)
00159 {
00160 std::string str;
00161 str += "FreeCAD exception thrown (";
00162 str += e.what();
00163 str += ")";
00164 e.ReportException();
00165 PyErr_SetString(PyExc_Exception,str.c_str());
00166 return NULL;
00167 }
00168 catch(const Py::Exception&)
00169 {
00170
00171 return NULL;
00172 }
00173 #endif // DONT_CATCH_CXX_EXCEPTIONS
00174
00175 PyObject *rvalue = Py_FindMethod(Methods, this, attr);
00176 if (rvalue == NULL)
00177 {
00178 PyErr_Clear();
00179 return GeometryCurvePy::_getattr(attr);
00180 }
00181 else
00182 {
00183 return rvalue;
00184 }
00185 }
00186
00187 int ArcPy::_setattr(char *attr, PyObject *value)
00188 {
00189 try {
00190
00191 int r = setCustomAttributes(attr, value);
00192 if(r==1) return 0;
00193 }
00194 #ifndef DONT_CATCH_CXX_EXCEPTIONS
00195 catch(const Base::Exception& e)
00196 {
00197 std::string str;
00198 str += "FreeCAD exception thrown (";
00199 str += e.what();
00200 str += ")";
00201 e.ReportException();
00202 PyErr_SetString(PyExc_Exception,str.c_str());
00203 return -1;
00204 }
00205 catch(const std::exception& e)
00206 {
00207 std::string str;
00208 str += "FC++ exception thrown (";
00209 str += e.what();
00210 str += ")";
00211 Base::Console().Error(str.c_str());
00212 PyErr_SetString(PyExc_Exception,str.c_str());
00213 return -1;
00214 }
00215 catch(const Py::Exception&)
00216 {
00217
00218 return -1;
00219 }
00220 catch(...)
00221 {
00222 PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00223 return -1;
00224 }
00225 #else // DONT_CATCH_CXX_EXCEPTIONS
00226 catch(const Base::Exception& e)
00227 {
00228 std::string str;
00229 str += "FreeCAD exception thrown (";
00230 str += e.what();
00231 str += ")";
00232 e.ReportException();
00233 PyErr_SetString(PyExc_Exception,str.c_str());
00234 return -1;
00235 }
00236 catch(const Py::Exception&)
00237 {
00238
00239 return -1;
00240 }
00241 #endif // DONT_CATCH_CXX_EXCEPTIONS
00242
00243 return GeometryCurvePy::_setattr(attr, value);
00244 }
00245
00246 GeomTrimmedCurve *ArcPy::getGeomTrimmedCurvePtr(void) const
00247 {
00248 return static_cast<GeomTrimmedCurve *>(_pcTwinPointer);
00249 }
00250
00251 #if 0
00252
00253
00254
00255
00256 PyObject *ArcPy::PyMake(struct _typeobject *, PyObject *, PyObject *)
00257 {
00258
00259 return new ArcPy(new GeomTrimmedCurve);
00260 }
00261
00262
00263 int ArcPy::PyInit(PyObject* , PyObject* )
00264 {
00265 return 0;
00266 }
00267
00268
00269 std::string ArcPy::representation(void) const
00270 {
00271 return std::string("<GeomTrimmedCurve object>");
00272 }
00273
00274
00275
00276 PyObject *ArcPy::getCustomAttributes(const char* attr) const
00277 {
00278 return 0;
00279 }
00280
00281 int ArcPy::setCustomAttributes(const char* attr, PyObject *obj)
00282 {
00283 return 0;
00284 }
00285 #endif
00286
00287
00288