$darkmode
VCG Library
component.h
1 /****************************************************************************
2 * VCGLib o o *
3 * Visual and Computer Graphics Library o o *
4 * _ O _ *
5 * Copyright(C) 2004-2016 \/)\/ *
6 * Visual Computing Lab /\/| *
7 * ISTI - Italian National Research Council | *
8 * \ *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
20 * for more details. *
21 * *
22 ****************************************************************************/
23 
24 #ifndef __VCG_FACE_PLUS_COMPONENT
25 #define __VCG_FACE_PLUS_COMPONENT
26 
27 #include <cassert>
28 #include <vector>
29 #include <string>
30 
31 #include <vcg/space/color4.h>
32 #include <vcg/space/texcoord2.h>
33 
34 namespace vcg {
35 namespace face {
39 /*------------------------- EMPTY CORE COMPONENTS -----------------------------------------*/
40 
41 template <class T> class EmptyCore: public T {
42 public:
43  inline typename T::VertexType * &V( const int ) { assert(0); static typename T::VertexType *vp=0; return vp; }
44  inline const typename T::VertexType * V( const int ) const { assert(0); static typename T::VertexType *vp=0; return vp; }
45  inline const typename T::VertexType * cV( const int ) const { assert(0); static typename T::VertexType *vp=0; return vp; }
46  inline typename T::VertexType * &FVp( const int i ) { return this->V(i); }
47  inline const typename T::VertexType * FVp( const int i ) const { return this->cV(i); }
48  inline const typename T::VertexType * cFVp( const int i ) const { return this->cV(i); }
49  inline typename T::CoordType &P( const int ) { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
50  inline typename T::CoordType P( const int ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
51  inline const typename T::CoordType &cP( const int ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
52 
53  static bool HasVertexRef() { return false; }
54  static bool HasFVAdjacency() { return false; }
55 
56  typedef typename T::VertexType::NormalType NormalType;
57  typedef NormalType WedgeNormalType;
58  NormalType &N() { static NormalType dummy_normal(0, 0, 0); assert(0); return dummy_normal; }
59  const NormalType& N() const { static NormalType dummy_normal(0, 0, 0); return dummy_normal; }
60  const NormalType& cN() const { static NormalType dummy_normal(0, 0, 0); return dummy_normal; }
61  WedgeNormalType &WN(int) { static NormalType dummy_normal(0, 0, 0); assert(0); return dummy_normal; }
62  const WedgeNormalType& WN(int) const { static NormalType dummy_normal(0, 0, 0); return dummy_normal; }
63  const WedgeNormalType& cWN(int) const { static NormalType dummy_normal(0, 0, 0); return dummy_normal; }
64 
65 
66  typedef int WedgeTexCoordType;
67  typedef vcg::TexCoord2<float,1> TexCoordType;
68  TexCoordType &WT(const int) { static TexCoordType dummy_texture; assert(0); return dummy_texture;}
69  const TexCoordType & WT(const int) const { static TexCoordType dummy_texture; return dummy_texture;}
70  const TexCoordType &cWT(const int) const { static TexCoordType dummy_texture; return dummy_texture;}
71 
72  typedef int FlagType;
73  int &Flags() { static int dummyflags(0); assert(0); return dummyflags; }
74  int Flags() const { return 0; }
75  int cFlags() const { return 0; }
76  static bool HasFlags() { return false; }
77 
78  inline void InitIMark() { }
79  inline int &IMark() { assert(0); static int tmp=-1; return tmp;}
80  inline int IMark() const { return 0;}
81  inline int cIMark() const { return 0;}
82 
83  typedef int MarkType;
84  typedef float QualityType;
85  typedef Point3f Quality3Type;
86  typedef vcg::Color4b ColorType;
87  typedef ColorType WedgeColorType;
88  ColorType &C() { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; }
89  const ColorType& C() const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; }
90  const ColorType& cC() const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; }
91  WedgeColorType &WC(const int) { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; }
92  const WedgeColorType& WC(const int) const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; }
93  const WedgeColorType& cWC(const int) const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; }
94  QualityType &Q() { static QualityType dummyQuality(0); assert(0); return dummyQuality; }
95  const QualityType& Q() const { static QualityType dummyQuality(0); assert(0); return dummyQuality; }
96  const QualityType& cQ() const { static QualityType dummyQuality(0); assert(0); return dummyQuality; }
97  Quality3Type &Q3() { static Quality3Type dummyQuality3(0,0,0); assert(0); return dummyQuality3; }
98  const Quality3Type& Q3() const { static Quality3Type dummyQuality3(0,0,0); assert(0); return dummyQuality3; }
99  const Quality3Type& cQ3() const { static Quality3Type dummyQuality3(0,0,0); assert(0); return dummyQuality3; }
100 
101  static bool HasColor() { return false; }
102  static bool HasQuality() { return false; }
103  static bool HasQuality3() { return false; }
104  static bool HasMark() { return false; }
105  static bool HasNormal() { return false; }
106 
107  static bool HasWedgeColor() { return false; }
108  static bool HasWedgeNormal() { return false; }
109  static bool HasWedgeTexCoord() { return false; }
110 
111  // Interfaces for dynamic types
112  inline bool IsColorEnabled( ) const { return T::FaceType::HasColor(); }
113  inline bool IsCurvatureDirEnabled( ) const { return T::FaceType::HasCurvatureDir(); }
114  inline bool IsMarkEnabled( ) const { return T::FaceType::HasMark(); }
115  inline bool IsNormalEnabled( ) const { return T::FaceType::HasNormal(); }
116  inline bool IsQualityEnabled( ) const { return T::FaceType::HasQuality(); }
117  inline bool IsQuality3Enabled( ) const { return T::FaceType::HasQuality3(); }
118 
119  inline bool IsWedgeColorEnabled( ) const { return T::FaceType::HasWedgeColor(); }
120  inline bool IsWedgeNormalEnabled( ) const { return T::FaceType::HasWedgeNormal(); }
121  inline bool IsWedgeTexCoordEnabled( ) const { return T::FaceType::HasWedgeTexCoord(); }
122 
123  typedef int VFAdjType;
124  typename T::FacePointer &VFp(int) { static typename T::FacePointer fp=0; assert(0); return fp; }
125  typename T::FacePointer VFp(int) const { static typename T::FacePointer fp=0; assert(0); return fp; }
126  const typename T::FacePointer &cVFp(int) const { static typename T::FacePointer fp=0; assert(0); return fp; }
127  typename T::FacePointer &FFp(int) { static typename T::FacePointer fp=0; assert(0); return fp; }
128  typename T::FacePointer FFp(int) const { static typename T::FacePointer fp=0; assert(0); return fp; }
129  const typename T::FacePointer &cFFp(int) const { static typename T::FacePointer fp=0; assert(0); return fp; }
130  typename T::EdgePointer &FEp(int) { static typename T::EdgePointer fp=0; assert(0); return fp; }
131  typename T::EdgePointer FEp(int) const { static typename T::EdgePointer fp=0; assert(0); return fp; }
132  const typename T::EdgePointer &cFEp(int) const { static typename T::EdgePointer fp=0; assert(0); return fp; }
133  typename T::HEdgePointer &FHp() { static typename T::HEdgePointer fp=0; assert(0); return fp; }
134  typename T::HEdgePointer FHp() const { static typename T::HEdgePointer fp=0; assert(0); return fp; }
135  const typename T::HEdgePointer &cFHp() const { static typename T::HEdgePointer fp=0; assert(0); return fp; }
136  char &VFi(int) { static char z=0; assert(0); return z;}
137  char VFi(int) const { static char z=0; assert(0); return z;}
138  char cVFi(int) const { static char z=0; assert(0); return z;}
139  char &FFi(int) { static char z=0; assert(0); return z;}
140  char FFi(int) const { static char z=0; assert(0); return z;}
141  char cFFi(int) const { static char z=0; assert(0); return z;}
142  bool IsVFInitialized(const int j) const {return static_cast<const typename T::FaceType *>(this)->cVFi(j)!=-1;}
143  void VFClear(int j) {
144  if(IsVFInitialized(j)) {
145  static_cast<typename T::FacePointer>(this)->VFp(j)=0;
146  static_cast<typename T::FacePointer>(this)->VFi(j)=-1;
147  }
148  }
149  static bool HasVFAdjacency() { return false; }
150  static bool HasFFAdjacency() { return false; }
151  static bool HasFEAdjacency() { return false; }
152  static bool HasFHAdjacency() { return false; }
153 
154  typedef typename T::VertexType::CurvatureDirType CurvatureDirType;
155  typedef typename T::CoordType CurVecType;
156  typedef typename T::ScalarType CurScalarType;
157  CurVecType &PD1() { static typename T::CoordType dummy(0, 0, 0); assert(0); return dummy; }
158  CurVecType &PD2() { static typename T::CoordType dummy(0, 0, 0); assert(0); return dummy; }
159  const CurVecType& PD1() const { static typename T::CoordType dummy(0, 0, 0); assert(0); return dummy; }
160  const CurVecType& PD2() const { static typename T::CoordType dummy(0, 0, 0); assert(0); return dummy; }
161  const CurVecType& cPD1() const { static typename T::CoordType dummy(0, 0, 0); assert(0); return dummy; }
162  const CurVecType& cPD2() const { static typename T::CoordType dummy(0, 0, 0); assert(0); return dummy; }
163 
164  CurScalarType &K1() { static typename T::ScalarType dummy(0); assert(0); return dummy; }
165  CurScalarType &K2() { static typename T::ScalarType dummy(0); assert(0); return dummy; }
166  const CurScalarType& K1() const { static typename T::ScalarType dummy(0); assert(0); return dummy; }
167  const CurScalarType& K2() const { static typename T::ScalarType dummy(0); assert(0); return dummy; }
168  const CurScalarType& cK1() const { static typename T::ScalarType dummy(0); assert(0); return dummy; }
169  const CurScalarType& cK2() const { static typename T::ScalarType dummy(0); assert(0); return dummy; }
170 
171  static bool HasCurvatureDir() { return false; }
172 
173 
174  static bool HasPolyInfo() { return false; }
175 
176  template <class RightValueType>
177  void ImportData(const RightValueType & rightF) {T::ImportData(rightF);}
178  inline void Alloc(const int & ns) {T::Alloc(ns);}
179  inline void Dealloc(){T::Dealloc();}
180  static void Name(std::vector<std::string> & name){T::Name(name);}
181  };
182 
183 /*-------------------------- VertexRef ----------------------------------------*/
190 template <class T> class VertexRef: public T {
191 public:
192  VertexRef(){
193  v[0]=0;
194  v[1]=0;
195  v[2]=0;
196  }
197 
198  typedef typename T::VertexType::CoordType CoordType;
199  typedef typename T::VertexType::ScalarType ScalarType;
200 
201  inline typename T::VertexType * &V( const int j ) { assert(j>=0 && j<3); return v[j]; }
202  inline const typename T::VertexType * V (const int j) const { assert(j>=0 && j<3); return v[j]; }
203  inline const typename T::VertexType * cV( const int j ) const { assert(j>=0 && j<3); return v[j]; }
204 
205  inline CoordType &P( const int j ) { assert(j>=0 && j<3); return v[j]->P(); }
206  inline const CoordType &P( const int j ) const { assert(j>=0 && j<3); return v[j]->P(); }
207  inline const CoordType &cP( const int j ) const { assert(j>=0 && j<3); return v[j]->cP(); }
208 
209  inline typename T::VertexType * & V0( const int j ) { return V(j);}
210  inline typename T::VertexType * & V1( const int j ) { return V((j+1)%3);}
211  inline typename T::VertexType * & V2( const int j ) { return V((j+2)%3);}
212  inline const typename T::VertexType * V0( const int j ) const { return V(j);}
213  inline const typename T::VertexType * V1( const int j ) const { return V((j+1)%3);}
214  inline const typename T::VertexType * V2( const int j ) const { return V((j+2)%3);}
215  inline const typename T::VertexType * cV0( const int j ) const { return cV(j);}
216  inline const typename T::VertexType * cV1( const int j ) const { return cV((j+1)%3);}
217  inline const typename T::VertexType * cV2( const int j ) const { return cV((j+2)%3);}
218 
219  inline CoordType & P0( const int j ) { return V(j)->P();}
220  inline CoordType & P1( const int j ) { return V((j+1)%3)->P();}
221  inline CoordType & P2( const int j ) { return V((j+2)%3)->P();}
222  inline const CoordType & P0( const int j ) const { return V(j)->P();}
223  inline const CoordType & P1( const int j ) const { return V((j+1)%3)->P();}
224  inline const CoordType & P2( const int j ) const { return V((j+2)%3)->P();}
225  inline const CoordType & cP0( const int j ) const { return cV(j)->P();}
226  inline const CoordType & cP1( const int j ) const { return cV((j+1)%3)->P();}
227  inline const CoordType & cP2( const int j ) const { return cV((j+2)%3)->P();}
228 
229  // Small comment about the fact that the pointers are zero filled.
230  // The importLocal is meant for copyng stuff between very different meshes, so copying the pointers would be meaningless.
231  // if you are using ImportData for copying internally simplex you have to set up all the pointers by hand.
232  template <class RightValueType>
233  void ImportData(const RightValueType & rightF){ T::ImportData(rightF);}
234  inline void Alloc(const int & ns){T::Alloc(ns);}
235  inline void Dealloc(){T::Dealloc();}
236 
237  static bool HasVertexRef() { return true; }
238  static bool HasFVAdjacency() { return true; }
239 
240  static void Name(std::vector<std::string> & name){name.push_back(std::string("VertexRef"));T::Name(name);}
241 
242 private:
243  typename T::VertexType *v[3];
244 };
245 
246 template <class A, class T> class NormalAbs: public T {
247 public:
248  typedef A NormalType;
249  inline NormalType &N() { return _norm; }
250  inline const NormalType &N() const { return _norm; }
251  inline const NormalType &cN() const { return _norm; }
252  template <class RightValueType>
253  void ImportData(const RightValueType & rightF)
254  {
255  if(rightF.IsNormalEnabled()) N().Import(rightF.cN());
256  T::ImportData(rightF);
257  }
258 
259  inline void Alloc(const int & ns){T::Alloc(ns);}
260  inline void Dealloc(){T::Dealloc();}
261  static bool HasNormal() { return true; }
262  static void Name(std::vector<std::string> & name){name.push_back(std::string("NormalAbs"));T::Name(name);}
263 
264 private:
265  NormalType _norm;
266 };
267 
268 template <class T> class WedgeNormal: public T {
269 public:
270  typedef typename T::VertexType::NormalType WedgeNormalType;
271  inline WedgeNormalType &WN(int j) { return _wnorm[j]; }
272  inline const WedgeNormalType &WN(int j) const { return _wnorm[j]; }
273  inline const WedgeNormalType &cWN(int j) const { return _wnorm[j]; }
274  template <class RightValueType>
275  void ImportData(const RightValueType & rightF){ if(rightF.IsWedgeNormalEnabled()) for (int i=0; i<3; ++i) { WN(i) = rightF.cWN(i); } T::ImportData(rightF);}
276  inline void Alloc(const int & ns){T::Alloc(ns);}
277  inline void Dealloc(){T::Dealloc();}
278  static bool HasWedgeNormal() { return true; }
279  static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeNormal"));T::Name(name);}
280 
281 private:
282  WedgeNormalType _wnorm[3];
283 };
284 
285 template <class A, class T> class WedgeRealNormal: public T {
286 public:
287  typedef A WedgeNormalType;
288  inline WedgeNormalType &WN(int i) { return _wn[i]; }
289  inline const WedgeNormalType &WN(int i) const { return _wn[i]; }
290  inline const WedgeNormalType &cWN(int i) const { return _wn[i]; }
291  template <class RightValueType>
292  void ImportData(const RightValueType & rightF){ if(RightValueType::HasWedgeNormal()) for (int i=0; i<3; ++i) { WN(i) = rightF.cWN(i); } T::ImportData(rightF);}
293  inline void Alloc(const int & ns){T::Alloc(ns);}
294  inline void Dealloc(){T::Dealloc();}
295  static bool HasWedgeNormal() { return true; }
296  static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeRealNormal"));T::Name(name);}
297 
298 private:
299  WedgeNormalType _wn[3];
300 };
301 
302 template <class TT> class WedgeRealNormal3s: public WedgeRealNormal<vcg::Point3s, TT> {
303 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeRealNormal2s"));TT::Name(name);}};
304 template <class TT> class WedgeRealNormal3f: public WedgeRealNormal<vcg::Point3f, TT> {
305 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeRealNormal2f"));TT::Name(name);}};
306 template <class TT> class WedgeRealNormal3d: public WedgeRealNormal<vcg::Point3d, TT> {
307 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeRealNormal2d"));TT::Name(name);}};
308 
309 template <class T> class Normal3s: public NormalAbs<vcg::Point3s, T> {
310 public:static void Name(std::vector<std::string> & name){name.push_back(std::string("Normal3s"));T::Name(name);}
311 };
312 template <class T> class Normal3f: public NormalAbs<vcg::Point3f, T> {
313 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Normal3f"));T::Name(name);}
314 };
315 template <class T> class Normal3d: public NormalAbs<vcg::Point3d, T> {
316 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Normal3d"));T::Name(name);}
317 };
318 
319 
320 /*-------------------------- TexCoord ----------------------------------------*/
321 
322 template <class A, class T> class WedgeTexCoord: public T {
323 public:
324  typedef int WedgeTexCoordType;
325  typedef A TexCoordType;
326  TexCoordType &WT(const int i) { return _wt[i]; }
327  const TexCoordType &WT(const int i) const { return _wt[i]; }
328  const TexCoordType &cWT(const int i) const { return _wt[i]; }
329  template <class RightValueType>
330  void ImportData(const RightValueType & rightF){
331  if(rightF.IsWedgeTexCoordEnabled())
332  for (int i=0; i<3; ++i) { WT(i) = rightF.cWT(i); }
333  T::ImportData(rightF);
334  }
335  inline void Alloc(const int & ns){T::Alloc(ns);}
336  inline void Dealloc(){T::Dealloc();}
337  static bool HasWedgeTexCoord() { return true; }
338  static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeTexCoord"));T::Name(name);}
339 
340 private:
341  TexCoordType _wt[3];
342 };
343 
344 template <class TT> class WedgeTexCoord2s: public WedgeTexCoord<TexCoord2<short,1>, TT> {
345 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeTexCoord2s"));TT::Name(name);}
346 };
347 template <class TT> class WedgeTexCoord2f: public WedgeTexCoord<TexCoord2<float,1>, TT> {
348 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeTexCoord2f"));TT::Name(name);}
349 };
350 template <class TT> class WedgeTexCoord2d: public WedgeTexCoord<TexCoord2<double,1>, TT> {
351 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeTexCoord2d"));TT::Name(name);}
352 };
353 
354 /*------------------------- BitFlags -----------------------------------------*/
359 template <class T> class BitFlags: public T {
360 public:
361  BitFlags():_flags(0) {}
362  typedef int FlagType;
363  int &Flags() {return _flags; }
364  int Flags() const {return _flags; }
365  int cFlags() const {return _flags; }
366  template <class RightValueType>
367  void ImportData(const RightValueType & rightF){
368  if(RightValueType::HasFlags())
369  Flags() = rightF.cFlags();
370  T::ImportData(rightF);
371  }
372  inline void Alloc(const int & ns){T::Alloc(ns);}
373  inline void Dealloc(){T::Dealloc();}
374  static bool HasFlags() { return true; }
375  static void Name(std::vector<std::string> & name){name.push_back(std::string("BitFlags"));T::Name(name);}
376 
377 private:
378  int _flags;
379 };
380 
381 /*-------------------------- Color ----------------------------------*/
382 template <class A, class T> class Color: public T {
383 public:
384  typedef A ColorType;
385  Color():_color(vcg::Color4b::White) {}
386  ColorType &C() { return _color; }
387  const ColorType &C() const { return _color; }
388  const ColorType &cC() const { return _color; }
389  template <class RightValueType>
390  void ImportData(const RightValueType & rightF){
391  if(rightF.IsColorEnabled()) C() = rightF.cC();
392  T::ImportData(rightF);
393  }
394  inline void Alloc(const int & ns){T::Alloc(ns);}
395  inline void Dealloc(){T::Dealloc();}
396  static bool HasColor() { return true; }
397  static void Name(std::vector<std::string> & name){name.push_back(std::string("Color"));T::Name(name);}
398 
399 private:
400  ColorType _color;
401 };
402 
403 template <class A, class T> class WedgeColor: public T {
404 public:
405  typedef A WedgeColorType;
406  WedgeColorType &WC(int i) { return _color[i]; }
407  const WedgeColorType &WC(int i) const { return _color[i]; }
408  const WedgeColorType &cWC(int i) const { return _color[i]; }
409 
410  template <class RightValueType>
411  void ImportData(const RightValueType & rightF){
412  if (rightF.IsWedgeColorEnabled())
413  {
414  for (int i=0; i<3; ++i) { WC(i) = rightF.cWC(i); }
415  }
416  T::ImportData(rightF);
417 
418  }
419  static bool HasWedgeColor() { return true; }
420  static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeColor"));T::Name(name);}
421 
422 private:
423  WedgeColorType _color[3];
424 };
425 
426 template <class T> class WedgeColor4b: public WedgeColor<vcg::Color4b, T> {
427 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeColor4b"));T::Name(name);}
428 };
429 template <class T> class WedgeColor4f: public WedgeColor<vcg::Color4f, T> {
430 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeColor4f"));T::Name(name);}
431 };
432 template <class T> class Color4b: public Color<vcg::Color4b, T> {
433 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Color4b"));T::Name(name);}
434 };
435 
436 /*-------------------------- Quality ----------------------------------*/
437 template <class A, class T> class Quality: public T {
438 public:
439  typedef A QualityType;
440  Quality():_quality(0) {}
441  QualityType &Q() { return _quality; }
442  const QualityType &Q() const { return _quality; }
443  const QualityType &cQ() const { return _quality; }
444  template <class RightValueType>
445  void ImportData(const RightValueType & rightF){
446  if(rightF.IsQualityEnabled())
447  Q() = rightF.cQ();
448  T::ImportData(rightF);
449  }
450  inline void Alloc(const int & ns){T::Alloc(ns);}
451  inline void Dealloc(){T::Dealloc();}
452  static bool HasQuality() { return true; }
453  static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality"));T::Name(name);}
454 private:
455  QualityType _quality;
456 };
457 
458 template <class T> class Qualitys: public Quality<short, T> {
459 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Qualitys"));T::Name(name);}
460 };
461 template <class T> class Qualityf: public Quality<float, T> {
462 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Qualityf"));T::Name(name);}
463 };
464 template <class T> class Qualityd: public Quality<double, T> {
465 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Qualityd"));T::Name(name);}
466 };
467 
468 /*-------------------------- Quality3 ----------------------------------*/
469 template <class A, class T> class Quality3: public T {
470 public:
472  Quality3Type &Q3() { return _quality; }
473  const Quality3Type &Q3() const { return _quality; }
474  const Quality3Type &cQ3() const { return _quality; }
475  template <class RightValueType>
476  void ImportData(const RightValueType & rightF){
477  if(rightF.IsQuality3Enabled()) Q3() = rightF.cQ3();
478  T::ImportData(rightF);
479  }
480  inline void Alloc(const int & ns){T::Alloc(ns);}
481  inline void Dealloc(){T::Dealloc();}
482  static bool HasQuality3() { return true; }
483  static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality3"));T::Name(name);}
484 private:
485  Quality3Type _quality;
486 };
487 
488 template <class T> class Quality3s: public Quality3<short, T> {
489 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality3s"));T::Name(name);}
490 };
491 template <class T> class Quality3f: public Quality3<float, T> {
492 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality3f"));T::Name(name);}
493 };
494 template <class T> class Quality3d: public Quality3<double, T> {
495 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality3d"));T::Name(name);}
496 };
497 
498 /*-------------------------- INCREMENTAL MARK ----------------------------------------*/
504 template <class T> class Mark: public T {
505 public:
506  Mark():_imark(0){}
507  inline int &IMark() { return _imark;}
508  inline int IMark() const { return _imark;}
509  inline int cIMark() const { return _imark;}
510  inline void InitIMark() { _imark = 0; }
511  static bool HasMark() { return true; }
512  template <class RightValueType>
513  void ImportData(const RightValueType & rightF){
514  if(rightF.IsMarkEnabled())
515  IMark() = rightF.cIMark();
516  T::ImportData(rightF);
517  }
518  static void Name(std::vector<std::string> & name){name.push_back(std::string("Mark"));T::Name(name);}
519 
520 private:
521  int _imark;
522 };
523 
524 /*-------------------------- Curvature Direction ----------------------------------*/
525 template <class S>
527  typedef Point3<S> CurVecType;
528  typedef S CurScalarType;
530  Point3<S>max_dir,min_dir; // max and min curvature direction
531  S k1,k2;// max and min curvature values
532 };
533 
534 template <class A, class TT> class CurvatureDir: public TT {
535 public:
536  typedef A CurvatureDirType;
537  typedef typename CurvatureDirType::CurVecType CurVecType;
538  typedef typename CurvatureDirType::CurScalarType CurScalarType;
539 
540  CurVecType &PD1() { return _curv.max_dir; }
541  CurVecType &PD2() { return _curv.min_dir; }
542  const CurVecType &PD1() const { return _curv.max_dir; }
543  const CurVecType &PD2() const { return _curv.min_dir; }
544  const CurVecType &cPD1() const { return _curv.max_dir; }
545  const CurVecType &cPD2() const { return _curv.min_dir; }
546 
547  CurScalarType &K1() { return _curv.k1; }
548  CurScalarType &K2() { return _curv.k2; }
549  const CurScalarType &K1() const { return _curv.k1; }
550  const CurScalarType &K2() const { return _curv.k2; }
551  const CurScalarType &cK1() const { return _curv.k1; }
552  const CurScalarType &cK2() const { return _curv.k2; }
553  template < class RightValueType>
554  void ImportData(const RightValueType & rightF ) {
555  if(rightF.IsCurvatureDirEnabled()) {
556  PD1() = rightF.cPD1(); PD2() = rightF.cPD2();
557  K1() = rightF.cK1(); K2() = rightF.cK2();
558  }
559  TT::ImportData(rightF);
560  }
561 
562  static bool HasCurvatureDir() { return true; }
563  static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureDir"));TT::Name(name);}
564 
565 private:
566  CurvatureDirType _curv;
567 };
568 
569 
570 template <class T> class CurvatureDirf: public CurvatureDir<CurvatureDirBaseType<float>, T> {
571 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureDirf"));T::Name(name);}
572 };
573 template <class T> class CurvatureDird: public CurvatureDir<CurvatureDirBaseType<double>, T> {
574 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureDird"));T::Name(name);}
575 };
576 
577 /*----------------------------- VFADJ ------------------------------*/
594 template <class T> class VFAdj: public T {
595 public:
596  VFAdj(){
597  _vfp[0]=0;
598  _vfp[1]=0;
599  _vfp[2]=0;
600  _vfi[0]=-1;
601  _vfi[1]=-1;
602  _vfi[2]=-1;
603  }
604  typename T::FacePointer &VFp(const int j) { assert(j>=0 && j<3); return _vfp[j]; }
605  typename T::FacePointer VFp(const int j) const { assert(j>=0 && j<3); return _vfp[j]; }
606  const typename T::FacePointer &cVFp(const int j) const { assert(j>=0 && j<3); return _vfp[j]; }
607  char &VFi(const int j) {return _vfi[j]; }
608  char VFi(const int j)const {return _vfi[j]; }
609  char cVFi(const int j)const {return _vfi[j]; }
610  template <class RightValueType>
611  void ImportData(const RightValueType & rightF){T::ImportData(rightF);}
612  inline void Alloc(const int & ns){T::Alloc(ns);}
613  inline void Dealloc(){T::Dealloc();}
614  static bool HasVFAdjacency() { return true; }
615  static void Name(std::vector<std::string> & name){name.push_back(std::string("VFAdj"));T::Name(name);}
616 
617 private:
618  typename T::FacePointer _vfp[3] ;
619  char _vfi[3] ;
620 };
621 
622 /*----------------------------- EFADJ ------------------------------*/
623 template <class T> class EFAdj: public T {
624 public:
625  EFAdj(){
626  _efp[0]=0;
627  _efp[1]=0;
628  _efp[2]=0;
629  _efi[0]=-1;
630  _efi[1]=-1;
631  _efi[2]=-1;
632  }
633  typename T::FacePointer &EFp(const int j) { assert(j>=0 && j<3); return _efp[j]; }
634  const typename T::FacePointer &cEFp(const int j) const { assert(j>=0 && j<3); return _efp[j]; }
635  char &VFi(const int j) {return _efi[j]; }
636  char VFi(const int j) const {return _efi[j]; }
637  template <class RightValueType>
638  void ImportData(const RightValueType & rightF){T::ImportData(rightF);}
639  inline void Alloc(const int & ns){T::Alloc(ns);}
640  inline void Dealloc(){T::Dealloc();}
641  static bool HasEFAdjacency() { return true; }
642  static void Name(std::vector<std::string> & name){name.push_back(std::string("EFAdj"));T::Name(name);}
643 
644 private:
645  typename T::FacePointer _efp[3] ;
646  char _efi[3] ;
647 };
648 
649 
650 /*----------------------------- FFADJ ------------------------------*/
664 template <class T> class FFAdj: public T {
665 public:
666  FFAdj(){
667  _ffp[0]=nullptr; // null == not initialized
668  _ffp[1]=nullptr;
669  _ffp[2]=nullptr;
670  }
671  typename T::FacePointer &FFp(const int j) { assert(j>=0 && j<3); return _ffp[j]; }
672  typename T::FacePointer FFp(const int j) const { assert(j>=0 && j<3); return _ffp[j]; }
673  const typename T::FacePointer &cFFp(const int j) const { assert(j>=0 && j<3); return _ffp[j]; }
674  char &FFi(const int j) { return _ffi[j]; }
675  char FFi(const int j) const { return _ffi[j]; }
676  char cFFi(const int j) const { return _ffi[j]; }
677 
678  typename T::FacePointer &FFp1( const int j ) { return FFp((j+1)%3);}
679  typename T::FacePointer &FFp2( const int j ) { return FFp((j+2)%3);}
680  typename T::FacePointer FFp1( const int j ) const { return FFp((j+1)%3);}
681  typename T::FacePointer FFp2( const int j ) const { return FFp((j+2)%3);}
682  const typename T::FacePointer &cFFp1( const int j ) const { return FFp((j+1)%3);}
683  const typename T::FacePointer &cFFp2( const int j ) const { return FFp((j+2)%3);}
684 
685  template <class RightValueType>
686  void ImportData(const RightValueType & rightF){T::ImportData(rightF);}
687  inline void Alloc(const int & ns){T::Alloc(ns);}
688  inline void Dealloc(){T::Dealloc();}
689  static bool HasFFAdjacency() { return true; }
690  static void Name(std::vector<std::string> & name){name.push_back(std::string("FFAdj"));T::Name(name);}
691 
692 private:
693  typename T::FacePointer _ffp[3] ;
694  char _ffi[3] ;
695 };
696 
697 
698 /*----------------------------- FEADJ ------------------------------*/
699 
700 template <class T> class FEAdj: public T {
701 public:
702  FEAdj(){
703  _fep[0]=0;
704  _fep[1]=0;
705  _fep[2]=0;
706  }
707 
708  typename T::EdgePointer &FEp( int j) { assert(j>=0 && j<3); return _fep[j]; }
709  typename T::EdgePointer FEp( int j) const { assert(j>=0 && j<3); return _fep[j]; }
710  const typename T::EdgePointer &cFEp( int j) const { assert(j>=0 && j<3); return _fep[j]; }
711 
712  typename T::EdgePointer &FEp1( int j ) { return FEp((j+1)%3);}
713  typename T::EdgePointer &FEp2( int j ) { return FEp((j+2)%3);}
714  typename T::EdgePointer FEp1( int j ) const { return FEp((j+1)%3);}
715  typename T::EdgePointer FEp2( int j ) const { return FEp((j+2)%3);}
716 
717  template <class RightValueType>
718  void ImportData(const RightValueType & rightF){T::ImportData(rightF);}
719  inline void Alloc(const int & ns){T::Alloc(ns);}
720  inline void Dealloc(){T::Dealloc();}
721  static bool HasFEAdjacency() { return true; }
722  static void Name(std::vector<std::string> & name){name.push_back(std::string("FEAdj"));T::Name(name);}
723 
724 private:
725  typename T::EdgePointer _fep[3] ;
726  char _fei[3] ;
727 };
728 
729 
730 /*----------------------------- FHADJ ------------------------------*/
731 template <class T> class FHAdj: public T {
732 public:
733  FHAdj(){_fh=0;}
734  typename T::HEdgePointer &FHp( ) { return _fh; }
735  typename T::HEdgePointer FHp( ) const { return _fh; }
736  const typename T::HEdgePointer &cFHp( ) const { return _fh; }
737 
738  template <class RightValueType>
739  void ImportData(const RightValueType & rightF){T::ImportData(rightF);}
740  inline void Alloc(const int & ns){T::Alloc(ns);}
741  inline void Dealloc(){T::Dealloc();}
742  static bool HasFHAdjacency() { return true; }
743  static void Name(std::vector<std::string> & name){name.push_back(std::string("FHAdj"));T::Name(name);}
744 
745 private:
746  typename T::HEdgePointer _fh ;
747 }; // End Doxygen FaceComponentGroup
749  } // end namespace face
750 }// end namespace vcg
751 #endif
Definition: color4.h:41
Definition: point3.h:43
Component: Per face Flags
Definition: component.h:359
Definition: component.h:432
Definition: component.h:382
Definition: component.h:534
Definition: component.h:573
Definition: component.h:570
Definition: component.h:623
Definition: component.h:41
Definition: component.h:700
Component: Per Face Face-Face adjacency relation
Definition: component.h:664
Definition: component.h:731
Per vertex Incremental Mark.
Definition: component.h:504
Definition: component.h:315
Definition: component.h:312
Definition: component.h:309
Definition: component.h:246
Definition: component.h:469
Definition: component.h:494
Definition: component.h:491
Definition: component.h:488
Definition: component.h:437
Definition: component.h:464
Definition: component.h:461
Definition: component.h:458
Component: Per Face Vertex-Face adjacency relation
Definition: component.h:594
The references to the vertexes of a triangular face.
Definition: component.h:190
T::VertexType *& V1(const int j)
Return the pointer to the j-th vertex of the face.
Definition: component.h:210
const T::VertexType * V(const int j) const
The pointer to the i-th vertex.
Definition: component.h:202
const T::VertexType * V2(const int j) const
Return the pointer to the ((j+1)%3)-th vertex of the face.
Definition: component.h:214
const T::VertexType * V0(const int j) const
Return the pointer to the ((j+2)%3)-th vertex of the face.
Definition: component.h:212
const T::VertexType * cV0(const int j) const
Return the pointer to the ((j+2)%3)-th vertex of the face.
Definition: component.h:215
const T::VertexType * V1(const int j) const
Return the pointer to the j-th vertex of the face.
Definition: component.h:213
const CoordType & P(const int j) const
Shortcut: the position of the i-th vertex (equivalent to V(i)->P() )
Definition: component.h:206
T::VertexType *& V2(const int j)
Return the pointer to the ((j+1)%3)-th vertex of the face.
Definition: component.h:211
Definition: component.h:426
Definition: component.h:429
Definition: component.h:403
Definition: component.h:268
Definition: component.h:306
Definition: component.h:304
Definition: component.h:302
Definition: component.h:285
Definition: component.h:350
Definition: component.h:347
Definition: component.h:344
Definition: component.h:322
Definition: namespaces.dox:6
Definition: component.h:526