File: component_occ.h

package info (click to toggle)
meshlab 1.3.2%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 21,096 kB
  • ctags: 33,630
  • sloc: cpp: 224,813; ansic: 8,170; xml: 119; makefile: 80
file content (268 lines) | stat: -rw-r--r-- 11,553 bytes parent folder | download | duplicates (4)
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
/****************************************************************************
* VCGLib                                                            o o     *
* Visual and Computer Graphics Library                            o     o   *
*                                                                _   O  _   *
* Copyright(C) 2004                                                \/)\/    *
* Visual Computing Lab                                            /\/|      *
* ISTI - Italian National Research Council                           |      *
*                                                                    \      *
* All rights reserved.                                                      *
*                                                                           *
* This program is free software; you can redistribute it and/or modify      *   
* it under the terms of the GNU General Public License as published by      *
* the Free Software Foundation; either version 2 of the License, or         *
* (at your option) any later version.                                       *
*                                                                           *
* This program is distributed in the hope that it will be useful,           *
* but WITHOUT ANY WARRANTY; without even the implied warranty of            *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)          *
* for more details.                                                         *
*                                                                           *
****************************************************************************/
/****************************************************************************
  History

$Log: not supported by cvs2svn $
Revision 1.2  2007/03/12 15:37:21  tarini
Texture coord name change!  "TCoord" and "Texture" are BAD. "TexCoord" is GOOD.

Revision 1.1  2005/10/15 16:24:10  ganovelli
Working release (compilata solo su MSVC), component_occ � migrato da component_opt



****************************************************************************/
#ifndef __VCG_VERTEX_PLUS_COMPONENT_OCC
#define __VCG_VERTEX_PLUS_COMPONENT_OCC

#include <vcg/simplex/vertex/component.h>
#include <vcg/container/vector_occ.h>


