60001294 Get the outline boundary (Convex Hull) from a collection of points

Article 60001294
Type Wish
Product Engine
Version 6020
Date Added 1/26/2011 12:00:00 AM
Fixed (6/9/2011 12:00:00 AM)
Submitted by Graham Parker

Summary

Get the outline boundary (Convex Hull) from a collection of points

Solution

In version 6021 a new method GetOutlineBoundary was added in gPoints object.

Returns an array of points that consist the outline boundary set (known as Convex Hull)containing all points of this collection.

Example C#:

 

//Find the outline boundary containing all grip points of selected entities

//Prompt the user to select some entities.

bool suc = doc.CommandAction.CmdSelect(null);

if (!suc) return;

//get the selection with selected entities

vdSelection set = doc.Selections.FindName("VDRAW_PREVIOUS_SELSET");

//A collection to hold all the grip points of selected entities

gPoints all_gpipoints = new gPoints();

//fill the collection with grip points of each entity

foreach (vdFigure fig in set)

{

all_gpipoints.AddRange(fig.GetGripPoints());

}

//Find the outline boundary containing all grip points of selected entities, as an array of gPoints

gPoints boundpoints = all_gpipoints.GetOutlineBoundary();

//create a new polyline that contains all points of the boundary in order to view the result in drawing area.

vdPolyline pline = new vdPolyline();

pline.SetUnRegisterDocument(doc);

pline.setDocumentDefaults();

pline.VertexList = new Vertexes(boundpoints);

doc.Model.Entities.AddItem(pline);

doc.Redraw(true);

 

Send comments on this topic.