VCG Library
face/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 #ifndef __VCG_MESH
24 #error "This file should not be included alone. It is automatically included by complex.h"
25 #endif
26 #ifndef __VCG_FACE_PLUS_COMPONENT
27 #define __VCG_FACE_PLUS_COMPONENT
28 
29 
30 namespace vcg {
31 namespace face {
35 /*------------------------- EMPTY CORE COMPONENTS -----------------------------------------*/
36 
37 template <class T> class EmptyCore: public T {
38 public:
39  inline typename T::VertexType * &V( const int ) { assert(0); static typename T::VertexType *vp=0; return vp; }
40  inline typename T::VertexType * cV( const int ) const { assert(0); static typename T::VertexType *vp=0; return vp; }
41  inline typename T::VertexType * &FVp( const int i ) { return this->V(i); }
42  inline typename T::VertexType * cFVp( const int i ) const { return this->cV(i); }
43  inline typename T::CoordType &P( const int ) { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
44  inline typename T::CoordType cP( const int ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
45 
46  static bool HasVertexRef() { return false; }
47  static bool HasFVAdjacency() { return false; }
48 
49  typedef typename T::VertexType::NormalType NormalType;
50  typedef NormalType WedgeNormalType;
51  NormalType &N() { static NormalType dummy_normal(0, 0, 0); assert(0); return dummy_normal; }
52  NormalType cN() const { static NormalType dummy_normal(0, 0, 0); return dummy_normal; }
53  WedgeNormalType &WN(int) { static NormalType dummy_normal(0, 0, 0); assert(0); return dummy_normal; }
54  WedgeNormalType cWN(int) const { static NormalType dummy_normal(0, 0, 0); return dummy_normal; }
55 
56 
57  typedef int WedgeTexCoordType;
58  typedef vcg::TexCoord2<float,1> TexCoordType;
59  TexCoordType &WT(const int) { static TexCoordType dummy_texture; assert(0); return dummy_texture;}
60  TexCoordType const &cWT(const int) const { static TexCoordType dummy_texture; return dummy_texture;}
61 
62  typedef int FlagType;
63  int &Flags() { static int dummyflags(0); assert(0); return dummyflags; }
64  int cFlags() const { return 0; }
65  static bool HasFlags() { return false; }
66 
67  inline void InitIMark() { }
68  inline int &IMark() { assert(0); static int tmp=-1; return tmp;}
69  inline int cIMark() const { return 0;}
70 
71  typedef int MarkType;
72  typedef float QualityType;
73  typedef Point3f Quality3Type;
74  typedef vcg::Color4b ColorType;
75  typedef ColorType WedgeColorType;
76  ColorType &C() { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; }
77  ColorType cC() const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; }
78  WedgeColorType &WC(const int) { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; }
79  WedgeColorType cWC(const int) const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; }
80  QualityType &Q() { static QualityType dummyQuality(0); assert(0); return dummyQuality; }
81  QualityType cQ() const { static QualityType dummyQuality(0); assert(0); return dummyQuality; }
82  Quality3Type &Q3() { static Quality3Type dummyQuality3(0,0,0); assert(0); return dummyQuality3; }
83  Quality3Type cQ3() const { static Quality3Type dummyQuality3(0,0,0); assert(0); return dummyQuality3; }
84 
85  static bool HasColor() { return false; }
86  static bool HasQuality() { return false; }
87  static bool HasQuality3() { return false; }
88  static bool HasMark() { return false; }
89  static bool HasNormal() { return false; }
90 
91  static bool HasWedgeColor() { return false; }
92  static bool HasWedgeNormal() { return false; }
93  static bool HasWedgeTexCoord() { return false; }
94 
95  // Interfaces for dynamic types
96  inline bool IsColorEnabled( ) const { return T::FaceType::HasColor(); }
97  inline bool IsCurvatureDirEnabled( ) const { return T::FaceType::HasCurvatureDir(); }
98  inline bool IsMarkEnabled( ) const { return T::FaceType::HasMark(); }
99  inline bool IsNormalEnabled( ) const { return T::FaceType::HasNormal(); }
100  inline bool IsQualityEnabled( ) const { return T::FaceType::HasQuality(); }
101  inline bool IsQuality3Enabled( ) const { return T::FaceType::HasQuality3(); }
102 
103  inline bool IsWedgeColorEnabled( ) const { return T::FaceType::HasWedgeColor(); }
104  inline bool IsWedgeNormalEnabled( ) const { return T::FaceType::HasWedgeNormal(); }
105  inline bool IsWedgeTexCoordEnabled( ) const { return T::FaceType::HasWedgeTexCoord(); }
106 
107  typedef int VFAdjType;
108  typename T::FacePointer &VFp(int) { static typename T::FacePointer fp=0; assert(0); return fp; }
109  typename T::FacePointer cVFp(int) const { static typename T::FacePointer fp=0; assert(0); return fp; }
110  typename T::FacePointer &FFp(int) { static typename T::FacePointer fp=0; assert(0); return fp; }
111  typename T::FacePointer cFFp(int) const { static typename T::FacePointer fp=0; assert(0); return fp; }
112  typename T::EdgePointer &FEp(int) { static typename T::EdgePointer fp=0; assert(0); return fp; }
113  typename T::EdgePointer cFEp(int) const { static typename T::EdgePointer fp=0; assert(0); return fp; }
114  typename T::HEdgePointer &FHp() { static typename T::HEdgePointer fp=0; assert(0); return fp; }
115  typename T::HEdgePointer cFHp() const { static typename T::HEdgePointer fp=0; assert(0); return fp; }
116  char &VFi(int) { static char z=0; assert(0); return z;}
117  char &FFi(int) { static char z=0; assert(0); return z;}
118  char cVFi(int) const { static char z=0; assert(0); return z;}
119  char cFFi(int) const { static char z=0; assert(0); return z;}
120  bool IsVFInitialized(const int j) const {return static_cast<const typename T::FaceType *>(this)->cVFi(j)!=-1;}
121  void VFClear(int j) {
122  if(IsVFInitialized(j)) {
123  static_cast<typename T::FacePointer>(this)->VFp(j)=0;
124  static_cast<typename T::FacePointer>(this)->VFi(j)=-1;
125  }
126  }
127  static bool HasVFAdjacency() { return false; }
128  static bool HasFFAdjacency() { return false; }
129  static bool HasFEAdjacency() { return false; }
130  static bool HasFHAdjacency() { return false; }
131 
132  typedef typename T::VertexType::CurvatureDirType CurvatureDirType;
133  typedef typename T::CoordType CurVecType;
134  typedef typename T::ScalarType CurScalarType;
135  CurVecType &PD1() { static typename T::CoordType dummy(0, 0, 0); assert(0); return dummy; }
136  CurVecType &PD2() { static typename T::CoordType dummy(0, 0, 0); assert(0); return dummy; }
137  CurVecType cPD1() const { static typename T::CoordType dummy(0, 0, 0); assert(0); return dummy; }
138  CurVecType cPD2() const { static typename T::CoordType dummy(0, 0, 0); assert(0); return dummy; }
139 
140  CurScalarType &K1() { static typename T::ScalarType dummy(0); assert(0); return dummy; }
141  CurScalarType &K2() { static typename T::ScalarType dummy(0); assert(0); return dummy; }
142  CurScalarType cK1() const { static typename T::ScalarType dummy(0); assert(0); return dummy; }
143  CurScalarType cK2() const { static typename T::ScalarType dummy(0); assert(0); return dummy; }
144 
145  static bool HasCurvatureDir() { return false; }
146 
147 
148  static bool HasPolyInfo() { return false; }
149 
150  template <class RightValueType>
151  void ImportData(const RightValueType & rightF) {T::ImportData(rightF);}
152  inline void Alloc(const int & ns) {T::Alloc(ns);}
153  inline void Dealloc(){T::Dealloc();}
154  static void Name(std::vector<std::string> & name){T::Name(name);}
155  };
156 
157 /*-------------------------- VertexRef ----------------------------------------*/
164 template <class T> class VertexRef: public T {
165 public:
166  VertexRef(){
167  v[0]=0;
168  v[1]=0;
169  v[2]=0;
170  }
171 
172  typedef typename T::VertexType::CoordType CoordType;
173  typedef typename T::VertexType::ScalarType ScalarType;
174 
175  inline typename T::VertexType * &V( const int j ) { assert(j>=0 && j<3); return v[j]; }
176  inline typename T::VertexType * cV( const int j ) const { assert(j>=0 && j<3); return v[j]; }
177 
178  inline CoordType &P( const int j ) { assert(j>=0 && j<3); return v[j]->P(); }
179  inline CoordType cP( const int j ) const { assert(j>=0 && j<3); return v[j]->cP(); }
180 
181  inline typename T::VertexType * & V0( const int j ) { return V(j);}
182  inline typename T::VertexType * & V1( const int j ) { return V((j+1)%3);}
183  inline typename T::VertexType * & V2( const int j ) { return V((j+2)%3);}
184  inline typename T::VertexType * cV0( const int j ) const { return cV(j);}
185  inline typename T::VertexType * cV1( const int j ) const { return cV((j+1)%3);}
186  inline typename T::VertexType * cV2( const int j ) const { return cV((j+2)%3);}
187 
188  inline CoordType & P0( const int j ) { return V(j)->P();}
189  inline CoordType & P1( const int j ) { return V((j+1)%3)->P();}
190  inline CoordType & P2( const int j ) { return V((j+2)%3)->P();}
191  inline const CoordType & cP0( const int j ) const { return cV(j)->P();}
192  inline const CoordType & cP1( const int j ) const { return cV((j+1)%3)->P();}
193  inline const CoordType & cP2( const int j ) const { return cV((j+2)%3)->P();}
194 
195  // Small comment about the fact that the pointers are zero filled.
196  // The importLocal is meant for copyng stuff between very different meshes, so copying the pointers would be meaningless.
197  // if you are using ImportData for copying internally simplex you have to set up all the pointers by hand.
198  template <class RightValueType>
199  void ImportData(const RightValueType & rightF){ T::ImportData(rightF);}
200  inline void Alloc(const int & ns){T::Alloc(ns);}
201  inline void Dealloc(){T::Dealloc();}
202 
203  static bool HasVertexRef() { return true; }
204  static bool HasFVAdjacency() { return true; }
205 
206  static void Name(std::vector<std::string> & name){name.push_back(std::string("VertexRef"));T::Name(name);}
207 
208 private:
209  typename T::VertexType *v[3];
210 };
211 
212 template <class A, class T> class NormalAbs: public T {
213 public:
214  typedef A NormalType;
215  inline NormalType &N() { return _norm; }
216  inline NormalType cN() const { return _norm; }
217  template <class RightValueType>
218  void ImportData(const RightValueType & rightF)
219  {
220  if(rightF.IsNormalEnabled()) N().Import(rightF.cN());
221  T::ImportData(rightF);
222  }
223 
224  inline void Alloc(const int & ns){T::Alloc(ns);}
225  inline void Dealloc(){T::Dealloc();}
226  static bool HasNormal() { return true; }
227  static void Name(std::vector<std::string> & name){name.push_back(std::string("NormalAbs"));T::Name(name);}
228 
229 private:
230  NormalType _norm;
231 };
232 
233 template <class T> class WedgeNormal: public T {
234 public:
235  typedef typename T::VertexType::NormalType WedgeNormalType;
236  inline WedgeNormalType &WN(int j) { return _wnorm[j]; }
237  inline WedgeNormalType cWN(int j) const { return _wnorm[j]; }
238  template <class RightValueType>
239  void ImportData(const RightValueType & rightF){ if(rightF.IsWedgeNormalEnabled()) for (int i=0; i<3; ++i) { WN(i) = rightF.cWN(i); } T::ImportData(rightF);}
240  inline void Alloc(const int & ns){T::Alloc(ns);}
241  inline void Dealloc(){T::Dealloc();}
242  static bool HasWedgeNormal() { return true; }
243  static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeNormal"));T::Name(name);}
244 
245 private:
246  WedgeNormalType _wnorm[3];
247 };
248 
249 template <class A, class T> class WedgeRealNormal: public T {
250 public:
251  typedef A WedgeNormalType;
252  inline WedgeNormalType &WN(int i) { return _wn[i]; }
253  inline WedgeNormalType cWN(int i) const { return _wn[i]; }
254  template <class RightValueType>
255  void ImportData(const RightValueType & rightF){ if(RightValueType::HasWedgeNormal()) for (int i=0; i<3; ++i) { WN(i) = rightF.cWN(i); } T::ImportData(rightF);}
256  inline void Alloc(const int & ns){T::Alloc(ns);}
257  inline void Dealloc(){T::Dealloc();}
258  static bool HasWedgeNormal() { return true; }
259  static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeRealNormal"));T::Name(name);}
260 
261 private:
262  WedgeNormalType _wn[3];
263 };
264 
265 template <class TT> class WedgeRealNormal3s: public WedgeRealNormal<vcg::Point3s, TT> {
266 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeRealNormal2s"));TT::Name(name);}};
267 template <class TT> class WedgeRealNormal3f: public WedgeRealNormal<vcg::Point3f, TT> {
268 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeRealNormal2f"));TT::Name(name);}};
269 template <class TT> class WedgeRealNormal3d: public WedgeRealNormal<vcg::Point3d, TT> {
270 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeRealNormal2d"));TT::Name(name);}};
271 
272 template <class T> class Normal3s: public NormalAbs<vcg::Point3s, T> {
273 public:static void Name(std::vector<std::string> & name){name.push_back(std::string("Normal3s"));T::Name(name);}
274 };
275 template <class T> class Normal3f: public NormalAbs<vcg::Point3f, T> {
276 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Normal3f"));T::Name(name);}
277 };
278 template <class T> class Normal3d: public NormalAbs<vcg::Point3d, T> {
279 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Normal3d"));T::Name(name);}
280 };
281 
282 
283 /*-------------------------- TexCoord ----------------------------------------*/
284 
285 template <class A, class T> class WedgeTexCoord: public T {
286 public:
287  typedef int WedgeTexCoordType;
288  typedef A TexCoordType;
289  TexCoordType &WT(const int i) { return _wt[i]; }
290  TexCoordType cWT(const int i) const { return _wt[i]; }
291  template <class RightValueType>
292  void ImportData(const RightValueType & rightF){
293  if(rightF.IsWedgeTexCoordEnabled())
294  for (int i=0; i<3; ++i) { WT(i) = rightF.cWT(i); }
295  T::ImportData(rightF);
296  }
297  inline void Alloc(const int & ns){T::Alloc(ns);}
298  inline void Dealloc(){T::Dealloc();}
299  static bool HasWedgeTexCoord() { return true; }
300  static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeTexCoord"));T::Name(name);}
301 
302 private:
303  TexCoordType _wt[3];
304 };
305 
306 template <class TT> class WedgeTexCoord2s: public WedgeTexCoord<TexCoord2<short,1>, TT> {
307 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeTexCoord2s"));TT::Name(name);}
308 };
309 template <class TT> class WedgeTexCoord2f: public WedgeTexCoord<TexCoord2<float,1>, TT> {
310 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeTexCoord2f"));TT::Name(name);}
311 };
312 template <class TT> class WedgeTexCoord2d: public WedgeTexCoord<TexCoord2<double,1>, TT> {
313 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeTexCoord2d"));TT::Name(name);}
314 };
315 
316 /*------------------------- BitFlags -----------------------------------------*/
321 template <class T> class BitFlags: public T {
322 public:
323  BitFlags():_flags(0) {}
324  typedef int FlagType;
325  int &Flags() {return _flags; }
326  int cFlags() const {return _flags; }
327  template <class RightValueType>
328  void ImportData(const RightValueType & rightF){
329  if(RightValueType::HasFlags())
330  Flags() = rightF.cFlags();
331  T::ImportData(rightF);
332  }
333  inline void Alloc(const int & ns){T::Alloc(ns);}
334  inline void Dealloc(){T::Dealloc();}
335  static bool HasFlags() { return true; }
336  static void Name(std::vector<std::string> & name){name.push_back(std::string("BitFlags"));T::Name(name);}
337 
338 private:
339  int _flags;
340 };
341 
342 /*-------------------------- Color ----------------------------------*/
343 template <class A, class T> class Color: public T {
344 public:
345  typedef A ColorType;
346  Color():_color(vcg::Color4b::White) {}
347  ColorType &C() { return _color; }
348  ColorType cC() const { return _color; }
349  template <class RightValueType>
350  void ImportData(const RightValueType & rightF){
351  if(rightF.IsColorEnabled()) C() = rightF.cC();
352  T::ImportData(rightF);
353  }
354  inline void Alloc(const int & ns){T::Alloc(ns);}
355  inline void Dealloc(){T::Dealloc();}
356  static bool HasColor() { return true; }
357  static void Name(std::vector<std::string> & name){name.push_back(std::string("Color"));T::Name(name);}
358 
359 private:
360  ColorType _color;
361 };
362 
363 template <class A, class T> class WedgeColor: public T {
364 public:
365  typedef A WedgeColorType;
366  WedgeColorType &WC(int i) { return _color[i]; }
367  WedgeColorType cWC(int i) const { return _color[i]; }
368 
369  template <class RightValueType>
370  void ImportData(const RightValueType & rightF){
371  if (rightF.IsWedgeColorEnabled())
372  {
373  for (int i=0; i<3; ++i) { WC(i) = rightF.cWC(i); }
374  }
375  T::ImportData(rightF);
376 
377  }
378  static bool HasWedgeColor() { return true; }
379  static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeColor"));T::Name(name);}
380 
381 private:
382  WedgeColorType _color[3];
383 };
384 
385 template <class T> class WedgeColor4b: public WedgeColor<vcg::Color4b, T> {
386 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeColor4b"));T::Name(name);}
387 };
388 template <class T> class WedgeColor4f: public WedgeColor<vcg::Color4f, T> {
389 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("WedgeColor4f"));T::Name(name);}
390 };
391 template <class T> class Color4b: public Color<vcg::Color4b, T> { public:
392 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Color4b"));T::Name(name);}
393 };
394 
395 /*-------------------------- Quality ----------------------------------*/
396 template <class A, class T> class Quality: public T {
397 public:
398  typedef A QualityType;
399  Quality():_quality(0) {}
400  QualityType &Q() { return _quality; }
401  QualityType cQ() const { return _quality; }
402  template <class RightValueType>
403  void ImportData(const RightValueType & rightF){
404  if(rightF.IsQualityEnabled())
405  Q() = rightF.cQ();
406  T::ImportData(rightF);
407  }
408  inline void Alloc(const int & ns){T::Alloc(ns);}
409  inline void Dealloc(){T::Dealloc();}
410  static bool HasQuality() { return true; }
411  static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality"));T::Name(name);}
412 private:
413  QualityType _quality;
414 };
415 
416 template <class T> class Qualitys: public Quality<short, T> {
417 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Qualitys"));T::Name(name);}
418 };
419 template <class T> class Qualityf: public Quality<float, T> {
420 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Qualityf"));T::Name(name);}
421 };
422 template <class T> class Qualityd: public Quality<double, T> {
423 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Qualityd"));T::Name(name);}
424 };
425 
426 /*-------------------------- Quality3 ----------------------------------*/
427 template <class A, class T> class Quality3: public T {
428 public:
429  typedef vcg::Point3<A> Quality3Type;
430  Quality3Type &Q3() { return _quality; }
431  Quality3Type cQ3() const { return _quality; }
432  template <class RightValueType>
433  void ImportData(const RightValueType & rightF){
434  if(rightF.IsQuality3Enabled()) Q3() = rightF.cQ3();
435  T::ImportData(rightF);
436  }
437  inline void Alloc(const int & ns){T::Alloc(ns);}
438  inline void Dealloc(){T::Dealloc();}
439  static bool HasQuality3() { return true; }
440  static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality3"));T::Name(name);}
441 private:
442  Quality3Type _quality;
443 };
444 
445 template <class T> class Quality3s: public Quality3<short, T> {
446 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality3s"));T::Name(name);}
447 };
448 template <class T> class Quality3f: public Quality3<float, T> {
449 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality3f"));T::Name(name);}
450 };
451 template <class T> class Quality3d: public Quality3<double, T> {
452 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality3d"));T::Name(name);}
453 };
454 
455 /*-------------------------- INCREMENTAL MARK ----------------------------------------*/
461 template <class T> class Mark: public T {
462 public:
463  Mark():_imark(0){}
464  inline int &IMark() { return _imark;}
465  inline int cIMark() const { return _imark;}
466  inline void InitIMark() { _imark = 0; }
467  static bool HasMark() { return true; }
468  template <class RightValueType>
469  void ImportData(const RightValueType & rightF){
470  if(rightF.IsMarkEnabled())
471  IMark() = rightF.cIMark();
472  T::ImportData(rightF);
473  }
474  static void Name(std::vector<std::string> & name){name.push_back(std::string("Mark"));T::Name(name);}
475 
476 private:
477  int _imark;
478 };
479 
480 /*-------------------------- Curvature Direction ----------------------------------*/
481 template <class S>
482 struct CurvatureDirBaseType{
483  typedef Point3<S> CurVecType;
484  typedef S CurScalarType;
485  CurvatureDirBaseType () {}
486  Point3<S>max_dir,min_dir; // max and min curvature direction
487  S k1,k2;// max and min curvature values
488 };
489 
490 template <class A, class TT> class CurvatureDir: public TT {
491 public:
492  typedef A CurvatureDirType;
493  typedef typename CurvatureDirType::CurVecType CurVecType;
494  typedef typename CurvatureDirType::CurScalarType CurScalarType;
495 
496  CurVecType &PD1() { return _curv.max_dir;}
497  CurVecType &PD2() { return _curv.min_dir;}
498  CurVecType cPD1() const { return _curv.max_dir;}
499  CurVecType cPD2() const { return _curv.min_dir;}
500 
501  CurScalarType &K1() { return _curv.k1;}
502  CurScalarType &K2() { return _curv.k2;}
503  CurScalarType cK1() const {return _curv.k1;}
504  CurScalarType cK2() const {return _curv.k2;}
505  template < class RightValueType>
506  void ImportData(const RightValueType & rightF ) {
507  if(rightF.IsCurvatureDirEnabled()) {
508  PD1() = rightF.cPD1(); PD2() = rightF.cPD2();
509  K1() = rightF.cK1(); K2() = rightF.cK2();
510  }
511  TT::ImportData(rightF);
512  }
513 
514  static bool HasCurvatureDir() { return true; }
515  static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureDir"));TT::Name(name);}
516 
517 private:
518  CurvatureDirType _curv;
519 };
520 
521 
522 template <class T> class CurvatureDirf: public CurvatureDir<CurvatureDirBaseType<float>, T> {
523 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureDirf"));T::Name(name);}
524 };
525 template <class T> class CurvatureDird: public CurvatureDir<CurvatureDirBaseType<double>, T> {
526 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureDird"));T::Name(name);}
527 };
528 
529 /*----------------------------- VFADJ ------------------------------*/
546 template <class T> class VFAdj: public T {
547 public:
548  VFAdj(){
549  _vfp[0]=0;
550  _vfp[1]=0;
551  _vfp[2]=0;
552  _vfi[0]=-1;
553  _vfi[1]=-1;
554  _vfi[2]=-1;
555  }
556  typename T::FacePointer &VFp(const int j) { assert(j>=0 && j<3); return _vfp[j]; }
557  typename T::FacePointer cVFp(const int j) const { assert(j>=0 && j<3); return _vfp[j]; }
558  char &VFi(const int j) {return _vfi[j]; }
559  char cVFi(const int j)const {return _vfi[j]; }
560  template <class RightValueType>
561  void ImportData(const RightValueType & rightF){T::ImportData(rightF);}
562  inline void Alloc(const int & ns){T::Alloc(ns);}
563  inline void Dealloc(){T::Dealloc();}
564  static bool HasVFAdjacency() { return true; }
565  static void Name(std::vector<std::string> & name){name.push_back(std::string("VFAdj"));T::Name(name);}
566 
567 private:
568  typename T::FacePointer _vfp[3] ;
569  char _vfi[3] ;
570 };
571 
572 /*----------------------------- EFADJ ------------------------------*/
573 template <class T> class EFAdj: public T {
574 public:
575  EFAdj(){
576  _efp[0]=0;
577  _efp[1]=0;
578  _efp[2]=0;
579  _efi[0]=-1;
580  _efi[1]=-1;
581  _efi[2]=-1;
582  }
583  typename T::FacePointer &EFp(const int j) { assert(j>=0 && j<3); return _efp[j]; }
584  typename T::FacePointer cEFp(const int j) const { assert(j>=0 && j<3); return _efp[j]; }
585  char &VFi(const int j) {return _efi[j]; }
586  template <class RightValueType>
587  void ImportData(const RightValueType & rightF){T::ImportData(rightF);}
588  inline void Alloc(const int & ns){T::Alloc(ns);}
589  inline void Dealloc(){T::Dealloc();}
590  static bool HasEFAdjacency() { return true; }
591  static void Name(std::vector<std::string> & name){name.push_back(std::string("EFAdj"));T::Name(name);}
592 
593 private:
594  typename T::FacePointer _efp[3] ;
595  char _efi[3] ;
596 };
597 
598 
599 /*----------------------------- FFADJ ------------------------------*/
613 template <class T> class FFAdj: public T {
614 public:
615  FFAdj(){
616  _ffp[0]=0;
617  _ffp[1]=0;
618  _ffp[2]=0;
619  }
620  typename T::FacePointer &FFp(const int j) { assert(j>=0 && j<3); return _ffp[j]; }
621  typename T::FacePointer cFFp(const int j) const { assert(j>=0 && j<3); return _ffp[j]; }
622  char &FFi(const int j) { return _ffi[j]; }
623  char cFFi(const int j) const { return _ffi[j]; }
624 
625  typename T::FacePointer &FFp1( const int j ) { return FFp((j+1)%3);}
626  typename T::FacePointer &FFp2( const int j ) { return FFp((j+2)%3);}
627  typename T::FacePointer cFFp1( const int j ) const { return FFp((j+1)%3);}
628  typename T::FacePointer cFFp2( const int j ) const { return FFp((j+2)%3);}
629 
630  template <class RightValueType>
631  void ImportData(const RightValueType & rightF){T::ImportData(rightF);}
632  inline void Alloc(const int & ns){T::Alloc(ns);}
633  inline void Dealloc(){T::Dealloc();}
634  static bool HasFFAdjacency() { return true; }
635  static void Name(std::vector<std::string> & name){name.push_back(std::string("FFAdj"));T::Name(name);}
636 
637 private:
638  typename T::FacePointer _ffp[3] ;
639  char _ffi[3] ;
640 };
641 
642 
643 /*----------------------------- FEADJ ------------------------------*/
644 
645 template <class T> class FEAdj: public T {
646 public:
647  FEAdj(){
648  _fep[0]=0;
649  _fep[1]=0;
650  _fep[2]=0;
651  }
652 
653  typename T::EdgePointer &FEp( int j) { assert(j>=0 && j<3); return _fep[j]; }
654  typename T::EdgePointer cFEp( int j) const { assert(j>=0 && j<3); return _fep[j]; }
655 
656  typename T::EdgePointer &FEp1( int j ) { return FEp((j+1)%3);}
657  typename T::EdgePointer &FEp2( int j ) { return FEp((j+2)%3);}
658  typename T::EdgePointer FEp1( int j ) const { return FEp((j+1)%3);}
659  typename T::EdgePointer FEp2( int j ) const { return FEp((j+2)%3);}
660 
661  template <class RightValueType>
662  void ImportData(const RightValueType & rightF){T::ImportData(rightF);}
663  inline void Alloc(const int & ns){T::Alloc(ns);}
664  inline void Dealloc(){T::Dealloc();}
665  static bool HasFEAdjacency() { return true; }
666  static void Name(std::vector<std::string> & name){name.push_back(std::string("FEAdj"));T::Name(name);}
667 
668 private:
669  typename T::EdgePointer _fep[3] ;
670  char _fei[3] ;
671 };
672 
673 
674 /*----------------------------- FHADJ ------------------------------*/
675 template <class T> class FHAdj: public T {
676 public:
677  FHAdj(){_fh=0;}
678  typename T::HEdgePointer &FHp( ) { return _fh; }
679  typename T::HEdgePointer cFHp( ) const { return _fh; }
680 
681  template <class RightValueType>
682  void ImportData(const RightValueType & rightF){T::ImportData(rightF);}
683  inline void Alloc(const int & ns){T::Alloc(ns);}
684  inline void Dealloc(){T::Dealloc();}
685  static bool HasFHAdjacency() { return true; }
686  static void Name(std::vector<std::string> & name){name.push_back(std::string("FHAdj"));T::Name(name);}
687 
688 private:
689  typename T::HEdgePointer _fh ;
690 }; // End Doxygen FaceComponentGroup
692  } // end namespace face
693 }// end namespace vcg
694 #endif