namespace vcg {
  namespace vertex {
/*
Some naming Rules
All the Components that can be added to a vertex should be defined in the namespace vert:

*/

/*------------------------- COORD -----------------------------------------*/ 

template <class A, class T> class CoordOcc: public T {
public:
  typedef A CoordType;
  typedef typename CoordType::ScalarType      ScalarType;
	typedef typename T::VertType VertType;
	CoordType &P() { return CAT< vector_occ<VertType>,CoordType>::Instance()->Get((VertType*)this); }
  CoordType &UberP() { return CAT< vector_occ<VertType>,CoordType>::Instance()->Get((VertType*)this); }
};
template <class T> class Coord3fOcc: public CoordOcc<vcg::Point3f, T> {};
template <class T> class Coord3dOcc: public CoordOcc<vcg::Point3d, T> {};


/*-------------------------- NORMAL ----------------------------------------*/ 

template <class A, class T> class NormalOcc: public T {
public:
  typedef A NormalType;
	typedef typename T::VertType VertType;
  NormalType &N() {return CAT< vector_occ<VertType>,NormalType>::Instance()->Get((VertType*)this); }
/*private:
  NormalType _norm;   */ 
};

template <class T> class Normal3sOcc: public NormalOcc<vcg::Point3s, T> {};
template <class T> class Normal3fOcc: public NormalOcc<vcg::Point3f, T> {};
template <class T> class Normal3dOcc: public NormalOcc<vcg::Point3d, T> {};

/*-------------------------- TEXCOORD ----------------------------------------*/ 

template <class A, class TT> class TexCoordOcc: public TT {
public:
  typedef A TexCoordType;
	typedef typename TT::VertType VertType;
  TexCoordType &T() {return CAT< vector_occ<VertType>,TexCoordType>::Instance()->Get((VertType*)this); }
  static bool HasTexCoord()   { return true; }
  static bool HasTexCoordOcc()   { return true; }

/* private:
  TexCoordType _t;   */ 
};

template <class T> class TexCoord2sOcc: public TexCoordOcc<TexCoord2<short,1>, T> {};
template <class T> class TexCoord2fOcc: public TexCoordOcc<TexCoord2<float,1>, T> {};
template <class T> class TexCoord2dOcc: public TexCoordOcc<TexCoord2<double,1>, T> {};

///*------------------------- FLAGS -----------------------------------------*/ 

template <class T> class FlagOcc:  public T {
public:
	typedef typename T::VertType VertType;
   int &Flags() {return CAT< vector_occ<VertType>,int>::Instance()->Get((VertType*)this); }
   const int Flags() const {return CAT< vector_occ<VertType>,int>::Instance()->Get((VertType*)this); }
	static bool HasFlags() {return true;}	
	static bool HasFlagsOcc() {return true;}	


};

///*-------------------------- COLOR ----------------------------------*/ 

template <class A, class T> class ColorOcc: public T {
public:
  typedef A ColorType;
	typedef typename T::VertType VertType;
  ColorType &C() { return CAT< vector_occ<VertType>,ColorType>::Instance()->Get((VertType*)this); }
  static bool HasColor()   { return true; }
/*private:
  ColorType _color;   */ 
};

template <class T> class Color4bOcc: public ColorOcc<vcg::Color4b, T> {};

///*-------------------------- Quality  ----------------------------------*/ 

template <class A, class T> class QualityOcc: public T {
public:
  typedef A QualityType;
	typedef typename T::VertType VertType;
  QualityType &Q() { return CAT< vector_occ<VertType>,QualityType>::Instance()->Get((VertType*)this);}
  static bool HasQuality()   { return true; }

/*private:
  QualityType _quality;  */  
};

template <class T> class QualitysOcc: public QualityOcc<short, T> {};
template <class T> class QualityfOcc: public QualityOcc<float, T> {};
template <class T> class QualitydOcc: public QualityOcc<double, T> {};
//

///*-------------------------- Curvature  ----------------------------------*/ 

template <class A, class TT> class CurvatureOcc: public TT {
public:
  typedef Point2<A> CurvatureTypeOcc;
	typedef typename TT::VertType VertType;
	typedef typename CurvatureTypeOcc::ScalarType ScalarType;

	ScalarType  &H(){  return CAT< vector_occ<VertType>,CurvatureTypeOcc>::Instance()->Get((VertType*)this)[0];}
	ScalarType  &K(){  return CAT< vector_occ<VertType>,CurvatureTypeOcc>::Instance()->Get((VertType*)this)[1];}
	const ScalarType &cH() const { return CAT< vector_occ<VertType>,CurvatureTypeOcc>::Instance()->Get((VertType*)this)[0];}
	const ScalarType &cK() const { return CAT< vector_occ<VertType>,CurvatureTypeOcc>::Instance()->Get((VertType*)this)[1];}

 	template <class LeftV>
	void ImportData(const LeftV & leftV){
			CAT< vector_occ<VertType>,CurvatureTypeOcc>::Instance()->Get((VertType*)this)[0] = leftV.cH();
			CAT< vector_occ<VertType>,CurvatureTypeOcc>::Instance()->Get((VertType*)this)[1] = leftV.cK();
			TT::ImporLocal(leftV);
	}

	static bool HasCurvature()   { return true; }
	static bool HasCurvatureOcc()   { return true; }
	static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureOcc"));TT::Name(name);}

private:   
};

template <class T> class CurvaturefOcc: public CurvatureOcc<float, T> {
	static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvaturefOcc"));T::Name(name);}
};
template <class T> class CurvaturedOcc: public CurvatureOcc<double, T> {
	static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvaturedOcc"));T::Name(name);}
};


/*-------------------------- Curvature Direction ----------------------------------*/ 

template <class S>
struct CurvatureDirTypeOcc{
	typedef Point3<S> VecType;
	typedef  S   ScalarType;
	CurvatureDirTypeOcc () {}
	Point3<S>max_dir,min_dir; // max and min curvature direction 
	S k1,k2;// max and min curvature values
};


template <class A, class TT> class CurvatureDirOcc: public TT {
public:
  typedef A CurvatureDirTypeOcc;
	typedef typename CurvatureDirTypeOcc::VecType VecType;
	typedef typename CurvatureDirTypeOcc::ScalarType ScalarType;
	typedef typename TT::VertType VertType;

	VecType &PD1(){ return CAT< vector_occ<VertType>,CurvatureDirTypeOcc>::Instance()->Get((VertType*)this).max_dir;}
	VecType &PD2(){ return CAT< vector_occ<VertType>,CurvatureDirTypeOcc>::Instance()->Get((VertType*)this).min_dir;}
	const VecType &cPD1() const {return CAT< vector_occ<VertType>,CurvatureDirTypeOcc>::Instance()->Get((VertType*)this).max_dir;}
	const VecType &cPD2() const {return CAT< vector_occ<VertType>,CurvatureDirTypeOcc>::Instance()->Get((VertType*)this).min_dir;}

	ScalarType &K1(){ return CAT< vector_occ<VertType>,CurvatureDirTypeOcc>::Instance()->Get((VertType*)this).k1;}
	ScalarType &K2(){ return CAT< vector_occ<VertType>,CurvatureDirTypeOcc>::Instance()->Get((VertType*)this).k2;}
	const ScalarType &cK1() const {return CAT< vector_occ<VertType>,CurvatureDirTypeOcc>::Instance()->Get((VertType*)this).k1;}
	const ScalarType &cK2()const  {return CAT< vector_occ<VertType>,CurvatureDirTypeOcc>::Instance()->Get((VertType*)this).k2;}

  static bool HasCurvatureDir()   { return true; }
  static bool HasCurvatureDirOcc()   { return true; }
	static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureDir"));TT::Name(name);}

};


template <class T> class CurvatureDirfOcc: public CurvatureDirOcc<CurvatureDirTypeOcc<float>, T> {
public:	static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureDirf"));T::Name(name);}
};
template <class T> class CurvatureDirdOcc: public CurvatureDirOcc<CurvatureDirTypeOcc<double>, T> {
public:	static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureDird"));T::Name(name);}
};

/*-------------------------- RADIUS ----------------------------------*/

template <class A, class TT> class RadiusOcc: public TT {
public:
  typedef A RadiusType;
  typedef A ScalarType;
  typedef typename TT::VertType VertType;

  RadiusType  &R(){  return CAT< vector_occ<VertType>,RadiusType>::Instance()->Get((VertType*)this);}
  const RadiusType &cR() const { return CAT< vector_occ<VertType>,RadiusType>::Instance()->Get((VertType*)this);}

  template <class LeftV>
	void ImportData(const LeftV & leftV){
    CAT< vector_occ<VertType>,RadiusType>::Instance()->Get((VertType*)this) = leftV.cR();
    TT::ImporLocal(leftV);
  }

  static bool HasRadius()     { return true; }
  static bool HasRadiusOcc()  { return true; }
  static void Name(std::vector<std::string> & name){name.push_back(std::string("RadiusOcc"));TT::Name(name);}

private:   
};

template <class T> class RadiusfOcc: public RadiusOcc<float, T> {
  static void Name(std::vector<std::string> & name){name.push_back(std::string("RadiusfOcc"));T::Name(name);}
};
template <class T> class RadiusdOcc: public RadiusOcc<double, T> {
  static void Name(std::vector<std::string> & name){name.push_back(std::string("RadiusdOcc"));T::Name(name);}
};

///*----------------------------- VFADJ ------------------------------*/ 

template <class T> class VFAdjOcc: public T {
public:
	typedef typename T::VertType VertType;
	typedef typename T::FacePointer FacePointer;	
 FacePointer &Fp() {return CAT< vector_occ<VertType>,FacePointer>::Instance()->Get((VertType*)this); }
  int &Zp() {return _zp; }
  static bool HasVFAdjacency()   {   return true; }
private:
  typename T::FacePointer _fp ;    
  int _zp ;    
};

  } // end namespace vert
}// end namespace vcg
#endif