How to update trimmed edges after the surface modification?

For the geometry visualizer, We use our own code using GcPnts_...Deflection() for each curves and surface edges.

Now We want to perform SetPole() or MovePoint() on a surface
to change it's shape slightly.

The problem is... for the trimmed surfaces,
there were no relevant changes on it's trimmed edges.
It seemes unchanged. While if I saved it to IGES and reloaded it.
It worked (???)

So we've made an idea that goes as follows

- obtain a matrix of 2d edge curves in parametric space of
a surface with BRep_Tool::CurveOnSurface() by using
TopAbs_WIRE & TopAbs_EDGE Explorer in turn.

- modify original surface with MovePoint() or SetPole()

- build a new face using already stored 2d parametric curves
by BRepBuilderAPI_MakeFace(TopoDs_Face, TopoDS_Wire)

but We don't know how to convert 2d paremetric curves into
3d curves on a surface. I can not find any relevant function
which can perform this feature.

If this method is wrong, please let me know the better approach.

Francois Lauzon's picture

To build a 3d curve from a curve on surface, you could use Approx_CurveOnSurface and use the Geom2dAdaptor_HCurve and GeomAdaptor_HSurface.

You could also simply build your face with your 2d curve (using BRepBuilderAPI_MakeEdge2d) and your Geom_Surface and then let Open Cascade build 3d curves for you and correct wire orientation:

TopoDS_Face aFaceWith3dEdges;
ShapeFix_Face fixer(aFaceWith2dEdges);
fixer.SetPrecision(1e-4);
fixer.SetMinTolerance(1e-4);
fixer.FixWireTool()->FixAddCurve3dMode()=1;
fixer.FixWireTool()->FixSmallMode()=1;
fixer.Perform();
// something was done
if (!fixer.Status(ShapeExtend_OK)) {
aFaceWith3dEdges=fixer.Result();
}

Good Luck,
Francois.

Dongki Lee's picture

I'm not quite good at OCC.
Would you explain about this in more detail ?

"You could also simply build your face with your 2d curve (using BRepBuilderAPI_MakeEdge2d) and your Geom_Surface and then let Open Cascade build 3d curves for you and correct wire orientation"

How could I build my face with my 2d curves?
There's no BRepBuilderAPI_MakeEdge2d() function which has Geom_Surface as an argument.

Francois Lauzon's picture

BRepBuilderAPI_MakeEdge2d build a TopoDS_Edge with 2d curve information in it. You then add your edges to a wire (BRepBuilderAPI_MakeWire), and use this wire to trim your Geom_Surface (BRepBuilderAPI_MakeFace).

For example, this will create a trimmed plane:

BRepBuilderAPI_MakeVertex v1(gp_Pnt(0,0,0));
BRepBuilderAPI_MakeVertex v2(gp_Pnt(0,10,0));
BRepBuilderAPI_MakeVertex v3(gp_Pnt(10,10,0));
BRepBuilderAPI_MakeVertex v4(gp_Pnt(10,0,0));
BRepBuilderAPI_MakeEdge2d edge1(gp_Lin2d(gp_Pnt2d(0,0),gp_Dir2d(0,1)),v1,v2);
BRepBuilderAPI_MakeEdge2d edge2(gp_Lin2d(gp_Pnt2d(0,10),gp_Dir2d(1,0)),v2,v3);
BRepBuilderAPI_MakeEdge2d edge3(gp_Lin2d(gp_Pnt2d(10,10),gp_Dir2d(0,-1)),v3,v4);
BRepBuilderAPI_MakeEdge2d edge4(gp_Lin2d(gp_Pnt2d(10,0),gp_Dir2d(-1,0)),v4,v1);
BRepBuilderAPI_MakeWire aWire(edge1,edge2,edge3,edge4);
aWire.Build();
BRepBuilderAPI_MakeFace aFace(gp_Pln(gp_Pnt(0,0,0),gp_Dir(0,0,1)),aWire);
aFace.Build();

but you have to add 3d curve to the edges to be able to shade:

TopoDS_Face aFaceWith3dEdges;
ShapeFix_Face fixer(aFace);
fixer.SetPrecision(1e-4);
fixer.SetMinTolerance(1e-4);
fixer.FixWireTool()->FixAddCurve3dMode()=1;
fixer.FixWireTool()->FixSmallMode()=1;
fixer.Perform();
// something was done
if (!fixer.Status(ShapeExtend_OK)) {
aFaceWith3dEdges=TopoDS::Face(fixer.Result());
}

Try this small example,
Good Luck,
Francois.