add Approximation option to TopoShape section
This commit is contained in:
@@ -1637,17 +1637,23 @@ TopoDS_Shape TopoShape::oldFuse(TopoDS_Shape shape) const
|
||||
#endif
|
||||
}
|
||||
|
||||
TopoDS_Shape TopoShape::section(TopoDS_Shape shape) const
|
||||
TopoDS_Shape TopoShape::section(TopoDS_Shape shape, const Standard_Boolean approximate) const
|
||||
{
|
||||
if (this->_Shape.IsNull())
|
||||
Standard_Failure::Raise("Base shape is null");
|
||||
if (shape.IsNull())
|
||||
Standard_Failure::Raise("Tool shape is null");
|
||||
BRepAlgoAPI_Section mkSection(this->_Shape, shape);
|
||||
BRepAlgoAPI_Section mkSection;
|
||||
mkSection.Init1(this->_Shape);
|
||||
mkSection.Init2(shape);
|
||||
mkSection.Approximation(approximate);
|
||||
mkSection.Build();
|
||||
if (!mkSection.IsDone())
|
||||
throw Base::RuntimeError("Section failed");
|
||||
return mkSection.Shape();
|
||||
}
|
||||
|
||||
TopoDS_Shape TopoShape::section(const std::vector<TopoDS_Shape>& shapes, Standard_Real tolerance) const
|
||||
TopoDS_Shape TopoShape::section(const std::vector<TopoDS_Shape>& shapes, Standard_Real tolerance, const Standard_Boolean approximate) const
|
||||
{
|
||||
if (this->_Shape.IsNull())
|
||||
Standard_Failure::Raise("Base shape is null");
|
||||
@@ -1658,6 +1664,7 @@ TopoDS_Shape TopoShape::section(const std::vector<TopoDS_Shape>& shapes, Standar
|
||||
#else
|
||||
BRepAlgoAPI_Section mkSection;
|
||||
mkSection.SetRunParallel(true);
|
||||
mkSection.Approximation(approximate);
|
||||
TopTools_ListOfShape shapeArguments,shapeTools;
|
||||
shapeArguments.Append(this->_Shape);
|
||||
for (std::vector<TopoDS_Shape>::const_iterator it = shapes.begin(); it != shapes.end(); ++it) {
|
||||
|
||||
@@ -165,8 +165,8 @@ public:
|
||||
TopoDS_Shape fuse(TopoDS_Shape) const;
|
||||
TopoDS_Shape fuse(const std::vector<TopoDS_Shape>&, Standard_Real tolerance = 0.0) const;
|
||||
TopoDS_Shape oldFuse(TopoDS_Shape) const;
|
||||
TopoDS_Shape section(TopoDS_Shape) const;
|
||||
TopoDS_Shape section(const std::vector<TopoDS_Shape>&, Standard_Real tolerance = 0.0) const;
|
||||
TopoDS_Shape section(TopoDS_Shape, const Standard_Boolean approximate=Standard_False) const;
|
||||
TopoDS_Shape section(const std::vector<TopoDS_Shape>&, Standard_Real tolerance = 0.0, const Standard_Boolean approximate=Standard_False) const;
|
||||
std::list<TopoDS_Wire> slice(const Base::Vector3d&, double) const;
|
||||
TopoDS_Compound slices(const Base::Vector3d&, const std::vector<double>&) const;
|
||||
/**
|
||||
|
||||
@@ -197,9 +197,11 @@ OCC 6.9.0 or later is required.</UserDocu>
|
||||
<Methode Name="section" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>Section of this with a given (list of) topo shape.
|
||||
section(tool) -> Shape
|
||||
section(tool,[approximation=False]) -> Shape
|
||||
or
|
||||
section((tool1,tool2,...),[tolerance=0.0]) -> Shape
|
||||
section((tool1,tool2,...),[tolerance=0.0, approximation=False]) -> Shape
|
||||
|
||||
If approximation is True, section edges are approximated to a C1-continuous BSpline curve.
|
||||
|
||||
Section of this and a given list of topo shapes.
|
||||
|
||||
|
||||
@@ -911,11 +911,12 @@ PyObject* TopoShapePy::common(PyObject *args)
|
||||
PyObject* TopoShapePy::section(PyObject *args)
|
||||
{
|
||||
PyObject *pcObj;
|
||||
if (PyArg_ParseTuple(args, "O!", &(TopoShapePy::Type), &pcObj)) {
|
||||
PyObject *approx = Py_False;
|
||||
if (PyArg_ParseTuple(args, "O!|O!", &(TopoShapePy::Type), &pcObj, &(PyBool_Type), &approx)) {
|
||||
TopoDS_Shape shape = static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr()->getShape();
|
||||
try {
|
||||
// Let's call algorithm computing a section operation:
|
||||
TopoDS_Shape secShape = this->getTopoShapePtr()->section(shape);
|
||||
TopoDS_Shape secShape = this->getTopoShapePtr()->section(shape,PyObject_IsTrue(approx) ? true : false);
|
||||
return new TopoShapePy(new TopoShape(secShape));
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
@@ -931,11 +932,11 @@ PyObject* TopoShapePy::section(PyObject *args)
|
||||
|
||||
PyErr_Clear();
|
||||
double tolerance = 0.0;
|
||||
if (PyArg_ParseTuple(args, "O!d", &(TopoShapePy::Type), &pcObj, &tolerance)) {
|
||||
if (PyArg_ParseTuple(args, "O!d|O!", &(TopoShapePy::Type), &pcObj, &tolerance, &(PyBool_Type), &approx)) {
|
||||
std::vector<TopoDS_Shape> shapeVec;
|
||||
shapeVec.push_back(static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr()->getShape());
|
||||
try {
|
||||
TopoDS_Shape sectionShape = this->getTopoShapePtr()->section(shapeVec,tolerance);
|
||||
TopoDS_Shape sectionShape = this->getTopoShapePtr()->section(shapeVec,tolerance,PyObject_IsTrue(approx) ? true : false);
|
||||
return new TopoShapePy(new TopoShape(sectionShape));
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
@@ -949,7 +950,7 @@ PyObject* TopoShapePy::section(PyObject *args)
|
||||
}
|
||||
|
||||
PyErr_Clear();
|
||||
if (PyArg_ParseTuple(args, "O|d", &pcObj, &tolerance)) {
|
||||
if (PyArg_ParseTuple(args, "O|dO!", &pcObj, &tolerance, &(PyBool_Type), &approx)) {
|
||||
std::vector<TopoDS_Shape> shapeVec;
|
||||
Py::Sequence shapeSeq(pcObj);
|
||||
for (Py::Sequence::iterator it = shapeSeq.begin(); it != shapeSeq.end(); ++it) {
|
||||
@@ -963,7 +964,7 @@ PyObject* TopoShapePy::section(PyObject *args)
|
||||
}
|
||||
}
|
||||
try {
|
||||
TopoDS_Shape multiSectionShape = this->getTopoShapePtr()->section(shapeVec,tolerance);
|
||||
TopoDS_Shape multiSectionShape = this->getTopoShapePtr()->section(shapeVec,tolerance,PyObject_IsTrue(approx) ? true : false);
|
||||
return new TopoShapePy(new TopoShape(multiSectionShape));
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
|
||||
Reference in New Issue
Block a user