AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
ConvexHull2D.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#pragma once
18
19#include <agxUtil/PointCurve.h>
20
22#include <agx/Plane.h>
23
24namespace agxUtil
25{
30 {
31 public:
36 struct Point
37 {
40 agx::UInt32 flags = 0u;
41 explicit operator const agx::Vec3&() const { return projected; }
42 };
43
44 public:
49
50 public:
55
65 const agx::Plane& plane,
66 const agx::UInt32Vector& flags = agx::UInt32Vector() );
67
79 const agx::Plane& plane,
80 agx::UInt numSubQuadrangles,
81 const agx::UInt32Vector& flags = agx::UInt32Vector() );
82
88 const Point& operator[]( agx::UInt index ) const;
89
93 const Point& front() const;
94
98 const Point& back() const;
99
103 agx::UInt size() const;
104
108 const_iterator begin() const;
109
113 const_iterator end() const;
114
124 const agx::Plane& plane,
125 const agx::UInt32Vector& flags = agx::UInt32Vector() );
126
138 const agx::Plane& plane,
139 agx::UInt numSubQuadrangles,
140 const agx::UInt32Vector& flags = agx::UInt32Vector() );
141
147
154
160 size_t findPointIndex( const agx::Vec3& original ) const;
161
167 void rotateOrder( size_t toIndex );
168
172 const HullContainer& getHull() const;
173
179 Curve asCurve( agx::Bool closed = true ) const;
180
181 private:
182 HullContainer m_hull;
183 };
184
186 {
187 return m_hull[ index ];
188 }
189
191 {
192 return m_hull.front();
193 }
194
196 {
197 return m_hull.back();
198 }
199
201 {
202 return m_hull.size();
203 }
204
206 {
207 return m_hull.begin();
208 }
209
211 {
212 return m_hull.end();
213 }
214}
#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:185
HullContainer::const_iterator const_iterator
Definition: ConvexHull2D.h:46
ConvexHull2D(const agx::Vec3Vector &points, const agx::Plane &plane, agx::UInt numSubQuadrangles, const agx::UInt32Vector &flags=agx::UInt32Vector())
Construct given point cloud, plane and number of sub-quadrangles.
const HullContainer & getHull() const
agx::UInt size() const
Definition: ConvexHull2D.h:200
const Point & back() const
Definition: ConvexHull2D.h:195
const HullContainer & computeHullQuadrangles(const agx::Vec3Vector &points, const agx::Plane &plane, agx::UInt numSubQuadrangles, const agx::UInt32Vector &flags=agx::UInt32Vector())
Computes the convex hull in the given plane using a set of quadrangles.
const Point & front() const
Definition: ConvexHull2D.h:190
Curve asCurve(agx::Bool closed=true) const
Current hull as a curve object.
const HullContainer & computeHullJarvisMarch(const agx::Vec3Vector &points, const agx::Plane &plane, const agx::UInt32Vector &flags=agx::UInt32Vector())
Computes the convex hull in the given plane using 2D gift wrapping algorithm - Jarvis march.
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.
size_t findPointIndex(const agx::Vec3 &original) const
Searches for the given original point original (i.e., not projected) in this hull.
const_iterator end() const
Definition: ConvexHull2D.h:210
ConvexHull2D(const agx::Vec3Vector &points, const agx::Plane &plane, const agx::UInt32Vector &flags=agx::UInt32Vector())
Construct given point cloud and a plane.
void rotateOrder(size_t toIndex)
Changing order of the points so that the given toIndex will become the first point.
const_iterator begin() const
Definition: ConvexHull2D.h:205
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.
uint32_t UInt32
Definition: Integer.h:32
bool Bool
Definition: Integer.h:40
uint64_t UInt
Definition: Integer.h:27
double Real
Definition: Real.h:41
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