MEPP2 Project
AIFMesh.inl
Go to the documentation of this file.
1 // Copyright (c) 2012-2019 University of Lyon and CNRS (France).
2 // All rights reserved.
3 //
4 // This file is part of MEPP2; you can redistribute it and/or modify
5 // it under the terms of the GNU Lesser General Public License as
6 // published by the Free Software Foundation; either version 3 of
7 // the License, or (at your option) any later version.
8 //
9 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11 #include "FEVV/DataStructures/AIF/AIFTopologyHelpers.h" // for copy constructor
12 #include "FEVV/DataStructures/AIF/AIFPropertiesHelpers.h" // for copy constructor
13 
14 namespace FEVV {
15 namespace DataStructures {
16 namespace AIF {
17 
18 inline
20 {
21  AddPropertyMap< AIFVertex::ptr, Point >(
22  "v:point"); // create vertex coordinates property map (mandatory, else
23  // cannot set vertex positions)
24 }
25 
26 inline
27 AIFMesh::AIFMesh(const Self &other)
28 {
29  this->operator=(other);
30 }
31 
32 inline
34 {
35  this->clear();
36 }
37 
38 inline
40 AIFMesh::operator=(const Self &other)
41 {
42  if(this==&other)
43  return *this;
45  this->clear();
48  typedef AIFPropertiesHelpers PropHelpers;
49  typedef helpers::vertex_container::const_iterator vertex_iterator;
50  typedef boost::iterator_range< vertex_iterator > vertex_range;
51  typedef helpers::edge_container::const_iterator edge_iterator;
52  typedef boost::iterator_range< edge_iterator > edge_range;
53  typedef helpers::face_container::const_iterator face_iterator;
54  typedef boost::iterator_range< face_iterator > face_range;
55  typedef helpers::vertex_container_in_face::const_iterator
56  vertex_face_iterator;
57  typedef boost::iterator_range< vertex_face_iterator > vertex_face_range;
58 
59  typedef AIFMesh::CoordinateType coord_type; // position coordinate type
60  typedef AIFMesh::NormalCoordinateType coordN_type; // normal coordinate type
61  typedef AIFMesh::CoordinateType coordC_type; // color coordinate type
62  typedef AIFMesh::CoordinateType coordT_type; // texture coordinate type
63  typedef unsigned long index_type;
64 
65  std::vector< std::vector< coord_type > > points_coords;
66  std::vector< std::vector< coordN_type > > normals_coords;
67  std::vector< std::vector< coordT_type > > texture_coords;
68  std::vector< std::vector< coordC_type > > vertex_color_coords;
69  std::vector< std::vector< coordC_type > > face_color_coords;
70  std::vector< std::vector< index_type > > lines_indices, faces_indices;
71  std::vector< std::vector< index_type > > texture_face_indices;
72  std::vector< std::vector< index_type > > normal_face_indices;
73  std::vector< std::vector< coordC_type > > line_color_coords;
74  std::vector< std::vector< std::vector< double > > > field_attributes ;
75  std::vector< std::string > field_names ;
76  // std::vector< Material > materials;
77  std::string texture_file_name;
78 
79  bool useVertexNormal = false;
80  bool useVertexColor = false;
81  bool useVertexTextureCoord = false;
82  bool useVertexDatafield = false;
83  bool useFaceDatafield = false;
84 
85  AddPropertyMap< AIFVertex::ptr, Point >(
86  "v:point"); // create vertex coordinates property map (mandatory, else
87  // cannot set vertex positions)
88 
89  if(other.isPropertyMap< AIFVertex::ptr >("v:normal"))
90  useVertexNormal = true;
91  if(other.isPropertyMap< AIFVertex::ptr >("v:color"))
92  useVertexColor = true;
93  if(other.isPropertyMap< AIFVertex::ptr >("v:texcoord"))
94  useVertexTextureCoord = true;
95 
96  bool useLineColor = false;
97  if(other.isPropertyMap< AIFEdge::ptr >("e:color"))
98  useLineColor = true;
99 
100  bool useFaceColor = false;
101  if(other.isPropertyMap< AIFFace::ptr >("f:color"))
102  useFaceColor = true;
103 
104  if (other.isAPropertyMapStartingWithPrefix< AIFVertex::ptr >("v:datafield:"))
105  useVertexDatafield = true;
106  if (other.isAPropertyMapStartingWithPrefix< AIFFace::ptr >("f:datafield:"))
107  useFaceDatafield = true;
108 
109  std::vector<std::string> dfv_names = other.GetPropertyMapNamesStartingWithPrefix< AIFVertex::ptr >("v:datafield:");
110  std::vector<std::string> dff_names = other.GetPropertyMapNamesStartingWithPrefix< AIFFace::ptr >("f:datafield:");
111 
112  //unused unsigned int pointDim = 3;
113  long vertexIndex = 0; // to be sure to start to 0
114  std::map< helpers::vertex_descriptor, long > indexMap;
115 
116  // VERTICES IN CONTAINER
117  vertex_range vRange = helpers::vertices(const_cast< Self * >(&other));
118 
119  for(vertex_iterator itV = vRange.begin(); itV != vRange.end(); ++itV)
120  {
122  PropHelpers::get_point(const_cast< Self * >(&other), *itV);
123  std::vector< coord_type > point;
124 
125  for(unsigned int i = 0; i < p.size(); ++i)
126  point.push_back(p[i]);
127 
128  points_coords.push_back(point);
129 
130  indexMap[*itV] = vertexIndex;
131  ++vertexIndex;
132 
133  // deal with vertex attributes here
134 
135  if(useVertexNormal)
136  {
137  // store vertex normal in standard container
138  const AIFMesh::Normal &vn =
140  "v:normal", (*itV)->GetIndex());
141  std::vector< coordN_type > normal(vn.cbegin(), vn.cend());
142  normals_coords.push_back(normal);
143  }
144 
145  if(useVertexColor)
146  {
147  // store vertex color in standard container
148  const AIFMesh::Vector &vc =
150  "v:color", (*itV)->GetIndex());
151  std::vector< coordC_type > color(vc.cbegin(), vc.cend());
152  vertex_color_coords.push_back(color);
153  }
154 
155  if(useVertexTextureCoord)
156  {
157  // store vertex texture-coordinates in standard container
158  const AIFMesh::PointUV &uv =
160  "v:texcoord", (*itV)->GetIndex());
161  std::vector< coordT_type > vt(uv.cbegin(), uv.cend());
162  texture_coords.push_back(vt);
163  }
164 
165  if (useVertexDatafield)
166  {
167  auto it_s = dfv_names.begin(), it_se = dfv_names.end();
168  size_t i = 0;
169  for (; it_s != it_se; ++it_s, ++i)
170  {
171  const std::vector< double >&vdata =
172  other.GetProperty< AIFVertex::ptr, std::vector< double > >(
173  *it_s, (*itV)->GetIndex());
174 
175  if (itV == vRange.begin())
176  {
177  field_names.push_back(*it_s);
178  field_attributes.resize(field_attributes.size() + 1);
179  }
180 
181  field_attributes[i].push_back(vdata);
182  }
183  }
184  }
185 
186  // EDGES IN CONTAINER (needed to take into accound dangling or isolated edges)
187  edge_range eRange = helpers::edges(const_cast< Self * >(&other));
188 
189  for(edge_iterator itE = eRange.begin(); itE != eRange.end(); ++itE)
190  {
192  {
193  std::vector< index_type > line;
194 
195  line.push_back(indexMap[(*itE)->get_first_vertex()]);
196  line.push_back(indexMap[(*itE)->get_second_vertex()]);
197 
198  lines_indices.push_back(line);
199 
200  if(useLineColor)
201  {
202  // store vertex color in standard container
203  const AIFMesh::Vector &vc =
205  "e:color", (*itE)->GetIndex());
206  std::vector< coordC_type > color(vc.cbegin(), vc.cend());
207  line_color_coords.push_back(color);
208  }
209  }
210  }
211 
212  // FACES IN CONTAINER
213  face_range fRange = helpers::faces(const_cast< Self * >(&other));
214 
215  for(face_iterator itF = fRange.begin(); itF != fRange.end(); ++itF)
216  {
217  std::vector< index_type > face;
218  std::vector< index_type > normal_indices;
219  std::vector< index_type > texture_indices;
220 
221  vertex_face_range vfRange = helpers::incident_vertices(*itF);
222 
223  for(vertex_face_iterator itVF = vfRange.begin(); itVF != vfRange.end();
224  ++itVF)
225  {
226  face.push_back(indexMap[*itVF]);
227 
228  // face's vertices attributes (normal & texture)
229  if(useVertexNormal)
230  normal_indices.push_back(indexMap[*itVF]);
231  if(useVertexTextureCoord)
232  texture_indices.push_back(indexMap[*itVF]);
233  }
234 
235  faces_indices.push_back(face);
236  if(useVertexNormal)
237  normal_face_indices.push_back(normal_indices);
238  if(useVertexTextureCoord)
239  texture_face_indices.push_back(texture_indices);
240 
241  if(useFaceColor)
242  {
243  // store vertex color in standard container
244  const AIFMesh::Vector &vc =
246  "f:color", (*itF)->GetIndex());
247  std::vector< coordC_type > color(vc.cbegin(), vc.cend());
248  face_color_coords.push_back(color);
249  }
250 
251  if (useFaceDatafield)
252  {
253  auto it_s = dff_names.begin(), it_se = dff_names.end();
254  size_t i = 0;
255  for (; it_s != it_se; ++it_s, ++i)
256  {
257  const std::vector< double >&vdata =
258  other.GetProperty< AIFFace::ptr, std::vector< double > >(
259  *it_s, (*itF)->GetIndex());
260 
261  if (itF == fRange.begin())
262  {
263  field_names.push_back(*it_s);
264  field_attributes.resize(field_attributes.size() + 1);
265  }
266  if (useVertexDatafield && (it_s == dff_names.begin()))
267  i = other.GetPropertyMapNamesStartingWithPrefix< AIFVertex::ptr >("v:datafield:").size();
268 
269  field_attributes[i].push_back(vdata);
270  }
271  }
272  }
273 
275  if(vertex_color_coords.size() != points_coords.size())
276  vertex_color_coords.clear();
277  for(auto &color : vertex_color_coords)
278  {
279  if(color.size() < 3 || color.size() > 4)
280  {
281  std::cout << "AIFMesh copy constructor: found vertex color with size != "
282  "3 and !=4. Disabling vertex color for all vertices."
283  << std::endl;
284  vertex_color_coords.clear();
285  break;
286  }
287  }
288 
289  if(face_color_coords.size() != faces_indices.size())
290  face_color_coords.clear();
291  for(auto &color : face_color_coords)
292  {
293  if(color.size() < 3 || color.size() > 4)
294  {
295  std::cout << "AIFMesh copy constructor: found face color with size != 3 "
296  "and !=4. Disabling face color for all faces."
297  << std::endl;
298  face_color_coords.clear();
299  break;
300  }
301  }
302 
303  if(!texture_file_name.empty())
304  {
305  // create a property map to store the texture name
306  auto tfn_pm = this->AddAssocPropertyMap< helpers::ptr_mesh, std::string >(
307  "m:texturefilename");
308  if(!this->isAssocPropertyMap("m:texturefilename"))
309  throw std::runtime_error(
310  "Failed to create texture-filename property map.");
311 
312  (*tfn_pm)[this] = texture_file_name;
313 
314  std::cout << "AIF property map for texture-filename created." << std::endl;
315  }
316 
317  // import data into AIF datastructure
318  bool useCornerTextureCoord = false;
319  bool useFaceNormal = false; // per-face vertices normals
320  if(!texture_coords.empty())
321  {
322  if(texture_coords.size() == points_coords.size())
323  {
324  // texture coordinates are given by vertex
325  useVertexTextureCoord = true;
326 
327  // create property map to store vertex texture-coord
328  this->AddPropertyMap< AIFVertex::ptr, AIFMesh::PointUV >("v:texcoord");
329  if(!this->isPropertyMap< AIFVertex::ptr >("v:texcoord"))
330  throw std::runtime_error(
331  "Failed to create vertex-texture-coordinate property map.");
332 
333  std::cout << "AIF property map for vertex-texture-coordinate created."
334  << std::endl;
335  }
336  else if(texture_face_indices.size() == faces_indices.size())
337  {
338  // texture coordinates are given by corner
339  useCornerTextureCoord = true;
340 
341  // create property map to store corner texture-coord
343  AIFMesh::PointUV >("h:texcoord");
344  if(!this->isAssocPropertyMap("h:texcoord"))
345  throw std::runtime_error(
346  "Failed to create halfedge-texture-coordinate property map.");
347 
348  std::cout << "AIF property map for halfedge-texture-coordinate created."
349  << std::endl;
350  }
351  }
352 
353  if(!normals_coords.empty())
354  {
355  // per-vertex normal or per-face-vertex normal ?
356  // if there are as many normals as vertices, then it's per-vertex normal
357 
358  if(normals_coords.size() == points_coords.size())
359  {
360  useVertexNormal = true;
361 
362  // create property map to store vertex normal
363  this->AddPropertyMap< AIFVertex::ptr, AIFMesh::Normal >("v:normal");
364  if(!this->isPropertyMap< AIFVertex::ptr >("v:normal"))
365  throw std::runtime_error(
366  "Failed to create vertex-normal property map.");
367 
368  std::cout << "AIF property map for vertex-normal created." << std::endl;
369  }
370  else if(!normal_face_indices[0].empty())
371  {
372  // per-face-vertex normal
373  useFaceNormal = true;
374 
375  // create property map to store face-vertex normal
376  this->AddPropertyMap< AIFFace::ptr, AIFMesh::Normal >("f:normal");
377  if(!this->isPropertyMap< AIFFace::ptr >("f:normal"))
378  throw std::runtime_error("Failed to create face-normal property map.");
379 
380  std::cout << "AIF property map for face-normal created." << std::endl;
381  }
382  }
383 
384  if(!vertex_color_coords.empty())
385  {
386  // create property map to store vertex color
387  this->AddPropertyMap< AIFVertex::ptr, AIFMesh::Vector >("v:color");
388  if(!this->isPropertyMap< AIFVertex::ptr >("v:color"))
389  throw std::runtime_error("Failed to create vertex-color property map.");
390 
391  std::cout << "AIF property map for vertex-color created." << std::endl;
392  }
393  if(!face_color_coords.empty())
394  {
395  // create property map to store vertex color
396  this->AddPropertyMap< AIFFace::ptr, AIFMesh::Vector >("f:color");
397  if(!this->isPropertyMap< AIFFace::ptr >("f:color"))
398  throw std::runtime_error("Failed to create face-color property map.");
399 
400  std::cout << "AIF property map for face-color created." << std::endl;
401  }
402 
403  if (!field_names.empty())
404  {
405  auto it = field_names.begin();
406  auto ite = field_names.end();
407  for (; it != ite; ++it)
408  {
409  if (it->find("v:datafield:") != std::string::npos)
410  { // property map associated to vertices
411 
412  // create property map to store vertex current data field
413  this->AddPropertyMap< AIFVertex::ptr, std::vector<double> >(
414  *it);
415  if (!this->isPropertyMap< AIFVertex::ptr >(*it))
416  throw std::runtime_error(
417  "Failed to create a vertex data field property map.");
418  }
419  else if (it->find("f:datafield:") != std::string::npos)
420  { // property map associated to faces
421 
422  // create property map to store face current data field
423  this->AddPropertyMap< AIFFace::ptr, std::vector<double> >(
424  *it);
425  if (!this->isPropertyMap< AIFFace::ptr >(*it))
426  throw std::runtime_error(
427  "Failed to create a face data field property map.");
428  }
429  }
430  }
431 
432 
435  std::vector< helpers::vertex_type::ptr > vertices;
436  vertices.reserve(points_coords.size());
437 
438  typedef std::vector< std::vector< coord_type > >::const_iterator point_it;
439  int index = 0;
440  for(point_it itP = points_coords.begin(); itP != points_coords.end(); ++itP)
441  {
442  helpers::vertex_descriptor currentVertex = helpers::add_vertex(this);
443  index++;
444 
445  PropHelpers::set_point(
446  this, currentVertex, (*itP)[0], (*itP)[1], (*itP)[2]);
447 
448  vertices.push_back(
449  currentVertex); // Warning : must keep the vertex in a vector to handle
450  // vertex indices for faces
451 
452  // Vertex normal/color/texture-coords addition when present
453  if(useVertexNormal || useVertexColor || useVertexTextureCoord)
454  {
455  if(useVertexNormal)
456  {
457  // DBG std::cout << "store normal by vertex #" << vertexNbr <<
458  // std::endl;
459  std::vector< coordN_type > &coords = normals_coords[index - 1];
460 
461  if(coords.size() != 3)
462  throw std::runtime_error("Support of normal coordinates of size != 3 "
463  "not yet implemented!");
464  // store normal in property map
465  AIFMesh::Normal vn(coords[0], coords[1], coords[2]);
466  this->SetProperty< AIFVertex::ptr, AIFMesh::Normal >(
467  "v:normal", currentVertex->GetIndex(), vn);
468  }
469  if(useVertexColor)
470  {
471  // DBG std::cout << "store color for vertex #" << index << std::endl;
472  std::vector< coordC_type > &coords = vertex_color_coords[index - 1];
473  // at this point we are sure that coords.size() == 3 because of
474  // previous sanity checks
475 
476  // store color in property map
477  AIFMesh::Vector vc(coords[0], coords[1], coords[2]);
478  this->SetProperty< AIFVertex::ptr, AIFMesh::Vector >(
479  "v:color", currentVertex->GetIndex(), vc);
480  }
481  if(useVertexTextureCoord)
482  {
483  // DBG std::cout << "store tex coord for vertex #" << vertexNbr <<
484  // std::endl;
485  std::vector< coordT_type > &coords = texture_coords[index - 1];
486 
487  if(coords.size() != 2)
488  throw std::runtime_error("Support of texture coordinates of size != "
489  "2 not yet implemented!");
490 
491  // store texture coordinates in property map
492  AIFMesh::PointUV texCoords = {coords[0], coords[1]};
493  this->SetProperty< AIFVertex::ptr, AIFMesh::PointUV >(
494  "v:texcoord", currentVertex->GetIndex(), texCoords);
495  }
496  }
497  if (!field_names.empty())
498  {
499  auto it = field_names.begin();
500  auto ite = field_names.end();
501  auto it_d = field_attributes.begin();
502  for (; it != ite; ++it, ++it_d)
503  {
504  if (it->find("v:datafield:") != std::string::npos)
505  { // property map associated to vertices
506 
507  this->SetProperty< AIFVertex::ptr, std::vector<double> >(
508  *it, currentVertex->GetIndex(), (*it_d)[index - 1]);
509  }
510  }
511  }
512  }
513 
514 
517  typedef std::vector< std::vector< index_type > >::const_iterator line_it;
518  index = 0;
519  for(line_it itL = lines_indices.begin(); itL != lines_indices.end(); ++itL)
520  {
521  // Dangling edge
522  // create the edge in the mesh
523  helpers::edge_type::ptr danglingEdge = helpers::add_edge(this);
524 
525  // find the corresponding vertices in the vertices std::vector (care about
526  // the potential decrementation)
527  helpers::vertex_descriptor firstVertex = vertices[(*itL)[0]];
528  helpers::vertex_descriptor secondVertex = vertices[(*itL)[1]];
529  // link the edge and the vertices
531  firstVertex, danglingEdge, helpers::vertex_pos::FIRST);
533  secondVertex, danglingEdge, helpers::vertex_pos::SECOND);
534 
535  if(useLineColor)
536  {
537  std::vector< coordC_type > &coords = line_color_coords[index++];
538 
539  // store color in property map
540  AIFMesh::Vector vc(coords[0], coords[1], coords[2]);
541  this->SetProperty< AIFEdge::ptr, AIFMesh::Vector >(
542  "e:color", danglingEdge->GetIndex(), vc);
543  }
544  }
545 
546 
549  typedef std::vector< std::vector< index_type > >::const_iterator face_it;
550  typedef std::vector< index_type >::const_iterator index_it;
551  size_t faceId = 0;
552  for(face_it itF = faces_indices.begin(); itF != faces_indices.end();
553  ++itF, ++faceId)
554  {
555  if(itF->size() < 2)
556  {
557  throw std::runtime_error("AIFMesh copy constructor -> find a face with "
558  "less than two vertices : not complying case.");
559  }
560  else if(itF->size() == 2)
561  {
562  // Dangling edge
563  // create the edge in the mesh
564  helpers::edge_type::ptr danglingEdge = helpers::add_edge(this);
565  // find the corresponding vertices in the vertices std::vector (care about
566  // the potential decrementation)
567  helpers::vertex_descriptor firstVertex = vertices[(*itF)[0]];
568  helpers::vertex_descriptor secondVertex = vertices[(*itF)[1]];
569  // link the edge and the vertices
571  firstVertex, danglingEdge, helpers::vertex_pos::FIRST);
573  secondVertex, danglingEdge, helpers::vertex_pos::SECOND);
574  }
575  else
576  {
577  // create the face in the mesh
578  helpers::face_descriptor currentFace = helpers::add_face(this);
579 
580  // get the first vertex of the face to successively constructs the face's
581  // edges (we can use back() here as vertices is explicitly an std::vector)
582  helpers::vertex_descriptor prevVertex = vertices[itF->back()];
583  helpers::vertex_descriptor currentVertex;
584  helpers::edge_descriptor currentEdge;
585 
586  // loop over face's vertices
587  index_type faceVertexId = 0;
588  for(index_it it = itF->begin(); it != itF->end(); ++it, ++faceVertexId)
589  {
590  currentVertex = vertices[(*it)];
591 
592  // check if the 2 vertices ain't already link by an edge
593  helpers::edge_descriptor currentEdge;
594  if((currentEdge = helpers::common_edge(prevVertex, currentVertex)) ==
596  {
597  // create the edge in the mesh
598  currentEdge = helpers::add_edge(this);
599  // link the edge and the vertices
601  prevVertex, currentEdge, helpers::vertex_pos::FIRST);
603  currentVertex, currentEdge, helpers::vertex_pos::SECOND);
604  }
605  // link the edge and the face
606  helpers::link_edge_and_face(currentEdge, currentFace);
607 
608  // corner (aka halfedge) texture
609  if(useCornerTextureCoord)
610  {
611  // DBG std::cout << "store tex coord for face #" << faceId << " and
612  // vertex #" << faceVertexId << std::endl;
613 
614  // retrieve texture coords
615  index_type textureId = texture_face_indices[faceId][faceVertexId];
616  std::vector< coordT_type > &coords = texture_coords[textureId];
617  if(coords.size() != 2)
618  throw std::runtime_error("Support of texture coordinates of size "
619  "!= 2 not yet implemented!");
620  AIFMesh::PointUV texCoords = {coords[0], coords[1]};
621 
622  // retrieve halfedge
624  helpers::AIFHalfEdge(prevVertex, currentVertex, currentFace);
625 
626  // fill in property map
628  AIFMesh::PointUV >("h:texcoord");
629  (*pm)[he] = texCoords;
630 
631  // DBG std::cout << __FILE__ << ":" << __LINE__ << " he=" << he << "
632  // (*pm)[he][0]=" << (*pm)[he][0] << " (*pm)[he][1]=" << (*pm)[he][1]
633  // << " coords[0]=" << coords[0] << " coords[1]=" << coords[1] << "
634  // texCoords[0]=" << texCoords[0] << " texCoords[1]=" << texCoords[1]
635  // << std::endl;
636  }
637 
638  // face-vertex-normal
639  if(useFaceNormal)
640  {
641  // DBG std::cout << "compute normal for face #" << faceId << " (vertex
642  // #" << faceVertexId << ")" << std::endl;
643 
644  // retrieve current vertex normal
645  index_type normalId = normal_face_indices[faceId][faceVertexId];
646  std::vector< coordN_type > &normal = normals_coords[normalId];
647  if(normal.size() != 3)
648  throw std::runtime_error(
649  "Support of normals of size != 3 not yet implemented!");
650  AIFMesh::Normal vnormal = {normal[0], normal[1], normal[2]};
651 
652  // retrieve face normal
653  auto pm =
654  this->GetPropertyMap< AIFFace::ptr, AIFMesh::Normal >("f:normal");
655  AIFMesh::Normal fnormal = (*pm)[currentFace];
656 
657  // computation of face normal (mean of the vertices normals)
658  fnormal = fnormal + vnormal;
659  if(it == itF->end() - 1)
660  fnormal =
661  fnormal / (faceVertexId +
662  1); // why to compute face normal not based on its
663  // underlying plane and just use the vertex
664  // normals to ensure correct orientation?
665 
666  // update face-normal map
667  (*pm)[currentFace] = fnormal;
668  }
669 
670  prevVertex = currentVertex;
671  }
672 
673  // face-color
674  if(useFaceColor)
675  {
676  std::vector< coordC_type > &coords = face_color_coords[faceId];
677 
678  // store color in property map
679  AIFMesh::Vector vc(coords[0], coords[1], coords[2]);
680  this->SetProperty< AIFFace::ptr, AIFMesh::Vector >(
681  "f:color", currentFace->GetIndex(), vc);
682  }
683  if (!field_names.empty())
684  {
685  auto it = field_names.begin();
686  auto ite = field_names.end();
687  auto it_d = field_attributes.begin();
688  for (; it != ite; ++it, ++it_d)
689  {
690  if (it->find("f:datafield:") != std::string::npos)
691  { // property map associated to faces
692 
693  this->SetProperty< AIFFace::ptr, std::vector<double> >(
694  *it, currentFace->GetIndex(), (*it_d)[faceId]);
695  }
696  }
697  }
698  }
699  }
701  return *this;
702 }
703 
704 inline
705 void
707  while (m_Faces.begin() != m_Faces.end())
709  while (m_Edges.begin() != m_Edges.end())
711  while (m_Vertices.begin() != m_Vertices.end())
713 
716 }
717 
718 inline
721 {
722  ptr_mesh ptr(new Self());
723  return ptr;
724 }
725 
726 inline
727 void
729 {
730  std::cout << " Nb of vertices = " << GetNumberOfVertices() << std::endl;
731  std::cout << " Nb of edges = " << GetNumberOfEdges() << std::endl;
732  std::cout << " Nb of faces = " << GetNumberOfFaces() << std::endl;
733 
734  if(GetNumberOfFaces() <= 30)
735  {
737  it != GetVertices().end();
738  ++it)
739  (*it)->Print();
740 
741  std::cout << "-----------------------------------------------------------"
742  << std::endl;
743 
744  for(EdgeContainerType::const_iterator it = GetEdges().begin();
745  it != GetEdges().end();
746  ++it)
747  (*it)->Print();
748 
749  std::cout << "-----------------------------------------------------------"
750  << std::endl;
751 
752  for(FaceContainerType::const_iterator it = GetFaces().begin();
753  it != GetFaces().end();
754  ++it)
755  (*it)->Print();
756  }
757 }
758 
759 
760 // specializations of GetPropertyMapContainer()
761 
762 template<>
763 inline
766 {
767  return &m_VertexPropertyMaps;
768 }
769 
770 template<>
771 inline
774 {
775  return &m_EdgePropertyMaps;
776 }
777 
778 template<>
779 inline
782 {
783  return &m_FacePropertyMaps;
784 }
785 
786 template<>
787 inline
790 {
791  return &m_VertexPropertyMaps;
792 }
793 
794 template<>
795 inline
798 {
799  return &m_EdgePropertyMaps;
800 }
801 
802 template<>
803 inline
806 {
807  return &m_FacePropertyMaps;
808 }
809 
810 } // namespace AIF
811 } // namespace DataStructures
812 } // namespace FEVV
FEVV::DataStructures::AIF::AIFMesh::GetNumberOfEdges
unsigned int GetNumberOfEdges() const
Definition: AIFMesh.hpp:214
FEVV::DataStructures::AIF::vertices
std::pair< typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_iterator, typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_iterator > vertices(const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns the iterator range of the vertices of the mesh.
Definition: Graph_traits_aif.h:172
FEVV::DataStructures::AIF::AIFTopologyHelpers::halfedge_descriptor
AIFHalfEdge halfedge_descriptor
Definition: AIFTopologyHelpers.h:5755
FEVV::DataStructures::AIF::AIFTopologyHelpers::common_edge
static edge_descriptor common_edge(vertex_descriptor vertex1, vertex_descriptor vertex2)
Definition: AIFTopologyHelpers.h:458
helpers
AIFTopologyHelpers helpers
Definition: test_helpers_aif.cpp:16
FEVV::DataStructures::AIF::AIFTopologyHelpers::incident_vertices
static boost::iterator_range< vertex_container_in_edge::const_iterator > incident_vertices(edge_descriptor edge)
Definition: AIFTopologyHelpers.h:1189
FEVV::DataStructures::AIF::AIFVertex::ptr
boost::shared_ptr< self > ptr
Definition: AIFVertex.hpp:47
FEVV::DataStructures::AIF::AIFMesh::GetAssocPropertyMap
AssocPropertyMap< KeyType, ValueType > * GetAssocPropertyMap(const std::string &mapName)
Definition: AIFMesh.hpp:507
FEVV::DataStructures::AIF::AIFMesh::m_FacePropertyMaps
PropertyMapContainer m_FacePropertyMaps
Definition: AIFMesh.hpp:96
FEVV::DataStructures::AIF::AIFTopologyHelpers::add_face
static face_descriptor add_face(ptr_mesh mesh)
Definition: AIFTopologyHelpers.h:2887
FEVV::DataStructures::AIF::AIFTopologyHelpers::is_isolated_edge
static bool is_isolated_edge(edge_descriptor edge)
Definition: AIFTopologyHelpers.h:995
FEVV::DataStructures::AIF::AIFMesh::GetEdges
boost::iterator_range< EdgeContainerType::const_iterator > GetEdges() const
Definition: AIFMesh.hpp:171
FEVV::DataStructures::AIF::AIFTopologyHelpers::AIFHalfEdge
Definition: AIFTopologyHelpers.h:4748
FEVV::DataStructures::AIF::AIFTopologyHelpers::link_edge_and_face
static void link_edge_and_face(edge_descriptor edge, face_descriptor face)
Definition: AIFTopologyHelpers.h:1305
FEVV::DataStructures::AIF::AIFTopologyHelpers::vertex_descriptor
vertex_type::ptr vertex_descriptor
Definition: AIFTopologyHelpers.h:70
AIFTopologyHelpers.h
FEVV::DataStructures::AIF::AIFMesh::ptr
boost::shared_ptr< Self > ptr
Definition: AIFMesh.hpp:50
FEVV::DataStructures::AIF::AIFMesh::GetPropertyMapNamesStartingWithPrefix
std::vector< std::string > GetPropertyMapNamesStartingWithPrefix(const std::string &mapPrefixName) const
Definition: AIFMesh.hpp:423
FEVV::DataStructures::AIF::AIFMesh::GetFaces
boost::iterator_range< FaceContainerType::const_iterator > GetFaces() const
Definition: AIFMesh.hpp:189
AIFPropertiesHelpers.h
FEVV::DataStructures::AIF::AIFFace::ptr
boost::shared_ptr< self > ptr
Definition: AIFFace.hpp:52
FEVV::DataStructures::AIF::AIFTopologyHelpers::edge_descriptor
edge_type::ptr edge_descriptor
Definition: AIFTopologyHelpers.h:71
Point
AIFMesh::Point Point
Definition: Graph_properties_aif.h:21
FEVV::DataStructures::AIF::AIFMesh::New
static ptr_mesh New()
Definition: AIFMesh.inl:720
FEVV::DataStructures::AIF::AIFTopologyHelpers::face_descriptor
face_type::ptr face_descriptor
Definition: AIFTopologyHelpers.h:72
FEVV::DataStructures::AIF::AIFTopologyHelpers::null_edge
static edge_descriptor null_edge()
Definition: AIFTopologyHelpers.h:113
FEVV::DataStructures::AIF::AIFTopologyHelpers::add_edge
static edge_descriptor add_edge(ptr_mesh mesh)
Definition: AIFTopologyHelpers.h:2772
FEVV::DataStructures::AIF::AIFTopologyHelpers::faces
static boost::iterator_range< face_container::const_iterator > faces(ptr_cmesh mesh)
Definition: AIFTopologyHelpers.h:2606
FEVV::DataStructures::AIF::AIFTopologyHelpers::is_dangling_edge
static bool is_dangling_edge(edge_descriptor edge)
Definition: AIFTopologyHelpers.h:1009
FEVV::DataStructures::AIF::AIFTopologyHelpers::link_vertex_and_edge
static void link_vertex_and_edge(vertex_descriptor vertex, edge_descriptor edge, vertex_pos position)
Definition: AIFTopologyHelpers.h:515
FEVV::DataStructures::AIF::AIFCellContainer::begin
iterator begin(void)
Definition: AIFCellContainer.h:108
FEVV::DataStructures::AIF::AIFMesh::GetNumberOfVertices
unsigned int GetNumberOfVertices() const
Definition: AIFMesh.hpp:206
FEVV::DataStructures::AIF::PropertyMapContainer
Definition: AIFProperties.h:469
FEVV::DataStructures::AIF::AIFMesh::EraseIsolatedFace
void EraseIsolatedFace(face_type::ptr face)
Definition: AIFMesh.hpp:321
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
FEVV::DataStructures::AIF::AIFMesh::m_EdgePropertyMaps
PropertyMapContainer m_EdgePropertyMaps
Definition: AIFMesh.hpp:92
FEVV::DataStructures::AIF::AIFMesh::isAssocPropertyMap
bool isAssocPropertyMap(const std::string &mapName)
Definition: AIFMesh.hpp:526
FEVV::DataStructures::AIF::AIFMesh::isAPropertyMapStartingWithPrefix
bool isAPropertyMapStartingWithPrefix(const std::string &mapPrefixName) const
Definition: AIFMesh.hpp:410
FEVV::DataStructures::AIF::AIFMesh::AddAssocPropertyMap
AssocPropertyMap< KeyType, ValueType > * AddAssocPropertyMap(const std::string &mapName)
Definition: AIFMesh.hpp:495
FEVV::DataStructures::AIF::AIFMesh::Print
void Print() const
Definition: AIFMesh.inl:728
FEVV::DataStructures::AIF::AIFMesh::AIFMesh
AIFMesh(void)
Definition: AIFMesh.inl:19
FEVV::DataStructures::AIF::AIFMesh::ptr_mesh
boost::shared_ptr< Self > ptr_mesh
Definition: AIFMesh.hpp:51
FEVV::DataStructures::AIF::AIFMesh::CoordinateType
AIFVertex::CoordinateType CoordinateType
Definition: AIFMesh.hpp:62
FEVV::DataStructures::AIF::AIFMesh::GetVertices
boost::iterator_range< VertexContainerType::const_iterator > GetVertices() const
Definition: AIFMesh.hpp:134
FEVV::DataStructures::AIF::AIFTopologyHelpers::edges
static boost::iterator_range< edge_container::const_iterator > edges(ptr_cmesh mesh)
Definition: AIFTopologyHelpers.h:2261
FEVV::DataStructures::AIF::AIFEdge::ptr
boost::shared_ptr< self > ptr
Definition: AIFEdge.hpp:56
FEVV::DataStructures::AIF::AIFVector
Definition: AIFProperties.h:173
FEVV::DataStructures::AIF::AIFMesh::operator=
Self & operator=(const Self &)
Definition: AIFMesh.inl:40
FEVV::DataStructures::AIF::AIFMesh::GetNumberOfFaces
unsigned int GetNumberOfFaces() const
Definition: AIFMesh.hpp:222
FEVV::DataStructures::AIF::GetPropertyMapContainer< AIFVertex::ptr >
PropertyMapContainer * AIFMesh::GetPropertyMapContainer< AIFVertex::ptr >(void)
Definition: AIFMesh.inl:765
FEVV::DataStructures::AIF::AIFMesh::m_Vertices
VertexContainerType m_Vertices
Definition: AIFMesh.hpp:75
FEVV::DataStructures::AIF::GetPropertyMapContainer< AIFFace::ptr >
PropertyMapContainer * AIFMesh::GetPropertyMapContainer< AIFFace::ptr >(void)
Definition: AIFMesh.inl:781
FEVV::DataStructures::AIF::AIFMesh::Self
AIFMesh Self
Definition: AIFMesh.hpp:49
FEVV::DataStructures::AIF::AIFMesh::EraseIsolatedVertex
void EraseIsolatedVertex(vertex_type::ptr vertex)
Definition: AIFMesh.hpp:290
FEVV::DataStructures::AIF::AIFMesh::PointUV
std::array< CoordinateType, 2 > PointUV
Definition: AIFMesh.hpp:65
FEVV::DataStructures::AIF::AIFMesh::isPropertyMap
bool isPropertyMap(const std::string &mapName) const
Definition: AIFMesh.hpp:397
FEVV::DataStructures::AIF::AIFMesh::clear
void clear()
Definition: AIFMesh.inl:706
FEVV::DataStructures::AIF::AIFMesh::m_VertexPropertyMaps
PropertyMapContainer m_VertexPropertyMaps
Definition: AIFMesh.hpp:88
FEVV::DataStructures::AIF::AIFCellContainer< vertex_type::ptr >::const_iterator
std::vector< vertex_type::ptr >::const_iterator const_iterator
Definition: AIFCellContainer.h:29
FEVV::DataStructures::AIF::GetPropertyMapContainer< AIFEdge::ptr >
PropertyMapContainer * AIFMesh::GetPropertyMapContainer< AIFEdge::ptr >(void)
Definition: AIFMesh.inl:773
FEVV::DataStructures::AIF::AIFMesh::m_Faces
FaceContainerType m_Faces
Definition: AIFMesh.hpp:83
FEVV::DataStructures::AIF::AIFTopologyHelpers
This class is an helper class associated to the AIFMesh structure. AIFTopologyHelpers implements all ...
Definition: AIFTopologyHelpers.h:57
FEVV::DataStructures::AIF::AIFMesh::m_Edges
EdgeContainerType m_Edges
Definition: AIFMesh.hpp:79
FEVV::DataStructures::AIF::AIFTopologyHelpers::vertices
static boost::iterator_range< vertex_container::const_iterator > vertices(ptr_cmesh mesh)
Definition: AIFTopologyHelpers.h:2227
FEVV::DataStructures::AIF::AIFMesh
This class represents an AIF structure. AIF structure can deal with both manifold and non-manifold su...
Definition: AIFMesh.hpp:47
FEVV::DataStructures::AIF::face
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::face_descriptor face(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor h, const FEVV::DataStructures::AIF::AIFMesh &)
Returns the face incident to halfedge h.
Definition: Graph_traits_aif.h:664
FEVV::DataStructures::AIF::AIFCellContainer::end
iterator end(void)
Definition: AIFCellContainer.h:112
FEVV::DataStructures::AIF::AIFTopologyHelpers::add_vertex
static vertex_descriptor add_vertex(ptr_mesh mesh)
Definition: AIFTopologyHelpers.h:2709
FEVV::DataStructures::AIF::AIFMesh::~AIFMesh
~AIFMesh()
Definition: AIFMesh.inl:33
FEVV::DataStructures::AIF::AIFMesh::GetProperty
T & GetProperty(const std::string &mapName, std::size_t cellId)
Definition: AIFMesh.hpp:465
FEVV::DataStructures::AIF::AIFMesh::EraseIsolatedEdge
void EraseIsolatedEdge(edge_type::ptr edge)
Definition: AIFMesh.hpp:299
FEVV::DataStructures::AIF::AIFMesh::NormalCoordinateType
AIFFace::NormalCoordinateType NormalCoordinateType
Definition: AIFMesh.hpp:68
FEVV::DataStructures::AIF::AIFMesh::m_AssocPropertyMaps
PropertyMapContainer m_AssocPropertyMaps
Definition: AIFMesh.hpp:100
FEVV::DataStructures::AIF::PropertyMapContainer::clear
void clear()
Definition: AIFProperties.h:587
FEVV::DataStructures::AIF::AIFPropertiesHelpers
This class is an helper class associated to the AIFMesh structure. AIFPropertiesHelpers implements al...
Definition: AIFPropertiesHelpers.h:28