MEPP2 Project
quads.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 // For are_collinear() and MACH_EPS_DOUBLE :
20 
21 namespace FEVV {
22 namespace Operators {
23 namespace Geometry {
36 template< typename GeometryTraits >
37 inline typename GeometryTraits::Point
39  const typename GeometryTraits::Point &b,
40  const typename GeometryTraits::Point &c,
41  const typename GeometryTraits::Point &d,
42  const GeometryTraits &gt)
43 {
44  typedef typename GeometryTraits::Point Point;
45 
46  return Point((a[0] + b[0] + c[0] + d[0]) / 4,
47  (a[1] + b[1] + c[1] + d[1]) / 4,
48  (a[2] + b[2] + c[2] + d[2]) / 4);
49 }
61 template< typename GeometryTraits >
62 inline double
64  const typename GeometryTraits::Point &b,
65  const typename GeometryTraits::Point &c,
66  const typename GeometryTraits::Point &d,
67  const GeometryTraits &gt)
68 {
69  typedef typename GeometryTraits::Vector Vector;
70 
71  Vector ab(b - a), bc(c - b), cd(d - c), da(a - d);
72 
73  return (gt.length(ab) + gt.length(bc) + gt.length(cd)) + gt.length(da));
74 }
75 
88 template< typename GeometryTraits >
89 inline double
90 quad_area(const typename GeometryTraits::Point &a,
91  const typename GeometryTraits::Point &b,
92  const typename GeometryTraits::Point &c,
93  const typename GeometryTraits::Point &d,
94  const GeometryTraits &gt)
95 {
96  typedef typename GeometryTraits::Vector Vector;
97 
98  Vector n1 = triangle_normal_unnormalized< GeometryTraits >(a, b, c, gt);
99  Vector n2 = triangle_normal_unnormalized< GeometryTraits >(c, d, a, gt);
100  return (gt.length(n1) + gt.length(n2)) * 0.5;
101 }
102 
103 } // namespace Geometry
104 } // namespace Operators
105 } // namespace FEVV
Vector
AIFMesh::Vector Vector
Definition: Graph_properties_aif.h:22
FEVV::Operators::Geometry::quad_area
double quad_area(const typename GeometryTraits::Point &a, const typename GeometryTraits::Point &b, const typename GeometryTraits::Point &c, const typename GeometryTraits::Point &d, const GeometryTraits &gt)
Compute the area of a quad (given by 4 points).
Definition: quads.hpp:90
Point
AIFMesh::Point Point
Definition: Graph_properties_aif.h:21
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
FEVV::Operators::Geometry::quad_perimeter
double quad_perimeter(const typename GeometryTraits::Point &a, const typename GeometryTraits::Point &b, const typename GeometryTraits::Point &c, const typename GeometryTraits::Point &d, const GeometryTraits &gt)
Compute the perimeter of a quad (given by 4 points).
Definition: quads.hpp:63
AngleOperations.hpp
Geometry_traits.h
FEVV::DataStructures::AIF::AIFVector
Definition: AIFProperties.h:173
FEVV::Operators::Geometry::quad_barycenter
GeometryTraits::Point quad_barycenter(const typename GeometryTraits::Point &a, const typename GeometryTraits::Point &b, const typename GeometryTraits::Point &c, const typename GeometryTraits::Point &d, const GeometryTraits &gt)
Compute the barycenter/mean position of a quad (given by 4 points).
Definition: quads.hpp:38
MatrixOperations.hpp