+ add method to offset arbitrary shapes

git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5005 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
wmayer 2011-10-11 11:47:57 +00:00
parent 54a4c04ef5
commit e9bc1bfff8
4 changed files with 44 additions and 0 deletions

View File

@ -56,6 +56,7 @@
# include <BRepMesh_Triangle.hxx>
# include <BRepMesh_Edge.hxx>
# include <BRepOffsetAPI_MakeThickSolid.hxx>
# include <BRepOffsetAPI_MakeOffsetShape.hxx>
# include <BRepOffsetAPI_MakePipe.hxx>
# include <BRepOffsetAPI_MakePipeShell.hxx>
# include <BRepOffsetAPI_Sewing.hxx>
@ -1491,6 +1492,16 @@ TopoDS_Shape TopoShape::makeThickSolid(const TopTools_ListOfShape& remFace,
return mkThick.Shape();
}
TopoDS_Shape TopoShape::makeOffset(double offset, double tol, bool intersection,
bool selfInter, short offsetMode, short join)
{
BRepOffsetAPI_MakeOffsetShape mkOffset(this->_Shape, offset, tol, BRepOffset_Mode(offsetMode),
intersection ? Standard_True : Standard_False,
selfInter ? Standard_True : Standard_False,
GeomAbs_JoinType(join));
return mkOffset.Shape();
}
void TopoShape::transformGeometry(const Base::Matrix4D &rclMat)
{
this->_Shape = transformGShape(rclMat);

View File

@ -199,6 +199,9 @@ public:
TopoDS_Shape makeTube(double radius, double tol) const;
TopoDS_Shape makeTube() const;
TopoDS_Shape makeLoft(const TopTools_ListOfShape& profiles, Standard_Boolean isSolid, Standard_Boolean isRuled) const;
TopoDS_Shape makeOffset(double offset, double tol,
bool intersection = false, bool selfInter = false,
short offsetMode = 0, short join = 0);
//@}
/** @name Manipulation*/

View File

@ -179,6 +179,11 @@ which are to be removed. The remaining faces of the solid become the walls of
the hollowed solid, their thickness defined at the time of construction.</UserDocu>
</Documentation>
</Methode>
<Methode Name="makeOffsetShape">
<Documentation>
<UserDocu>Offset a given shape</UserDocu>
</Documentation>
</Methode>
<Methode Name="reverse">
<Documentation>
<UserDocu>Reverses the orientation of this shape.</UserDocu>

View File

@ -965,6 +965,31 @@ PyObject* TopoShapePy::makeThickness(PyObject *args)
}
}
PyObject* TopoShapePy::makeOffsetShape(PyObject *args)
{
double offset, tolerance;
PyObject* inter = Py_False;
PyObject* self_inter = Py_False;
short offsetMode = 0, join = 0;
if (!PyArg_ParseTuple(args, "dd|O!O!hh",
&offset, &tolerance,
&(PyBool_Type), &inter,
&(PyBool_Type), &self_inter,
&offsetMode, &join))
return 0;
try {
TopoDS_Shape shape = this->getTopoShapePtr()->makeOffset(offset, tolerance,
(inter == Py_True), (self_inter == Py_True), offsetMode, join);
return new TopoShapePy(new TopoShape(shape));
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PyExc_Exception, e->GetMessageString());
return NULL;
}
}
PyObject* TopoShapePy::reverse(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))