1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273
|
/****************************************************************************
* VCGLib o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004 \/)\/ *
* Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | *
* \ *
* All rights reserved. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
* for more details. *
* *
****************************************************************************/
/****************************************************************************
History
$Log: not supported by cvs2svn $
Revision 1.13 2007/03/12 15:38:03 tarini
Texture coord name change! "TCoord" and "Texture" are BAD. "TexCoord" is GOOD.
Revision 1.12 2005/12/12 11:10:35 ganovelli
modifications to compile with gcc
Revision 1.11 2005/01/12 11:06:54 ganovelli
added InitVertexIMark
Revision 1.10 2004/10/11 17:44:07 ganovelli
added include of color4
Revision 1.9 2004/07/15 00:16:37 cignoni
Better doxigen documentation
Revision 1.8 2004/07/09 10:18:49 ganovelli
added access functions to vn and tn
Revision 1.7 2004/06/25 11:27:21 pietroni
added function to access temporary mark for decimation
Revision 1.6 2004/06/01 17:17:29 ganovelli
pragma once removed ,
load ts removed to be put in io_tetramesh
CLear() added
Revision 1.5 2004/05/13 12:16:12 pietroni
first version... add vertex to mesh
Revision 1.4 2004/05/13 07:41:47 turini
Chenged #include <space\\box3.h> in #include <vcg\\space\\box3.h>
Revision 1.3 2004/05/06 10:57:49 pietroni
changed names to topology functions
Revision 1.2 2004/04/28 11:37:14 pietroni
*** empty log message ***
Revision 1.1 2004/04/20 12:41:39 pietroni
*** empty log message ***
Revision 1.1 2004/04/15 08:54:20 pietroni
*** empty log message ***
***************************************************************************/
#ifndef __VCG_TETRAMESH
#define __VCG_TETRAMESH
#include <vcg/space/box3.h>
#include <vcg/space/color4.h>
namespace vcg {
namespace tetra {
/** \addtogroup tetramesh */
/*@{*/
/** Class TetraMesh.
This is class for definition of a mesh.
@param STL_VERT_CONT (Template Parameter) Specifies the type of the vertices container any the vertex type.
@param STL_FACE_CONT (Template Parameter) Specifies the type of the faces container any the face type.
*/
template < class STL_VERT_CONT ,class STL_TETRA_CONT >
class Tetramesh{
public:
/***********************************************/
/** @name Tetramesh Type Definitions **/
//@{
/// The mesh type
typedef Tetramesh<STL_VERT_CONT,STL_TETRA_CONT> TetraMeshType;
/// The vertex container
typedef STL_VERT_CONT VertexContainer;
/// The tethaedhron container
typedef STL_TETRA_CONT TetraContainer;
/// The vertex type
typedef typename STL_VERT_CONT::value_type VertexType;
/// The tetrahedron type
typedef typename STL_TETRA_CONT::value_type TetraType;
/// The type of vertex iterator
typedef typename STL_VERT_CONT::iterator VertexIterator;
/// The type of tetra iterator
typedef typename STL_TETRA_CONT::iterator TetraIterator;
/// The type of constant vertex iterator
typedef typename STL_VERT_CONT::const_iterator const_VertexIterator;
/// The type of constant face iterator
typedef typename STL_TETRA_CONT::const_iterator const_TetraIterator;
/// The vertex pointer type
typedef VertexType * VertexPointer;
/// The tetra pointer type
typedef TetraType * TetraPointer;
/// The type of the constant vertex pointer
typedef const VertexType * const_VertexPointer;
/// The type of the constant tetrahedron pointer
typedef const VertexType * const_TetraPointer;
typedef typename VertexType::ScalarType ScalarType;
//@}
/***********************************************/
/** @Common Attributes of a tetrahedral mesh **/
//@{
///temporary mark for decimation
int IMark;
/// Set of vertices
STL_VERT_CONT vert;
/// Real number of vertices
int vn;
/// Set of tetrahedron
STL_TETRA_CONT tetra;
/// Real number of tetrahedron
int tn;
/// Real number of edges
int en;
///Boundingbox della mesh
Box3<ScalarType> bbox;
//@}
/***********************************************/
/** @Default Functions **/
//@{
/// Default constructor
Tetramesh()
{
tn = vn = en = 0;
}
Tetramesh(VertexContainer v,TetraContainer t)
{
this->vert=v;
this->tetra=t;
vn=v.size();
tn=t.size();
}
inline int MemUsed() const
{
return sizeof(Tetramesh)+sizeof(VertexType)*vert.size()+sizeof(TetraType)*tetra.size();
}
void Clear(){
vert.clear();
tetra.clear();
tn = 0;
vn = 0;
}
/// Initialize the imark-system of the vertices
void InitVertexIMark()
{
VertexIterator vi;
for(vi=vert.begin();vi!=vert.end();++vi)
if( !(*vi).IsD() && (*vi).IsRW() )
(*vi).InitIMark();
}
//@}
/***********************************************/
/** @Functions used to retrieve informations**/
//@{
/// Reflection functions that speak about vertex and face properties.
static bool HasPerVertexNormal() { return VertexType::HasNormal() ; }
static bool HasPerVertexColor() { return VertexType::HasColor() ; }
static bool HasPerVertexMark() { return VertexType::HasMark() ; }
static bool HasPerVertexQuality() { return VertexType::HasQuality(); }
static bool HasPerVertexTexCoord(){ return VertexType::HasTexCoord(); }
static bool HasPerTetraNormal() { return TetraType::HasTetraNormal() ; }
static bool HasPerTetraMark() { return TetraType::HasTetraMark() ; }
static bool HasPerTetraQuality() { return TetraType::HasTetraQuality(); }
static bool HasTTTopology() { return TetraType::HasTTAdjacency(); }
static bool HasVTTopology() { return TetraType::HasVTAdjacency(); }
static bool HasTopology() { return HasTTTopology() || HasVTTopology(); }
int & SimplexNumber(){ return tn;}
int & VertexNumber(){ return vn;}
/***********************************************/
/** @Functions used for handle the temporany mark of a tetrahedron used in decimation**/
//@{
///Increase the current mark.
void UnMarkAll()
{
++IMark;
}
///Mark the vertex with current value
void Mark(VertexType *v)
{
v->IMark()=IMark;
}
///return the current mark
int GetMark()
{
return (IMark);
}
///Initialize the mark of all vertices
void InitIMark()
{
VertexIterator vi;
IMark=0;
for(vi=vert.begin();vi!=vert.end();vi++)
{
(*vi).InitIMark();
}
}
//@}
};//End class
/*@}*/
};//end namespace
};//end namespace
#endif
|