24
24
#include "PreCompiled.h"
26
# include <BRepBuilderAPI_MakeEdge.hxx>
27
# include <BRepBuilderAPI_MakeFace.hxx>
28
26
# include <gp_Ax1.hxx>
29
27
# include <gp_Dir.hxx>
30
28
# include <gp_Pnt.hxx>
31
29
# include <gp_Vec.hxx>
32
# include <gp_Trsf.hxx>
30
# include <gp_Trsf.hxx>
33
31
# include <Geom_Geometry.hxx>
34
32
# include <Geom_Curve.hxx>
35
33
# include <Geom_Surface.hxx>
34
# include <Precision.hxx>
36
35
# include <Standard_Failure.hxx>
52
51
#include "TopoShape.h"
53
52
#include "TopoShapePy.h"
54
#include "TopoShapeEdgePy.h"
55
#include "TopoShapeFacePy.h"
57
54
using namespace Part;
59
56
// returns a string which represents the object e.g. when printed in python
60
const char *GeometryPy::representation(void) const
57
std::string GeometryPy::representation(void) const
62
59
return "<Geometry object>";
110
107
Base::Placement* plm = static_cast<Base::PlacementPy*>(o)->getPlacementPtr();
111
Base::Rotation rot(plm->_rot);
108
Base::Rotation rot(plm->getRotation());
112
109
Base::Vector3d pnt, dir;
115
112
rot.getValue(dir, angle);
113
pnt = plm->getPosition();
118
115
gp_Ax1 ax1(gp_Pnt(pnt.x,pnt.y,pnt.z), gp_Dir(dir.x,dir.y,dir.z));
119
116
getGeometryPtr()->handle()->Rotate(ax1, angle);
155
152
mat[1][0],mat[1][1],mat[1][2],mat[1][3],
156
153
mat[2][0],mat[2][1],mat[2][2],mat[2][3],
157
154
0.00001,0.00001);
158
trf.SetScaleFactor(mat[3][3]);
159
155
getGeometryPtr()->handle()->Transform(trf);
186
PyObject* GeometryPy::toShape(PyObject *args)
188
Handle_Geom_Geometry g = getGeometryPtr()->handle();
189
Handle_Geom_Curve c = Handle_Geom_Curve::DownCast(g);
190
Handle_Geom_Surface s = Handle_Geom_Surface::DownCast(g);
194
u=c->FirstParameter();
195
v=c->LastParameter();
196
if (!PyArg_ParseTuple(args, "|dd", &u,&v))
198
BRepBuilderAPI_MakeEdge mkBuilder(c, u, v);
199
TopoDS_Shape sh = mkBuilder.Shape();
200
return new TopoShapeEdgePy(new TopoShape(sh));
204
s->Bounds(u1,u2,v1,v2);
205
if (!PyArg_ParseTuple(args, "|dddd", &u1,&u2,&v1,&v2))
207
BRepBuilderAPI_MakeFace mkBuilder(s, u1, u2, v1, v2);
208
TopoDS_Shape sh = mkBuilder.Shape();
209
return new TopoShapeFacePy(new TopoShape(sh));
212
catch (Standard_Failure) {
213
Handle_Standard_Failure e = Standard_Failure::Caught();
214
PyErr_SetString(PyExc_Exception, e->GetMessageString());
218
PyErr_SetString(PyExc_Exception, "Geometry is neither curve nor surface");
222
PyObject* GeometryPy::value(PyObject *args)
224
Handle_Geom_Geometry g = getGeometryPtr()->handle();
225
Handle_Geom_Curve c = Handle_Geom_Curve::DownCast(g);
226
Handle_Geom_Surface s = Handle_Geom_Surface::DownCast(g);
230
if (!PyArg_ParseTuple(args, "d", &u))
232
gp_Pnt p = c->Value(u);
233
return new Base::VectorPy(Base::Vector3d(p.X(),p.Y(),p.Z()));
237
if (!PyArg_ParseTuple(args, "dd", &u,&v))
239
gp_Pnt p = s->Value(u,v);
240
return new Base::VectorPy(Base::Vector3d(p.X(),p.Y(),p.Z()));
243
catch (Standard_Failure) {
244
Handle_Standard_Failure e = Standard_Failure::Caught();
245
PyErr_SetString(PyExc_Exception, e->GetMessageString());
249
PyErr_SetString(PyExc_Exception, "Geometry is neither curve nor surface");
253
182
PyObject *GeometryPy::getCustomAttributes(const char* /*attr*/) const