Check intersection between Solid objects

Check intersection between Solid objects

giancarlo.web
Contributor Contributor
9,303 Views
2 Replies
Message 1 of 3

Check intersection between Solid objects

giancarlo.web
Contributor
Contributor

I tried using 

var unionvolume = BooleanOperationsUtils.ExecuteBooleanOperation(solid1, solid2, BooleanOperationsType.Union).Volume
                        if (solid1.Volume < unionvolume)
                        {
                            //Do something
                        }

but it looks like it somehow merge those two solids even if they are miles away.

 

BooleanOperationsType.Intersection/Difference doesn't work either since i need even touching solids

 

is there a solution to this problem?

 

Also a BoundingBox is not a solution since i may have complex shaped stuff

0 Likes
Accepted solutions (1)
9,304 Views
2 Replies
Replies (2)
Message 2 of 3

FAIR59
Advisor
Advisor
Accepted solution

Using a combination of Intersect and union gives you a pretty good answer. If the solids touch at an edge this will return [not intersecting, not touching]  instead of [touching].

 

			Solid interSolid = BooleanOperationsUtils.ExecuteBooleanOperation(s1,s2, BooleanOperationsType.Intersect);
			if (Math.Abs( interSolid.Volume)>0.000001) 
			{
				TaskDialog.Show("debug", "intersecting");
				return;
			}
			Solid unionSolid = BooleanOperationsUtils.ExecuteBooleanOperation(s1,s2, BooleanOperationsType.Union);
			double dArea = Math.Abs(s1.SurfaceArea+s2.SurfaceArea -unionSolid.SurfaceArea);
			if (dArea< 0.00001 && s1.Edges.Size+s2.Edges.Size == unionSolid.Edges.Size)
				{ TaskDialog.Show("debug","not intersecting, not touching"); }
			else{TaskDialog.Show("debug","touching");}
Message 3 of 3

danielpinheiro860
Contributor
Contributor

Very great solution! 

Just to contribue with the situation, I've created another kind of analysis based on the above method and its works very well on my workflow, I am just sharing with you below just for the sake of contribution in some way: 

 

 

Solid unionSolid = BooleanOperationsUtils.ExecuteBooleanOperation(solid1, solid2, BooleanOperationsType.Union);
Solid interSolid = BooleanOperationsUtils.ExecuteBooleanOperation(solid1, solid2, BooleanOperationsType.Intersect);
double sumArea = Math.Round(Math.Abs(solid1.SurfaceArea + solid2.SurfaceArea), 5);
double sumFaces = Math.Abs(solid1.Faces.Size + solid2.Faces.Size);
double unionArea = Math.Round(Math.Abs(unionSolid.SurfaceArea), 5);
double unionFaces = Math.Abs(unionSolid.Faces.Size);

if (sumArea == unionArea && sumFaces == unionFaces && interSolid.Volume < 0.00001){TaskDialog.Show("debug", "not touching, not intersecting");
else if (sumArea > unionArea && sumFaces > unionFaces && interSolid.Volume > 0.00001)  {TaskDialog.Show("debug", "intersecting"); }
else if (sumArea > unionArea && sumFaces > unionFaces && interSolid.Volume < 0.00001) {TaskDialog.Show("debug", "touching");}