MEPP2 Project
AIFMeshHelpers.h
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 #pragma once
12 
15 
16 namespace FEVV {
17 namespace DataStructures {
18 namespace AIF {
19 
28 {
29 public:
34 
52 
61  template< typename GeometryTraits >
63  ref_mesh mesh,
64  const GeometryTraits &gt)
65  {
66  // Does not give stable results (several successive runs give different results)
68  return false;
69  // all incident edges are interior edges, thus we are sure
70  // there is not T-junction at this position
71 
75  auto it = oneR.begin();
76  auto ite = oneR.end();
77  decltype(it) it2;
78  if(it == ite)
79  return false;
81  // We must find 3 aligned points including current point (this) =>
82  // T-junction detection which does not work for general crack detection for
83  // 3D surfaces [in that case we can apply an orthogonal projection for this
84  // point, but it is sensitive to numerical precision...]. Anyway, a crack
85  // can also be considered as wanted surface holes...
86  while(it != ite)
87  {
88  it2 = it;
89  ++it2;
90  while(it2 != ite)
91  {
92  Point &vPoint = AIFPropertiesHelpers::get_point(mesh, v);
93  Point &itPoint = AIFPropertiesHelpers::get_point(mesh, *it);
94  Point &it2Point = AIFPropertiesHelpers::get_point(mesh, *it2);
95 
96  std::vector< double > it2Vector(it2Point.cbegin(), it2Point.cend());
97 
98  if(Math::Vector::are_aligned<GeometryTraits>(vPoint, itPoint, it2Point) &&
99  // must be on both on the same side of v vertex for an adjacent T-junction
100  // or on both side of v for a T-junction on v. However last case may be confused with
101  // a classical border case.
102  (gt.dot_product(gt.sub_p(vPoint, itPoint),
103  gt.sub_p(vPoint, it2Point)) < 0.)
104  )
105  {
110  {
111  if(AIFTopologyHelpers::are_adjacent(*it, *it2))
112  {
113  // simple T-junction case (2 triangles)
114  return true;
115  }
116 
119  *it2);
120  auto tmpI = tmp.begin();
121  auto tmpIe = tmp.end();
122 
123  while(tmpI != tmpIe)
124  {
125  if(**tmpI == *v)
126  {
127  ++tmpI;
128  continue;
129  }
130 
131  Point &tmpIPoint = AIFPropertiesHelpers::get_point(mesh, *tmpI);
132 
133  if(Math::Vector::are_aligned<GeometryTraits>(vPoint, itPoint, tmpIPoint))
134  {
135  if(AIFTopologyHelpers::are_adjacent(*tmpI, *it) &&
137  AIFTopologyHelpers::common_edge(*tmpI, *it)))
138  {
139  // more complex T-junction case (3 triangles)
140  return true;
141  }
142 
143  // more complex T-junction case (4 and more triangles)
144  // are not taken into account yet
145  }
146 
147  ++tmpI;
148  }
149  }
150  }
151 
152  ++it2;
153  }
154  ++it;
155  }
157  return false; // not found any collinear triplet
158  }
159 
160  template< typename GeometryTraits >
162  ref_mesh mesh,
163  const GeometryTraits &gt)
164  {
165 #if 0
166  // Does not give stable results (several successive runs give different results)
169  auto it = oneR.begin();
170  auto ite = oneR.end();
171  for (; it != ite; ++it)
172  {
173  if (is_a_T_junction_vertex(*it, mesh, gt))
174  return true;
175  }
176 #else
177  // Does not give stable results (several successive runs give different results)
179  return false;
180  // all incident edges are interior edges, thus we are sure
181  // there is not T-junction at this position
182 
186  auto it = oneR.begin();
187  auto ite = oneR.end();
188  decltype(it) it2;
189  if (it == ite)
190  return false;
192  // We must find 3 aligned points including current point (this) =>
193  // T-junction detection which does not work for general crack detection for
194  // 3D surfaces [in that case we can apply an orthogonal projection for this
195  // point, but it is sensitive to numerical precision...]. Anyway, a crack
196  // can also be considered as wanted surface holes...
197  while (it != ite)
198  {
199  it2 = it;
200  ++it2;
201  while (it2 != ite)
202  {
203  Point &vPoint = AIFPropertiesHelpers::get_point(mesh, v);
204  Point &itPoint = AIFPropertiesHelpers::get_point(mesh, *it);
205  Point &it2Point = AIFPropertiesHelpers::get_point(mesh, *it2);
206 
207  std::vector< double > it2Vector(it2Point.cbegin(), it2Point.cend());
208 
209  if (Math::Vector::are_aligned<GeometryTraits>(vPoint, itPoint, it2Point) &&
210  // must be on both on the same side of v vertex for an adjacent T-junction
211  // or on both side of v for a T-junction on v. However last case may be confused with
212  // a classical border case.
213  (gt.dot_product(gt.sub_p(vPoint, itPoint),
214  gt.sub_p(vPoint, it2Point)) > 0.)
215  )
216  {
221  {
222  if (AIFTopologyHelpers::are_adjacent(*it, *it2))
223  {
224  // simple T-junction case (2 triangles)
225  return true;
226  }
227 
230  *it2);
231  auto tmpI = tmp.begin();
232  auto tmpIe = tmp.end();
233 
234  while (tmpI != tmpIe)
235  {
236  if (**tmpI == *v)
237  {
238  ++tmpI;
239  continue;
240  }
241 
242  Point &tmpIPoint = AIFPropertiesHelpers::get_point(mesh, *tmpI);
243 
244  if (Math::Vector::are_aligned<GeometryTraits>(vPoint, itPoint, tmpIPoint))
245  {
246  if (AIFTopologyHelpers::are_adjacent(*tmpI, *it) &&
248  AIFTopologyHelpers::common_edge(*tmpI, *it)))
249  {
250  // more complex T-junction case (3 triangles)
251  return true;
252  }
253 
254  // more complex T-junction case (4 and more triangles)
255  // are not taken into account yet
256  }
257 
258  ++tmpI;
259  }
260  }
261  }
262 
263  ++it2;
264  }
265  ++it;
266  }
267 #endif
268  return false; // not found any collinear triplet
270  }
271 
278  template< typename GeometryTraits >
280  ref_mesh mesh,
281  const GeometryTraits &gt)
282  {
283  if(is_a_T_junction_vertex(v, mesh, gt))
284  return false;
285 
287  }
288 };
289 
290 
291 } // namespace AIF
292 } // namespace DataStructures
293 } // namespace FEVV
294 
FEVV::DataStructures::AIF::AIFMeshHelpers::face_container_in_edge
AIFTopologyHelpers::face_container_in_edge face_container_in_edge
Definition: AIFMeshHelpers.h:45
FEVV::DataStructures::AIF::AIFTopologyHelpers::common_edge
static edge_descriptor common_edge(vertex_descriptor vertex1, vertex_descriptor vertex2)
Definition: AIFTopologyHelpers.h:458
FEVV::DataStructures::AIF::AIFPropertiesHelpers::NormalCoordinateType
AIFMesh::NormalCoordinateType NormalCoordinateType
Definition: AIFPropertiesHelpers.h:32
FEVV::DataStructures::AIF::AIFTopologyHelpers::edge_container_in_vertex
vertex_type::EdgeContainerType edge_container_in_vertex
Definition: AIFTopologyHelpers.h:75
FEVV::DataStructures::AIF::AIFMeshHelpers::face_container_in_face
AIFTopologyHelpers::face_container_in_face face_container_in_face
Definition: AIFMeshHelpers.h:48
FEVV::DataStructures::AIF::AIFTopologyHelpers::vertex_descriptor
vertex_type::ptr vertex_descriptor
Definition: AIFTopologyHelpers.h:70
FEVV::DataStructures::AIF::AIFMeshHelpers::Vector
AIFPropertiesHelpers::Vector Vector
Definition: AIFMeshHelpers.h:33
FEVV::DataStructures::AIF::AIFPropertiesHelpers::get_point
static Point & get_point(const ptr_mesh m, vertex_descriptor v)
Definition: AIFPropertiesHelpers.h:100
FEVV::DataStructures::AIF::AIFMeshHelpers::CoordinateType
AIFPropertiesHelpers::CoordinateType CoordinateType
Definition: AIFMeshHelpers.h:30
FEVV::DataStructures::AIF::AIFMeshHelpers::Point
AIFPropertiesHelpers::Point Point
Definition: AIFMeshHelpers.h:32
FEVV::DataStructures::AIF::AIFMeshHelpers::is_a_T_junction_vertex
static bool is_a_T_junction_vertex(vertex_descriptor v, ref_mesh mesh, const GeometryTraits &gt)
Definition: AIFMeshHelpers.h:62
FEVV::DataStructures::AIF::AIFMeshHelpers::has_adjacent_T_junction_vertex
static bool has_adjacent_T_junction_vertex(vertex_descriptor v, ref_mesh mesh, const GeometryTraits &gt)
Definition: AIFMeshHelpers.h:161
FEVV::DataStructures::AIF::AIFMeshHelpers::vertex_descriptor
AIFTopologyHelpers::vertex_descriptor vertex_descriptor
Definition: AIFMeshHelpers.h:37
FEVV::DataStructures::AIF::AIFMeshHelpers::vertex_container_in_face
AIFTopologyHelpers::vertex_container_in_face vertex_container_in_face
Definition: AIFMeshHelpers.h:46
FEVV::DataStructures::AIF::AIFMeshHelpers::edge_container_in_edge
AIFTopologyHelpers::edge_container_in_edge edge_container_in_edge
Definition: AIFMeshHelpers.h:44
FEVV::DataStructures::AIF::AIFTopologyHelpers::edge_container_in_edge
edge_type::EdgeContainerType edge_container_in_edge
Definition: AIFTopologyHelpers.h:78
FEVV::DataStructures::AIF::AIFTopologyHelpers::are_adjacent
static bool are_adjacent(vertex_descriptor vertex1, vertex_descriptor vertex2)
Definition: AIFTopologyHelpers.h:358
FEVV::DataStructures::AIF::AIFTopologyHelpers::edge_descriptor
edge_type::ptr edge_descriptor
Definition: AIFTopologyHelpers.h:71
FEVV::DataStructures::AIF::AIFTopologyHelpers::vertex_container_in_edge
edge_type::VertexContainerType vertex_container_in_edge
Definition: AIFTopologyHelpers.h:77
FEVV::DataStructures::AIF::AIFMeshHelpers::vertex_container_in_edge
AIFTopologyHelpers::vertex_container_in_edge vertex_container_in_edge
Definition: AIFMeshHelpers.h:43
FEVV::DataStructures::AIF::AIFMeshHelpers::edge_container
AIFTopologyHelpers::edge_container edge_container
Definition: AIFMeshHelpers.h:50
FEVV::DataStructures::AIF::AIFTopologyHelpers::vertex_container_in_face
face_type::VertexContainerType vertex_container_in_face
Definition: AIFTopologyHelpers.h:80
FEVV::DataStructures::AIF::AIFMeshHelpers::is_one_ring_2_manifold
static bool is_one_ring_2_manifold(vertex_descriptor v, ref_mesh mesh, const GeometryTraits &gt)
Definition: AIFMeshHelpers.h:279
FEVV::DataStructures::AIF::AIFMeshHelpers::ref_mesh
AIFTopologyHelpers::ref_mesh ref_mesh
Definition: AIFMeshHelpers.h:35
FEVV::DataStructures::AIF::AIFMeshHelpers::NormalCoordinateType
AIFPropertiesHelpers::NormalCoordinateType NormalCoordinateType
Definition: AIFMeshHelpers.h:31
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
FEVV::DataStructures::AIF::AIFTopologyHelpers::is_surface_border_edge
static bool is_surface_border_edge(edge_descriptor edge)
Definition: AIFTopologyHelpers.h:949
AIFMesh.hpp
FEVV::DataStructures::AIF::AIFMeshHelpers::face_container
AIFTopologyHelpers::face_container face_container
Definition: AIFMeshHelpers.h:51
FEVV::DataStructures::AIF::AIFMeshHelpers
This class is an helper class associated to the AIFMesh structure. It hosts helper functions that do ...
Definition: AIFMeshHelpers.h:28
FEVV::DataStructures::AIF::AIFMeshHelpers::vertex_container_in_vertex
AIFTopologyHelpers::vertex_container_in_vertex vertex_container_in_vertex
Definition: AIFMeshHelpers.h:40
FEVV::DataStructures::AIF::AIFTopologyHelpers::is_one_ring_2_manifold
static bool is_one_ring_2_manifold(vertex_descriptor v)
Definition: AIFTopologyHelpers.h:4334
FEVV::DataStructures::AIF::AIFPropertiesHelpers::CoordinateType
AIFMesh::CoordinateType CoordinateType
Definition: AIFPropertiesHelpers.h:31
FEVV::DataStructures::AIF::AIFMeshHelpers::edge_descriptor
AIFTopologyHelpers::edge_descriptor edge_descriptor
Definition: AIFMeshHelpers.h:38
FEVV::DataStructures::AIF::AIFVector
Definition: AIFProperties.h:173
FEVV::DataStructures::AIF::AIFTopologyHelpers::face_container_in_vertex
vertex_type::FaceContainerType face_container_in_vertex
Definition: AIFTopologyHelpers.h:76
FEVV::DataStructures::AIF::AIFTopologyHelpers::vertex_container_in_vertex
vertex_type::VertexContainerType vertex_container_in_vertex
Definition: AIFTopologyHelpers.h:74
FEVV::DataStructures::AIF::AIFCellContainer< vertex_type::ptr >
FEVV::DataStructures::AIF::AIFMeshHelpers::ptr_mesh
AIFTopologyHelpers::ptr_mesh ptr_mesh
Definition: AIFMeshHelpers.h:36
FEVV::DataStructures::AIF::AIFTopologyHelpers::face_container_in_face
face_type::FaceContainerType face_container_in_face
Definition: AIFTopologyHelpers.h:82
FEVV::DataStructures::AIF::AIFTopologyHelpers::face_container_in_edge
edge_type::FaceContainerType face_container_in_edge
Definition: AIFTopologyHelpers.h:79
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::AIFMeshHelpers::face_container_in_vertex
AIFTopologyHelpers::face_container_in_vertex face_container_in_vertex
Definition: AIFMeshHelpers.h:42
FEVV::DataStructures::AIF::AIFMeshHelpers::vertex_container
AIFTopologyHelpers::vertex_container vertex_container
Definition: AIFMeshHelpers.h:49
FEVV::DataStructures::AIF::AIFTopologyHelpers::is_surface_interior_vertex
static bool is_surface_interior_vertex(vertex_descriptor vertex)
Definition: AIFTopologyHelpers.h:288
FEVV::DataStructures::AIF::AIFMeshHelpers::edge_container_in_vertex
AIFTopologyHelpers::edge_container_in_vertex edge_container_in_vertex
Definition: AIFMeshHelpers.h:41
MatrixOperations.hpp
FEVV::DataStructures::AIF::AIFTopologyHelpers::get_ordered_one_ring_of_adjacent_vertices
static vertex_container_in_vertex get_ordered_one_ring_of_adjacent_vertices(vertex_descriptor v)
Definition: AIFTopologyHelpers.h:4305
FEVV::DataStructures::AIF::AIFPoint
Definition: AIFProperties.h:31
FEVV::DataStructures::AIF::AIFTopologyHelpers::edge_container_in_face
face_type::EdgeContainerType edge_container_in_face
Definition: AIFTopologyHelpers.h:81
FEVV::DataStructures::AIF::AIFMeshHelpers::edge_container_in_face
AIFTopologyHelpers::edge_container_in_face edge_container_in_face
Definition: AIFMeshHelpers.h:47