How to properly copy a TopoDS_Shape

Hello,

I wan't to do a copy of some shapes, in order to keep the originals before doing any modification, I used the class BRepBuilderAPI_Copy :
"BRepBuilderAPI_Copy copy_shape;
copy_shape.Perform(Edge);
TopoDS_Edge Edge2 = TopoDS::Edge(copy_shape.Shape());"
, but I think the copy are not always exact because when copying a TopoDS_Face and one of its corresponding TopoDS_Edge where the function BRep_Tool::CurveOnSurface(Edge, Face, f, l) works perfectly, this function return a NULL curve for copied shapes in some cases.
What can I do ?

Thanks,
Antoine.

Cauchy Ding's picture

Hi Antoine,

If you just want to keep pcurves after coping an edge from a face. You can record pcurves manually to new edge.

int CopyEdgeAndPCurve(const TopoDS_Edge& srcEdge, TopoDS_Edge& newEdge)
{
int count = 0;
BRepBuilderAPI_Copy copier(srcEdge);
newEdge = TopoDS::Edge(copier.Shape());

BRep_ListOfCurveRepresentation& srcCurList = (*((Handle(BRep_TEdge)*)&srcEdge.TShape()))->ChangeCurves();
BRep_ListIteratorOfListOfCurveRepresentation srcIter(srcCurList);
BRep_ListOfCurveRepresentation& newCurList = (*((Handle(BRep_TEdge)*)&newEdge.TShape()))->ChangeCurves();

while (srcIter.More())
{
const Handle(BRep_CurveRepresentation)& cr = srcIter.Value();
try
{
cr->PCurve();
newCurList.Append(cr);
++count;
}
catch(...)
{
}
srcIter.Next();
}
return count;
}