C++ boundingbox - how to get tight?


(Menno Deij - van Rijswijk) #1

Today I was trying something I thought would be super simple. Draw a sphere, select it with a command, get the BREP and get its bounding box from C++ code.

I tried .BoundingBox(), .GetBoundingBox(…), .GetBBox(…) an .GetTightBoundingBox(…). None gave a true bounding box for spheres that were not centered to the origin.

Are there any examples on how to do this correctly?


Surface vs Mesh Bounding box
(Dale Fugier) #2

Use RhinoGetTightBoundingBox. See rhinoSdkUtilities.h for more information.

Note, for Breps, tight bounding boxes are calculated from the object’s render mesh. If the object does not have a cached render mesh, one will be generated.


(Menno Deij - van Rijswijk) #3

Aha! Thanks :smile:


(Dale Fugier) #4

A sample if needed:

https://github.com/mcneel/Rhino5Samples_CPP/blob/master/SampleCommands/cmdSampleBoundingBox.cpp