HowTo : How can i check if a point is inside a polyline?
| Article | 60000412 |
| Type | HowTo |
| Product | Engine |
| Version | 6 |
| Date Added | 2/5/2008 |
| Submitted by | Kerry 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));