Skip to content

Commit

Permalink
+ Projection of edges and wires
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jan 12, 2014
1 parent 1e135aa commit 0f6ccf1
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Mod/Part/App/TopoShapePy.xml
Expand Up @@ -307,6 +307,16 @@ Orientation is not taken into account.</UserDocu>
<UserDocu>Project a shape on this shape</UserDocu>
</Documentation>
</Methode>
<Methode Name="makeCylindricalProjection" Const="true">
<Documentation>
<UserDocu>Cylindrical projection of an edge or wire on this shape</UserDocu>
</Documentation>
</Methode>
<Methode Name="makeConicalProjection" Const="true">
<Documentation>
<UserDocu>Conical projection of an edge or wire on this shape</UserDocu>
</Documentation>
</Methode>
<Methode Name="makeShapeFromMesh">
<Documentation>
<UserDocu>Make a compund shape out of mesh data.
Expand Down
45 changes: 45 additions & 0 deletions src/Mod/Part/App/TopoShapePyImp.cpp
Expand Up @@ -32,6 +32,7 @@
# include <BRepFilletAPI_MakeChamfer.hxx>
# include <BRepOffsetAPI_MakePipe.hxx>
# include <BRepOffsetAPI_MakePipeShell.hxx>
# include <BRepProj_Projection.hxx>
# include <BRepTools.hxx>
# include <gp_Ax1.hxx>
# include <gp_Ax2.hxx>
Expand Down Expand Up @@ -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<TopoShapePy*>(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<TopoShapePy*>(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;
Expand Down

0 comments on commit 0f6ccf1

Please sign in to comment.