Could you share a sample model?
Archived discussion
Accuracy of Bnd_OBB on imported STEP model
Hello Community,
I am trying to get a precise Oriented Bounding Box of a model I imported. The model i am working with has a rectangular base.
The problem i am facing is that the OBB seems to be slightly rotated, making it a little larger than it should be and the Directions off by a few degrees in consequence.
Archived image: external image
This also happens on other models.
Here is the code i am using to import the model, convert it and build the OBB:
STEPControl_Reader reader;
reader.ReadFile(path);
reader.TransferRoots();
TopoDS_Shape shape = reader.OneShape();
// Shape Healing
Handle(ShapeFix_Shape) aFixShape = new ShapeFix_Shape();
aFixShape->Init(shape);
aFixShape->Perform();
shape = aFixShape->Shape();
Handle(ShapeFix_Wireframe) aFixWire = new ShapeFix_Wireframe(shape);
FixWire->ModeDropSmallEdges() = true;
aFixWire->FixSmallEdges();
aFixWire->FixWireGaps();
shape = aFixWire->Shape();
// Create OBB
Bnd_OBB obb;
BRepBndLib::AddOBB(shape, obb, true, true, false);If i make a simple box (1x1x1 with origin (0,0,0)) and build its OBB, it's perfectly precise.
So I am wondering if the problem I am having is due to the complexity of the model? Or because of the conversion from the STEP format?
Any help will be appreciated!
Discussion
8 archived replies
Posts are displayed in their archived order.
I have created a one-time download link link for you, since I unfortunately am not allowed to fully publicly post the model here, I hope that is OK.
If model is not public, please don't publish it there. There are a lot of people who will download it faster then developers. Please create a new ticket in bug tracker and Mark that as private.
Best regards, Commenter-2.
Thanks for the advice, I will do that. I assume by bug tracker you mean tracker.dev.opencascade.org?
Yes, that's correct.
I have opened an issue, but there is no way for me to mark it as private, nor edit it in any other way. How do I make it private?
Or you can use "contact us from" in the current site.
Best regards, Commenter-2
I was now able to solve the problem, so for anyone finding this in the future:
I simply had to use
BRepMesh_IncrementalMeshto further refine the mesh of my model before I created the OBB:
Standard_Real deflection = 0.01;
BRepMesh_IncrementalMesh mesher(shape, deflection);
Bnd_OBB boundingBoxShape;
BRepBndLib::AddOBB(newShape, boundingBoxShape);
Now the OBB fits tightly around any part I tested so far and results when processing the part further seem to be accurate.