Prod.: Engine, ver.: 6, ID: 60000412, HowTo : How can i check if a point is inside a polyline?

HowTo : How can i check if a point is inside a polyline?

Article60000412
TypeHowTo
ProductEngine
Version6
Date Added2/5/2008
Submitted byKerry Francis
Keywords

Subject

How can i check if a point is inside a polyline?

Summary

How can i check if a point is inside a polyline?

Solution

You can create a Region (object) which has these functionalities. Please check the following sample code.

//Create A Polyline
vdPolyline poly = new vdPolyline();
poly.SetUnRegisterDocument(vdFramedControl1.BaseControl.ActiveDocument);
poly.setDocumentDefaults();
poly.VertexList.Add(
new gPoint());
poly.VertexList.Add(
new gPoint(1,1));
poly.VertexList.Add(
new gPoint(2,2));
poly.VertexList.Add(
new gPoint(3,2));
poly.VertexList.Add(
new gPoint(5,2));
poly.VertexList.Add(
new gPoint(6,1));
poly.VertexList.Add(
new gPoint(3,0));
poly.VertexList.Add(
new gPoint(0,0));
vdFramedControl1.BaseControl.ActiveDocument.Model.Entities.AddItem(poly);

//Create A Region From the Polyline's points
VectorDraw.Render.Region reg = new VectorDraw.Render.Region(poly.GetSamplePoints(0, 0));
//Check if a point is inside the polyline or not.
bool a = reg.IsPointInside (new gPoint (0,1));
bool b = reg.IsPointInside (new gPoint (2,1));