This reference page is linked to from the following overview topics: MNMesh Edges, MNMesh Note on Debugging.
The face structure used with the MNMesh mesh.
MNFace are not necessarily triangles. They also may contain hidden vertices which are used in converting the face back to triangles. This triangulation is always maintained in the face.
#include <mnmesh.h>
Public Member Functions |
|
MNFace () | |
Constructor. |
|
MNFace (int d) | |
Constructor. |
|
DllExport | MNFace (const MNFace *from) |
Constructor. |
|
~MNFace () | |
Frees all arrays. |
|
DllExport void | Init () |
Initialize the face. |
|
DllExport void | SetDeg (int d) |
Set the number of edges and vertices this
face has. |
|
DllExport void | Clear () |
Frees all arrays, setting them to NULL, and
resets degree. |
|
int | TriNum () |
Returns the number of triangles in this
face. |
|
DllExport int | FindTriPoint (int edge) |
Given the index of a particular edge, this
routine returns the point (distinct from edge and (edge+1)deg) that
forms a triangle with the edge, given the current scheme of
diagonals. |
|
DllExport int | FindTriPoint (int a, int b) |
Given two verts that form a diagonal in the
polygon, this method finds the vertex between them that connects by
a diagonal or an outer edge to both of them. |
|
DllExport void | GetTriangles (Tab< int > &tri) |
This method fills in the table with the full
triangulation for the face, based on the internal diagonal list.
|
|
DllExport void | SetAlloc (int d) |
Allocates enough memory in the arrays for
the face to have degree d, but does not actually set the degree.
|
|
DllExport void | MakePoly (int fdeg, int *vv, bool *vis=NULL, bool *sel=NULL) |
Makes this face into a polygon with the
specified vertices and other information. |
|
DllExport void | Insert (int pos, int num=1) |
Inserts space for more vertices and edges on
this face. |
|
DllExport bool | Delete (int pos, int num=1, int edir=1, bool fixtri=TRUE) |
Deletes vertices & edges from this face.
|
|
DllExport void | RotateStart (int newstart) |
Re-indexes the vertices and edges so that
the vertex in position newstart becomes the new first vertex.
|
|
DllExport void | Flip () |
Reverses order of verts, effectively
inverting the face. |
|
DllExport int | VertIndex (int vv, int ee=-1) |
Returns the position of vertex vv in this
face's list of vertices. |
|
DllExport int | EdgeIndex (int ee, int vv=-1) |
Returns the position of edge ee in this
face's list of edges. |
|
DllExport void | ReplaceVert (int ov, int nv, int ee=-1) |
Replaces vertex ov with vertex nv in the
list of vertices. |
|
DllExport void | ReplaceEdge (int oe, int ne, int vv=-1) |
Replaces edge oe with edge ne in the list of
edges. |
|
DllExport MNFace & | operator= (const MNFace &from) |
Assignment operator. |
|
DllExport bool | operator== (const MNFace &from) |
Comparison operator. |
|
int & | operator[] (int i) |
Access operator. |
|
const int & | operator[] (int i) const |
Access operator. |
|
DllExport void | MNDebugPrint (bool triprint=FALSE) |
Uses DebugPrint to print out face
information to the Debug Results window in DevStudio. |
|
DllExport IOResult | Save (ISave *isave) |
DllExport IOResult | Load (ILoad *iload) |
Public Attributes |
|
int | deg |
This is the degree: the number of vertices
and edges that this face has. |
|
int * | vtx |
This is the list of vertices that make up
the corners of this face. |
|
int * | edg |
This is the list of edges that border this
face, in order. |
|
int * | diag |
This is where the triangulation is stored.
|
|
DWORD | smGroup |
This contains the smoothing groups assigned
to this face. |
|
MtlID | material |
This is the material ID assigned to this
face. |
|
int | track |
BitArray | visedg |
Contains a visibility bit for each edge on
this face. |
|
BitArray | edgsel |
Contains a selection bit for each edge on
this face. |
|
BitArray | bndedg |
Boundary Edges. |
|
Friends |
|
class | MNMesh |
MNFace | ( | int | d | ) | [inline] |
Constructor.
Copies flags, smoothing groups, and material from "from", but initializes the face's arrays to NULL and degree to 0.
DllExport void Init | ( | ) |
Initialize the face.
DllExport void SetDeg | ( | int | d | ) |
Set the number of edges and vertices this face has.
DllExport void Clear | ( | ) |
Frees all arrays, setting them to NULL, and resets degree.
int TriNum | ( | ) | [inline] |
DllExport int FindTriPoint | ( | int | edge | ) |
Given the index of a particular edge, this routine returns the point (distinct from edge and (edge+1)deg) that forms a triangle with the edge, given the current scheme of diagonals.
DllExport int FindTriPoint | ( | int | a, |
int | b | ||
) |
Given two verts that form a diagonal in the polygon, this method finds the vertex between them that connects by a diagonal or an outer edge to both of them.
(Here, "between them" means after a and before b in sequence around the outside of the polygon. If we have an octagon where a=6 and b=2, the result would be 7, 0, or 1. To get the other result, in the 3,4,5 range, call the method with a=2 and b=6.)
DllExport void GetTriangles | ( | Tab< int > & | tri | ) |
This method fills in the table with the full triangulation for the face, based on the internal diagonal list.
The table is set to size (deg-2)*3.
DllExport void SetAlloc | ( | int | d | ) |
Allocates enough memory in the arrays for the face to have degree d, but does not actually set the degree.
If the arrays are already large enough (or larger), it does not reallocate them. You generally don't need to use this method separately; MakePoly, Insert, and other methods which may require additional memory will call this if needed.
DllExport void MakePoly | ( | int | fdeg, |
int * | vv, | ||
bool * | vis = NULL , |
||
bool * | sel = NULL |
||
) |
Makes this face into a polygon with the specified vertices and other information.
This routine also supplies a default triangulation for the face; however, since this MNFace-level routine cannot access the vertex positions contained in the parent MNMesh, this triangulation may not work for non-convex faces. If the face may not be convex, a call to MNMesh::RetriangulateFace for this face will correct the triangulation.
DllExport void Insert | ( | int | pos, |
int | num = 1 |
||
) |
Inserts space for more vertices and edges on this face.
This is used, for example, when two faces are joined, to add room for the vertices & edges of one face to the other. This routine also renumbers the existing vertices and corrects the existing face triangulation, although it cannot provide the triangulation for the new vertices. It reserves space for the new triangles at the end of the triangle array. If you do not want to compute the triangulation for the new vertices yourself, you may use the MNMesh RetriangulateFace method after filling in the new vertices.
DllExport bool Delete | ( | int | pos, |
int | num = 1 , |
||
int | edir = 1 , |
||
bool | fixtri =
TRUE |
||
) |
Deletes vertices & edges from this face.
This routine also corrects the face triangulation, removing those triangles that include the deleted edges and re-indexing the rest. However, delete may cause the triangulation to become invalid, by causing one or more of the corrected triangles to have a flipped normal.
This argument indicates how far Delete should go in fixing the triangulation. Delete will always correct the values of the tri array to correspond to the reduced-degree face. If fixtri is true, it will also delete those triangles that have collapsed because they had two vertices in the deleted region. If not, it will leave these triangles with overlapping vertices, as in (0,0,2).
DllExport void RotateStart | ( | int | newstart | ) |
Re-indexes the vertices and edges so that the vertex in position newstart becomes the new first vertex.
Triangulation is also corrected. Mapping coordinates and vertex colors are corrected automatically.
DllExport void Flip | ( | ) |
Reverses order of verts, effectively inverting the face.
vtx[0] remains unchanged, but vertex deg-1 becomes vertex 1, etc. Note that this operation wreaks havoc on nearby edges and should be used with caution.
DllExport int VertIndex | ( | int | vv, |
int | ee = -1 |
||
) |
Returns the position of vertex vv in this face's list of vertices.
For a given face fc, if fc.vtx[i] = vv, fc.VertIndex (vv) = i. Sometimes a single vertex from the MNMesh's MNVert list can be referenced more than once by a single face. The picture below illustrates this problem. The small triangle is actually outside of the face, and the vertex at the top of it is referenced twice by the face. Thus an additional edge parameter can be accepted. If ee is -1, it is ignored, and the first instance of vv is used. If ee>-1, this method looks for the instance of vv that starts out edge ee. Thus if fc.vtx[i] = vv and fc.vtx[j] = vv, but fc.edg[i] != ee and fc.edg[j] = ee, j is returned. IMPORTANT: If no vertex is found matching the given parameters, this method generates an assertion failure. Please be sure that vertex vv is actually on the face (and that edge ee follows it if ee is not -1) before using this method.
DllExport int EdgeIndex | ( | int | ee, |
int | vv = -1 |
||
) |
Returns the position of edge ee in this face's list of edges.
For a given face fc, if fc.edg[i] = ee, fc.EdgeIndex (ee) = i. Sometimes a single edge from the MNMesh's MNEdge list can be referenced more than once by a single face. The small rectangle is actually outside of the face, and the edge above it is referenced twice by the face, once in each direction. Thus an additional vertex parameter can be accepted. If vv is -1, it is ignored, and the first instance of ee is used. If vv>-1, this method looks for the instance of ee that starts out with vertex vv. Thus if fc.edg[i] = ee and fc.edg[j] = ee, but fc.vtx[i] != vv and fc.vtx[j] = vv, j is returned. IMPORTANT: If no edge is found matching the given parameters, this method generates an assertion failure. Please be sure that edge ee is actually on the face (and that vertex vv follows it if vv is not -1) before using this method.
DllExport void ReplaceVert | ( | int | ov, |
int | nv, | ||
int | ee = -1 |
||
) |
Replaces vertex ov with vertex nv in the list of vertices.
It is possible for a face to reference the same vertex more than once, however the combination of a vertex followed by a specified edge is unique. Therefore if ee<0, all instances of ov are replaced by nv, but if not, only the instance of ov followed by ee is replaced.
DllExport void ReplaceEdge | ( | int | oe, |
int | ne, | ||
int | vv = -1 |
||
) |
Replaces edge oe with edge ne in the list of edges.
It is possible for a face to reference the same edge twice, however the combination of an edge preceded by a specified vertex is unique. Therefore if vv<0, all instances of oe are replaced by ne, but if not, only the instance of oe preceded by vv is replaced.
Assignment operator.
Copies all information from "from", including triangulation, hidden vertices, flags, smoothing & material info, and "track".
DllExport bool operator== | ( | const MNFace & | from | ) |
Comparison operator.
int& operator[] | ( | int | i | ) | [inline] |
Access operator.
{ return vtx[i]; }
const int& operator[] | ( | int | i | ) | const [inline] |
Access operator.
{ return vtx[i]; }
DllExport void MNDebugPrint | ( | bool | triprint = FALSE |
) |
Uses DebugPrint to print out face information to the Debug Results window in DevStudio.
The information consists of the vertices and edges used by this face. It is generally a good idea to put in a DebugPrint immediately before this with the index of the edge, so you know which one is being printed out:
DebugPrint(_M("Face %d: "), fid);
F(fid)->MNDebugPrint();
friend class MNMesh [friend] |
int deg |
This is the degree: the number of vertices and edges that this face has.
int* vtx |
This is the list of vertices that make up the corners of this face.
Each value is an index into the parent MNMesh's list of MNVerts.
int* edg |
This is the list of edges that border this face, in order.
Each edg[i] goes between vtx[i] and vtx[(i+1)deg]. Each value is an index into the parent MNMesh's list of MNEdges. These values may not be valid if the MNMesh's MN_MESH_FILLED_IN flag is not set.
int* diag |
This is where the triangulation is stored.
The number of triangles in a face is given by deg - 2 + hdeg*2. This array contains three times this number, for all the corners of all the sub-triangles. The triangle values are indices into the vtx and hvtx arrays of this face. Hidden vertices are indicated by values less than zero: hvtx[i] is represented by -1-i. Thus a triangle (1, 2, -2) would represent a triangle using vtx[1], vtx[2], and hvtx[-1]. The diag array's allocated size is always (dalloc-3)*2. If dalloc==3 (triangle), this pointer is NULL.
DWORD smGroup |
This contains the smoothing groups assigned to this face.
MtlID material |
This is the material ID assigned to this face.
int track |
Don't use.
Contains a visibility bit for each edge on this face.
See the MNMesh note on edge selection & visibility for more information.
Contains a selection bit for each edge on this face.
See the MNMesh note on edge selection & visibility for more information.
Boundary Edges.