SurfaceOfExtrusionPyImp.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "PreCompiled.h"
00025 #ifndef _PreComp_
00026 # include <Geom_SurfaceOfLinearExtrusion.hxx>
00027 #endif
00028
00029 #include "Geometry.h"
00030 #include "SurfaceOfExtrusionPy.h"
00031 #include "SurfaceOfExtrusionPy.cpp"
00032
00033 #include <Base/GeometryPyCXX.h>
00034 #include <Base/VectorPy.h>
00035
00036 using namespace Part;
00037
00038
00039 std::string SurfaceOfExtrusionPy::representation(void) const
00040 {
00041 return std::string("<SurfaceOfExtrusion object>");
00042 }
00043
00044 PyObject *SurfaceOfExtrusionPy::PyMake(struct _typeobject *, PyObject *, PyObject *)
00045 {
00046
00047 return new SurfaceOfExtrusionPy(new GeomSurfaceOfExtrusion);
00048 }
00049
00050
00051 int SurfaceOfExtrusionPy::PyInit(PyObject* args, PyObject* )
00052 {
00053 PyObject* pGeom;
00054 PyObject* pDir;
00055 if (!PyArg_ParseTuple(args, "O!O!",
00056 &(GeometryPy::Type), &pGeom,
00057 &(Base::VectorPy::Type),&pDir))
00058 return -1;
00059
00060 GeometryPy* pcGeo = static_cast<GeometryPy*>(pGeom);
00061 Handle_Geom_Curve curve = Handle_Geom_Curve::DownCast
00062 (pcGeo->getGeometryPtr()->handle());
00063 if (curve.IsNull()) {
00064 PyErr_SetString(PyExc_TypeError, "geometry is not a curve");
00065 return -1;
00066 }
00067
00068 try {
00069 Base::Vector3d dir = static_cast<Base::VectorPy*>(pDir)->value();
00070 Handle_Geom_SurfaceOfLinearExtrusion curve2 = new Geom_SurfaceOfLinearExtrusion(curve,
00071 gp_Dir(dir.x,dir.y,dir.z));
00072 getGeomSurfaceOfExtrusionPtr()->setHandle(curve2);
00073 return 0;
00074 }
00075 catch (Standard_Failure) {
00076 Handle_Standard_Failure e = Standard_Failure::Caught();
00077 PyErr_SetString(PyExc_Exception, e->GetMessageString());
00078 return -1;
00079 }
00080 }
00081
00082 Py::Object SurfaceOfExtrusionPy::getDirection(void) const
00083 {
00084 Handle_Geom_SurfaceOfLinearExtrusion curve = Handle_Geom_SurfaceOfLinearExtrusion::DownCast
00085 (getGeometryPtr()->handle());
00086 const gp_Dir& dir = curve->Direction();
00087 return Py::Vector(Base::Vector3d(dir.X(),dir.Y(),dir.Z()));
00088 }
00089
00090 void SurfaceOfExtrusionPy::setDirection(Py::Object arg)
00091 {
00092 PyObject* p = arg.ptr();
00093 if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
00094 Base::Vector3d dir = static_cast<Base::VectorPy*>(p)->value();
00095 Handle_Geom_SurfaceOfLinearExtrusion curve = Handle_Geom_SurfaceOfLinearExtrusion::DownCast
00096 (getGeometryPtr()->handle());
00097 curve->SetDirection(gp_Dir(dir.x,dir.y,dir.z));
00098 }
00099 else if (PyObject_TypeCheck(p, &PyTuple_Type)) {
00100 Base::Vector3d dir = Base::getVectorFromTuple<double>(p);
00101 Handle_Geom_SurfaceOfLinearExtrusion curve = Handle_Geom_SurfaceOfLinearExtrusion::DownCast
00102 (getGeometryPtr()->handle());
00103 curve->SetDirection(gp_Dir(dir.x,dir.y,dir.z));
00104 }
00105 else {
00106 std::string error = std::string("type must be 'Vector', not ");
00107 error += p->ob_type->tp_name;
00108 throw Py::TypeError(error);
00109 }
00110 }
00111
00112 Py::Object SurfaceOfExtrusionPy::getBasisCurve(void) const
00113 {
00114 throw Py::Exception(PyExc_NotImplementedError, "Not yet implemented");
00115 }
00116
00117 void SurfaceOfExtrusionPy::setBasisCurve(Py::Object arg)
00118 {
00119 PyObject* p = arg.ptr();
00120 if (PyObject_TypeCheck(p, &(GeometryPy::Type))) {
00121 GeometryPy* pcGeo = static_cast<GeometryPy*>(p);
00122 Handle_Geom_Curve curve = Handle_Geom_Curve::DownCast
00123 (pcGeo->getGeometryPtr()->handle());
00124 if (curve.IsNull()) {
00125 throw Py::TypeError("geometry is not a curve");
00126 }
00127
00128 try {
00129 Handle_Geom_SurfaceOfLinearExtrusion curve2 = Handle_Geom_SurfaceOfLinearExtrusion::DownCast
00130 (getGeometryPtr()->handle());
00131 curve2->SetBasisCurve(curve);
00132 }
00133 catch (Standard_Failure) {
00134 Handle_Standard_Failure e = Standard_Failure::Caught();
00135 throw Py::Exception(e->GetMessageString());
00136 }
00137 }
00138 }
00139
00140 PyObject *SurfaceOfExtrusionPy::getCustomAttributes(const char* ) const
00141 {
00142 return 0;
00143 }
00144
00145 int SurfaceOfExtrusionPy::setCustomAttributes(const char* , PyObject* )
00146 {
00147 return 0;
00148 }