AGX Dynamics 2.41.1.2
Loading...
Searching...
No Matches
agxUtil::ConvexHull2D Class Reference

Utility class to create a convex hull in a plane given point cloud. More...

#include <ConvexHull2D.h>

Classes

struct  Point
 Point in hull containing the point projected onto the plane and the original point. More...
 

Public Types

using const_iterator = HullContainer::const_iterator
 
using Curve = PointCurve< Point >
 
using CurveSegment = PointCurve< Point >::Segment
 
using HullContainer = agx::VectorPOD< Point >
 

Public Member Functions

 ConvexHull2D ()
 Default constructor.
 
 ConvexHull2D (const agx::Vec3Vector &points, const agx::Plane &plane)
 Construct given point cloud and a plane.
 
 ConvexHull2D (const agx::Vec3Vector &points, const agx::Plane &plane, agx::UInt numSubQuadrangles)
 Construct given point cloud, plane and number of sub-quadrangles.
 
Curve asCurve (agx::Bool closed=true) const
 Current hull as a curve object.
 
const Pointback () const
 
const_iterator begin () const
 
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 HullContainercomputeHullJarvisMarch (const agx::Vec3Vector &points, const agx::Plane &plane)
 Computes the convex hull in the given plane using 2D gift wrapping algorithm - Jarvis march.
 
const HullContainercomputeHullQuadrangles (const agx::Vec3Vector &points, const agx::Plane &plane, agx::UInt numSubQuadrangles)
 Computes the convex hull in the given plane using a set of quadrangles.
 
const_iterator end () const
 
const Pointfront () const
 
const HullContainergetHull () const
 
const Pointoperator[] (agx::UInt index) const
 Access hull points of given index.
 
agx::UInt size () const
 

Detailed Description

Utility class to create a convex hull in a plane given point cloud.

Definition at line 29 of file ConvexHull2D.h.

Member Typedef Documentation

◆ const_iterator

◆ Curve

Definition at line 46 of file ConvexHull2D.h.

◆ CurveSegment

Definition at line 47 of file ConvexHull2D.h.

◆ HullContainer

Constructor & Destructor Documentation

◆ ConvexHull2D() [1/3]

agxUtil::ConvexHull2D::ConvexHull2D ( )

Default constructor.

◆ ConvexHull2D() [2/3]

agxUtil::ConvexHull2D::ConvexHull2D ( const agx::Vec3Vector points,
const agx::Plane plane 
)

Construct given point cloud and a plane.

The hull will be calculated during construction using the Jarvis march algorithm.

Parameters
points- original point cloud
plane- plane to project point cloud onto

◆ ConvexHull2D() [3/3]

agxUtil::ConvexHull2D::ConvexHull2D ( const agx::Vec3Vector points,
const agx::Plane plane,
agx::UInt  numSubQuadrangles 
)

Construct given point cloud, plane and number of sub-quadrangles.

The hull will be calculated during construction using the Quadrangles algorithm.

Parameters
points- original point cloud
plane- plane to project point cloud onto
numSubQuadrangles- number of sub quadrangles defining the accuracy of this algorithm (3 is very low and 100 is large and probably accurate)

Member Function Documentation

◆ asCurve()

Curve agxUtil::ConvexHull2D::asCurve ( agx::Bool  closed = true) const

Current hull as a curve object.

Parameters
closed- true if the curve should be closed, i.e., first point == last point
Returns
current hull points as a curve object

◆ back()

const ConvexHull2D::Point & agxUtil::ConvexHull2D::back ( ) const
inline
Returns
last element of the hull assuming the hull isn't empty

Definition at line 164 of file ConvexHull2D.h.

References agx::VectorPOD< T, Allocator >::back().

◆ begin()

ConvexHull2D::const_iterator agxUtil::ConvexHull2D::begin ( ) const
inline
Returns
begin iterator of this hull

Definition at line 174 of file ConvexHull2D.h.

References agx::VectorPOD< T, Allocator >::begin().

◆ calculateArea()

agx::Real agxUtil::ConvexHull2D::calculateArea ( ) const

Calculates the area of the hull - if the hull is present.

If the hull is empty, i.e., number of points < 2, the area is 0.

Returns
area of the hull in the plane

◆ calculatePerimeter()

agx::Real agxUtil::ConvexHull2D::calculatePerimeter ( ) const

Computes the perimeter of the hull - if the hull is present.

If the hull is empty, i.e., number of points < 2, the perimeter is 0.

Returns
the perimeter of the hull in the plane

◆ computeHullJarvisMarch()

const HullContainer & agxUtil::ConvexHull2D::computeHullJarvisMarch ( const agx::Vec3Vector points,
const agx::Plane plane 
)

Computes the convex hull in the given plane using 2D gift wrapping algorithm - Jarvis march.

Parameters
points- original point cloud
plane- plane to project point cloud onto
Returns
hull points if successful - otherwise an empty array

◆ computeHullQuadrangles()

const HullContainer & agxUtil::ConvexHull2D::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.

This approach can be much faster than the Jarvis march but points could be missed if numSubQuadrangles is too low. The lower number of sub-quadrangles the quicker this method will find a hull.

Parameters
points- original point cloud
plane- plane to project point cloud onto
numSubQuadrangles- number of sub quadrangles defining the accuracy of this algorithm (3 is very low and 100 is large and probably accurate)
Returns
hull points if successful - otherwise an empty array

◆ end()

ConvexHull2D::const_iterator agxUtil::ConvexHull2D::end ( ) const
inline
Returns
begin iterator of this hull

Definition at line 179 of file ConvexHull2D.h.

References agx::VectorPOD< T, Allocator >::end().

◆ front()

const ConvexHull2D::Point & agxUtil::ConvexHull2D::front ( ) const
inline
Returns
first element of the hull assuming the hull isn't empty

Definition at line 159 of file ConvexHull2D.h.

References agx::VectorPOD< T, Allocator >::front().

◆ getHull()

const HullContainer & agxUtil::ConvexHull2D::getHull ( ) const
Returns
the hull (empty array if not created)

◆ operator[]()

const ConvexHull2D::Point & agxUtil::ConvexHull2D::operator[] ( agx::UInt  index) const
inline

Access hull points of given index.

No bounds checks make sure index < size().

Parameters
index- hull point index
Returns
point with index index in the hull

Definition at line 154 of file ConvexHull2D.h.

◆ size()

agx::UInt agxUtil::ConvexHull2D::size ( ) const
inline
Returns
number of points in the hull

Definition at line 169 of file ConvexHull2D.h.

References agx::Container::size().


The documentation for this class was generated from the following file: