Also fixes some other types of external geo --------- Co-authored-by: Andrew Shkolik <andrew.shkolik@selerix.com> Co-authored-by: realthunder <realthunder.dev@gmail.com>
This commit is contained in:
@@ -1136,6 +1136,30 @@ Base::BoundBox3d TopoShape::getBoundBox() const
|
||||
return box;
|
||||
}
|
||||
|
||||
Base::BoundBox3d TopoShape::getBoundBoxOptimal() const
|
||||
{
|
||||
Base::BoundBox3d box;
|
||||
try {
|
||||
// If the shape is empty an exception may be thrown
|
||||
Bnd_Box bounds;
|
||||
BRepBndLib::AddOptimal(_Shape, bounds, false, false);
|
||||
bounds.SetGap(0.0);
|
||||
Standard_Real xMin, yMin, zMin, xMax, yMax, zMax;
|
||||
bounds.Get(xMin, yMin, zMin, xMax, yMax, zMax);
|
||||
|
||||
box.MinX = xMin;
|
||||
box.MaxX = xMax;
|
||||
box.MinY = yMin;
|
||||
box.MaxY = yMax;
|
||||
box.MinZ = zMin;
|
||||
box.MaxZ = zMax;
|
||||
}
|
||||
catch (Standard_Failure&) {
|
||||
}
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
namespace {
|
||||
bool getShapeProperties(const TopoDS_Shape& shape, GProp_GProps& prop)
|
||||
{
|
||||
|
||||
@@ -316,6 +316,8 @@ public:
|
||||
Base::Matrix4D getTransform() const override;
|
||||
/// Bound box from the CasCade shape
|
||||
Base::BoundBox3d getBoundBox() const override;
|
||||
/// More precise bound box from the CasCade shape
|
||||
Base::BoundBox3d getBoundBoxOptimal() const;
|
||||
bool getCenterOfGravity(Base::Vector3d& center) const override;
|
||||
static void convertTogpTrsf(const Base::Matrix4D& mtrx, gp_Trsf& trsf);
|
||||
static void convertToMatrix(const gp_Trsf& trsf, Base::Matrix4D& mtrx);
|
||||
|
||||
Reference in New Issue
Block a user