Wrong BoundingBox in BrepFace

Hi, I am struggling with getting the correct BoundingBox in C++ of the spherical cap surface of the file in attach.
I wrote this code to evaluate the bounding box.

const CRhinoObject* p_object = RhinoApp().ActiveDoc()->LookupObject(srfId);
if (p_object != nullptr)
	CRhinoObjRef ref(p_object);
	const ON_Brep* p_brep = ref.Brep();
	if (p_brep != nullptr)
		ON_BoundingBox bb0 = p_brep->BoundingBox();
	    for (int i = 0; i < p_brep->m_F.Count(); i++)
			const ON_BrepFace* p_face = p_brep->Face(i);
			if (p_face != nullptr)
				ON_BoundingBox face_bound;						
				ON_BoundingBox bb1 = p_face->BoundingBox();

I noticed that bb0, bb1 and also face_bound return a wrong maximum Z bb value of 3.91 mm while I expected to have 0.0. The other bounding box values are correct.
I tried also to untrim the surface but I stil have the same results.
wrong_sphere_bb.3dm (7.4 MB)

Hi @Gabriele_Cuccolini,

In this case, were you have a document object, you might just call RhinoGetTightBoundingBox.


– Dale

Hi Dale, thank you very much. I changed my code with this:

		for (int k = 0; k < drive_geometries.Count(); k++)
				const CRhinoObject* p_object = RhinoApp().ActiveDoc()->LookupObject(drive_geometries[k]);

				if (p_object != nullptr)
					ON_SimpleArray<const CRhinoObject*> objArray;


					ON_BoundingBox bb;
					RhinoGetTightBoundingBox(objArray, bb);


And now I have the correct bounding box.
So in your opinion is always better to use this method to compute the bounding box of a collection of surfaces?