From 0f6ccf11bfa0d7e98de7dad4fbdcca49d0fb517f Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 12 Jan 2014 18:48:55 +0100 Subject: [PATCH] + Projection of edges and wires --- src/Mod/Part/App/TopoShapePy.xml | 10 +++++++ src/Mod/Part/App/TopoShapePyImp.cpp | 45 +++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/src/Mod/Part/App/TopoShapePy.xml b/src/Mod/Part/App/TopoShapePy.xml index 157f1ae45..6e8b54e05 100644 --- a/src/Mod/Part/App/TopoShapePy.xml +++ b/src/Mod/Part/App/TopoShapePy.xml @@ -307,6 +307,16 @@ Orientation is not taken into account. Project a shape on this shape + + + Cylindrical projection of an edge or wire on this shape + + + + + Conical projection of an edge or wire on this shape + + Make a compund shape out of mesh data. diff --git a/src/Mod/Part/App/TopoShapePyImp.cpp b/src/Mod/Part/App/TopoShapePyImp.cpp index d61189d2c..42f0243eb 100644 --- a/src/Mod/Part/App/TopoShapePyImp.cpp +++ b/src/Mod/Part/App/TopoShapePyImp.cpp @@ -32,6 +32,7 @@ # include # include # include +# include # include # include # include @@ -1273,6 +1274,50 @@ PyObject* TopoShapePy::project(PyObject *args) return 0; } +PyObject* TopoShapePy::makeCylindricalProjection(PyObject *args) +{ + PyObject *pShape, *pDir; + if (PyArg_ParseTuple(args, "O!O!", &(Part::TopoShapePy::Type), &pShape, &Base::VectorPy::Type, &pDir)) { + try { + const TopoDS_Shape& shape = this->getTopoShapePtr()->_Shape; + const TopoDS_Shape& wire = static_cast(pShape)->getTopoShapePtr()->_Shape; + Base::Vector3d vec = Py::Vector(pDir,false).toVector(); + BRepProj_Projection proj(wire, shape, gp_Dir(vec.x,vec.y,vec.z)); + TopoDS_Shape projected = proj.Shape(); + return new TopoShapePy(new TopoShape(projected)); + } + catch (Standard_Failure) { + Handle_Standard_Failure e = Standard_Failure::Caught(); + PyErr_SetString(PyExc_Exception, e->GetMessageString()); + return 0; + } + } + + return 0; +} + +PyObject* TopoShapePy::makeConicalProjection(PyObject *args) +{ + PyObject *pShape, *pDir; + if (PyArg_ParseTuple(args, "O!O!", &(Part::TopoShapePy::Type), &pShape, &Base::VectorPy::Type, &pDir)) { + try { + const TopoDS_Shape& shape = this->getTopoShapePtr()->_Shape; + const TopoDS_Shape& wire = static_cast(pShape)->getTopoShapePtr()->_Shape; + Base::Vector3d vec = Py::Vector(pDir,false).toVector(); + BRepProj_Projection proj(wire, shape, gp_Pnt(vec.x,vec.y,vec.z)); + TopoDS_Shape projected = proj.Shape(); + return new TopoShapePy(new TopoShape(projected)); + } + catch (Standard_Failure) { + Handle_Standard_Failure e = Standard_Failure::Caught(); + PyErr_SetString(PyExc_Exception, e->GetMessageString()); + return 0; + } + } + + return 0; +} + PyObject* TopoShapePy::makeShapeFromMesh(PyObject *args) { PyObject *tup;