DiscussionsIssue archiveModeling Data and Algorithms

Archived discussion

How to Compare TopoDS_Shapes for Equivalence

Modeling Data and AlgorithmsSun, 06/08/2025 - 17:562 replies

Browse this forum
QuestionAuthor

I'd like to write some regression tests for my shape generation code. The idea is to read a gold standard BRep file and compare it to what the test code generates. I know that TopoDS_Shape::IsEqual simply compares the underlying TShape pointers for identity. Is there a method which compares two TopoDS_Shapes for equivalence of the actual topology and geometry?
Thanks,
Author

Discussion

2 archived replies

Posts are displayed in their archived order.

01Commenter-1

There is no such a tool in OCCT itself that would compare for equality two B-Rep shapes created independently.

However, if you would like to check deviations of some algoritm from a reference, you may implement a comparison tool based on OCCT persistence - e.g. write/read shape into/from file using BinTools::Write()/BimTools::Read() and compare binary files / streams for equality.

This wouldn't help to recognize what exactly is different in two shapes, but it's very fast and straightforward to implement. If algoritm will involve different versions of OCCT - the shapes in binary format might be different.

Multithreading and order-undefined acceleration structures like std::unordered_map might produce shapes, which has different order of sub-shapes, but topologically and geometrically identical.

Differences in floating point math and compiler optimizations might also produce deviations.

02Author

It occurred to me that BRepAlgoAPI_Cut might work. The result should be an empty shape. There's no guarantee of that, of course.
Thanks,
Author