For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings


Need to speed up your development?
Have a look at our:

Samples & Tools


Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

About Intersection of a line and a revolution shape

Wang Yue's picture

We want to use OCC to construct a geometry solid shape and use a line to intersect with the solid shape, we get the intersecting points and every point's transition (in, out or tangent) information.

Firstly, we use the B-Spline method to construct a curve(to represent y=sin(x)+y0 with x=[0, 200*PI] ); secondly, we use the B-Spline curve and three line segments to construct a wire and get a face; thirdly, by revoluting the face, we get a revolution solid shape ; then we use a line to intersect with the solid shape, but we get some wrong output.

1, the number of intersecting points is wrong;
For this wrong output, I read the OCC6.3.0 source code of "IntCurvesFace_Intersector.cxx", "BRepTopAdaptor_TopolTool.cxx" and "IntCurvesFace_ShapeIntersector.cxx". IntCurvesFace_ShapeIntersector's perform function call perform method of "IntCurvesFace_Intersector" . In IntCurvesFace_Intersector's constuctor "IntCurvesFace_Intersector(const TopoDS_Face& Face, const Standard_Real aTol)", myTopolTool (from BRepTopAdaptor_TopolTool) is used to set the sample numbers of surface's parameters (u,v). I find that the wrong output is caused by the "nbsu" and "nbsv" which are calculated by BRepTopAdaptor_TopolTool. In ComputeSamplePoints() of BRepTopAdaptor_TopolTool, for the case of "GeomAbs_SurfaceOfRevolution", the sample numbers is seted as "nbsv = 15; nbsu=25;", that is to say for all revolution surface "nbsv = 15; nbsu=25;", I think this is not properly.

2, when the line is tangent to the surface, the intersecting points' transition information is not correct. There is output result(for y=sin(x)+y0 with x=[0, 20*PI]) as the following:

The number of intersection points is 10
i=1 0 3 0 Transition == In IN a Face
i=2 0 3 0 Transition == Out ON a Face
i=3 6.28319 3 0 Transition == Tangent ON a Face
i=4 6.28319 3 0 Transition == Out ON a Face
i=5 12.5664 3 0 Transition == Tangent ON a Face
i=6 18.8496 3 0 Transition == Tangent ON a Face
i=7 25.1327 3 0 Transition == In ON a Face
i=8 25.1327 3 0 Transition == Tangent ON a Face
i=9 31.4159 3 0 Transition == In ON a Face
i=10 31.4159 3 0 Transition == Out IN a Face

The output result show that a "In" point is not corresponding with a "Out" point!

Another problem: In "BRepClass3d_SolidExplorer.cxx", "PointInTheFace" function is used to find sample points, I think the method used to find the sample points is not sutable for a solid shape which has a complex face.

The code is given as following.

#include "occtest.hxx"
void mk_aShape(TopoDS_Shape &aShape);
Standard_Real aTol = 1e-6;
int main(int argc, char** argv)
TopoDS_Shape aShape;
Standard_Real dx,dy,dz;
Standard_Real P1x,P1y,P1z;
Standard_Real D1x,D1y,D1z;
dx = dy = dz = 0.01;

gp_Pnt P1(P1x,P1y,P1z);
gp_Dir D1(D1x,D1y,D1z);
gp_Lin L1(P1,D1);

IntCurvesFace_ShapeIntersector aIntersector;
aIntersector.Load (aShape, aTol);
aIntersector.Perform(L1, -10.0, 5000.0);

Standard_Integer nb = aIntersector.NbPnt();


for(int i=1;i {

cout if( aIntersector.Transition(i)==IntCurveSurface_Tangent ) cout else if(aIntersector.Transition(i)==IntCurveSurface_In ) cout else if(aIntersector.Transition(i)==IntCurveSurface_Out ) cout else cout if(aIntersector.State(i)==TopAbs_IN) cout else if(aIntersector.State(i)==TopAbs_ON) cout else cout }
return 0;

void mk_aShape(TopoDS_Shape &aShape)
Standard_Real Sample_Radian;
Standard_Integer N_Period=100;
Standard_Integer Num_Period_Points=50;
Standard_Integer Num_Points_Total=N_Period*Num_Period_Points+1;
Standard_Real aOffset = 2.0;

Handle_TColgp_HArray1OfPnt Polygon_Points = new TColgp_HArray1OfPnt(1,Num_Points_Total);
Standard_Real x=0,y=0,z=0;
for(Standard_Integer i=1;i {
x = PI*Standard_Real(i-1)/Standard_Real(Num_Period_Points);
y = cos(x)+aOffset;
Polygon_Points->SetValue(i, gp_Pnt(x, y, z));
GeomAPI_Interpolate P_to_Interpolate(Polygon_Points,false,aTol);
Handle(Geom_BSplineCurve) Point_to_C = P_to_Interpolate.Curve();

Standard_Real t0 = Point_to_C->FirstParameter();
Standard_Real t1 = Point_to_C->LastParameter();

gp_Pnt p0 = Point_to_C->Value(t0);
gp_Pnt p1 = Point_to_C->Value(t1);

gp_Pnt p0_0 = gp_Pnt(p0.X(),0,0);
gp_Pnt p1_1 = gp_Pnt(p1.X(),0,0);

Handle(Geom_TrimmedCurve) aSegment1 = GC_MakeSegment(p0_0 , p0);
Handle(Geom_TrimmedCurve) aSegment2 = GC_MakeSegment(p1 , p1_1);
Handle(Geom_TrimmedCurve) aSegment3 = GC_MakeSegment(p1_1 , p0_0);

TopoDS_Edge aEdge1 = BRepBuilderAPI_MakeEdge(aSegment1);
TopoDS_Edge aEdge2 = BRepBuilderAPI_MakeEdge(Point_to_C);
TopoDS_Edge aEdge3 = BRepBuilderAPI_MakeEdge(aSegment2);
TopoDS_Edge aEdge4 = BRepBuilderAPI_MakeEdge(aSegment3);

TopoDS_Wire aWire = BRepBuilderAPI_MakeWire(aEdge1 , aEdge2 , aEdge3, aEdge4);
TopoDS_Face aFace = BRepBuilderAPI_MakeFace(aWire);

gp_Vec aVec = gp_Vec(p0_0,p1_1);
gp_Dir aDir = gp_Dir(aVec);
gp_Ax1 aAxis = gp_Ax1(p0_0,aDir);

aShape = BRepPrimAPI_MakeRevol(aFace,aAxis);

I do not whether my method of getting the intersection points is right? Can anyone give me some suggestion? Thanks!