Prod.: Engine, ver.: 6020, ID: 60001294, Wish : Get the outline boundary (Convex Hull) from a collection of points

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

Article60001294
TypeWish
ProductEngine
Version6020
Date Added1/26/2011
FixedYes [6/9/2011]
Submitted byGraham Parker
Keywords

Subject

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

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);