$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_EDGE_PLUS_COMPONENT
25 #define __VCG_EDGE_PLUS_COMPONENT
26 
27 #include <cassert>
28 #include <vector>
29 #include <string>
30 
31 #include <vcg/space/color4.h>
32 
33 
34 namespace vcg {
35 namespace edge {
36 
41 /*
42 Some naming Rules
43 All the Components that can be added to a vertex should be defined in the namespace edge:
44 
45 */
46 /*------------------------- EMPTY CORE COMPONENTS -----------------------------------------*/
47 
48 template <class T> class EmptyCore: public T
49 {
50 public:
51  inline typename T::VertexType * & V( const int j ) { (void)j; assert(0); static typename T::VertexType *vp=0; return vp; }
52  inline typename T::VertexType * const & V( const int j ) const { (void)j; assert(0); static typename T::VertexType *vp=0; return vp; }
53  inline typename T::VertexType * cV( const int j ) const { (void)j; assert(0); static typename T::VertexType *vp=0; return vp; }
54  inline typename T::CoordType & P( const int j ) { (void)j; assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
55  inline const typename T::CoordType & P( const int j ) const { (void)j; assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
56  inline const typename T::CoordType & cP( const int j ) const { (void)j; assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
57  static bool HasEVAdjacency() { return false; }
58  static bool HasVertexRef() { return false; }
59 
60  typedef vcg::Color4b ColorType;
61  ColorType &C() { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; }
62  ColorType cC() const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; }
63  static bool HasColor() { return false; }
64  inline bool IsColorEnabled() const { return T::EdgeType::HasColor(); }
65 
66 
67  typedef float QualityType;
68  QualityType &Q() { static QualityType dummyQuality(0); assert(0); return dummyQuality; }
69  QualityType cQ() const { static QualityType dummyQuality(0); assert(0); return dummyQuality; }
70  static bool HasQuality() { return false; }
71  inline bool IsQualityEnabled() const { return T::EdgeType::HasQuality(); }
72 
73  typedef int MarkType;
74  inline void InitIMark() { }
75  inline int cIMark() const { assert(0); static int tmp=-1; return tmp;}
76  inline int &IMark() { assert(0); static int tmp=-1; return tmp;}
77  static bool HasMark() { return false; }
78  inline bool IsMarkEnabled( ) const { return T::EdgeType::HasMark(); }
79 
80 
81  typedef int FlagType;
82  int &Flags() { static int dummyflags(0); assert(0); return dummyflags; }
83  int Flags() const { return 0; }
84  static bool HasFlags() { return false; }
85 
86  typename T::EdgePointer &VEp(const int & ) { static typename T::EdgePointer ep=0; assert(0); return ep; }
87  typename T::EdgePointer cVEp(const int & ) const { static typename T::EdgePointer ep=0; assert(0); return ep; }
88  int &VEi(const int &){static int z=0; assert(0); return z;}
89  int VEi(const int &) const {static int z=0; assert(0); return z;}
90  int cVEi(const int &) const {static int z=0; assert(0); return z;}
91  static bool HasVEAdjacency() { return false; }
92 
93  typename T::EdgePointer &EEp(const int & ) { static typename T::EdgePointer ep=0; assert(0); return ep; }
94  typename T::EdgePointer cEEp(const int & ) const { static typename T::EdgePointer ep=0; assert(0); return ep; }
95  int &EEi(const int &){static int z=0; assert(0); return z;}
96  int cEEi(const int &) const {static int z=0; assert(0); return z;}
97  static bool HasEEAdjacency() { return false; }
98 
99  typename T::HEdgePointer &EHp( ) { static typename T::HEdgePointer hp=0; assert(0); return hp; }
100  typename T::HEdgePointer cEHp( ) const { static typename T::HEdgePointer hp=0; assert(0); return hp; }
101  static bool HasEHAdjacency() { return false; }
102 
103  typename T::FacePointer &EFp() { static typename T::FacePointer fp=0; assert(0); return fp; }
104  typename T::FacePointer cEFp() const { static typename T::FacePointer fp=0; assert(0); return fp; }
105  int &EFi() {static int z=0; return z;}
106  int &cEFi() const {static int z=0; return z;}
107  static bool HasEFAdjacency() { return false; }
108 
109  template <class LeftF>
110  void ImportData(const LeftF & leftF) {T::ImportData(leftF);}
111  static void Name(std::vector<std::string> & name){T::Name(name);}
112 };
113 
114 /*-------------------------- VertexRef ----------------------------------------*/
120 template <class T> class VertexRef: public T {
121 public:
122  VertexRef(){
123  v[0]=0;
124  v[1]=0;
125  }
126 
127  typedef typename T::VertexType::CoordType CoordType;
128  typedef typename T::VertexType::ScalarType ScalarType;
129 
130  inline typename T::VertexType * & V( const int j ) { assert(j>=0 && j<2); return v[j]; }
131  inline typename T::VertexType * const & V( const int j ) const { assert(j>=0 && j<2); return v[j]; }
132  inline typename T::VertexType * cV( const int j ) const { assert(j>=0 && j<2); return v[j]; }
133 
135  inline CoordType & P( const int j ) { assert(j>=0 && j<2); return v[j]->P();}
136  inline const CoordType & P( const int j ) const { assert(j>=0 && j<2); return v[j]->P();}
137  inline const CoordType & cP( const int j ) const { assert(j>=0 && j<2); return v[j]->P();}
138 
142  inline typename T::VertexType * & V0( const int j ) { return V(j);}
143  inline typename T::VertexType * & V1( const int j ) { return V((j+1)%2);}
144  inline const typename T::VertexType * const & V0( const int j ) const { return V(j);}
145  inline const typename T::VertexType * const & V1( const int j ) const { return V((j+1)%2);}
146  inline const typename T::VertexType * const & cV0( const int j ) const { return cV(j);}
147  inline const typename T::VertexType * const & cV1( const int j ) const { return cV((j+1)%2);}
148 
150  inline CoordType & P0( const int j ) { return V(j)->P();}
151  inline CoordType & P1( const int j ) { return V((j+1)%2)->P();}
152  inline const CoordType & P0( const int j ) const { return V(j)->P();}
153  inline const CoordType & P1( const int j ) const { return V((j+1)%2)->P();}
154  inline const CoordType & cP0( const int j ) const { return cV(j)->P();}
155  inline const CoordType & cP1( const int j ) const { return cV((j+1)%2)->P();}
156 
157  template <class LeftF>
158  void ImportData(const LeftF & leftF){ T::ImportData(leftF);}
159 
160  static bool HasEVAdjacency() { return true; }
161  static bool HasVertexRef() { return true; }
162  static void Name(std::vector<std::string> & name){name.push_back(std::string("VertexRef"));T::Name(name);}
163 
164 
165 private:
166  typename T::VertexType *v[2];
167 };
168 
169 template <class T> class EVAdj : public VertexRef<T>{};
170 
171 
172 /*-------------------------- INCREMENTAL MARK ----------------------------------------*/
173 
178 template <class T> class Mark: public T {
179 public:
180  Mark():_imark(0){}
181  static bool HasMark() { return true; }
182  static bool HasMarkOcc() { return true; }
183  inline void InitIMark() { _imark = 0; }
184  inline int & IMark() { return _imark;}
185  inline int cIMark() const { return _imark;}
186 
187  template < class RightValueType>
188  void ImportData(const RightValueType & rightE )
189  {
190  if(rightE.IsMarkEnabled())
191  IMark() = rightE.cIMark();
192  T::ImportData(rightE);
193  }
194  static void Name(std::vector<std::string> & name){name.push_back(std::string("Mark"));T::Name(name);}
195 
196 private:
197  int _imark;
198 };
199 
200 /*------------------------- FLAGS -----------------------------------------*/
205 template <class T> class BitFlags: public T {
206 public:
207  BitFlags(){_flags=0;}
208  typedef int FlagType;
209  int &Flags() {return _flags; }
210  int Flags() const {return _flags; }
211  template < class LeftV>
212  void ImportData(const LeftV & left ) { Flags() = left.Flags(); T::ImportData( left); }
213  static bool HasFlags() { return true; }
214  static void Name(std::vector<std::string> & name){name.push_back(std::string("BitFlags"));T::Name(name);}
215 
216 private:
217  int _flags;
218 };
219 
220 /*-------------------------- Color ----------------------------------*/
226 template <class A, class T> class Color: public T {
227 public:
228  Color():_color(vcg::Color4b::White) {}
229  typedef A ColorType;
230  ColorType &C() { return _color; }
231  const ColorType &C() const { return _color; }
232  const ColorType &cC() const { return _color; }
233  template < class LeftV>
234  void ImportData(const LeftV & left ) { if (left.IsColorEnabled()) C() = left.cC(); T::ImportData( left); }
235  static bool HasColor() { return true; }
236  static void Name(std::vector<std::string> & name){name.push_back(std::string("Color"));T::Name(name);}
237 
238 private:
239  ColorType _color;
240 };
241 
242 template <class TT> class Color4b: public edge::Color<vcg::Color4b, TT> {
243 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Color4b"));TT::Name(name);}
244 };
245 
246 /*-------------------------- Quality ----------------------------------*/
253 template <class A, class TT> class Quality: public TT {
254 public:
255  typedef A QualityType;
256  QualityType &Q() { return _quality; }
257  const QualityType & cQ() const {return _quality; }
258  template < class LeftV>
259  void ImportData(const LeftV & left ) { if (left.IsQualityEnabled()) Q() = left.cQ(); TT::ImportData( left); }
260  static bool HasQuality() { return true; }
261  static void Name(std::vector<std::string> & name){name.push_back(std::string("Quality"));TT::Name(name);}
262 
263 private:
264  QualityType _quality;
265 };
266 
267 template <class TT> class Qualitys: public Quality<short, TT> {
268 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Qualitys"));TT::Name(name);}
269 };
270 template <class TT> class Qualityf: public Quality<float, TT> {
271 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Qualityf"));TT::Name(name);}
272 };
273 template <class TT> class Qualityd: public Quality<double, TT> {
274 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("Qualityd"));TT::Name(name);}
275 };
276 
277 /*----------------------------- VEADJ ------------------------------*/
285 template <class T> class VEAdj: public T {
286 public:
287  VEAdj(){_ep[0]=0;_ep[1]=0;_zp[0]=-1;_zp[1]=-1;}
288  typename T::EdgePointer &VEp(const int & i) {return _ep[i]; }
289  typename T::EdgePointer cVEp(const int & i) const {return _ep[i]; }
290  int &VEi(const int & i){ return _zp[i];}
291  int VEi(const int & i)const {return _zp[i];}
292  int cVEi(const int &i )const {return _zp[i];}
293 
294  template < class LeftV>
295  void ImportData(const LeftV & left ) { T::ImportData( left); }
296  static bool HasVEAdjacency() { return true; }
297  static bool HasVEAdjacencyOcc() { return true; }
298  static void Name(std::vector<std::string> & name){name.push_back(std::string("VEAdj"));T::Name(name);}
299 
300 private:
301  typename T::EdgePointer _ep[2] ;
302  int _zp[2] ;
303 };
304 
305 /*----------------------------- EEADJ ------------------------------*/
319 template <class T> class EEAdj: public T {
320 public:
321  EEAdj(){_ep[0]=0;_ep[1]=0;_zp[0]=-1;_zp[1]=-1;}
322  typename T::EdgePointer &EEp(const int & i) {return _ep[i]; }
323  typename T::EdgePointer cEEp(const int & i) const {return _ep[i]; }
324  int &EEi(const int & i){ return _zp[i];}
325  int cEEi(const int &i )const {return _zp[i];}
326 
327  template < class LeftV>
328  void ImportData(const LeftV & left ) { T::ImportData( left); }
329  static bool HasEEAdjacency() { return true; }
330  static bool HasEEAdjacencyOcc() { return true; }
331  static void Name(std::vector<std::string> & name){name.push_back(std::string("EEAdj"));T::Name(name);}
332 
333 private:
334  typename T::EdgePointer _ep[2] ;
335  int _zp[2] ;
336 };
337 
338 /*----------------------------- EHADJ ------------------------------*/
339 template <class T> class EHAdj: public T {
340 public:
341  EHAdj(){_hp=0;}
342  typename T::HEdgePointer &EHp( ) {return _hp ; }
343  const typename T::HEdgePointer cEHp( ) const {return _hp ; }
344 
345  template < class LeftV>
346  void ImportData(const LeftV & left ) { T::ImportData( left); }
347  static bool HasEHAdjacency() { return true; }
348  static bool HasEHAdjacencyOcc() { return true; }
349  static void Name(std::vector<std::string> & name){name.push_back(std::string("EHAdj"));T::Name(name);}
350 
351 private:
352  typename T::HEdgePointer _hp ;
353 };
354 
355 /*----------------------------- EFADJ ------------------------------*/
363 template <class T> class EFAdj: public T {
364 public:
365  EFAdj(){_fp=0;}
366  typename T::FacePointer &EFp() {return _fp; }
367  typename T::FacePointer cEFp() const {return _fp; }
368  int &EFi() {return _zp; }
369  int cEFi() const {return _zp; }
370  template < class LeftV>
371  void ImportData(const LeftV & left ) { T::ImportData( left); }
372  static bool HasEFAdjacency() { return true; }
373  static bool HasEFAdjacencyOcc() { return true; }
374  static void Name(std::vector<std::string> & name){name.push_back(std::string("EFAdj"));T::Name(name);}
375 
376 private:
377  typename T::FacePointer _fp ;
378  int _zp ;
379 };
380  // End Doxygen EdgeComponentGroup
382 } // end namespace edge
383 }// end namespace vcg
384 #endif
Definition: color4.h:41
Component: Per edge Flags
Definition: component.h:205
Definition: component.h:242
Component: Per edge Color
Definition: component.h:226
Component: Edge-Edge adjacency relation This component implement store the pointer (and index) of the...
Definition: component.h:319
Component: Edge-Face adjacency relation This component implement store the pointer to a face sharing ...
Definition: component.h:363
Definition: component.h:339
Definition: component.h:169
Definition: component.h:49
Component: Per edge Incremental Mark
Definition: component.h:178
Component: Per edge quality
Definition: component.h:253
Definition: component.h:273
Definition: component.h:270
Definition: component.h:267
Component: Per vertex Vertex-Edge adjacency relation companion component This component implement one...
Definition: component.h:285
The references to the two vertexes of a edge.
Definition: component.h:120
CoordType & P0(const int j)
Shortcuts to access points.
Definition: component.h:150
T::VertexType *& V0(const int j)
Definition: component.h:142
CoordType & P(const int j)
Shortcuts to access points.
Definition: component.h:135
Definition: namespaces.dox:6