60001690 A method to remove triangles with area 0 from gTriangles collection

Article 60001690
Type Wish
Product Engine
Version 6022
Date Added 5/3/2012 12:00:00 AM
Fixed (5/3/2012 12:00:00 AM)
Submitted by Graham Parker

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


 

Send comments on this topic.