Offset 2D Polygon

How can I offset an open Polygon?

Roman Lygin's picture

Hi Andrea,

Won't BRepOffsetAPI_MakeOffset work ?


Vaclav Smilauer's picture

Provided offset function (for wires and geomcurves) never worked reliably for me; for polygons, I just went through the nodes and would offset every one in the angle determined by adjacent edges.

[UNFORTUNATELY, one can not paste preformatted code in this FORUM... I wonder if SOMEONE can do SOMETHING about it - please!]

The code (ignore line numbers):
10 Handle(Poly_Polygon3D)
11 Heal::OffsetPoly(Handle(Poly_Polygon3D) P, Standard_Real offset){
12 const TColgp_Array1OfPnt& Pp=P->Nodes();
13 TColgp_Array1OfPnt offPp(1,Pp.Length());
14 int imax=Pp.Length()-1, iprev, inext;
15 for(int i=1; i<=Pp.Length(); i++){
16 iprev=i>1?i-1:imax;
17 inext=i<=imax?i+1:2;
18 //DBG_HEAL<<"["<