DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
MeshFromPoints.ih
1 
30 
31 
32 #include <cstdlib>
34 
36 // IMPLEMENTATION of inline methods.
38 
40 // ----------------------- Standard services ------------------------------
41 
45 template <typename TPoint>
46 inline
48 {
49  mySaveFaceColor=saveFaceColor;
50  myDefaultColor = DGtal::Color::White;
51 }
52 
56 template <typename TPoint>
57 inline
59 {
60  mySaveFaceColor=false;
61  myDefaultColor = aColor;
62 }
63 
67 template <typename TPoint>
68 inline
70 {
71 }
72 
74 // Interface - public :
75 
80 template <typename TPoint>
81 inline
82 void
83 DGtal::MeshFromPoints<TPoint>::selfDisplay ( std::ostream & out ) const
84 {
85  out << "[MeshFromPoints]";
86 }
87 
92 template <typename TPoint>
93 inline
94 bool
96 {
97  return true;
98 }
99 
100 
101 
102 
104 // Implementation of inline functions //
105 
106 
107 
108 
109 
110 
111 
112 template<typename TPoint>
113 inline
114 DGtal::MeshFromPoints<TPoint>::MeshFromPoints(const vector<TPoint> &vertexSet)
115 {
116  mySaveFaceColor=false;
117  for(int i =0; i< vertexSet.size(); i++){
118  myVertexList.push_back(vertexSet.at(i));
119  }
120 
121 }
122 
123 
124 
125 template<typename TPoint>
126 inline
127 void
129 {
130  myVertexList.push_back(point);
131 }
132 
133 
134 
135 template<typename TPoint>
136 inline
137 void
138 DGtal::MeshFromPoints<TPoint>::addTriangularFace(unsigned int indexVertex1, unsigned int indexVertex2,
139  unsigned int indexVertex3, const DGtal::Color &aColor)
140 {
141  MeshFace aFace;
142  aFace.push_back(indexVertex1);
143  aFace.push_back(indexVertex2);
144  aFace.push_back(indexVertex3);
145  myFaceList.push_back(aFace);
146  if(mySaveFaceColor){
147  myFaceColorList.push_back(aColor);
148  }
149 }
150 
151 
152 
153 
154 template<typename TPoint>
155 inline
156 void
157 DGtal::MeshFromPoints<TPoint>::addQuadFace(unsigned int indexVertex1, unsigned int indexVertex2,
158  unsigned int indexVertex3, unsigned int indexVertex4,
159  const DGtal::Color &aColor)
160 {
161  MeshFace aFace;
162  aFace.push_back(indexVertex1);
163  aFace.push_back(indexVertex2);
164  aFace.push_back(indexVertex3);
165  aFace.push_back(indexVertex4);
166  myFaceList.push_back(aFace);
167  if(mySaveFaceColor){
168  myFaceColorList.push_back(aColor);
169  }
170 }
171 
172 
173 
174 template<typename TPoint>
175 inline
176 void
178  myFaceList.push_back(aFace);
179  if(mySaveFaceColor){
180  myFaceColorList.push_back(aColor);
181  }
182 
183 
184 }
185 
186 
187 template<typename TPoint>
188 inline
189 const TPoint &
191 {
192  return myVertexList.at(i);
193 }
194 
195 
196 
197 template<typename TPoint>
198 inline
201 {
202  return myFaceList.at(i);
203 }
204 
205 
206 template<typename TPoint>
207 inline
208 unsigned int
210 {
211  return myFaceList.size();
212 }
213 
214 template<typename TPoint>
215 inline
216 unsigned int
218 {
219  return myVertexList.size();
220 }
221 
222 template<typename TPoint>
223 inline
224 const DGtal::Color &
226  if(mySaveFaceColor){
227  return myFaceColorList.at(i);
228  }else{
229  return myDefaultColor;
230  }
231 }
232 
233 
234 
235 
236 template<typename TPoint>
237 inline
238 void
240  for(unsigned int i=0; i<myFaceList.size(); i++){
241  vector<unsigned int> & aFace = myFaceList.at(i);
242  for(unsigned int j=0; j < aFace.size()/2; j++){
243  unsigned int tmp=aFace.at(j);
244  aFace.at(j)=aFace.at(aFace.size()-1-j);
245  aFace.at(aFace.size()-1-j)=tmp;
246  }
247  }
248 }
249 
250 
251 
252 //------------------------------------------------------------------------------
253 template<typename TPoint>
254 inline
255 std::string
257 {
258  return "MeshFromPoints";
259 }
260 
261 
262 
263 
264 
265 template <typename TPoint>
266 inline
267 std::ostream&
268 DGtal::operator<< ( std::ostream & out,
269  const MeshFromPoints<TPoint> & object )
270 {
271  object.selfDisplay( out );
272  return out;
273 }
274 
275 // //
277 
278