Hi.
When exporting geometries with OpenNURBS 8.0, I found some ON_Brep with invalid bounding box and the meshes got from ON_Brep::GetMesh() seem distorted. For example, ON_Brep::m_box:{m_min={x=-1.033144777886e-309#DEN y=0.0000000000000000 z=18373.311983570755 } m_max={x=4252825.4858648088 y=3476811.6673364569 z=4.9228653096998468e+179 } }
. How can I solve these problems? Thanks.
It would be helpful if you tell some more about how you got the invalid ON_Brep objects, and share your code that gives this problems if possible.
This is part of my code.
ONX_ModelComponentIterator it(onxModel, ON_ModelComponent::Type::ModelGeometry);
for (ON_ModelComponentReference mcr = it.FirstComponentReference(); false == mcr.IsEmpty(); mcr = it.NextComponentReference())
{
const ON_ModelComponent* modelComponent = mcr.ModelComponent();
const ON_ModelGeometryComponent* mgc = dynamic_cast<const ON_ModelGeometryComponent*>(modelComponent);
const ON_Geometry* geometry = mgc->Geometry();
ON_Brep* aBrep = const_cast<ON_Brep*>(dynamic_cast<const ON_Brep*>(geometry));
//get boundingBox
if (NULL != aBrep)
{
ON_SimpleArray<const ON_Mesh*> meshs;
int retValue = aBrep->GetMesh(ON::MeshType(4), meshs);
for (int mesh_index = 0; mesh_index < meshs.Count(); mesh_index++)
{
const ON_Mesh** aMesh = meshs.At(mesh_index);
int size = (*aMesh)->m_dV.Count() ? (*aMesh)->m_dV.Count() : (*aMesh)->m_V.Count();
for (int vertexIndex = 0; vertexIndex < size; vertexIndex++)
{
ON_3dPoint point = (*aMesh)->m_dV.Count() ? (*aMesh)->m_dV[vertexIndex] : (*aMesh)->m_V[vertexIndex];
//get vertices...
}
}
}
}
Hi Dale,
The .3dm file is too large(997M), how can I send it to you?
The file has been uploaded.
Hi @dale
I’ve reuploaded it. Did you received the file?
Hi @sw11,
Yes, I was finally able to get your file - thank you.
I’m not finding any Breps with invalid bounding boxes.
int brep_count = 0;
int invalid_bbox_count = 0;
ONX_ModelComponentIterator it(model, ON_ModelComponent::Type::ModelGeometry);
const ON_ModelComponent* model_component = nullptr;
for (model_component = it.FirstComponent(); nullptr != model_component; model_component = it.NextComponent())
{
const ON_ModelGeometryComponent* model_geometry = ON_ModelGeometryComponent::Cast(model_component);
if (nullptr != model_geometry)
{
const ON_Brep* brep = ON_Brep::Cast(model_geometry->Geometry(nullptr));
if (nullptr != brep)
{
brep_count++;
ON_BoundingBox bbox = brep->BoundingBox();
if (!bbox.IsValid())
{
invalid_bbox_count++;
}
}
}
}
8432 Breps, 0 with invalid bounding boxes.
To compute the bounding box of a mesh, use ON_Mesh::GetBoundingBox
.
– Dale
Hi @dale ,
For example, ON_ModelGeometryComponent{af5e78fb-be34-48bf-834b-ae1a4c4e85eb} and
{9170d6f7-1390-4df7-bfb6-8cc77b3f3200}, the z value of their box.m_max is extremely large. Is that normal?
I also get the corresponding meshes from ON_Brep::GetMesh(). And the bounding box computed from ON_Mesh::m_dV is different from ON_Mesh::BoundingBox(). And the mesh got from brep seems to be distorted when rendering. Why does this happen?
Thanks.
Hi @sw11,
The two objects appear to be microscopic - use Rhino’s SelId
command to select them.
The model’s unit seem is in millimeters, seems wrong.
– Dale
Hi @dale ,
When I use the SelId command, I still can’ see the two objects. May be the .3dm file obtained from the upstream users is wrong. - so Is the problematic bounding box caused by microscopic objects? Is there any approach to identify this kind of objects in advance?