00001 /* 00002 File: MeshJoin.h 00003 00004 Function: Connect up adjacent triangles in a shared-vertex mesh. 00005 Sets the 'nbFace' and 'nbEdge' fields correctly for 00006 groups of triangles belonging to the same surface. 00007 00008 This representation consists of 00009 + faces with a fixed number of edges 00010 + neighbour edge pointers 00011 for each edge of the face, you can find the corresponding 00012 edge of the neighbouring face. 00013 00014 This is not as general as a full winged-edge structure, but 00015 more space efficient in a mesh that will only have triangles 00016 (or quads in our case). Drawbacks: 00017 + can't handle input meshes with t-intersections 00018 + can't get from vertex to neighbouring faces 00019 can solve by keeping 1:1 vertex->face list 00020 00021 Notes: Requires triangles to share a single vertex array 00022 00023 Calling conventions: 00024 Call Init() with the number of vertices in the model 00025 Call StartGroup() for each surface group 00026 Call AddTriangle for all faces in that group 00027 Call EndGroup() when done. 00028 Repeat the last 3 calls as necessary, then call Finished(). 00029 00030 Author: Andrew Willmott, 1997 00031 */ 00032 00033 #ifndef __MeshJoin__ 00034 #define __MeshJoin__ 00035 00036 /* 00037 Data structures are face-orientated: each triangle 00038 contains three neighbour fields, which point to 00039 the neighbouring triangle along each edge, as well 00040 as an edgeIndex, which tells us which edge of the 00041 neighbour triangle abuts ours. 00042 00043 One of these (face, edgeIndex) pairs defines 00044 an edge. As in, edge 'edgeIndex' of face 'face'. 00045 */ 00046 00047 // For HierElems ... 00048 00049 #include "RadMesh.h" 00050 00051 typedef IndexList EdgeList; 00052 typedef Byte Edge; 00053 typedef NbRadElem Face; 00054 typedef Face *FacePtr; 00055 00056 // the rest of the code is more general, though EdgesMatch() will 00057 // require customisation. 00058 00059 class MeshJoin 00060 { 00061 public: 00062 Void Init(Int numVertices); 00063 Void StartGroup(); 00064 Void AddTriangle(Face *addFace); 00065 Void EndGroup(); 00066 Int Finished(); 00067 00068 protected: 00069 Bool EdgesMatch( 00070 FacePtr face1, 00071 Edge edge1, 00072 FacePtr face2, 00073 Edge edge2 00074 ); 00075 Void SetFaceChainVertices(Face *f, Int edge, Int i); 00076 00077 FacePtr *vertexFaces; 00078 Edge *vertexEdges; 00079 Int numVertices; 00080 Int surfaceVertices; 00081 00082 // together these define the start of a linked list of edges 00083 // for each vertex. 00084 }; 00085 00086 #endif 00087