Choosing wire exploration methods

I understand that there are two ways to explore a wire, i.e. to get its edges and vertices, namely by using BRepTools_WireExplorer and TopExp_Explorer. The first one returns the edges and vertices in a sequential order, but it may not work when the wire has defects, such as "loops, wrong orientation of edges (two edges go in to shared vertex or go out from shared vertex), branching of edges, the presens of edges with INTERNAL or EXTERNAL orientation", as per the documentation. The second one I suppose will work for any kind of wire. My question is, is there any way to properly choose the exploration method, such that BRepTools_WireExplorer is used if the wire is valid, otherwise TopExp_Explorer is used? 

Many thanks,
Dan

Benjamin Bihler's picture

I guess that you would use BRepTools_WireExplorer if you are interested in the topology of the wire. On the other hand, I use TopExp_Explorer when I want to iterate over the wire's edges, but I am not interested in their order. So you have to choose the wire exploration method depending on your purpose.

Benjamin

Daniel Woodman's picture

Thank you Benjamin, but that's what I am doing now. At the moment I am asking the user which method they would like to use (basically a boolean argument, use A or use B), but I would like to remove this parameter. I suppose there must be a method in OCCT to detect if there is any defect with the wire? For example, if a user gives me a graph-like wire with many branches, I would not like them to set the extra boolean argument. Instead, the algorithm should identify that it has branches, and use TopExp_Explorer.

Many thanks,
Dan

Benjamin Bihler's picture

Now I got you, Daniel. For some other purposes I am using a check like this:

bool GeometricUtilities::isValid(const TopoDS_Shape& shape)
{
    BRepCheck_Analyzer analyzer(shape);

    return analyzer.IsValid();
}

The probability seems high that BRepTools_WireExplorer will be able to iterate over a wire, if this method reports the wire to be valid. But actually it should be tested...

Benjamin

Daniel Woodman's picture

Thanks a lot Benjamin! I will give it a try.

Dan

Daniel Woodman's picture

Benjamin, unfortunately BRepCheck_Analyzer did not seem to work...I was testing it with the attached wire, which has a graph-like structure with 4 branches. It is detected as valid, which would prompt me to use BRepTools_WireExplorer, and only get one edge. Also tried with methods in BRepCheck_Wire and ShapeAnalysis_Wire. I ended up writing a GetNumberOfBranches() method, which returns the number of vertices connected to more than 2 edges. If the result is more than 0, use BRepTools_WireExplorer, otherwise use TopExp_Explorer. Not very sure if that is sufficient, but it will do for now...would need more testing.

Many thanks,
Dan

Attachments: 
Benjamin Bihler's picture

That's a pity, but okay.

Benjamin