MEPP2 Project
AIFFace.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.
12 
13 namespace FEVV {
14 namespace DataStructures {
15 namespace AIF {
16 
17 inline
20 {
21  ptr_face ptr(new self());
22  return ptr;
23 }
24 
25 inline
27 AIFFace::New(const self &other)
28 {
29  ptr_face ptr(new self(other));
30  return ptr;
31 }
32 
33 inline
34 void
36 {
37  std::cout << "face " << this << " at index " << m_Index << std::endl;
38  EdgeContainerType::const_iterator itBegin = m_Incident_PtrEdges.begin(),
39  itEnd = m_Incident_PtrEdges.end();
40  for(; itBegin != itEnd; ++itBegin)
41  (*itBegin)->Print();
42  std::cout << std::endl;
43 }
44 
45 inline
46 boost::iterator_range< AIFFace::VertexContainerType::const_iterator >
48 {
50  {
51  // adjacent vertices info is up-to-date, so we use it!
52  // DBG std::cout << "Use face-incident-vertices cache for face " << this <<
53  // std::endl;
55  }
56 
57  // DBG std::cout << "No face-incident-vertices cache, computing it for face "
58  // << this << std::endl;
59  m_Incident_PtrVertices.clear();
61  // we are computing a new one, so at the end of the computation this will be
62  // true
63 
64  size_t nbEdge = m_Incident_PtrEdges.size();
65  if(nbEdge == 1)
66  { // Special case of a one edged face (only on face construction as this is an
67  // invalid configuration)
68  ptr_edge edge = *(m_Incident_PtrEdges.begin());
70  edge->get_first_vertex());
72  edge->get_second_vertex());
73  }
74  else if(nbEdge > 1)
75  { // All other cases
76  ptr_vertex currentVertex;
77  EdgeContainerType::const_iterator itE = m_Incident_PtrEdges.cbegin();
78  ptr_edge currentEdge = *itE;
79  ++itE;
80  ptr_edge nextEdge = *itE;
81 
82  if(currentEdge->get_first_vertex() == nextEdge->get_first_vertex() ||
83  currentEdge->get_first_vertex() == nextEdge->get_second_vertex())
84  currentVertex = currentEdge->get_first_vertex();
85  else
86  currentVertex = currentEdge->get_second_vertex();
87 
88  m_Incident_PtrVertices.insert(m_Incident_PtrVertices.end(), currentVertex);
89  for(; itE != m_Incident_PtrEdges.cend(); ++itE)
90  {
91  if((*itE)->get_first_vertex() == currentVertex)
92  {
94  (*itE)->get_second_vertex());
95  currentVertex = (*itE)->get_second_vertex();
96  }
97  else
98  {
100  (*itE)->get_first_vertex());
101  currentVertex = (*itE)->get_first_vertex();
102  }
103  }
104  } // if not the first two cases -> vertices container has been invalidate
105  // after topological changes
106  return boost::make_iterator_range(m_Incident_PtrVertices.cbegin(),
107  m_Incident_PtrVertices.cend());
108 }
109 
110 } // namespace AIF
111 } // namespace DataStructures
112 } // namespace FEVV
AIFEdge.hpp
FEVV::DataStructures::AIF::AIFFace::ptr_edge
boost::shared_ptr< edge_type > ptr_edge
Definition: AIFFace.hpp:58
FEVV::DataStructures::AIF::AIFFace::Print
void Print() const
Definition: AIFFace.inl:35
FEVV::DataStructures::AIF::AIFFace::m_Incident_PtrVertices
VertexContainerType m_Incident_PtrVertices
Definition: AIFFace.hpp:82
FEVV::DataStructures::AIF::AIFFace::m_Incident_PtrEdges
EdgeContainerType m_Incident_PtrEdges
Definition: AIFFace.hpp:74
FEVV::DataStructures::AIF::AIFFace::ptr
boost::shared_ptr< self > ptr
Definition: AIFFace.hpp:52
FEVV::DataStructures::AIF::AIFFace::m_Is_Incident_PtrVertices_Computed
bool m_Is_Incident_PtrVertices_Computed
Definition: AIFFace.hpp:87
FEVV::DataStructures::AIF::edge
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::edge_descriptor edge(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor h, const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns the edge corresponding to h and opposite(h).
Definition: Graph_traits_aif.h:345
FEVV::DataStructures::AIF::AIFFace::ptr_face
boost::shared_ptr< self > ptr_face
Definition: AIFFace.hpp:53
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
FEVV::DataStructures::AIF::AIFFace::ptr_vertex
boost::shared_ptr< vertex_type > ptr_vertex
Definition: AIFFace.hpp:57
FEVV::DataStructures::AIF::AIFFace::m_Index
std::size_t m_Index
Definition: AIFFace.hpp:70
FEVV::DataStructures::AIF::AIFFace::New
static ptr_face New()
Definition: AIFFace.inl:19
FEVV::DataStructures::AIF::AIFFace::GetIncidentVertices
boost::iterator_range< VertexContainerType::const_iterator > GetIncidentVertices()
Definition: AIFFace.inl:47