offset problem

hello all,

I'm having a problem with BRepOffsetAPI_MakeOffset. Any ideas why this is crashing :

TopoDS_Wire *s2;
s2 = TopoDS::Wire(GetShape("Contour",ic));
BRepOffsetAPI_MakeOffset mkOffset(*s2)
mkOffset.Perform(dist);

GetShape returns a TopoDS_Shape (a wire) , dist is a real (0.001) an ic is an integer

It crashes, whatever I do. Please help

Jouke

hylkema's picture

forgot to say that ther error message is
terminate called after throwing an instance of 'StdFail_NotDone'

hylkema's picture

OK .. I figured out what the problem is. The wire consists of one single edge so the algorithm can not decide on what plane to use for the offset.
The question is now, how can I offset a single edge ?

Bill Chen's picture

Maybe you can try Geom_OffsetCurve

zhangzhigang824's picture

Hi,

You can specify a plane for offset, and then offset a single edge will OK.
The sample code is followed.

TopoDS_Face workingPlane = BRepBuilderAPI_MakeFace(gp_Pln(gp::Origin(),gp::DZ()));
BRepOffsetAPI_MakeOffset offset(workingPlane);
offset.AddWire(aWire);
offset.Perform(distance);
TopoDS_Shape newWire = offset.Shape();

Thanks!

PaddleStroke's picture

I have tried this for FreeCAD's sketcher's offset tool as I was having the same issue : offset failing on single lines.
But with this the offset is not working properly for negative distances anymore...
I mean that before if the distance was positive, then we made the offset outward, if distance negative offset inward.

When I initialize with workingPlane as in @zhangzhigang824 example, then the offset always go in the same direction (inward or inward depending on the wires), ie exactly as if I was doing offset.Perform(fabs(distance));
Which of course is not intended...
Any idea what is happening?

Matthias K.'s picture

Hi, I've not analysed this deeper, but if you define your working plane with its opposite normal direction then you get the offset into the other direction.