MEPP2 Project
is_geometrical_fold.hpp
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 
13 #include <boost/graph/graph_traits.hpp>
14 #include <boost/graph/properties.hpp>
16 
18 
19 namespace FEVV {
20 namespace Operators {
21 
40 template< typename FaceGraph,
41  typename PointMap,
42  typename GeometryTraits = FEVV::Geometry_traits< FaceGraph > >
43 inline bool
45  const typename boost::graph_traits< FaceGraph >::halfedge_descriptor h1,
46  const typename boost::graph_traits< FaceGraph >::halfedge_descriptor h2,
47  const FaceGraph &g,
48  const PointMap &pm,
49  const GeometryTraits &gt)
50 {
51  typedef typename GeometryTraits::Vector Vector;
52 
53  // Variables declaration
54  Vector next_h1, nnext, left_dir = gt.NULL_VECTOR, vg, next_h2,
55  right_dir = gt.NULL_VECTOR, vh;
57  next_h1 =
58  gt.sub_p(get(pm, target(h1, g)),
59  get(pm,
60  target(next(h1, g),
61  g))); // target(next(h1, g),g) instead of
62  // source(prev(h1, g) to handle polygonal cases
63 
64  // Compute unit normal
65  nnext = FEVV::Operators::
66  calculate_vertex_normal< FaceGraph, PointMap, GeometryTraits >(
67  target(next(h1, g), g), g, pm, gt);
68 
69  if(next_h1 != gt.NULL_VECTOR)
70  left_dir = gt.cross_product(next_h1, nnext); // LeftDir = next_h1 X Nnext
71  else
72  return true;
74  next_h2 = gt.sub_p(get(pm, target(h2, g)), get(pm, source(prev(h2, g), g)));
75 
76  // Compute unit normal
77  nnext = FEVV::Operators::
78  calculate_vertex_normal< FaceGraph, PointMap, GeometryTraits >(
79  source(prev(h2, g), g), g, pm, gt);
80 
81  if(next_h2 != gt.NULL_VECTOR)
82  right_dir = gt.cross_product(next_h2, nnext); // RightDir = next_h2 X Nnext
83  else
84  return true;
85 
86  vg = gt.sub_p(get(pm, target(h2, g)), get(pm, target(next(h1, g), g)));
87  vh = gt.sub_p(get(pm, target(h1, g)), get(pm, source(prev(h2, g), g)));
88 
89  // fold to the right fold to the left
90  return ((gt.dot_product(left_dir, vg) <= 0.0) ||
91  (gt.dot_product(right_dir, vh) <= 0.0));
92 }
93 
94 } // namespace Operators
95 } // namespace FEVV
FEVV::DataStructures::AIF::next
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor next(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor h, const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns the next halfedge around its face.
Definition: Graph_traits_aif.h:599
Vector
AIFMesh::Vector Vector
Definition: Graph_properties_aif.h:22
FEVV::Geometry_traits
Refer to Geometry_traits_documentation_dummy for further documentation on provided types and algorith...
Definition: Geometry_traits.h:162
FEVV::Operators::is_geometrical_fold
bool is_geometrical_fold(const typename boost::graph_traits< FaceGraph >::halfedge_descriptor h1, const typename boost::graph_traits< FaceGraph >::halfedge_descriptor h2, const FaceGraph &g, const PointMap &pm, const GeometryTraits &gt)
Geometric fold detection, usually during iterations of an CGAL::Halfedge_around_target_circulator obj...
Definition: is_geometrical_fold.hpp:44
FEVV::DataStructures::AIF::source
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_descriptor source(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::edge_descriptor e, const FEVV::DataStructures::AIF::AIFMesh &)
Returns the source vertex of e.
Definition: Graph_traits_aif.h:387
FEVV::get
FEVV::PCLPointCloudPointMap::value_type get(const FEVV::PCLPointCloudPointMap &pm, FEVV::PCLPointCloudPointMap::key_type key)
Specialization of get(point_map, key) for PCLPointCloud.
Definition: Graph_properties_pcl_point_cloud.h:117
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
FEVV::DataStructures::AIF::target
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_descriptor target(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::edge_descriptor e, const FEVV::DataStructures::AIF::AIFMesh &)
Returns the target vertex of e.
Definition: Graph_traits_aif.h:400
Geometry_traits.h
FEVV::DataStructures::AIF::AIFVector
Definition: AIFProperties.h:173
FEVV::DataStructures::AIF::prev
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor prev(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor h, const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns the previous halfedge around its face.
Definition: Graph_traits_aif.h:612
calculate_vertex_normal.hpp