Prod.: Engine, ver.: 6022, ID: 60001690, Wish : A method to remove triangles with area 0 from gTriangles collection

Wish : A method to remove triangles with area 0 from gTriangles collection

Article60001690
TypeWish
ProductEngine
Version6022
Date Added5/3/2012
FixedYes [5/3/2012]
Submitted byGraham Parker
Keywords

Subject

A method to remove triangles with area 0 from gTriangles collection

Summary

Is it possible to add a method that will remove triangles with area 0 from a gTriangles collection ?

Solution

In version 6023 new method RemoveZeroAreaTriangles of gTriangles was added.

Remove all triangles in the collection that their is equal to 0.0 . Globals.DefaultAreaEquality is used to compare area values.

return the number of items that removed from the collection.


Also new method Area was added for gTriagle and gTriangles collection objects.

 

Example

It gets the triangles of a vdPolyface that their area is different from zero.

gPoints verts = new gPoints();

verts.Add(new gPoint(0, 0, 0)); verts.Add(new gPoint(1, 0, 0)); verts.Add(new gPoint(1, 1, 0)); verts.Add(new gPoint(0, 1, 0)); // face 1 from 4 different points

verts.Add(new gPoint(1, 0, 0)); verts.Add(new gPoint(1, 2, 0)); verts.Add(new gPoint(2, 2, 0)); verts.Add(new gPoint(2, 2, 0)); // face 2 from 3 different points

Int32Array fl = new Int32Array();

fl.AddItem(1); fl.AddItem(2); fl.AddItem(3); fl.AddItem(4); fl.AddItem(-1); //face 1

fl.AddItem(5); fl.AddItem(6); fl.AddItem(7); fl.AddItem(8); fl.AddItem(-1); //face 2

vdPolyface polyf = new vdPolyface(doc, verts, fl);

doc.Model.Entities.AddItem(polyf);

polyf.Update();

polyf.Invalidate();

gTriangles gtr = polyf.GetTriangles(); // contains 4 triangles 2 for each face, but one ofe them has zero area

int ret = gtr.RemoveZeroAreaTriangles(); // will return 1, the number of the triangle removed and gTriangles will have 3 traingles left