TriangleByRef class
From Solid Graphics Wiki

The TriangleByRef class specifies a triangle using three integer values. The values specify indexes into a point array which contain actual triangle points coordinates. Therefore using this type is always accompanied by using some kind of point array type, usually the PointList class or the PointdList class.
Constructors
Default class constructor does not initialize the triangle point indexes to any value. This is on purpose for performance reasons. Other class costructors allow to initialize the an object using three integer values.
Fields
Field name  Type  Description 
point0  int  index of the first triangle point 
point1  int  index of the second triangle point 
point2  int  index of the third triangle point 
point  int[ 3 ]  array of three integer values. Note: the point0, point1, point2 fields and the point array are actually defined as union, so for example the code triangle.point[ 1 ] = 23 also changes the triangle.point1 value to 23 
Methods
Method name  Description 
Area  Calculates the triangle area. 
Center  Calculates the triangle center point 
NormalVector  Calculates triangle's normal vector 
IsSharingPoint  Determines whether the triangle is sharing a point with anothr triangle 
FindPointIndex  Returns index (0, 1 or 2 ) into it's point field for given point id (point index). If the point id is not used by the triangle then it returns 1. 
FindEdge  Returns index of specified edge, or 1 if edge does is not a part of the triangle. Orientation of the specified edge is ignored during the search. 
FindOrientedEdge  Returns index of specified edge, or 1 if edge does is not a part of the triangle. Orientation of the specified edge is NOT ignored during the search. 
FindCommonPointIndex  Returns index (0, 1, or 2) of a point which is common to the triangle and another specified triangle, or 1 if the two triangles don't have a common point. 
FindNonCommonPointIndex  Returns index (0, 1, or 2) of first noncommon point index of two triangles, or 1 if both triangles use the same points. 
AddOffset  Increments all the point field indexes by given offset. 
Reorient  Reverses the triangle's orientation. 
IsSmall  Returns true if any of the two triangle points are closer to each other than the cMinDistance 'constant'. Otherwise it returns false. 
IsValid  Returns true if the triangle definition is invalid  if any two of it's point indexes reference the same point in the point array. Otherwise it returns false. 
LoadFromXML  Loads the triangle definition from XmlReader. 
SaveToXML  Saves triangle definition into MemoryBuffer as XML. 
Operators
=  Allows assignment of one triangle to another. 
==  Returns true if two triangles have all points common. Otherwise returns false. The function ignores triangles orientation. 
Remarks
The Point class does not have any virtual functions on purpose, so it is safe (in MS Visual C++) to typecast pointer to the class object to int pointer and access the point0, point1, point2 point indexes by float array indexes 0, 1 and 2.
Also it is safe to use functions such as memcpy to copy values of one TriangleByRef object to other, or values of Carray of TriangleByRef objects to another CArray of TriangleByRef objects (as long as the destination array has enough capacity).
See Also