Why Can't I fetch curve..........

Hello All,

I got section lines between a solid shape and an infinite plane. Next I build a shape of it.Then I tried to explore the Edges from the shape.Again converted the Edges into curve with an intention to fetch the vertices of the shape just created using sectional lines. But unfortunately no opetation is supported over the converted curve. Initially I thought that it might be due to it's infinite nature so I trimmed it.Though I can't get the end points of the curve. Why????

Help me Pls.

Here's the code :-

Standard_Boolean PerformNow=Standard_False;

BRepAlgoAPI_Section sectionalg(Sbox,plane,PerformNow);//plane is infinite.
TopoDS_Shape section = sectionalg.Shape();//Working fine.

gp_Pnt firstPnt,lastPnt;
Handle(Geom_Curve) crv[4];
Handle(Geom_Curve) crvTem;
Handle(Geom_TrimmedCurve) Line[4];
Handle(Geom_TrimmedCurve) LineTem;
Standard_Real U1, U2;
int i=0;
for (ExpEdges.Init (section, TopAbs_EDGE) ;
ExpEdges.More() ; ExpEdges.Next())
const TopoDS_Edge& Edge = TopoDS::Edge (ExpEdges.Current()) ;
crvTem= BRep_Tool::Curve(Edge, U1, U2) ;
Line[i] = Handle(Geom_TrimmedCurve)::DownCast(crvTem);

Standard_Real FirstGGH = Line[i]->FirstParameter();// Segmentation Fault.
Standard_Real LastGGH = Line[i]->LastParameter();
gp_Pnt P1ggh,P2ggh;
Line[i]->D0(FirstGGH, P1ggh);
Line[i]->D0(LastGGH, P2ggh);

cout cout }



I need to get the end points of the curve or at least a finite and accessible curve.

Thanx a lot for your attention.

Pavitra K. Mukherjee.

Rob Bachrach's picture

Just downcasting the curve to a TrimmedCurve does not make it one. My guess is that the resulting curve is not a Geom_TrimmedCurve, so the DownCast is returning a NULL handle. Then you call a function on that handle and crash. If you check the actual type of crvTem, I think you will find it is something other than a Geom_TrimmedCurve (or derived from it). Instead of calling FirstParameter and LastParameter, try using U1 and U2 returned from the Curve function. These are your parameters on the curve. If you wish to create a trimmed curve, you can do so using the crvTem and the 2 parameters.

Pavitra's picture

Thanx Mr. Bachrach,

You hav pointed correctly that the returned type may be something else. It's 'Geom_Line' and I already did everything to process that returned line but I failed.

I used the returned U1 and U2 parameter earlier but not for Trimmed curve generation. But now,after your supervision I'll try these to get the trimmed curve. Get back to you Soon.

Really grateful to you.



Pavitra's picture

It's working.

Pavitra K. Mukherjee.