Overlapping detection using Common operation

I had a quite unpleasant surprise today when trying to get an algorithm to detect overlapping working. Volume overlapping was quite straight forward: just call Common with a Solid and a Compound of all other Solids you want to check. To detect area overlapping I used Shells instead, but the first issue I found was that calling Common between a Shell and a Compound of Shells does not work. Then, I decided to try a slower approach: call Common for each pair of Shells. The result is effectively a Shell of the overlapping area, but what I have been completely unable to acquire is which Faces from Shell_1 and Shell_2 produced which Faces in the result. Actually, it half works. In the current test case (only 1 overlapping Face) I get which Face from one of the Shells became a Face in result, but I cannot get the corresponding Face from the other Shell.

I am completely clueless as to how to proceed now. I do really need to know the overlapping Faces and their result, not just one of them.

Any insight is highly appreciated.

Paul Jimenez's picture

After some struggling with Boolean Operations, and the meaning of everything in them, I have found Fuse more appropriate to detect area overlaps. Part of the trick is to use the modified Edges to calculate the Faces that where replaced in the process. It still needs more work, but so far it is able to detect all area overlaps I have tried. I still need a reliable, yet optimal, algorithm to detect the Faces that overlap with any other given Face.

Anyway, that seems to be the way to go without abusing boolean operations.

Ideas are still welcomed.

andria's picture

I also have an algorithm that works only with plane face if you want:

explore the list of faces of the solid
compare them each other
if there are same (for ex plane/plane) , compute the angle and distance between them
if it's good i use common() operation from BRepAlgo_BooleanOperations to detect common face
cut the original face by the common face

when you create the shell you have to sew the cutted face and the common face

It's reliable with simple config but now i'm trying to make it very strong !!!!

Paul Jimenez's picture

One of the issues of main concern is which groups of Faces (by pair) are involved into the process. Being able to build the new shapes while keeping control of what is being created is also quite important. Achieving they both without abusing Boolean Operations is difficult (from my experience trying to use them like that). I could reduce the number of operations called by sorting the Faces (I was thinking to classify them by a ['normalized'^ normal, point in plane]^^ pair). I see you did something alike for your algorithm (with angle and distance).

The trick of using Common, Cut and Sew sounds good, but it is hard to keep track of shapes with them.

Thanks for sharing your algorithm. If I get something working reliably, I will be commenting it here also.

^ By 'normalized' I mean that both a given direction and its opposite are transformed into the same direction (the 'normalized' normal).
^^ Having the 'normalized' normal, the point in plane can be calculated as the closest point in the plane to the origin. All Faces that produce the same pair are candidates for overlapping. A 2D bounding box could also be used to reduce that number even further.

SINDHU's picture

Hi Paul,

I have a doubt regarding the calculation of the area of a face. I want to perform the CUT operation based on the area of the face obtained. Can you please tell me the related functions or the process for finding the area of a face.

Thanks a lot for a good thread about Boolean operations
Sindhu

Paul Jimenez's picture

It gets off topic, but the answer is not long anyway.

To get the area of a Shape (Shape being a Face in your case), you just need the following code:

double AreaOfShape(const TopoDS_Shape &aShape)
{
GProp_GProps sprops;
BRepGProp::SurfaceProperties(aShape, sprops);
return sprops.Mass();
}

-- -- -- -- --

Now, adding a little bit more to this topic, I forgot to say that the Common operation works if you call it with a Face and a Compound of Faces. I think it also works with two Compounds of Faces, but I am not really sure if I tried that one. It is probably the closest thing to calculating Common having multiple Shells (the one operation I already said does not work). Still, the issue of fully detecting what produced what exactly is not easy.

SINDHU's picture

Hi Paul,

Thank you for the fast reply.

Sindhu