AGX Dynamics  2.35.0.1
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:
48 
49  public:
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 
130 
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 }
#define AGXPHYSICS_EXPORT
Utility class to create a convex hull in a plane given point cloud.
Definition: ConvexHull2D.h:30
const Point & operator[](agx::UInt index) const
Access hull points of given index.
Definition: ConvexHull2D.h:154
ConvexHull2D(const agx::Vec3Vector &points, const agx::Plane &plane)
Construct given point cloud and a plane.
HullContainer::const_iterator const_iterator
Definition: ConvexHull2D.h:45
const HullContainer & getHull() const
ConvexHull2D(const agx::Vec3Vector &points, const agx::Plane &plane, agx::UInt numSubQuadrangles)
Construct given point cloud, plane and number of sub-quadrangles.
const HullContainer & computeHullQuadrangles(const agx::Vec3Vector &points, const agx::Plane &plane, agx::UInt numSubQuadrangles)
Computes the convex hull in the given plane using a set of quadrangles.
agx::UInt size() const
Definition: ConvexHull2D.h:169
const Point & back() const
Definition: ConvexHull2D.h:164
const Point & front() const
Definition: ConvexHull2D.h:159
Curve asCurve(agx::Bool closed=true) const
Current hull as a curve object.
agx::Real calculateArea() const
Calculates the area of the hull - if the hull is present.
agx::Real calculatePerimeter() const
Computes the perimeter of the hull - if the hull is present.
const_iterator end() const
Definition: ConvexHull2D.h:179
const_iterator begin() const
Definition: ConvexHull2D.h:174
const HullContainer & computeHullJarvisMarch(const agx::Vec3Vector &points, const agx::Plane &plane)
Computes the convex hull in the given plane using 2D gift wrapping algorithm - Jarvis march.
ConvexHull2D()
Default constructor.
Utility class curve defined by a set of points.
Definition: PointCurve.h:42
size_t size() const
Definition: Container.h:134
Class representing the mathematical concept of a plane, also called a half- space.
Definition: agx/Plane.h:32
iterator begin()
Definition: agx/Vector.h:1609
const Point * const_iterator
Definition: agx/Vector.h:256
T & back() const
Definition: agx/Vector.h:1354
iterator end()
Definition: agx/Vector.h:1612
T & front() const
Definition: agx/Vector.h:1346
The agxUtil namespace contain classes and methods for utility functionality.
bool Bool
Definition: Integer.h:48
LinearProbingHashSetImplementation< KeyT, HashT >::iterator begin(LinearProbingHashSetImplementation< KeyT, HashT > &set)
uint32_t UInt
Definition: Integer.h:34
double Real
Definition: Real.h:42
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
Point in hull containing the point projected onto the plane and the original point.
Definition: ConvexHull2D.h:37
agx::Vec3 original
Original point.
Definition: ConvexHull2D.h:39
agx::Vec3 projected
Hull point projected onto the given plane.
Definition: ConvexHull2D.h:38
Segment data with begin and end point.
Definition: PointCurve.h:52