1

As shown in the figure below:

enter image description here

I want to calculate the intersections of an u direction iso curve and the boundary of TopoDS_Face in occt,but i don't know how to write the code,anyone who can give some advices or sample code with c++?

Any useful suggestions and codes would be appreciated!

zero
  • 33
  • 4

2 Answers2

1

In your question I have several places which are not clear to me. So this is how I understand your question. You have a TopoDS_Face and ISO curve (U direction or V direction). You need to find the gp_Pnt of the intersection between the boundary edges of the given shape and the given ISO curve. Here is the small code snippet to do that.

You can get an ISO curve using the following code snippet.

TopoDS_Face face = ...                                      // the face object
Handle(Geom_Surface) surface = BRep_Tool::Surface(face);    // get the surface of the given face
double u = 0.5;                                             // define the u parameter value
Handle(Geom_Curve) curve = surface->UIso(u);                // get the ISO curve
TopoDS_Shape edge = BRepBuilderAPI_MakeEdge(curve).Shape(); // Make edge of the given ISO curve

You can find the intersection points of the given edges using the following code. Here assume the face contains multiple edges.

for (TopExp_Explorer exp(face, TopAbs_EDGE); exp.More(); exp.Next()) // explor the shape to get the edge
{
    TopoDS_Edge shapeEdge = TopoDS::Edge(exp.Current());            // get the current edge of the face
    BRepExtrema_DistShapeShape dist(edge, shapeEdge);

    if (dist.IsDone() && dist.NbSolution() > 0)                    // get the result
    {
        for (int i = 1; i <= dist.NbSolution(); i++) 
        {
            gp_Pnt point1 = dist.PointOnShape1(i);                // point on the iso curve
            gp_Pnt point2 = dist.PointOnShape2(i);                // point on the edge of the face
            // since both these points are same, you can use any of them.
            bool check = true;
        }
    }
}

Hope this is the correct answer you find.

  • Thanks for your answer, it's useful. But i want to get the u and v parameters of the intersection points, not the xyz parameters, how can i get the parameters? – zero May 10 '23 at 06:13
0

Curves have only one parameter and surfaces have two paramters (U and V).

To find the parameters on a curve or a surface you can use the following method. Since you have Geom_Curve, Geom_Surface and relevant points, you can use the following code snippet.

gp_Pnt point;// = ...; // point you know
Handle(Geom_Curve) curve;// = ..; // point on the curve
double tolerance = 1e-6;
double u; // u value of the curve
GeomLib_Tool::Parameter(curve, point, tolerance, u); // get the parameters

Handle(Geom_Surface) surface; // point on the surface
double surfaceU, surfaceV;      // u and v parameters on the surface
GeomLib_Tool::Parameters(surface, point, tolerance, surfaceU, surfaceV); // get the parameters

Adjust your tolerance value according to your requirement.