For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

TopoDS_Edge to Geom2d_Curve

Lars's picture
Forums: 

I'm sure this is very basic, but I haven't found a solution yet. I have a TopoDS_Edge that was created using the BRepBuilderAPI_MakeEdge2d function. I would like to turn the TopoDS_Edge into a Geom2d_Curve. I noticed that this is straightforward in 3d: a TopoDS_Edge can be converted to a Geom_Curve. However, in 2d, the following code leads to a segmentation fault:

TopoDS_Edge myEdge = BRepBuilderAPI_MakeEdge2d( ... );
Handle(Geom2d_Curve) C;
Handle(Geom_Surface) surface;
TopLoc_Location location;
Standard_Real first, last;
C = BRep_Tool::CurveOnSurface(myEdge, surface, location, first, last);

Is there a simple conversion that I'm totally missing?

Thanks.

Venugopal Gudimetla's picture

Hi Lars,

I have the same problem, however, there is a reply another thread with similar Geom2d_Curve retrieval problem may be you can use the method to retrieve Geom2d_Curve in a different way. I didn't try it yet, please let me know if it works so I too can use.

http://www.opencascade.org/org/forum/thread_17169/
Thanks,
Venu

Sharjith Naramparambath's picture

Hi Lars,

If you have shown the code here exactly as you are using in your program, it has every reason to bring up a segmentation fault. The only valid entity here is the myEdge variable that is pointing to an Edge. The surface onto which it is to be projected and the location are invalid. Look at the argument list of the method-- the first 3 are const references meaning that they are the required inputs which must point to valid data. From your code it looks like that you have not created a valid surface and location. Hope this helps.

Venugopal Gudimetla's picture

Hi Sharjith,

my initial reaction just that, but please take look the function implementation :

http://opencascade.sourcearchive.com/documentation/6.3.0.dfsg.1-1/classBRep__Tool_29e74a19fe10476e15a86826e55892b5.html#29e74a19fe10476e15a86826e55892b5

you will see that we don't need to provide another variables except for TopoDS_Edge as input and just of the variables are calculated from it.

I implemented it and my results look fine.

Thanks,
Venu

Venugopal Gudimetla's picture

and pardon my plingish, I don't check after typing :)

Sharjith Naramparambath's picture

yes, that looks fine. i just missed to see that version of the method.

Fabian Hachenberg's picture

Hi,
in method BRep_Tool::CurveOnSurface there's the following line

// find the representation
BRep_ListIteratorOfListOfCurveRepresentation itcr
((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());

They're expecting a BRep_TEdge here and a TopoDS_Edge based on a 2d curve is propably not a BRep_TEdge (no supporting surface avaible!)

Fabian Hachenberg's picture

Correction:

BRepBuilderAPI_MakeEdge2d actually creates instances of BRep_TEdge. In the course of creation of the edge, this routine in BRepLib is called

const Handle(Geom_Plane)& BRepLib::Plane()
{
if (thePlane.IsNull()) thePlane = new Geom_Plane(gp::XOY());
return thePlane;
}

So the 2d edges are actually 3d edges located on a xy plane. Therefore this doesn't seem to be the reason for the above mentioned seg fault...

Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.