libmove3d  3.13.0
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
gpConvexHull Class Reference

#include <gpConvexHull.h>

Inheritance diagram for gpConvexHull:
gpConvexHull3D gpConvexHull6D

List of all members.

Public Member Functions

 gpConvexHull ()
 gpConvexHull (const std::vector< std::vector< double > > &points)
int setPoints (const std::vector< std::vector< double > > &points)
unsigned int nbVertices ()
unsigned int nbFaces ()
int pointCoordinates (unsigned int i, std::vector< double > &coord)
int compute (bool simplicial_facets, double postMergingCentrumRadius, bool verbose=true)
virtual int voronoi (bool verbose=true)
int draw ()
int drawFace (unsigned int face_index)
int print ()
double largest_ball_radius ()
int isPointInside (std::vector< double > point, bool &inside, double &distance)

Public Attributes

std::vector< unsigned int > hull_vertices
std::vector< gpFacehull_faces
 the hull faces (arrays containing indices to elements of the point set).
std::vector< std::vector
< double > > 
voronoi_vertices_
 for voronoi regions computation:
std::vector< gpVoronoiRidgevoronoi_ridges_
std::vector< gpVoronoiCellvoronoi_cells_

Protected Member Functions

int reset ()

Protected Attributes

unsigned int dimension_
bool up_to_date_
 space dimension (size of the point vectors)
std::vector< std::vector
< double > > 
points_
double largest_ball_radius_

Detailed Description

This class is used to compute the convex hull (or the voronoi regions) of a set of points in arbitrary dimension (via Qhull library). Special 3D and 6D case has a specific class (see below). Set the point set at creation or with setPoints() and then call compute() to compute the convex hull or voronoi() to compute the voronoi regions.


Constructor & Destructor Documentation

gpConvexHull::gpConvexHull ( )

Default constructor of the class gpConvexHull. All is left void.


Member Function Documentation

int gpConvexHull::compute ( bool  simplicial_facets,
double  postMergingCentrumRadius,
bool  verbose = true 
)

Computes the convex hull of the point set stored in the calling gpConvexHull variable. The user can choose to have simplicial or non-simplicial output facets and to enable/disable post-merging of nearly coplanar facets.

Parameters:
simplicial_facetsselects wether the computed facets will be simplicial or not
postMergingCentrumRadiuscentrum radius for post-merging: merges facets when the centrum is less than the given value from a neighboring hyperplane. This allows Qhull to merge the hull facets that are adjacent and nearly coplanar. Set postMergingCentrumRadius to a negative or null value to disable post-merging.
verboseselects if Qhull will print its messages in the console or not
Returns:
GP_OK in case of success, GP_ERROR otherwise. NB: this function relies on Qhull library's functions and frees the memory used by Qhull once the convex hull computation is done (TODO: check this last point (memory management)).
int gpConvexHull::isPointInside ( std::vector< double >  point,
bool &  inside,
double &  distance 
)

Tests if a given point is inside the convex hull. If it is the case, the function also gives the distance from the points to the hull.

Parameters:
pointthe point's coordinates
resulttrue if the point is inside, false otherwise
distancetrue if the point is inside, false otherwise
Returns:
GP_OK in case of success, GP_ERROR otherwise
double gpConvexHull::largest_ball_radius ( )

Returns the radius of the largest ball centered on the origin and fully contained in the hull. The function compute() must have been called before.

int gpConvexHull::pointCoordinates ( unsigned int  i,
std::vector< double > &  coord 
)

Gets the coordinates of the i-th input point used for convex hull computation.

Parameters:
iindex of a point in the input point array (starts from 0)
coordwhere to copy the coordinates of the point
Returns:
GP_OK in case of success, GP_ERROR otherwise
int gpConvexHull::print ( )

Prints the content of the current convex hull.

Returns:
GP_OK in case of success, GP_ERROR otherwise
int gpConvexHull::reset ( ) [protected]

Reinitializes everything.

Returns:
GP_OK in case of success, GP_ERROR otherwise
int gpConvexHull::setPoints ( const std::vector< std::vector< double > > &  points)

Sets the point set that will then be used when calling compute() or voronoi().

Parameters:
pointsa vector of vectors whose size will give the dimension of the space
Returns:
GP_OK in case of success, GP_ERROR otherwise
int gpConvexHull::voronoi ( bool  verbose = true) [virtual]

Computes the voronoi regions of the point set stored in the calling gpConvexHull variable. The function does not read into Qhulll's internal data but redirects Qhull's output into a temporary file and read into this file.

Parameters:
verboseselects if Qhull will print its messages in the console or not
Returns:
GP_OK in case of success, GP_ERROR otherwise. NB: this function relies on Qhull library's functions and frees the memory used by Qhull once the computation is done (TODO: check this last point (memory management)).

Reimplemented in gpConvexHull3D.


Member Data Documentation

std::vector<unsigned int> gpConvexHull::hull_vertices

the hull vertices (indices to elements of the point set)

the radius of the largest sphere centered on the origin and fully contained in the convex hull (it is null if the hull does not contain the origin):

std::vector< std::vector<double> > gpConvexHull::points_ [protected]

the input set of points

bool gpConvexHull::up_to_date_ [protected]

space dimension (size of the point vectors)

flag to tell wether or not the current content of hull_vertices and hull_faces corresponds to the actual convex hull of the current point set


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines