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 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510
|
/****************************************************************************
* VCGLib o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004-2016 \/)\/ *
* 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.1 2007/05/09 10:31:53 ganovelli
added
****************************************************************************/
#ifndef __VCG_TETRAHEDRON_PLUS_COMPONENT
#define __VCG_TETRAHEDRON_PLUS_COMPONENT
#include <vector>
#include <vcg/space/tetra3.h>
namespace vcg {
namespace tetrahedron {
/*
Some naming Rules
All the Components that can be added to a tetra should be defined in the namespace tetra:
*/
template <class T> class EmptyCore : public T {
public:
//Empty vertexref
inline typename T::VertexType * & V( const int ) { assert(0); static typename T::VertexType *vp=0; return vp; }
inline typename T::VertexType * const & V( const int ) const { assert(0); static typename T::VertexType *vp=0; return vp; }
inline const typename T::VertexType * cV( const int ) { assert(0); static typename T::VertexType *vp=0; return vp; }
inline typename T::CoordType & P( const int ) { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
inline const typename T::CoordType & P( const int ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
inline const typename T::CoordType &cP( const int ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
static bool HasVertexRef() { return false; }
static bool HasTVAdjacency() { return false; }
// //Empty normals
// typedef typename T::VertexType::NormalType NormalType;
// NormalType &N(const int & ){ static NormalType dummynormal(0, 0, 0); assert(0); return dummynormal; }
// const NormalType cN(const int & ) const { static NormalType dummynormal(0, 0, 0); assert(0); return dummynormal; }
// static bool HasFaceNormal() { return false; }
// static bool HasFaceNormalOcc() { return false; }
//Empty color
typedef vcg::Color4b ColorType;
ColorType &C() { static ColorType dummycolor(vcg::Color4b::White); assert(0); return dummycolor; }
ColorType cC() const { static ColorType dummycolor(vcg::Color4b::White); assert(0); return dummycolor; }
static bool HasColor() { return false; }
static bool IsColorEnabled() { return T::TetraType::HasColor(); }
//Empty Quality
typedef float QualityType;
typedef vcg::Point3f Quality3Type;
QualityType &Q() { static QualityType dummyquality(0); assert(0); return dummyquality; }
QualityType cQ() const { static QualityType dummyquality(0); assert(0); return dummyquality; }
Quality3Type &Q3() { static Quality3Type dummyQuality3(0,0,0); assert(0); return dummyQuality3; }
Quality3Type cQ3() const { static Quality3Type dummyQuality3(0,0,0); assert(0); return dummyQuality3; }
static bool HasQuality() { return false; }
static bool HasQuality3() { return false; }
inline bool IsQualityEnabled() const { return T::TetraType::HasQuality(); }
inline bool IsQuality3Enabled() const { return T::TetraType::HasQuality3(); }
//Empty flags
int &Flags() { static int dummyflags(0); assert(0); return dummyflags; }
int cFlags() const { return 0; }
static bool HasFlags() { return false; }
static bool HasFlagsOcc() { return false; }
//Empty IMark
typedef int MarkType;
inline void InitIMark() { }
inline int & IMark() { assert(0); static int tmp=-1; return tmp;}
inline int cIMark() const {return 0;}
inline bool IsMarkEnabled() const { return T::TetraType::HasMark(); }
static bool HasMark() { return false; }
static bool HasMarkOcc() { return false; }
//Empty Adjacency
typedef int VTAdjType;
typename T::TetraPointer & VTp ( const int ) { static typename T::TetraPointer tp=0; assert(0); return tp; }
typename T::TetraPointer const cVTp( const int ) const { static typename T::TetraPointer const tp=0; assert(0); return tp; }
typename T::TetraPointer & TTp ( const int ) { static typename T::TetraPointer tp=0; assert(0); return tp; }
typename T::TetraPointer const cTTp( const int ) const { static typename T::TetraPointer const tp=0; assert(0); return tp; }
char & VTi( const int ) { static char z=0; assert(0); return z; }
char cVTi( const int ) const { static char z=0; assert(0); return z; }
char & TTi( const int ) { static char z=0; assert(0); return z; }
char cTTi( const int ) const { static char z=0; assert(0); return z; }
bool IsVTInitialized(const int j) const {return static_cast<const typename T::TetraType *>(this)->cVTi(j)!=-1;}
void VTClear(int j) {
if(IsVTInitialized(j)) {
static_cast<typename T::TetraPointer>(this)->VTp(j)=0;
static_cast<typename T::TetraPointer>(this)->VTi(j)=-1;
}
}
static bool HasVTAdjacency() { return false; }
static bool HasTTAdjacency() { return false; }
static bool HasTTAdjacencyOcc() { return false; }
static bool HasVTAdjacencyOcc() { return false; }
template <class RightValuteType>
void ImportData(const RightValuteType & ) {}
static void Name(std::vector<std::string> & name) { T::Name(name); }
};
/*-------------------------- VERTEX ----------------------------------------*/
// template <class T> class EmptyVertexRef: public T {
// public:
// // typedef typename T::VertexType VertexType;
// // typedef typename T::CoordType CoordType;
// inline typename T::VertexType * & V( const int j ) { assert(0); static typename T::VertexType *vp=0; return vp; }
// inline typename T::VertexType * const & V( const int j ) const { assert(0); static typename T::VertexType *vp=0; return vp; }
// inline typename T::VertexType * const cV( const int j ) const { assert(0); static typename T::VertexType *vp=0; return vp; }
// inline typename T::CoordType & P( const int j ) { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
// inline const typename T::CoordType & P( const int j ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
// inline const typename T::CoordType &cP( const int j ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
// static bool HasVertexRef() { return false; }
// };
template <class T> class VertexRef: public T {
public:
VertexRef(){
v[0]=0;
v[1]=0;
v[2]=0;
v[3]=0;
/******* vertex and faces indices scheme*********
*
* /2\`
* / \ `
* / \ `
* / \ _ 3`
* / _ \ '
* / _ \ '
* /0___________1\'
*
*/
findices[0][0] = 0; findices[0][1] = 1; findices[0][2] = 2;
findices[1][0] = 0; findices[1][1] = 3; findices[1][2] = 1;
findices[2][0] = 0; findices[2][1] = 2; findices[2][2] = 3;
findices[3][0] = 1; findices[3][1] = 3; findices[3][2] = 2;
}
typedef typename T::VertexType::CoordType CoordType;
typedef typename T::VertexType::ScalarType ScalarType;
inline typename T::VertexType * & V( const int j ) { assert(j>=0 && j<4); return v[j]; }
inline const typename T::VertexType * cV( const int j ) { assert(j>=0 && j<4); return v[j]; }
inline size_t cFtoVi (const int f, const int j) const { assert(f >= 0 && f < 4); assert(j >= 0 && j < 3); return findices[f][j]; }
// Shortcut for tetra points
inline CoordType & P( const int j ) { assert(j>=0 && j<4); return v[j]->P(); }
inline const CoordType &cP( const int j ) const { assert(j>=0 && j<4); return v[j]->P(); }
/** Return the pointer to the ((j+1)%4)-th vertex of the tetra.
@param j Index of the face vertex.
*/
inline typename T::VertexType * & V0( const int j ) { return V(j);}
inline typename T::VertexType * & V1( const int j ) { return V((j+1)%4);}
inline typename T::VertexType * & V2( const int j ) { return V((j+2)%4);}
inline typename T::VertexType * & V3( const int j ) { return V((j+3)%4);}
inline const typename T::VertexType * const & V0( const int j ) const { return V(j);}
inline const typename T::VertexType * const & V1( const int j ) const { return V((j+1)%4);}
inline const typename T::VertexType * const & V2( const int j ) const { return V((j+2)%4);}
inline const typename T::VertexType * const & V3( const int j ) const { return V((j+3)%4);}
inline const typename T::VertexType * const & cV0( const int j ) const { return cV(j);}
inline const typename T::VertexType * const & cV1( const int j ) const { return cV((j+1)%4);}
inline const typename T::VertexType * const & cV2( const int j ) const { return cV((j+2)%4);}
inline const typename T::VertexType * const & cV3( const int j ) const { return cV((j+3)%4);}
/// Shortcut to get vertex values
inline CoordType &P0 (const int j) { return V(j)->P(); }
inline CoordType &P2 (const int j) { return V((j + 2) % 4)->P(); }
inline CoordType &P3 (const int j) { return V((j + 3) % 4)->P(); }
inline CoordType &P1 (const int j) { return V((j + 1) % 4)->P(); }
inline const CoordType &P0 (const int j) const { return V(j)->P(); }
inline const CoordType &P1 (const int j) const { return V((j + 1) % 4)->P(); }
inline const CoordType &P2 (const int j) const { return V((j + 2) % 4)->P(); }
inline const CoordType &P3 (const int j) const { return V((j + 3) % 4)->P(); }
inline const CoordType &cP0(const int j) const { return cV(j)->P(); }
inline const CoordType &cP1(const int j) const { return cV((j + 1) % 4)->P(); }
inline const CoordType &cP2(const int j) const { return cV((j + 2) % 4)->P(); }
inline const CoordType &cP3(const int j) const { return cV((j + 3) % 4)->P(); }
static bool HasVertexRef() { return true; }
static bool HasTVAdjacency() { return true; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("VertexRef"));T::Name(name);}
template <class RightValueType>
void ImportData(const RightValueType & rTetra) { T::ImportData(rTetra); }
private:
typename T::VertexType *v[4];
size_t findices[4][3];
};
/*------------------------- FACE NORMAL -----------------------------------------*/
// template <class A, class T> class EmptyFaceNormal: public T {
// public:
// typedef ::vcg::Point3<A> NormalType;
// /// Return the vector of Flags(), senza effettuare controlli sui bit
// NormalType N(const int & ){ static int dummynormal(0); return dummynormal; }
// const NormalType cN(const int & ) const { return 0; }
// static bool HasFaceNormal() { return false; }
// static bool HasFaceNormalOcc() { return false; }
// static void Name(std::vector<std::string> & name){T::Name(name);}
// };
// template <class A, class T> class FaceNormal: public T {
// public:
// typedef A NormalType;
// inline NormalType N(const int & i){ assert((i>=0)&&(i < 4)); return _facenormals[i]; }
// inline NormalType cN(const int & i) const { assert((i>=0)&&(i < 4)); return _facenormals[i]; }
// static bool HasFaceNormals() { return true; }
// static bool HasFaceNormalOcc() { return false; }
// template <class RightValueType>
// void ImportData(const RightValueType & rightT)
// {
// if(rightT.IsNormalEnabled()) N().Import(rightT.cN());
// T::ImportData(rightT);
// }
// static void Name(std::vector<std::string> & name){name.push_back(std::string("FaceNormal"));T::Name(name);}
// private:
// NormalType _facenormals[4];
// };
//template <class T> class FaceNormal3f: public FaceNormal<vcg::Point3f, T>{
//public:static void Name(std::vector<std::string> & name){name.push_back(std::string("FaceNormal3f"));T::Name(name);} };
//template <class T> class FaceNormal3d: public FaceNormal<vcg::Point3d, T>{
//public:static void Name(std::vector<std::string> & name){name.push_back(std::string("FaceNormal3d"));T::Name(name);} };
/*------------------------- FLAGS -----------------------------------------*/
// template <class T> class EmptyBitFlags: public T {
// public:
// /// Return the vector of Flags(), senza effettuare controlli sui bit
// int &Flags() { static int dummyflags(0); return dummyflags; }
// const int Flags() const { return 0; }
// static bool HasFlags() { return false; }
// static bool HasFlagsOcc() { return false; }
// static void Name(std::vector<std::string> & name){T::Name(name);}
// };
template <class T> class BitFlags: public T {
public:
typedef int FlagType;
BitFlags(){_flags=0;}
inline int &Flags() {return _flags; }
inline int cFlags() const {return _flags; }
template <class RightValueType>
void ImportData(const RightValueType & rightT){
if(RightValueType::HasFlags())
Flags() = rightT.cFlags();
T::ImportData(rightT);
}
static bool HasFlags() { return true; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("BitFlags"));T::Name(name);}
private:
int _flags;
};
/*-------------------------- QUALITY ----------------------------------------*/
template <class A, class T> class Quality: public T {
public:
typedef A QualityType;
Quality():_quality(0) {}
QualityType &Q() { return _quality; }
QualityType cQ() const { return _quality; }
template <class RightValueType>
void ImportData(const RightValueType & rightT){
if(rightT.IsQualityEnabled())
Q() = rightT.cQ();
T::ImportData(rightT);
}
static bool HasQuality() { return true; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality"));T::Name(name);}
private:
QualityType _quality;
};
template <class T> class Qualityf: public Quality<float, T> {
public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Qualityf"));T::Name(name);}
};
template <class T> class Qualityd: public Quality<double, T> {
public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Qualityd"));T::Name(name);}
};
/*-------------------------- Quality3 ----------------------------------*/
template <class A, class T> class Quality3: public T {
public:
typedef vcg::Point3<A> Quality3Type;
Quality3Type &Q3() { return _quality; }
Quality3Type cQ3() const { return _quality; }
template <class RightValueType>
void ImportData(const RightValueType & rightT){
if(rightT.IsQuality3Enabled()) Q3() = rightT.cQ3();
T::ImportData(rightT);
}
static bool HasQuality3() { return true; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality3"));T::Name(name);}
private:
Quality3Type _quality;
};
template <class T> class Quality3f: public Quality3<float, T> {
public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality3f"));T::Name(name);}
};
template <class T> class Quality3d: public Quality3<double, T> {
public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality3d"));T::Name(name);}
};
/*-------------------------- COLOR ----------------------------------------*/
template <class A, class T>
class Color: public T {
public:
typedef A ColorType;
Color():_color(vcg::Color4b::White) {}
ColorType &C() { return _color; }
ColorType cC() const { return _color; }
template <class RightValueType>
void ImportData(const RightValueType & rightT){
if(rightT.IsColorEnabled()) C() = rightT.cC();
T::ImportData(rightT);
}
static bool HasColor() { return true; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("Color"));T::Name(name);}
private:
ColorType _color;
};
template <class T> class Color4b : public Color<vcg::Color4b, T> {
public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Color4b"));T::Name(name); }
};
/*-------------------------- INCREMENTAL MARK ----------------------------------------*/
// template <class T> class EmptyMark: public T {
// public:
// typedef int MarkType;
// static bool HasMark() { return false; }
// static bool HasMarkOcc() { return false; }
// inline void InitIMark() { }
// inline int & IMark() { assert(0); static int tmp=-1; return tmp;}
// inline const int IMark() const {return 0;}
// static void Name(std::vector<std::string> & name){T::Name(name);}
// };
template <class T> class Mark: public T {
public:
static bool HasMark() { return true; }
static bool HasMarkOcc() { return false; }
inline void InitIMark() { _imark = 0; }
inline int & IMark() { return _imark;}
inline int cIMark() const {return _imark;}
template <class RightValueType>
void ImportData(const RightValueType & rightT){
if(rightT.IsMarkEnabled()) IMark() = rightT.cIMark();
T::ImportData(rightT);
}
static void Name(std::vector<std::string> & name){name.push_back(std::string("Mark"));T::Name(name);}
private:
int _imark;
};
/*----------------------------- VTADJ ------------------------------*/
// template <class T> class EmptyAdj: public T {
// public:
// typedef int VFAdjType;
// typename T::TetraPointer & VTp( const int ) { static typename T::TetraPointer tp=0; return tp; }
// typename T::TetraPointer const cVTp( const int ) const { static typename T::TetraPointer const tp=0; return tp; }
// typename T::TetraPointer & TTp( const int ) { static typename T::TetraPointer tp=0; return tp; }
// typename T::TetraPointer const cTTp( const int ) const { static typename T::TetraPointer const tp=0; return tp; }
// char & VTi( const int j ) { static char z=0; return z; }
// char & TTi( const int j ) { static char z=0; return z; }
// static bool HasVTAdjacency() { return false; }
// static bool HasTTAdjacency() { return false; }
// static bool HasTTAdjacencyOcc() { return false; }
// static bool HasVTAdjacencyOcc() { return false; }
// static void Name( std::vector< std::string > & name ){ T::Name(name); }
// };
template <class T> class VTAdj: public T {
public:
VTAdj() {
_vtp[0]=0;
_vtp[1]=0;
_vtp[2]=0;
_vtp[3]=0;
_vti[0]=-1;
_vti[1]=-1;
_vti[2]=-1;
_vti[3]=-1;
}
typename T::TetraPointer & VTp( const int j ) { assert( j >= 0 && j < 4 ); return _vtp[j]; }
typename T::TetraPointer const VTp( const int j ) const { assert( j >= 0 && j < 4 ); return _vtp[j]; }
typename T::TetraPointer const cVTp( const int j ) const { assert( j >= 0 && j < 4 ); return _vtp[j]; }
char & VTi( const int j ) { return _vti[j]; }
const char & cVTi( const int j ) const { return _vti[j]; }
static bool HasVTAdjacency() { return true; }
static bool HasVTAdjacencyOcc() { return false; }
static void Name( std::vector< std::string > & name ) { name.push_back( std::string("VTAdj") ); T::Name(name); }
template <class RightValueType>
void ImportData(const RightValueType & rightT){T::ImportData(rightT);}
private:
typename T::TetraPointer _vtp[4];
char _vti[4];
};
/*----------------------------- TTADJ ------------------------------*/
template <class T> class TTAdj: public T {
public:
TTAdj(){
_ttp[0]=0;
_ttp[1]=0;
_ttp[2]=0;
_ttp[3]=0;
}
typename T::TetraPointer &TTp(const int j) { assert(j>=0 && j<4); return _ttp[j]; }
typename T::TetraPointer const TTp(const int j) const { assert(j>=0 && j<4); return _ttp[j]; }
typename T::TetraPointer const cTTp(const int j) const { assert(j>=0 && j<4); return _ttp[j]; }
char &TTi(const int j) { return _tti[j]; }
const char &cTTi(const int j) const { return _tti[j]; }
typename T::TetraPointer &TTp1( const int j ) { return TTp((j+1)%4);}
typename T::TetraPointer &TTp2( const int j ) { return TTp((j+2)%4);}
typename T::TetraPointer &TTp3( const int j ) { return TTp((j+3)%4);}
typename T::TetraPointer const TTp1( const int j ) const { return TTp((j+1)%4);}
typename T::TetraPointer const TTp2( const int j ) const { return TTp((j+2)%4);}
typename T::TetraPointer const TTp3( const int j ) const { return TTp((j+3)%4);}
bool IsBorderF(const int & i) const { assert( (i>=0) && (i < 4)); { return TTp(i) == this;}}
static bool HasTTAdjacency() { return true; }
static bool HasTTAdjacencyOcc() { return false; }
static void Name(std::vector<std::string> & name){name.push_back(std::string("TTAdj"));T::Name(name);}
template <class RightValueType>
void ImportData(const RightValueType & rightT){T::ImportData(rightT);}
private:
typename T::TetraPointer _ttp[4] ;
char _tti[4] ;
};
} // end namespace vert
}// end namespace vcg
#endif
|