Open CASCADE, the 3D modelling kernel
3D modeling & numerical simulation

Search the Forums
See All Topics

Quickest way to check if two shapes intersect?

Quickest way to check if two shapes intersect?
EricThompson 2011/04/06 22:21
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?

Deepak Agrawal 2012/10/17 20:05
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 2012/10/18 19:34
Sorry, I never did. I ended up reworking what I was doing to avoid having to check that.     
Pawel 2012/10/24 02:24

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).

AlexP 2012/11/13 11:59
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. 2012/11/13 15:51
I have the following problem. Read two IGES files. The problem is, that visual crash here:

BRepAlgoAPI_Common aCMP= BRepAlgoAPI_Common (myIGESShape1, myIGESShape2);
// 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. 2012/11/13 18:48
I have the same problem with two cubes models. I atached this file ... what's te problem?

You have to be logged in to download the attached file
Forum supervisor 2012/11/14 14:27
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...
James D. 2012/11/14 21:08
"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. 2012/11/16 17:56
??? Can you explain me what you mean?     
Forum supervisor 2012/11/19 11:30
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.
James D. 2012/11/19 14:09
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. 2012/11/19 16:48
When I create a solid I get this message:

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

StdFail_NotDone at memory location 0x0043f478..
Forum supervisor 2012/11/19 17:06
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 -
In case of need you may contact us via the Contact Form
James D. 2012/11/19 17:41
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. 2012/11/19 17:50
here are the to solids
You have to be logged in to download the attached file
Forum supervisor 2012/11/20 11:52
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.
James D. 2012/11/20 13:50
create a part -> Join -> ... -> close surfaces -> Solid ???-
Forum supervisor 2012/11/20 14:38
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.
James D. 2012/11/20 20:33
I think the problem is that IGES supports only surfaces and STEP supports solids ...
James D. 2012/11/19 21:04
I create two cylinder, no problem. I create this two objects -> Error
You have to be logged in to download the attached file
James D. 2012/11/19 21:58
Here are another two files:
You have to be logged in to download the attached file
Latest news
  • Open CASCADE CAD Assistant for iOS platform is available!
  • Open CASCADE Technology 6.9.0 is available for download!
  • JT Assistant for Android

  • © OPEN CASCADE 2000 - 2015  |  Search  |  Contacts   |  Site map