00001 /**************************************************************************** 00002 * VCGLib o o * 00003 * Visual and Computer Graphics Library o o * 00004 * _ O _ * 00005 * Copyright(C) 2004 \/)\/ * 00006 * Visual Computing Lab /\/| * 00007 * ISTI - Italian National Research Council | * 00008 * \ * 00009 * All rights reserved. * 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 * This program is distributed in the hope that it will be useful, * 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00019 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * 00020 * for more details. * 00021 * * 00022 ****************************************************************************/ 00023 /**************************************************************************** 00024 History 00025 00026 $Log: not supported by cvs2svn $ 00027 Revision 1.13 2007/03/12 15:38:03 tarini 00028 Texture coord name change! "TCoord" and "Texture" are BAD. "TexCoord" is GOOD. 00029 00030 Revision 1.12 2005/12/12 11:10:35 ganovelli 00031 modifications to compile with gcc 00032 00033 Revision 1.11 2005/01/12 11:06:54 ganovelli 00034 added InitVertexIMark 00035 00036 Revision 1.10 2004/10/11 17:44:07 ganovelli 00037 added include of color4 00038 00039 Revision 1.9 2004/07/15 00:16:37 cignoni 00040 Better doxigen documentation 00041 00042 Revision 1.8 2004/07/09 10:18:49 ganovelli 00043 added access functions to vn and tn 00044 00045 Revision 1.7 2004/06/25 11:27:21 pietroni 00046 added function to access temporary mark for decimation 00047 00048 Revision 1.6 2004/06/01 17:17:29 ganovelli 00049 pragma once removed , 00050 load ts removed to be put in io_tetramesh 00051 CLear() added 00052 00053 Revision 1.5 2004/05/13 12:16:12 pietroni 00054 first version... add vertex to mesh 00055 00056 Revision 1.4 2004/05/13 07:41:47 turini 00057 Chenged #include <space\\box3.h> in #include <vcg\\space\\box3.h> 00058 00059 Revision 1.3 2004/05/06 10:57:49 pietroni 00060 changed names to topology functions 00061 00062 Revision 1.2 2004/04/28 11:37:14 pietroni 00063 *** empty log message *** 00064 00065 Revision 1.1 2004/04/20 12:41:39 pietroni 00066 *** empty log message *** 00067 00068 Revision 1.1 2004/04/15 08:54:20 pietroni 00069 *** empty log message *** 00070 00071 00072 ***************************************************************************/ 00073 00074 00075 #ifndef __VCG_TETRAMESH 00076 #define __VCG_TETRAMESH 00077 #include <vcg/space/box3.h> 00078 #include <vcg/space/color4.h> 00079 00080 00081 namespace vcg { 00082 namespace tetra { 00085 00093 template < class STL_VERT_CONT ,class STL_TETRA_CONT > 00094 class Tetramesh{ 00095 public: 00096 00097 /***********************************************/ 00100 00102 typedef Tetramesh<STL_VERT_CONT,STL_TETRA_CONT> TetraMeshType; 00103 00105 typedef STL_VERT_CONT VertexContainer; 00106 00108 typedef STL_TETRA_CONT TetraContainer; 00109 00111 typedef typename STL_VERT_CONT::value_type VertexType; 00112 00114 typedef typename STL_TETRA_CONT::value_type TetraType; 00115 00117 typedef typename STL_VERT_CONT::iterator VertexIterator; 00118 00120 typedef typename STL_TETRA_CONT::iterator TetraIterator; 00121 00123 typedef typename STL_VERT_CONT::const_iterator const_VertexIterator; 00124 00126 typedef typename STL_TETRA_CONT::const_iterator const_TetraIterator; 00127 00129 typedef VertexType * VertexPointer; 00130 00132 typedef TetraType * TetraPointer; 00133 00135 typedef const VertexType * const_VertexPointer; 00136 00138 typedef const VertexType * const_TetraPointer; 00139 00140 typedef typename VertexType::ScalarType ScalarType; 00142 00143 /***********************************************/ 00146 00148 int IMark; 00149 00151 STL_VERT_CONT vert; 00152 00154 int vn; 00155 00157 STL_TETRA_CONT tetra; 00158 00160 int tn; 00161 00163 int en; 00164 00166 Box3<ScalarType> bbox; 00168 00169 /***********************************************/ 00172 00174 Tetramesh() 00175 { 00176 tn = vn = en = 0; 00177 } 00178 00179 Tetramesh(VertexContainer v,TetraContainer t) 00180 { 00181 this->vert=v; 00182 this->tetra=t; 00183 vn=v.size(); 00184 tn=t.size(); 00185 } 00186 00187 inline int MemUsed() const 00188 { 00189 return sizeof(Tetramesh)+sizeof(VertexType)*vert.size()+sizeof(TetraType)*tetra.size(); 00190 } 00191 00192 void Clear(){ 00193 vert.clear(); 00194 tetra.clear(); 00195 tn = 0; 00196 vn = 0; 00197 } 00198 00200 void InitVertexIMark() 00201 { 00202 VertexIterator vi; 00203 00204 for(vi=vert.begin();vi!=vert.end();++vi) 00205 if( !(*vi).IsD() && (*vi).IsRW() ) 00206 (*vi).InitIMark(); 00207 } 00209 00210 /***********************************************/ 00213 00214 static bool HasPerVertexNormal() { return VertexType::HasNormal() ; } 00215 static bool HasPerVertexColor() { return VertexType::HasColor() ; } 00216 static bool HasPerVertexMark() { return VertexType::HasMark() ; } 00217 static bool HasPerVertexQuality() { return VertexType::HasQuality(); } 00218 static bool HasPerVertexTexCoord(){ return VertexType::HasTexCoord(); } 00219 00220 static bool HasPerTetraNormal() { return TetraType::HasTetraNormal() ; } 00221 static bool HasPerTetraMark() { return TetraType::HasTetraMark() ; } 00222 static bool HasPerTetraQuality() { return TetraType::HasTetraQuality(); } 00223 00224 static bool HasTTTopology() { return TetraType::HasTTAdjacency(); } 00225 static bool HasVTTopology() { return TetraType::HasVTAdjacency(); } 00226 static bool HasTopology() { return HasTTTopology() || HasVTTopology(); } 00227 00228 int & SimplexNumber(){ return tn;} 00229 int & VertexNumber(){ return vn;} 00230 /***********************************************/ 00231 00234 00236 void UnMarkAll() 00237 { 00238 ++IMark; 00239 } 00240 00242 void Mark(VertexType *v) 00243 { 00244 v->IMark()=IMark; 00245 } 00246 00248 int GetMark() 00249 { 00250 return (IMark); 00251 } 00252 00254 void InitIMark() 00255 { 00256 VertexIterator vi; 00257 IMark=0; 00258 for(vi=vert.begin();vi!=vert.end();vi++) 00259 { 00260 (*vi).InitIMark(); 00261 } 00262 } 00263 00265 };//End class 00266 00270 };//end namespace 00271 };//end namespace 00272 #endif 00273