diff --git a/Geo/OCCEdge.cpp b/Geo/OCCEdge.cpp index 5e869775fc2256f23850484835c29009cd370794..9f6386efe736b28f3df518a8b45eacac2cb3a0f5 100644 --- a/Geo/OCCEdge.cpp +++ b/Geo/OCCEdge.cpp @@ -45,6 +45,16 @@ OCCEdge::~OCCEdge() model()->getOCCInternals()->unbind(c); } +SBoundingBox3d OCCEdge::bounds() const +{ + Bnd_Box b; + BRepBndLib::Add(c, b); + double xmin, ymin, zmin, xmax, ymax, zmax; + b.Get(xmin, ymin, zmin, xmax, ymax, zmax); + SBoundingBox3d bbox(xmin, ymin, zmin, xmax, ymax, zmax); + return bbox; +} + Range<double> OCCEdge::parBounds(int i) const { return Range<double>(s0, s1); diff --git a/Geo/OCCEdge.h b/Geo/OCCEdge.h index ba176b283b0c1d052e37bc2cc7b764c48c151cfb..4170ce64ab84c5db3d72ef36ba3d5480227ac706 100644 --- a/Geo/OCCEdge.h +++ b/Geo/OCCEdge.h @@ -28,6 +28,7 @@ class OCCEdge : public GEdge { public: OCCEdge(GModel *model, TopoDS_Edge _e, int num, GVertex *v1, GVertex *v2); virtual ~OCCEdge(); + virtual SBoundingBox3d bounds() const; virtual Range<double> parBounds(int i) const; virtual GeomType geomType() const; virtual bool degenerate(int) const { return BRep_Tool::Degenerated(c); } diff --git a/Geo/OCCFace.cpp b/Geo/OCCFace.cpp index 3495091cbd38e8f6227c22815aab9df2182e1ea7..cbf2d27dec0f32c5b1542a4db29669de98d1db19 100644 --- a/Geo/OCCFace.cpp +++ b/Geo/OCCFace.cpp @@ -125,6 +125,16 @@ void OCCFace::setup() // } } +SBoundingBox3d OCCFace::bounds() const +{ + Bnd_Box b; + BRepBndLib::Add(s, b); + double xmin, ymin, zmin, xmax, ymax, zmax; + b.Get(xmin, ymin, zmin, xmax, ymax, zmax); + SBoundingBox3d bbox(xmin, ymin, zmin, xmax, ymax, zmax); + return bbox; +} + Range<double> OCCFace::parBounds(int i) const { double umin2, umax2, vmin2, vmax2; diff --git a/Geo/OCCFace.h b/Geo/OCCFace.h index d51baa26a96a9283ceba33ca06339ae36ccc5da5..d98ba4509be512993c7ce350620ee2fcc164116c 100644 --- a/Geo/OCCFace.h +++ b/Geo/OCCFace.h @@ -31,6 +31,7 @@ class OCCFace : public GFace { public: OCCFace(GModel *m, TopoDS_Face s, int num); virtual ~OCCFace(); + virtual SBoundingBox3d bounds() const; Range<double> parBounds(int i) const; virtual GPoint point(double par1, double par2) const; virtual GPoint closestPoint(const SPoint3 & queryPoint, diff --git a/Geo/OCCRegion.cpp b/Geo/OCCRegion.cpp index d4df9425d71fe51b69c38372178203fcc2fb17c4..3a485b1578c4eb22820f64df5f97b2f23bbfe4cb 100644 --- a/Geo/OCCRegion.cpp +++ b/Geo/OCCRegion.cpp @@ -47,6 +47,16 @@ void OCCRegion::setup() Msg::Debug("OCC Region %d with %d faces", tag(), l_faces.size()); } +SBoundingBox3d OCCRegion::bounds() const +{ + Bnd_Box b; + BRepBndLib::Add(s, b); + double xmin, ymin, zmin, xmax, ymax, zmax; + b.Get(xmin, ymin, zmin, xmax, ymax, zmax); + SBoundingBox3d bbox(xmin, ymin, zmin, xmax, ymax, zmax); + return bbox; +} + GEntity::GeomType OCCRegion::geomType() const { return Unknown; diff --git a/Geo/OCCRegion.h b/Geo/OCCRegion.h index 2fcd174d96fe1a30a8f3f8579f0238edf6597144..b132f02da21448206b1a06d50b0b0bea2e7fbdde 100644 --- a/Geo/OCCRegion.h +++ b/Geo/OCCRegion.h @@ -19,6 +19,7 @@ class OCCRegion : public GRegion { public: OCCRegion(GModel *m, TopoDS_Solid s, int num); virtual ~OCCRegion(); + virtual SBoundingBox3d bounds() const; virtual GeomType geomType() const; ModelType getNativeType() const { return OpenCascadeModel; } void * getNativePtr() const { return (void*)&s; }