DiscussionsIssue archiveData Exchange and Application Framework

Archived discussion

Accuracy of Bnd_OBB on imported STEP model

Data Exchange and Application FrameworkWed, 03/20/2024 - 18:298 replies

Browse this forum
QuestionAuthor

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.

01Commenter-1

Could you share a sample model?

02Author

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.

03Commenter-2

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.

04Author

Thanks for the advice, I will do that. I assume by bug tracker you mean tracker.dev.opencascade.org?

05Commenter-2

Yes, that's correct.

06Author

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?

07Commenter-2

Or you can use "contact us from" in the current site.

Best regards, Commenter-2 

08Author

I was now able to solve the problem, so for anyone finding this in the future:

I simply had to use

BRepMesh_IncrementalMesh

to 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.