Detecting edge intersections of faces

I'm working on a problem where I want to detect any overlap between two solids. Using BRrepAlgoAPI_Common, I can figure out when the two solids intersect, or when their shells have some (part of) a face in common. However, this approach does not seem to work for edges.

In particular, I'm looking at a problem such as the one described in the attached figure. The cylinder touches the box on a single edge (highlighted in red), situated somewhere in the middle of a box face. BRepAlgoAPI_Common does not identify it (I initialize it with the pair of faces).

Is there some other operation, or set of operations that allows me to find this overlapping edge? Any hint is greatly appreciated.

Attachments: 
Tiberiu Chelcea's picture

Problem solved -- BRepAlgoAPI_Section does the trick. To identify edges like that, each pair of face from the two solids needs to be added to a BRepAlgoAPI_Section object, which then can produce the result.

BTW, what is the difference between BRepAlgoAPI_Common and BRepAlgoAPI_Section -- is it that .._Section applies only to faces?

Now I have a slightly different problem, illustrated in the newly attached figure. This time, there are two boxes, and the corner of one of them is on a face belonging to the other box. This time BRepAlgoAPI_Section does not identify the vertex as being in common. Is there some operation/algorithm to check this case?

Attachments: 
sergey zaritchny's picture

Probably you may find something interesting for you at the next page - http://www.opencascade.org/support/products/coldet/.
Regards

Tiberiu Chelcea's picture

Sergey, thanks for the pointer.

I found a partial solution that solves the attached example, but it's not general. Given two solids (sld1 and sld2), I can use BRepClass3d_SolidClassifier(sld1) on each vertex of sld2 and call IsOnAFace. Of course, for curbed surfaces, (e.g. a cylinder), this will probably not work and something like what you've outlined in that tool (meshing the models and checking each element) should be employed, but I'm still hoping that there is some other way to improve on what I have now.

Wang Chris's picture

Hi, Tiberiu Chelcea,

May I know how you use BRepAlgoAPI_Common to detect the overlap between two solid?

I use the following code, and it fails to get the correct results.

BRepAlgoAPI_Common mkcommon(topoShape0, topoShape);
if(!mkcommon.ErrorStatus()){ TopoDS_Shape Com = mkcommon.Shape(); if(!Com.IsNull()) {
BOOL blOverlap = TRUE;
}
}

Thanks a lot!

Chris