Intersection with a surface of revolution

Hello,

I can't manage to make an intersection (with GeomAPI_IntCS) between
my curve (Handle_Geom_Line) and my surface of revolution (Handle_Geom_SurfaceOfRevolution). Please help me !

my code:

gp_Pnt point(70,-30,50);
gp_Dir direction(-10,-10,-100);
Handle(Geom_Line) ligne = new Geom_Line(point,direction);

gp_Pnt P1(150,0,0);
gp_Pnt P2(30,0,100);
gp_Pnt P3(0,0,0);
gp_Dir d1(0,0,10);

gp_Ax1 axe(P3,d1);

Handle(Geom_Curve) aCurve = GC_MakeSegment(P1,P2).Value();

Handle_Geom_SurfaceOfRevolution base = new Geom_SurfaceOfRevolution(aCurve,axe);

GeomAPI_IntCS longueur_gene(ligne,base);

int nomb = longueur_gene.NbPoints();

if (nomb == 1)
{
gp_Pnt point22 = longueur_gene.Point(1);

TopoDS_Vertex V=BRepBuilderAPI_MakeVertex(point22);
Handle(AIS_Shape) Point = new AIS_Shape(V);
myAISContext->Display(Point,Standard_False);
}

Rob Bachrach's picture

I had the same problem but could not come up with a simple example that illustrated it. I believe this is a bug in OCC. In our code, we first perform an OCC intersection. If none is found and the surface is revolved, spherical, B-Spline or Bezier, we intersect the line with the tesselation on the surface (which we already have and have the code to perform). This is a pure workaround. But now that you have exposed the bug, maybe it will get fixed.

MANU's picture

Thank you Rob Bachrach

I've just managed to solve my problem converting my 'SurfaceOfRevolution' in 'Geom_BSplineSurface'

Handle_Geom_BSplineSurface newbase = GeomConvert::SurfaceToBSplineSurface( base );

Do you think it's a good method ?

Rob Bachrach's picture

Since it is still just a workaround for a bug...
If it works, its a good method. Just remember that the BSplineSurface may not be a perfect representation of your original surface. The point may be away from the surface by some tolerance. Depending on your use for the point, you may have to massage it after the intersection.