Problem with BRepBuilderAPI_Transform

Hi,

I have some problems to use the BRepBuilderAPI_Transform class.
First i work in 2D. So i ask me if it is posible to use BRepBuilderAPI_Transform in a 2D environment.
I explain. I create edge 2d with the command GCE2d_MakeEdge2d and store them in a TopoDS_wire.
I would like to make a mirror of my TopoDS_wire but it doesn't work. It returns me the same wire instead of doing the mirror.

I have try with the tutorial example and it is the same it doesn't work.

TopoDS_wire Test()
{
//Profile : Define Support Points
Standard_Real myWidth = 50.0;
Standard_Real myThickness = 30.0;
gp_Pnt2d aPnt1(-myWidth / 2. , 0 );
gp_Pnt2d aPnt2(-myWidth / 2. , -myThickness / 4.);
gp_Pnt2d aPnt3(0 , -myThickness / 2.);
gp_Pnt2d aPnt4(myWidth / 2. , -myThickness / 4.);
gp_Pnt2d aPnt5(myWidth / 2. , 0);

Handle(Geom2d_TrimmedCurve) aArcOfCircle = GCE2d_MakeArcOfCircle(aPnt2,aPnt3 ,aPnt4);
Handle(Geom2d_TrimmedCurve) aSegment1 = GCE2d_MakeSegment(aPnt1 , aPnt2);
Handle(Geom2d_TrimmedCurve) aSegment2 = GCE2d_MakeSegment(aPnt4 , aPnt5);

//Profile : Define the Topology
TopoDS_Edge aEdge1 = BRepBuilderAPI_MakeEdge2d(aSegment1);
TopoDS_Edge aEdge2 = BRepBuilderAPI_MakeEdge2d(aArcOfCircle);
TopoDS_Edge aEdge3 = BRepBuilderAPI_MakeEdge2d(aSegment2);

TopoDS_Wire aWire = BRepBuilderAPI_MakeWire(aEdge1 , aEdge2 , aEdge3);

//Complete Profile
gp_Pnt2d aOrigin(0 , 0);
gp_Dir2d xDir(1 , 0);
gp_Ax2d xAxis(aOrigin , xDir);

gp_Trsf2d aTrsf;
aTrsf.SetMirror(xAxis);

/// I have try with Standard_false but is worst, it crash the application
BRepBuilderAPI_Transform aBRepTrsf(aWire , aTrsf, Standard_True);
TopoDS_Shape aMirroredShape = aBRepTrsf.Shape();

TopoDS_Wire aMirroredWire = TopoDS::Wire(aBRepTrsf.Shape());

return aMirroredWire ;
}

The problem is that instead of having wire mirrored, it gave me the same wire (the mirrored wire is equal as the original wire).
It is like if the transformation doesn't modify the shape.

I've try with all in 3d (gp_Pnt instead of gp_Pnt2d etc..) but it is the same. I don't understand why it doesn't work !!!!

Thanks in advance for some idea.

Steph's picture

I have forgotten to say that after i go through the wire to display each edge.

I have seen that when i put "standard_true" for the Copy parameter of
BRepBuilderAPI_Transform aBRepTrsf(aWire , aTrsf, Standard_True);
in the function drawedge it crash when it is called : Geom2dAdaptor_Curve adaptedCurve(curve2D);
If i use "standard_false" it doesn't crash but i give me the same wire without any transformation.

void Displaywire(const TopoDS_Wire& wire)
{
TopExp_Explorer contourExp;
for (contourExp.Init(wire,TopAbs_EDGE); contourExp.More() ; contourExp.Next())
{
const TopoDS_Edge& edge = TopoDS::Edge(contourExp.Current());
DrawEdge(ged,edge,color,lineType);
}
}

void DrawEdge(...)
{
Standard_Real firstParam, lastParam;
Handle_Geom2d_Curve curve2D;
Handle_Geom_Surface surface;
TopLoc_Location location;
gp_Pnt2d firstPoint,lastPoint,centerPoint;

///Get the Handle_Geom2d_Curve which correspond to the current edge
BRep_Tool::CurveOnSurface(edge,curve2D,surface,location,firstParam,lastParam);

///We use an Geom2dAdaptor_Curve to compute the two extremities points of the curve
Geom2dAdaptor_Curve adaptedCurve(curve2D);
adaptedCurve.D0(firstParam,firstPoint);
adaptedCurve.D0(lastParam,lastPoint);

switch (adaptedCurve.GetType())
{
case GeomAbs_Line:
DrawSegment(ged,firstPoint,lastPoint,color,lineType);
break;
....
....
}

Steph's picture

Up. Please answer.