collision

Help?

How should I perform the collision detection and feed the collision parts back to the users?

Thanks!
Vicart

Stephane Routelous's picture

As far as I know, there is nothing in OpenCASCADE to quickly compute collisions.

You can check some external tools or libraries to do that.

It you really want to use OpenCASCADE, you can use the Bnd_Box for you first tests ( using BRepBndLib to compute the Bnd_Box for the shapes and test the collisions ).
If the bounding boxes have collision, you can compute the common part of the shapes, but it will take a lot of time to compute, It cannot be "interactive".

You can also voxelize your shapes to be able to compute quickly the collisions.

Try a search for collisions on google or in the newsgroups.

HTH

t5vk8g's picture

Thanks to you two!
Hi Stephane,Would you please tell me more about "voxelize your shapes to be able to compute quickly the collisions". I have difficulty to understand it.

What's more is that what Bnd_Box::SetGap() means?

I have a try to evaluate the intersections of two Geom_Surface which comes from the TopoDS_Face of my shape.It seems like this:
------------------------------Standard_Real Tol = 0.1e-7;
GeomAPI_IntSS aInterSS(aMovingSurface,aStaticSurface,Tol);
if(!aInterSS.IsDone()) return true;
// number of intersection lines
Standard_Integer aNumberLines = aInterSS.NbLines();
for(Standard_Integer i = 1; i <= aNumberLines; i++)
{
Handle(Geom_Curve) aCurve = aInterSS.Line(i);
// display the intersection curve
TopoDS_Edge aEdge;
BRep_Builder aBuilder;
aBuilder.MakeEdge(aEdge,aCurve,Tol);
Handle(AIS_Shape) theSectionShape = new AIS_Shape(aEdge);
myAISContext->SetColor(theSectionShape,Quantity_NOC_GREEN);
myAISContext->Display(theSectionShape);
Handle(AIS_Shape) aisStaticFace = new AIS_Shape(aStaticFace);
myAISContext->SetColor(aisStaticFace,Quantity_NOC_RED);
myAISContext->Display(aisStaticFace);
Handle(AIS_Shape) aisMovingFace = new AIS_Shape(aMovingFace);
myAISContext->SetColor(aisMovingFace,Quantity_NOC_BLUE1);
myAISContext->Display(aisMovingFace);
// display the collising surface
return true;// only display the first line and then return
}
------------------------------

I found that intersection curve 'aCurve' is not on the surface of both aMovingFace and aStaticFace sometimes.
What's wrong and how to solve this problem?
Must I triangulate the two surface and calculate at the level of triangular planes?

Thanks a million!
Vicart

Stephane Routelous's picture

Hi,

1/ voxelize : a voxel is a 3d pixel. It means a small box.
You can approximate your shape with a lot of small boxes. For collision, you can compute the intersection of 2 sets of boxes ( of course, you need to pre-process your voxels in order to test only the relevant ones ).

2/ Bnd_Box::SetGap is used to "enlarge" your box.
It means if you put a box (0,0,0,1,1,1) into your bnd_box and a gap of 0.1, you will get (-0.1,-0.1,-0.1,1.1,1.1,1.1).

3/ if you only deal with geometry, the intersection is very fast.
You said that the intersection curve is not an both surfaces. I think it is only a problem of display ( triangulation of your faces and discretisation of the curve ).Try to increase the precision of the triangulation.

HTH

t5vk8g's picture

Thanks you very much!

I am now working on gears-matching simulation.
I model the gears with SolidEdge and load the models into my application as STEP file.
Please do me a favor to clear up my wonder on OpenCasCade!

1.When the model is loaded into TopoDS_Shape,Is it parametric?
2.If the underlying TopoDS_TShape is still parametric,is it possible to get the common parts by solving the parametric equations ,not triangulating the model?
3.If the underlying TopoDS_TShape is not parametric,how does OpenCasCade work when a local context is opened and actived as face selection mode?

For example,I model a sphere in SolidEdge and load it,when a local context is opened as face selection mode,the viewer feeds two circles (exactly two polygons) representing the whole surface back to me.Obviously OpenGL only displays polygons.

I wonder that
-----------------------
the two circles are held as circle's parametric equation inner OpenCasCade and OpenCasCade hands the polygon down to OpenGL by simpling the circle.
or
they are polygons in nature.
-----------------------
If the circles are held as circle's parametric equation,the equation's parameters must come from AIS_Shape::Compute().What is the underlying workflow?
-----------------------

When the shape is displayed,the AIS_InteractiveObject::Compute() is called to triangulate the shape.Does this happen every time? I think it must be buffered. Is the buffer related to BRepTools::Clean(aShape) and BRepMesh::Mesh(aShape,aDeflection)?

Finally, there are a cube and a gear,I triangulate the two shapes using BRepMesh::Mesh() and pass the triangular planes to my collision detection tool. In order to reduce the time needed to perform collision detection, different deflection policy must be carried on based on the shape's surface characteristic,for example, a cube and a gear. But I get the shape at runtime by iterating all the displayed objects. How can I adjust the deflection parameter of BRepMesh::Mesh()?

I am not sure whether I have had you caught me!

Vicart!

Roman Lygin's picture

Dear all,

Please also feel free to visit our website for the advanced product "Collision Detection" - http://www.opencascade.com/products/store/91/. It is capable of determining both collisions and
proximity between models.

From the site you can also download evaluation version before your purchase.

Should you need further information, please do not hesitate to contact me.

Sincerely yours,
Roman Lygin

--
Roman Lygin - Pre-sales and qualification manager
Open CASCADE S.A.
email: r-lygin@opencascade.com
http://www.opencascade.com
Open CASCADE, the open source approach at the service of industry