AGXDynamics  2.35.0.2
ConvexHull2D.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #pragma once
18 
19 #include <agxUtil/PointCurve.h>
20 
21 #include <agx/agx_vector_types.h>
22 #include <agx/Plane.h>
23 
24 namespace agxUtil
25 {
30  {
31  public:
36  struct Point
37  {
40  explicit operator const agx::Vec3&() const { return projected; }
41  };
42 
43  public:
45  using const_iterator = HullContainer::const_iterator;
48 
49  public:
53  ConvexHull2D();
54 
61  ConvexHull2D( const agx::Vec3Vector& points, const agx::Plane& plane );
62 
71  ConvexHull2D( const agx::Vec3Vector& points, const agx::Plane& plane, agx::UInt numSubQuadrangles );
72 
78  const Point& operator[]( agx::UInt index ) const;
79 
83  const Point& front() const;
84 
88  const Point& back() const;
89 
93  agx::UInt size() const;
94 
98  const_iterator begin() const;
99 
103  const_iterator end() const;
104 
111  const HullContainer& computeHullJarvisMarch( const agx::Vec3Vector& points, const agx::Plane& plane );
112 
123  const HullContainer& computeHullQuadrangles( const agx::Vec3Vector& points, const agx::Plane& plane, agx::UInt numSubQuadrangles );
124 
129  agx::Real calculateArea() const;
130 
136  agx::Real calculatePerimeter() const;
137 
141  const HullContainer& getHull() const;
142 
148  Curve asCurve( agx::Bool closed = true ) const;
149 
150  private:
151  HullContainer m_hull;
152  };
153 
155  {
156  return m_hull[ index ];
157  }
158 
160  {
161  return m_hull.front();
162  }
163 
165  {
166  return m_hull.back();
167  }
168 
170  {
171  return m_hull.size();
172  }
173 
175  {
176  return m_hull.begin();
177  }
178 
180  {
181  return m_hull.end();
182  }
183 }
agx::VectorPOD::begin
iterator begin()
Definition: Vector.h:1609
agx::end
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
Definition: LinearProbingHashSet.h:612
agx::Real
double Real
Definition: Real.h:42
agxUtil::ConvexHull2D::front
const Point & front() const
Definition: ConvexHull2D.h:159
agxUtil::ConvexHull2D::back
const Point & back() const
Definition: ConvexHull2D.h:164
agx::Container::size
size_t size() const
Definition: Container.h:134
agx::VectorPOD::back
T & back() const
Definition: Vector.h:1354
PointCurve.h
agxUtil::ConvexHull2D::end
const_iterator end() const
Definition: ConvexHull2D.h:179
agx::VectorPOD< Point >
Plane.h
AGXPHYSICS_EXPORT
#define AGXPHYSICS_EXPORT
agx::begin
LinearProbingHashSetImplementation< KeyT, HashT >::iterator begin(LinearProbingHashSetImplementation< KeyT, HashT > &set)
Definition: LinearProbingHashSet.h:606
agx::PlaneT
Class representing the mathematical concept of a plane, also called a half- space.
Definition: Plane.h:31
agxUtil::ConvexHull2D::operator[]
const Point & operator[](agx::UInt index) const
Access hull points of given index.
Definition: ConvexHull2D.h:154
agx::VectorPOD::end
iterator end()
Definition: Vector.h:1612
agxUtil::PointCurve::Segment
Segment data with begin and end point.
Definition: PointCurve.h:51
agxUtil::ConvexHull2D::size
agx::UInt size() const
Definition: ConvexHull2D.h:169
agxUtil::ConvexHull2D::begin
const_iterator begin() const
Definition: ConvexHull2D.h:174
agxUtil::PointCurve
Utility class curve defined by a set of points.
Definition: PointCurve.h:41
agx::UInt
uint32_t UInt
Definition: Integer.h:34
agx::Bool
bool Bool
Definition: Integer.h:48
agxUtil::ConvexHull2D::Point::original
agx::Vec3 original
Original point.
Definition: ConvexHull2D.h:39
agxUtil::ConvexHull2D::const_iterator
HullContainer::const_iterator const_iterator
Definition: ConvexHull2D.h:45
agxUtil::ConvexHull2D
Utility class to create a convex hull in a plane given point cloud.
Definition: ConvexHull2D.h:29
agxUtil::ConvexHull2D::Point::projected
agx::Vec3 projected
Hull point projected onto the given plane.
Definition: ConvexHull2D.h:38
agx::Vec3T< Real >
agxUtil
The agxUtil namespace contain classes and methods for utility functionality.
Definition: CylindricalJoint.h:22
agx_vector_types.h
agx::VectorPOD::front
T & front() const
Definition: Vector.h:1346
agxUtil::ConvexHull2D::Point
Point in hull containing the point projected onto the plane and the original point.
Definition: ConvexHull2D.h:36