MEPP2 Project
Geometry_traits_aif.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 
16 
17 namespace FEVV {
18 
31 {
32 public:
37 
38  // part dedicated to CGAL adaptation without including CGAL types
39  typedef typename Point::CoordinateType FT;
40  typedef Point Point_3;
41  typedef Vector Vector_3;
42  typedef typename Point::SuperClass::const_iterator Cartesian_const_iterator_3;
43  typedef typename Point::SuperClass::iterator Cartesian_iterator_3;
45 };
46 
53 template<>
54 struct RetrieveKernel< DataStructures::AIF::AIFMesh >
55 {
57 };
58 
59 
69 template< typename MeshT >
71 {
72 public:
73  typedef MeshT Mesh;
75  typedef typename Kernel::Point Point;
76  typedef typename Kernel::Vector Vector;
77  typedef typename Kernel::Scalar Scalar;
79 
80  Geometry_traits(const Mesh &m) : m_mesh(const_cast< Mesh & >(m)) {}
81 
82  template< int D >
83  static Scalar get(const Point &p)
84  {
85  return p[D];
86  }
87 
88  static Scalar get_x(const Point &p) { return get< 0 >(p); }
89 
90  static Scalar get_y(const Point &p) { return get< 1 >(p); }
91 
92  static Scalar get_z(const Point &p) { return get< 2 >(p); }
93 
94  static Vector unit_normal(const Point &p1, const Point &p2, const Point &p3)
95  {
96  return PropHelpers::compute_unit_normal(p1, p2, p3);
97  }
98 
99  static Vector normal(const Point &p1, const Point &p2, const Point &p3)
100  {
101  return PropHelpers::compute_normal(p1, p2, p3);
102  }
103 
104  static Scalar dot_product(const Vector &v1, const Vector &v2)
105  {
106  return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];
107  }
108 
109  static Vector cross_product(const Vector &v1, const Vector &v2)
110  {
111  Vector res(0, 0, 0);
112  size_t nb_e = 3;
113  for(size_t i = 0; i < nb_e; ++i)
114  res[i] = v1[(1 + i) % nb_e] * v2[(2 + i) % nb_e] -
115  v1[(2 + i) % nb_e] * v2[(1 + i) % nb_e];
116 
117  return res;
118  }
119 
120  static Scalar length2(const Vector &v)
121  {
122  return dot_product(v, v);
123  }
124 
125  static Scalar length(const Vector &v) { return sqrt(length2(v)); }
126 
127  static Scalar length(const Point &p1, const Point &p2)
128  {
129  Vector v(p1[0] - p2[0], p1[1] - p2[1], p1[2] - p2[2]);
130  return length(v);
131  }
132 
133  static Vector normalize(const Vector &v)
134  {
135  Scalar dist = length(v);
136  Vector res;
137  if(dist > 2e-7)
138  {
139  res = Vector(v[0] / dist, v[1] / dist, v[2] / dist);
140  }
141  else
142  res = v;
143  return res;
144  }
145 
146  static Vector add_v(const Vector &v1, const Vector &v2)
147  {
148  Vector result(v1[0] + v2[0], v1[1] + v2[1], v1[2] + v2[2]);
149  return result;
150  }
151 
152  static Point add_pv(
153  const Point &p,
154  const Vector &v) // we need addP and add functions to have function names
155  // consistent with those of OpenMesh geometry trait
156  {
157  Point result(p[0] + v[0], p[1] + v[1], p[2] + v[2]);
158  return result;
159  }
160 
161  static Point sub_pv(const Point &p1,
162  const Vector &v) // subP to be consistent with addP
163  {
164  Point result(p1[0] - v[0], p1[1] - v[1], p1[2] - v[2]);
165  return result;
166  }
167 
168  static Vector sub_p(const Point &p1, const Point &p2)
169  {
170  Vector result(p1[0] - p2[0], p1[1] - p2[1], p1[2] - p2[2]);
171  return result;
172  }
173 
174  static Vector sub_v(const Vector &v1, const Vector &v2)
175  {
176  Vector result(v1[0] - v2[0], v1[1] - v2[1], v1[2] - v2[2]);
177  return result;
178  }
179 
180  static Vector scalar_mult(const Vector &v, Scalar s)
181  {
182  Vector result(v[0] * s, v[1] * s, v[2] * s);
183  return result;
184  }
185 
186  static const Vector NULL_VECTOR;
187  static const Point ORIGIN;
188 
189 protected:
191 };
192 
193 // Initialisation of static member NULL_VECTOR of above AIFMesh specialization
194 template< typename MeshT >
197  typename Geometry_traits< MeshT >::Vector(0.0, 0.0, 0.0);
198 
199 // Initialisation of static member ORIGIN of above AIFMesh specialization
200 template< typename MeshT >
203  typename Geometry_traits< MeshT >::Point(0.0, 0.0, 0.0);
204 
205 } // namespace FEVV
206 
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::sub_v
static Vector sub_v(const Vector &v1, const Vector &v2)
Definition: Geometry_traits_aif.h:174
FEVV::DataStructures::AIF::AIFPoint::CoordinateType
CoordinateT CoordinateType
Definition: AIFProperties.h:33
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::length2
static Scalar length2(const Vector &v)
Definition: Geometry_traits_aif.h:120
Vector
AIFMesh::Vector Vector
Definition: Graph_properties_aif.h:22
FEVV::AIF_mesh_kernel_generator::Cartesian_const_iterator_3
Point::SuperClass::const_iterator Cartesian_const_iterator_3
Definition: Geometry_traits_aif.h:42
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::Kernel
RetrieveKernel< Mesh >::Kernel Kernel
Definition: Geometry_traits_aif.h:74
FEVV::AIF_mesh_kernel_generator::Kernel
AIF_mesh_kernel_generator Kernel
Definition: Geometry_traits_aif.h:33
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::length
static Scalar length(const Point &p1, const Point &p2)
Definition: Geometry_traits_aif.h:127
FEVV::AIF_mesh_kernel_generator::Point_3
Point Point_3
Definition: Geometry_traits_aif.h:40
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::Scalar
Kernel::Scalar Scalar
Definition: Geometry_traits_aif.h:77
FEVV::RetrieveKernel< DataStructures::AIF::AIFMesh >::Kernel
AIF_mesh_kernel_generator Kernel
Definition: Geometry_traits_aif.h:56
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::m_mesh
Mesh & m_mesh
Definition: Geometry_traits_aif.h:190
FEVV::AIF_mesh_kernel_generator::Vector_3
Vector Vector_3
Definition: Geometry_traits_aif.h:41
FEVV::Geometry_traits
Refer to Geometry_traits_documentation_dummy for further documentation on provided types and algorith...
Definition: Geometry_traits.h:162
Point
AIFMesh::Point Point
Definition: Graph_properties_aif.h:21
FEVV::AIF_mesh_kernel_generator::Vector
DataStructures::AIF::AIFMesh::Vector Vector
Definition: Geometry_traits_aif.h:35
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::Vector
Kernel::Vector Vector
Definition: Geometry_traits_aif.h:76
FEVV::AIF_mesh_kernel_generator
AIF specialization. Refer to for concrete usage .
Definition: Geometry_traits_aif.h:31
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::normal
static Vector normal(const Point &p1, const Point &p2, const Point &p3)
Definition: Geometry_traits_aif.h:99
FEVV::RetrieveKernel
A generic definition, that is template specialized for every supported native implementation,...
Definition: Geometry_traits.h:118
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
AIFMesh.hpp
FEVV::AIF_mesh_kernel_generator::Scalar
DataStructures::AIF::AIFMesh::CoordinateType Scalar
Definition: Geometry_traits_aif.h:36
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::cross_product
static Vector cross_product(const Vector &v1, const Vector &v2)
Definition: Geometry_traits_aif.h:109
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::get_x
static Scalar get_x(const Point &p)
Definition: Geometry_traits_aif.h:88
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::PropHelpers
FEVV::DataStructures::AIF::AIFPropertiesHelpers PropHelpers
Definition: Geometry_traits_aif.h:78
Geometry_traits.h
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::get_y
static Scalar get_y(const Point &p)
Definition: Geometry_traits_aif.h:90
FEVV::DataStructures::AIF::AIFMesh::CoordinateType
AIFVertex::CoordinateType CoordinateType
Definition: AIFMesh.hpp:62
FEVV::DataStructures::AIF::AIFVector
Definition: AIFProperties.h:173
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::NULL_VECTOR
static const Vector NULL_VECTOR
Definition: Geometry_traits_aif.h:186
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::Geometry_traits
Geometry_traits(const Mesh &m)
Definition: Geometry_traits_aif.h:80
FEVV::AIF_mesh_kernel_generator::Point
DataStructures::AIF::AIFMesh::Point Point
Definition: Geometry_traits_aif.h:34
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::sub_pv
static Point sub_pv(const Point &p1, const Vector &v)
Definition: Geometry_traits_aif.h:161
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::get
static Scalar get(const Point &p)
Definition: Geometry_traits_aif.h:83
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::add_v
static Vector add_v(const Vector &v1, const Vector &v2)
Definition: Geometry_traits_aif.h:146
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::dot_product
static Scalar dot_product(const Vector &v1, const Vector &v2)
Definition: Geometry_traits_aif.h:104
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::ORIGIN
static const Point ORIGIN
Definition: Geometry_traits_aif.h:187
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::add_pv
static Point add_pv(const Point &p, const Vector &v)
Definition: Geometry_traits_aif.h:152
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::normalize
static Vector normalize(const Vector &v)
Definition: Geometry_traits_aif.h:133
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::length
static Scalar length(const Vector &v)
Definition: Geometry_traits_aif.h:125
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::AIF_mesh_kernel_generator::FT
Point::CoordinateType FT
Definition: Geometry_traits_aif.h:39
FEVV::AIF_mesh_kernel_generator::Construct_cartesian_const_iterator_3
Cartesian_const_iterator_3 Construct_cartesian_const_iterator_3
Definition: Geometry_traits_aif.h:44
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::Mesh
MeshT Mesh
Definition: Geometry_traits_aif.h:73
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::scalar_mult
static Vector scalar_mult(const Vector &v, Scalar s)
Definition: Geometry_traits_aif.h:180
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::unit_normal
static Vector unit_normal(const Point &p1, const Point &p2, const Point &p3)
Definition: Geometry_traits_aif.h:94
FEVV::AIF_mesh_kernel_generator::Cartesian_iterator_3
Point::SuperClass::iterator Cartesian_iterator_3
Definition: Geometry_traits_aif.h:43
AIFMesh
FEVV::DataStructures::AIF::AIFMesh AIFMesh
Definition: Graph_properties_aif.h:19
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::sub_p
static Vector sub_p(const Point &p1, const Point &p2)
Definition: Geometry_traits_aif.h:168
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::get_z
static Scalar get_z(const Point &p)
Definition: Geometry_traits_aif.h:92
FEVV::Math::Vector::dot_product
static ElementType dot_product(const ElementType v1[DIM], const ElementType v2[DIM])
Compute v1 * v2 scalar product.
Definition: MatrixOperations.hpp:421
FEVV::DataStructures::AIF::AIFPoint
Definition: AIFProperties.h:31
FEVV::Geometry_traits< MeshT, AIF_mesh_kernel_generator >::Point
Kernel::Point Point
Definition: Geometry_traits_aif.h:75
Geometry_traits_operators.h
FEVV::DataStructures::AIF::AIFPropertiesHelpers
This class is an helper class associated to the AIFMesh structure. AIFPropertiesHelpers implements al...
Definition: AIFPropertiesHelpers.h:28