TopoDS_Shape dimensions (width, height, depth)

Hello, i know that i can calculate with OpenCascade Volumes and Areas of TopoDS_Shape objects. I am struggling to find how to measure such things like width/length/depth and height.

I understand that the interpretation of this properties can be different for different 3D objects (which side should be considered as a length, which as a depth), but i was hoping to find methods in framework that could at least give me "raw" dimensions of a 3D models.

Has anyone had a similar problem or have suggestions how can i tackle it in a manner that would be "not against the framework"?

Alexander Trotsenko's picture

I didn't find such methods in OCC.

I suggest the following approach. A 3D model has different width/length/depth in the different directions of searching. That is you must define the direction for length, width and depth measuring. Then create a bound box of a model in this directions. A bound box length, width and depth is that you need. You can use Bnd_Box class. Take into account that Bnd_Box is parallel to the axes of the coordinates system.

Pseudo algorithm:

1. Orient a 3D model (TopoDS_Shape) length, width and depth directions with the coordinates system.

2. Create a mesh (BRepMesh_IncrementalMesh) of a 3D model and generate points array from it (mesh nodes).

3. Create a bound box (Bnd_Box) for the points array.

4. Extract length, width and depth from the bound box.

Note: the calculation tolerance depends on the mesh tolerance