00001 // Wild Magic Source Code 00002 // David Eberly 00003 // http://www.geometrictools.com 00004 // Copyright (c) 1998-2007 00005 // 00006 // This library is free software; you can redistribute it and/or modify it 00007 // under the terms of the GNU Lesser General Public License as published by 00008 // the Free Software Foundation; either version 2.1 of the License, or (at 00009 // your option) any later version. The license is available for reading at 00010 // either of the locations: 00011 // http://www.gnu.org/copyleft/lgpl.html 00012 // http://www.geometrictools.com/License/WildMagicLicense.pdf 00013 // The license applies to versions 0 through 4 of Wild Magic. 00014 // 00015 // Version: 4.0.0 (2006/06/28) 00016 00017 #ifndef WM4DELAUNAY_H 00018 #define WM4DELAUNAY_H 00019 00020 // The base class for Delaunay algorithms stores the number of mesh components 00021 // and the connectivity information for the mesh. 00022 00023 #include "Wm4FoundationLIB.h" 00024 #include "Wm4System.h" 00025 #include "Wm4Query.h" 00026 00027 namespace Wm4 00028 { 00029 00030 template <class Real> 00031 class WM4_FOUNDATION_ITEM Delaunay 00032 { 00033 public: 00034 // Abstract base class. 00035 virtual ~Delaunay (); 00036 00037 // Member accessors. For notational purposes in this class documentation, 00038 // The number of vertices is VQ and the vertex array is V. 00039 int GetQueryType () const; 00040 int GetVertexQuantity () const; 00041 Real GetEpsilon () const; 00042 bool GetOwner () const; 00043 00044 // The dimension of the result, call it d. If n is the dimension of the 00045 // space of the input points, then 0 <= d <= n. 00046 int GetDimension () const; 00047 00048 // The interpretations of the return values of these functions depends on 00049 // the dimension. Generally, SQ = GetSimplexQuantity() is the number of 00050 // simplices in the mesh. The array returned by I = GetIndices() contains 00051 // SQ tuples, each tuple having d+1 elements and representing a simplex. 00052 // An index I[*] is relative to the vertex array V. The array returned by 00053 // A = GetAdjacencies() contains SQ tuples, each tuple having d+1 elements 00054 // and representing those simplices adjacent to the d+1 faces of a 00055 // simplex. An index A[*] is relative to the index array I. 00056 int GetSimplexQuantity () const; 00057 const int* GetIndices () const; 00058 const int* GetAdjacencies () const; 00059 00060 // Dimension d = 0. 00061 // SQ = 1 00062 // I = null (use index zero for vertices) 00063 // A = null (use index zero for vertices) 00064 00065 // Dimension d = 1. 00066 // SQ = VQ-1 00067 // I = Array of 2-tuples of indices into V that represent the 00068 // segments (2*SQ total elements). 00069 // A = Array of 2-tuples of indices into I that represent the 00070 // adjacent segments (2*SQ total elements). 00071 // The i-th segment has vertices 00072 // vertex[0] = V[I[2*i+0]] 00073 // vertex[1] = V[I[2*i+1]]. 00074 // The segments adjacent to these vertices have indices 00075 // adjacent[0] = A[2*i+0] is the segment sharing vertex[0] 00076 // adjacent[1] = A[2*i+1] is the segment sharing vertex[1] 00077 // If there is no adjacent segment, the A[*] value is set to -1. The 00078 // segment adjacent to vertex[j] has vertices 00079 // adjvertex[0] = V[I[2*adjacent[j]+0]] 00080 // adjvertex[1] = V[I[2*adjacent[j]+1]] 00081 00082 // Dimension d = 2. 00083 // SQ = number of triangles 00084 // I = Array of 3-tuples of indices into V that represent the 00085 // triangles (3*SQ total elements). 00086 // A = Array of 3-tuples of indices into I that represent the 00087 // adjacent triangles (3*SQ total elements). 00088 // The i-th triangle has vertices 00089 // vertex[0] = V[I[3*i+0]] 00090 // vertex[1] = V[I[3*i+1]] 00091 // vertex[2] = V[I[3*i+2]] 00092 // and edge index pairs 00093 // edge[0] = <I[3*i+0],I[3*i+1]> 00094 // edge[1] = <I[3*i+1],I[3*i+2]> 00095 // edge[2] = <I[3*i+2],I[3*i+0]> 00096 // The triangles adjacent to these edges have indices 00097 // adjacent[0] = A[3*i+0] is the triangle sharing edge[0] 00098 // adjacent[1] = A[3*i+1] is the triangle sharing edge[1] 00099 // adjacent[2] = A[3*i+2] is the triangle sharing edge[2] 00100 // If there is no adjacent triangle, the A[*] value is set to -1. The 00101 // triangle adjacent to edge[j] has vertices 00102 // adjvertex[0] = V[I[3*adjacent[j]+0]] 00103 // adjvertex[1] = V[I[3*adjacent[j]+1]] 00104 // adjvertex[2] = V[I[3*adjacent[j]+2]] 00105 00106 // Dimension d = 3. 00107 // SQ = number of tetrahedra 00108 // I = Array of 4-tuples of indices into V that represent the 00109 // tetrahedra (4*SQ total elements). 00110 // A = Array of 4-tuples of indices into I that represent the 00111 // adjacent tetrahedra (4*SQ total elements). 00112 // The i-th tetrahedron has vertices 00113 // vertex[0] = V[I[4*i+0]] 00114 // vertex[1] = V[I[4*i+1]] 00115 // vertex[2] = V[I[4*i+2]] 00116 // vertex[3] = V[I[4*i+3]] 00117 // and face index triples listed below. The face vertex ordering when 00118 // viewed from outside the tetrahedron is counterclockwise. 00119 // face[0] = <I[4*i+1],I[4*i+2],I[4*i+3]> 00120 // face[1] = <I[4*i+0],I[4*i+3],I[4*i+2]> 00121 // face[2] = <I[4*i+0],I[4*i+1],I[4*i+3]> 00122 // face[3] = <I[4*i+0],I[4*i+2],I[4*i+1]> 00123 // The tetrahedra adjacent to these faces have indices 00124 // adjacent[0] = A[4*i+0] is the tetrahedron opposite vertex[0], so it 00125 // is the tetrahedron sharing face[0]. 00126 // adjacent[1] = A[4*i+1] is the tetrahedron opposite vertex[1], so it 00127 // is the tetrahedron sharing face[1]. 00128 // adjacent[2] = A[4*i+2] is the tetrahedron opposite vertex[2], so it 00129 // is the tetrahedron sharing face[2]. 00130 // adjacent[3] = A[4*i+3] is the tetrahedron opposite vertex[3], so it 00131 // is the tetrahedron sharing face[3]. 00132 // If there is no adjacent tetrahedron, the A[*] value is set to -1. The 00133 // tetrahedron adjacent to face[j] has vertices 00134 // adjvertex[0] = V[I[4*adjacent[j]+0]] 00135 // adjvertex[1] = V[I[4*adjacent[j]+1]] 00136 // adjvertex[2] = V[I[4*adjacent[j]+2]] 00137 // adjvertex[3] = V[I[4*adjacent[j]+3]] 00138 00139 protected: 00140 // Abstract base class. The number of vertices to be processed is 00141 // iVQuantity. The value of fEpsilon is a tolerance used for determining 00142 // the intrinsic dimension of the input set of vertices. Ownership of the 00143 // input points to the constructors for the derived classes may be 00144 // transferred to this class. If you want the input vertices to be 00145 // deleted by this class, set bOwner to 'true'; otherwise, you own the 00146 // array and must delete it yourself. 00147 Delaunay (int iVertexQuantity, Real fEpsilon, bool bOwner, 00148 Query::Type eQueryType); 00149 00150 // Support for streaming to/from disk. 00151 bool Load (FILE* pkIFile); 00152 bool Save (FILE* pkOFile) const; 00153 00154 Query::Type m_eQueryType; 00155 int m_iVertexQuantity; 00156 int m_iDimension; 00157 int m_iSimplexQuantity; 00158 int* m_aiIndex; 00159 int* m_aiAdjacent; 00160 Real m_fEpsilon; 00161 bool m_bOwner; 00162 }; 00163 00164 typedef Delaunay<float> Delaunayf; 00165 typedef Delaunay<double> Delaunayd; 00166 00167 } 00168 00169 #endif