AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
ConvexHull2D.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. 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 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.
const Point & operator[](agx::UInt index) const
Access hull points of given index.
ConvexHull2D(const agx::Vec3Vector &points, const agx::Plane &plane)
Construct given point cloud and a plane.
HullContainer::const_iterator const_iterator
ConvexHull2D(const agx::Vec3Vector &points, const agx::Plane &plane, agx::UInt numSubQuadrangles)
Construct given point cloud, plane and number of sub-quadrangles.
const HullContainer & getHull() const
agx::UInt size() const
const Point & back() const
const Point & front() const
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
const_iterator begin() const
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.
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.
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()
const Point * const_iterator
Definition agx/Vector.h:256
T & back() const
iterator end()
T & front() const
The agxUtil namespace contain classes and methods for utility functionality.
bool Bool
Definition Integer.h:40
uint64_t UInt
Definition Integer.h:27
double Real
Definition Real.h:42
Point in hull containing the point projected onto the plane and the original point.
agx::Vec3 original
Original point.
agx::Vec3 projected
Hull point projected onto the given plane.
Segment data with begin and end point.
Definition PointCurve.h:52