Merge branch 'master' of github.com:FreeCAD/FreeCAD

This commit is contained in:
Yorik van Havre
2018-05-30 19:07:48 -03:00
2 changed files with 45 additions and 0 deletions

View File

@@ -697,6 +697,13 @@ infos contains additional info on the solutions. It is a list of tuples:
</UserDocu>
</Documentation>
</Methode>
<Methode Name="optimalBoundingBox" Const="true">
<Documentation>
<UserDocu>
optimalBoundingBox(useTriangulation = True, useShapeTolerance = False) -> bound box
</UserDocu>
</Documentation>
</Methode>
<!--
<Attribute Name="Location" ReadOnly="false">
<Documentation>

View File

@@ -40,6 +40,7 @@
# include <BRepExtrema_ShapeProximity.hxx>
#endif
# include <BRepExtrema_SupportType.hxx>
# include <BRepBndLib.hxx>
# include <gp_Ax1.hxx>
# include <gp_Ax2.hxx>
# include <gp_Dir.hxx>
@@ -2610,6 +2611,43 @@ PyObject* TopoShapePy::distToShape(PyObject *args)
return Py_BuildValue("dOO", minDist, solnPts,solnGeom);
}
PyObject* TopoShapePy::optimalBoundingBox(PyObject *args)
{
PyObject* useT = Py_True;
PyObject* useS = Py_False;
if (!PyArg_ParseTuple(args, "|O!O!", &PyBool_Type, &PyBool_Type, &useT, &useS))
return 0;
try {
#if OCC_VERSION_HEX >= 0x070200
TopoDS_Shape shape = this->getTopoShapePtr()->getShape();
Bnd_Box bounds;
BRepBndLib::AddOptimal(shape, bounds,
PyObject_IsTrue(useT) ? Standard_True : Standard_False,
PyObject_IsTrue(useS) ? Standard_True : Standard_False);
bounds.SetGap(0.0);
Standard_Real xMin, yMin, zMin, xMax, yMax, zMax;
bounds.Get(xMin, yMin, zMin, xMax, yMax, zMax);
Base::BoundBox3d box;
box.MinX = xMin;
box.MaxX = xMax;
box.MinY = yMin;
box.MaxY = yMax;
box.MinZ = zMin;
box.MaxZ = zMax;
Py::BoundingBox pybox(box);
return Py::new_reference_to(pybox);
#else
throw Py::RuntimeError("Need OCCT 7.2.0 or higher");
#endif
}
catch (const Standard_Failure& e) {
throw Py::RuntimeError(e.GetMessageString());
}
}
// End of Methods, Start of Attributes
#if 0 // see ComplexGeoDataPy::Matrix which does the same