Counting holes/tunnels

Hi, I need to count the holes from a 3D mode.

For now, I've tried counting inner wires for each face using "TopExp_Explorer explorer(shape, TopAbs_WIRE);", but I need more than this because sometimes 2 holes form a tunnel. In this case I'd need to avoid double counting inner wires. How would I check if 2 inner wires on different faces are actually connected?

Dmitrii Pasukhin's picture

Hello, if you want to develop general algorithm for hole detection, I'm afraid it is more complicated task. If you are not sure about simplicity of input models, then there are much more special cases for holes then just splitter wire(periodical wire offer splitter).

OCCT offer general algorithm, but I'm afraid this SDK is too much for small task:

Best regards, Dmitrii.


Dmitrii Pasukhin's picture

As for a connection, you can check closed status and check connected points. Or check higher topology(shell) to content both wires and check connections of them. But each case can be unique. Depends on input shape. In case of step file checking shell is more common solution.

Best, regards Dmitrii.

Sergey Slyadnev's picture
Andrei Dinca's picture

How does a naive solution like the following sounds to you guys?

1) Iterate over faces
2) Find inner wires
3) For each inner wire check if it intersects outer wire of a different face - face that should be inside the shape
4) Avoid double counting inner wire that intersect same outer wire since probably it's another end of a surface that goes through the shape

In my head it doesn't sound so stupid, but I'd like to have input from someone with more experience

Michel BORY's picture

If the model is a closed manifold surface , a solution may be to triangulate the whole model and use the the Euler formula.
You can find an efficiant and easy to use application to convert an iges , step or brep file to a triangle mesh at and export it to a stl or obj file.