Quickest way to check if two shapes intersect?

I need to determine if two TopoDS_Shapes intersect. I don't care about the topology of the intersection, I just need a yes or no answer.

I'm currently using BRepAlgoAPI_Common, but this is fairly slow because it is performing the entire boolean operation.

Does anyone know of a quicker way to get a simple yes/no?

Thanks

Deepak Agrawal's picture

Did you figure it out? I am having some problems using BRepAlgoAPI_Common and BRepAlgoAPI_Section. I would be really grateful if you can help me out.

EricThompson's picture

Sorry, I never did. I ended up reworking what I was doing to avoid having to check that.

Pawel's picture

Hello,

you can try the Voxel package.

I've been testing it (although not very intensively) for some weeks now. It looks very interesting although I have already spotted some problems. However, I think this is suitable for telling if two shapes intersect (with respect to the specified tolerance).

Pawel

AP's picture

this might work:

bool isintersecting(TopoDS_Shape shape1,TopoDS_Shape shape2, double detail)
{
if (!(detail > 0)) detail = 0.1;

BRepExtrema_DistShapeShape dst (shap1, shape2,detail);
if (dst.IsDone())
{

gp_Pnt P1, P2;
for (int i = 1; i <= dst.NbSolution(); i++)
{
P1 = dst.PointOnShape1(i);
P2 = dst.PointOnShape2(i);
Standard_Real Dist = P1.Distance(P2);
if ( Dist <= Precision::Confusion()+0.1 )
{
return true;
}
}
}

return false;

}

This works as long as the shape only has one face in it, if there are more than one faces

bool isintersecting(TopoDS_Shape srf1,TopoDS_Shape srf2)
{

qDebug() << "precision" << Precision::Intersection();
srf1 = HSF::getfacefromshape(srf1);
srf2 = HSF::getfacefromshape(srf2);
Handle(Geom_Surface) S1 = BRep_Tool::Surface(TopoDS::Face(srf1));
Handle(Geom_Surface) S2 = BRep_Tool::Surface(TopoDS::Face(srf2));
//double precision = Precision::Confusion();
double precision = 0.1;
qDebug() << "before intersect";
GeomAPI_IntSS Intersector(S1, S2, precision);
qDebug() << "after intersect";
if (Intersector. NbLines() > 0) { return true; } else { return false;}

}

TopoDS_Shape getfacefromshape(TopoDS_Shape shape1)
{
TopoDS_Shape myshape;//=shape1 ;
TopExp_Explorer Ex;
for (Ex.Init(shape1,TopAbs_FACE); Ex.More(); Ex.Next())
{
myshape = Ex.Current();
}
return myshape;
}

James D.'s picture

I have the following problem. Read two IGES files. The problem is, that visual crash here:

BRepAlgoAPI_Common aCMP= BRepAlgoAPI_Common (myIGESShape1, myIGESShape2);
aCMP.Build();
// here is the crash ...
TopoDS_Shape myIGES_Result= myIgesReader2.OneShape();

with simple models I have no problem. But when I have a cube an a cylinder it crash ...

James D.'s picture

I have the same problem with two cubes models. I atached this file ... what's te problem?

Forum supervisor's picture

Dear James,
The problem is that the common operation fails with
the specified arguments (no result):
==> not done ErrorStatus()=101
Your arguments are set of independent faces...
Regards

James D.'s picture

"Your arguments are set of independent faces..."

Ok I understand, but what can I do?

Second question: Is it possible to compare two objects with XDE?

James D.'s picture

??? Can you explain me what you mean?

Forum supervisor's picture

Dear James,
I mean that in spite you call your objects 'cubes'
no one of them is not a cube. It is just a set of separate
independent faces. To have a cube you should sew faces and
only after that apply boolean operations.
Regards

James D.'s picture

You mean face-modell and shell-modell (face and brep). Ok, I understand.

But I have a lot of obejcts without Error 101. The programm crashed (tb_alloc .... )

James D.'s picture

When I create a solid I get this message:

Unhandled exception at 0x779715de in ***.exe: 0x00000000:

StdFail_NotDone at memory location 0x0043f478..

Forum supervisor's picture

Dear James,
It means that you made a mistake.
First you should create a shell from the mentioned faces.
And only after that - create a solid.
If you feel some luck of knowledge in 3D modeling our training and e-learning courses are at your disposal - http://www.opencascade.org/support/training/.
In case of need you may contact us via the Contact Form http://www.opencascade.org/about/contacts/.
Regards

James D.'s picture

Yes, I create a face-model, join the faces and close surfaces ...

Unhandled exception at 0x779715de in ***.exe: Microsoft C++ exception: StdFail_NotDone at memory location 0x002afa58..

James D.'s picture

here are the to solids

Forum supervisor's picture

Dear James,
Your attachment has no solids.
It seems you don't have clear understanding what you are doing.
The best solution for you is some basic training.
Pay attention to my previous post.
Regards.

James D.'s picture

create a part -> Join -> ... -> close surfaces -> Solid ???-

Forum supervisor's picture

Dear James,
I just can suggest you to read more carefully
chapter "5.Topology" of "Modeling Data User's Guide".
I do hope you will find all necessary information
at this guide.
Regards

James D.'s picture

I think the problem is that IGES supports only surfaces and STEP supports solids ...

James D.'s picture

Hi,
I create two cylinder, no problem. I create this two objects -> Error

James D.'s picture

Here are another two files: