How to get the points on the boundary of the shape in 2D case

is there any method to get the points on the boundary of the shape in 2D case. Because I want use lines to approximate the boundaries.

thank you in advance!

LI's picture

Get the edges of the boundary and then get the curve of the edges.
With the curve, you can get any point you want.

lejingwang's picture

Could you give me some examples? Thank you !

LI's picture

Here is an example in 3D case. 3D case is general.
Suppose that you have already a face that is TopoDS_Face.

double aFirst,aLast,t,x,y,z;
gp_Pnt gp;
TopExp_Explorer expw;
TopExp_Explorer expe;
for(expw.Init(face,TopAbs_WIRE);expw.More(); expw.Next())
{
TopoDS_Wire wire = TopoDS::Wire(expw.Current());
for (expe.Init(expw.Current(), TopAbs_EDGE);expe.More(); expe.Next())
{
TopoDS_Edge edge = TopoDS::Edge(expe.Current());
Handle(Geom_Curve) myCurve=BRep_Tool::Curve(edge,aFirst,aLast);
if(!myCurve.IsNull())
{
//here you can get any point on the curve, for example:
t=(aFirst+aLast)/2.;
myCurve->D0(t,gp);
x=gp.X();
y=gp.Y();
z=gp.Z();
}
}
}

lejingwang's picture

Thank you :)

Another question, Have you used Poly_Polygon2/3D? It looks like can approximating representation of a curve and providing the points that are used to define Polygon.

LI's picture

You are welcome. But I've never used Poly_Polygon2/3D.