Visual Servoing Platform  version 3.6.1 under development (2024-11-21)
vpPolygon3D Class Reference

#include <visp3/core/vpPolygon3D.h>

+ Inheritance diagram for vpPolygon3D:

Public Types

enum  vpPolygon3DClippingType {
  NO_CLIPPING = 0 , NEAR_CLIPPING = 1 , FAR_CLIPPING = 2 , LEFT_CLIPPING = 4 ,
  RIGHT_CLIPPING = 8 , UP_CLIPPING = 16 , DOWN_CLIPPING = 32 , FOV_CLIPPING = 60 ,
  ALL_CLIPPING = 63
}
 

Public Member Functions

 vpPolygon3D ()
 
 vpPolygon3D (const vpPolygon3D &mbtp)
 
virtual ~vpPolygon3D ()
 
void addPoint (unsigned int n, const vpPoint &P)
 
void changeFrame (const vpHomogeneousMatrix &cMo)
 
void computePolygonClipped (const vpCameraParameters &cam=vpCameraParameters())
 
unsigned int getClipping () const
 
double getFarClippingDistance () const
 
unsigned int getNbPoint () const
 
unsigned int getNbCornerInsidePrevImage () const
 
unsigned int getNbCornerInsideImage (const vpImage< unsigned char > &I, const vpCameraParameters &cam)
 
double getNearClippingDistance () const
 
vpPointgetPoint (const unsigned int _index)
 
std::vector< vpImagePointgetRoi (const vpCameraParameters &cam)
 
std::vector< vpImagePointgetRoi (const vpCameraParameters &cam, const vpHomogeneousMatrix &cMo)
 
void getRoiClipped (const vpCameraParameters &cam, std::vector< vpImagePoint > &roi)
 
void getRoiClipped (const vpCameraParameters &cam, std::vector< vpImagePoint > &roi, const vpHomogeneousMatrix &cMo)
 
void getRoiClipped (const vpCameraParameters &cam, std::vector< std::pair< vpImagePoint, unsigned int > > &roi)
 
void getRoiClipped (const vpCameraParameters &cam, std::vector< std::pair< vpImagePoint, unsigned int > > &roi, const vpHomogeneousMatrix &cMo)
 
void getPolygonClipped (std::vector< std::pair< vpPoint, unsigned int > > &poly)
 
void getPolygonClipped (std::vector< vpPoint > &poly)
 
vpPolygon3Doperator= (const vpPolygon3D &mbtp)
 
void setClipping (const unsigned int &flags)
 
void setFarClippingDistance (const double &dist)
 
virtual void setNbPoint (unsigned int nb)
 
void setNearClippingDistance (const double &dist)
 

Static Public Member Functions

static void getClippedPolygon (const std::vector< vpPoint > &ptIn, std::vector< vpPoint > &ptOut, const vpHomogeneousMatrix &cMo, const unsigned int &clippingFlags, const vpCameraParameters &cam=vpCameraParameters(), const double &znear=0.001, const double &zfar=100)
 
static void getMinMaxRoi (const std::vector< vpImagePoint > &roi, int &i_min, int &i_max, int &j_min, int &j_max)
 
static bool roiInsideImage (const vpImage< unsigned char > &I, const std::vector< vpImagePoint > &corners)
 

Public Attributes

unsigned int nbpt
 
unsigned int nbCornersInsidePrev
 
vpPointp
 
std::vector< std::pair< vpPoint, unsigned int > > polyClipped
 
unsigned int clippingFlag
 
double distNearClip
 
double distFarClip
 

Detailed Description

Implements a 3D polygon with render functionalities like clipping.

Definition at line 56 of file vpPolygon3D.h.

Member Enumeration Documentation

◆ vpPolygon3DClippingType

Enumerator
NO_CLIPPING 
NEAR_CLIPPING 
FAR_CLIPPING 
LEFT_CLIPPING 
RIGHT_CLIPPING 
UP_CLIPPING 
DOWN_CLIPPING 
FOV_CLIPPING 
ALL_CLIPPING 

Definition at line 59 of file vpPolygon3D.h.

Constructor & Destructor Documentation

◆ vpPolygon3D() [1/2]

BEGIN_VISP_NAMESPACE vpPolygon3D::vpPolygon3D ( )

Basic constructor.

Definition at line 55 of file vpPolygon3D.cpp.

◆ vpPolygon3D() [2/2]

vpPolygon3D::vpPolygon3D ( const vpPolygon3D mbtp)

Definition at line 60 of file vpPolygon3D.cpp.

References nbpt, and p.

◆ ~vpPolygon3D()

vpPolygon3D::~vpPolygon3D ( )
virtual

Basic destructor.

Definition at line 92 of file vpPolygon3D.cpp.

References p.

Member Function Documentation

◆ addPoint()

void vpPolygon3D::addPoint ( unsigned int  n,
const vpPoint P 
)

Add a corner point to the list of polygon's corners.

Parameters
n: The index of the corner.
P: The point to add.

Definition at line 134 of file vpPolygon3D.cpp.

References p.

Referenced by vpMbTracker::addPolygon(), vpMbTracker::addProjectionErrorPolygon(), vpMbtDistanceLine::buildFrom(), and getClippedPolygon().

◆ changeFrame()

void vpPolygon3D::changeFrame ( const vpHomogeneousMatrix cMo)

Project the 3D corner points into the image thanks to the pose of the camera.

Parameters
cMo: The pose of the camera.

Definition at line 146 of file vpPolygon3D.cpp.

References vpPoint::changeFrame(), nbpt, p, and vpPoint::projection().

Referenced by getClippedPolygon(), getRoi(), getRoiClipped(), and vpMbtPolygon::isVisible().

◆ computePolygonClipped()

void vpPolygon3D::computePolygonClipped ( const vpCameraParameters cam = vpCameraParameters())

Compute the region of interest in the image according to the used clipping.

Warning
If the FOV clipping is used, camera normals have to be precomputed.
Parameters
cam: camera parameters used to compute the field of view.

Definition at line 161 of file vpPolygon3D.cpp.

References clippingFlag, distFarClip, distNearClip, DOWN_CLIPPING, FAR_CLIPPING, vpCameraParameters::getFovNormals(), vpCameraParameters::isFovComputed(), LEFT_CLIPPING, nbpt, NO_CLIPPING, p, polyClipped, vpPoint::projection(), RIGHT_CLIPPING, and UP_CLIPPING.

Referenced by getClippedPolygon(), vpMbtDistanceLine::getModelForDisplay(), getRoiClipped(), vpMbtDistanceLine::initMovingEdge(), vpMbtPolygon::isVisible(), and vpMbtDistanceLine::updateMovingEdge().

◆ getClippedPolygon()

void vpPolygon3D::getClippedPolygon ( const std::vector< vpPoint > &  ptIn,
std::vector< vpPoint > &  ptOut,
const vpHomogeneousMatrix cMo,
const unsigned int &  clippingFlags,
const vpCameraParameters cam = vpCameraParameters(),
const double &  znear = 0.001,
const double &  zfar = 100 
)
static

Static method to compute the clipped points from a set of initial points.

Warning
When using FOV clipping and personnal camera parameters, camera normals have to be computed before (see vpCameraParameters::computeFov())
Parameters
ptIn: Input points
ptOut: Output points (result of the clipping).
cMo: Pose considered for the clipping.
clippingFlagsClipping flag (see vpPolygon3D::vpPolygon3DClippingType).
cam: Camera parameters (Only used if clipping flags contain FOV clipping).
znear: Near clipping distance value (Only used if clipping flags contain Near clipping).
zfar: Far clipping distance value (Only used if clipping flags contain Far clipping).

Definition at line 572 of file vpPolygon3D.cpp.

References addPoint(), changeFrame(), computePolygonClipped(), FAR_CLIPPING, getPolygonClipped(), NEAR_CLIPPING, setClipping(), setFarClippingDistance(), setNbPoint(), and setNearClippingDistance().

Referenced by vpImageSimulator::setCameraPosition().

◆ getClipping()

unsigned int vpPolygon3D::getClipping ( ) const
inline

Get the clipping used.

See also
vpPolygon3DClipping
Returns
Clipping flags.

Definition at line 116 of file vpPolygon3D.h.

Referenced by vpMbtDistanceLine::getModelForDisplay(), vpMbtDistanceLine::initMovingEdge(), and vpMbtDistanceLine::updateMovingEdge().

◆ getFarClippingDistance()

double vpPolygon3D::getFarClippingDistance ( ) const
inline

Get the far distance for clipping.

Returns
Far clipping value.

Definition at line 123 of file vpPolygon3D.h.

◆ getMinMaxRoi()

void vpPolygon3D::getMinMaxRoi ( const std::vector< vpImagePoint > &  roi,
int &  i_min,
int &  i_max,
int &  j_min,
int &  j_max 
)
static

Definition at line 595 of file vpPolygon3D.cpp.

◆ getNbCornerInsideImage()

unsigned int vpPolygon3D::getNbCornerInsideImage ( const vpImage< unsigned char > &  I,
const vpCameraParameters cam 
)

Static method to check the number of points of a region defined by the vector of image point that are inside the image.

Parameters
I: The image used for its size.
cam: The camera parameters.

Definition at line 535 of file vpPolygon3D.cpp.

References vpMeterPixelConversion::convertPoint(), vpImagePoint::get_i(), vpImagePoint::get_j(), vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), nbCornersInsidePrev, nbpt, and p.

◆ getNbCornerInsidePrevImage()

unsigned int vpPolygon3D::getNbCornerInsidePrevImage ( ) const
inline

Return the number of corners at the previous computation.

Returns
number of corner of the face at the previous computation

Definition at line 137 of file vpPolygon3D.h.

◆ getNbPoint()

◆ getNearClippingDistance()

double vpPolygon3D::getNearClippingDistance ( ) const
inline

Get the near distance for clipping.

Returns
Near clipping value.

Definition at line 146 of file vpPolygon3D.h.

◆ getPoint()

vpPoint & vpPolygon3D::getPoint ( const unsigned int  _index)

Get a reference to a corner.

Exceptions
vpException::dimensionErrorif the _index is out of range.
Parameters
_index: the index of the corner

Definition at line 107 of file vpPolygon3D.cpp.

References vpException::dimensionError, nbpt, and p.

◆ getPolygonClipped() [1/2]

void vpPolygon3D::getPolygonClipped ( std::vector< std::pair< vpPoint, unsigned int > > &  poly)

Get the 3D clipped points and their clipping information.

Warning
Suppose that changeFrame() and computePolygonClipped() have already been called.
Parameters
poly: resulting points plus clipping information.

Definition at line 439 of file vpPolygon3D.cpp.

References polyClipped.

Referenced by vpMbtFaceDepthNormal::computeNormalVisibility(), vpMbtFaceDepthDense::computeROI(), getClippedPolygon(), and vpMbtFaceDepthNormal::planeIsInvalid().

◆ getPolygonClipped() [2/2]

void vpPolygon3D::getPolygonClipped ( std::vector< vpPoint > &  poly)

Get the 3D clipped points.

Warning
Suppose that changeFrame() and computePolygonClipped() have already been called.
Parameters
poly: resulting points.

Definition at line 449 of file vpPolygon3D.cpp.

References polyClipped.

◆ getRoi() [1/2]

std::vector< vpImagePoint > vpPolygon3D::getRoi ( const vpCameraParameters cam)

Get the region of interest in the image.

Warning
Suppose that changeFrame() has already been called.
Parameters
cam: camera parameters.
Returns
Image point corresponding to the region of interest.

Definition at line 388 of file vpPolygon3D.cpp.

References vpMeterPixelConversion::convertPoint(), nbpt, and p.

Referenced by getRoi().

◆ getRoi() [2/2]

std::vector< vpImagePoint > vpPolygon3D::getRoi ( const vpCameraParameters cam,
const vpHomogeneousMatrix cMo 
)

Get the region of interest in the image.

Parameters
cam: camera parameters.
cMo: pose.
Returns
Image point corresponding to the region of interest.

Definition at line 408 of file vpPolygon3D.cpp.

References changeFrame(), and getRoi().

◆ getRoiClipped() [1/4]

void vpPolygon3D::getRoiClipped ( const vpCameraParameters cam,
std::vector< std::pair< vpImagePoint, unsigned int > > &  roi 
)

Get the region of interest clipped in the image and the information to know if it's a clipped point.

Warning
Suppose that changeFrame() and computePolygonClipped() have already been called.
Parameters
cam: camera parameters.
roi: image point corresponding to the region of interest with clipping information.

Definition at line 502 of file vpPolygon3D.cpp.

References vpMeterPixelConversion::convertPoint(), and polyClipped.

◆ getRoiClipped() [2/4]

void vpPolygon3D::getRoiClipped ( const vpCameraParameters cam,
std::vector< std::pair< vpImagePoint, unsigned int > > &  roi,
const vpHomogeneousMatrix cMo 
)

Get the region of interest clipped in the image and the information to know if it's a clipped point.

Parameters
cam: camera parameters.
roi: image point corresponding to the region of interest with clipping information.
cMo: pose.

Definition at line 520 of file vpPolygon3D.cpp.

References changeFrame(), computePolygonClipped(), and getRoiClipped().

◆ getRoiClipped() [3/4]

void vpPolygon3D::getRoiClipped ( const vpCameraParameters cam,
std::vector< vpImagePoint > &  roi 
)

Get the region of interest clipped in the image.

Warning
Suppose that changeFrame() and computePolygonClipped() have already been called.
Parameters
cam: camera parameters.
roi: image point corresponding to the region of interest.

Definition at line 465 of file vpPolygon3D.cpp.

References vpMeterPixelConversion::convertPoint(), and polyClipped.

Referenced by vpMbtFaceDepthNormal::computeNormalVisibility(), vpMbtFaceDepthNormal::computeROI(), vpMbtFaceDepthDense::computeROI(), getRoiClipped(), and vpMbtPolygon::isVisible().

◆ getRoiClipped() [4/4]

void vpPolygon3D::getRoiClipped ( const vpCameraParameters cam,
std::vector< vpImagePoint > &  roi,
const vpHomogeneousMatrix cMo 
)

Get the region of interest clipped in the image.

Parameters
cam: camera parameters.
cMo: pose.
roi: image point corresponding to the region of interest.

Definition at line 483 of file vpPolygon3D.cpp.

References changeFrame(), computePolygonClipped(), and getRoiClipped().

◆ operator=()

vpPolygon3D & vpPolygon3D::operator= ( const vpPolygon3D mbtp)

Definition at line 71 of file vpPolygon3D.cpp.

References clippingFlag, distFarClip, distNearClip, nbCornersInsidePrev, nbpt, p, and polyClipped.

Referenced by vpMbtPolygon::operator=().

◆ roiInsideImage()

bool vpPolygon3D::roiInsideImage ( const vpImage< unsigned char > &  I,
const std::vector< vpImagePoint > &  corners 
)
static

Static method to check whether the region defined by the vector of image point is contained entirely in the image.

Parameters
I: The image used for its size.
corners: The vector of points defining a region

Definition at line 636 of file vpPolygon3D.cpp.

References vpImage< Type >::getHeight(), and vpImage< Type >::getWidth().

◆ setClipping()

void vpPolygon3D::setClipping ( const unsigned int &  flags)
inline

Specify which clipping to use.

See also
vpPolygon3DClipping
Parameters
flags: New clipping flags.

Definition at line 185 of file vpPolygon3D.h.

Referenced by vpMbEdgeTracker::addLine(), vpMbtFaceDepthDense::addLine(), vpMbtFaceDepthNormal::addLine(), vpMbTracker::addProjectionErrorLine(), getClippedPolygon(), and vpMbEdgeTracker::setClipping().

◆ setFarClippingDistance()

void vpPolygon3D::setFarClippingDistance ( const double &  dist)
inline

Set the far distance for clipping.

Parameters
dist: Far clipping value.

Definition at line 192 of file vpPolygon3D.h.

References FAR_CLIPPING.

Referenced by vpMbEdgeTracker::addLine(), vpMbtFaceDepthDense::addLine(), vpMbtFaceDepthNormal::addLine(), vpMbTracker::addProjectionErrorLine(), getClippedPolygon(), and vpMbEdgeTracker::setFarClippingDistance().

◆ setNbPoint()

void vpPolygon3D::setNbPoint ( unsigned int  nb)
virtual

Set the number of points which are the corners of the polygon.

Parameters
nb: The number of corners.

Definition at line 120 of file vpPolygon3D.cpp.

References nbpt, and p.

Referenced by vpMbTracker::addPolygon(), vpMbTracker::addProjectionErrorPolygon(), vpMbtDistanceLine::buildFrom(), and getClippedPolygon().

◆ setNearClippingDistance()

void vpPolygon3D::setNearClippingDistance ( const double &  dist)
inline

Set the near distance for clipping.

Parameters
dist: Near clipping value.

Definition at line 205 of file vpPolygon3D.h.

References NEAR_CLIPPING.

Referenced by vpMbEdgeTracker::addLine(), vpMbtFaceDepthDense::addLine(), vpMbtFaceDepthNormal::addLine(), vpMbTracker::addProjectionErrorLine(), getClippedPolygon(), and vpMbEdgeTracker::setNearClippingDistance().

Member Data Documentation

◆ clippingFlag

unsigned int vpPolygon3D::clippingFlag

Clipping flag.

Definition at line 83 of file vpPolygon3D.h.

Referenced by computePolygonClipped(), vpMbtPolygon::isVisible(), and operator=().

◆ distFarClip

double vpPolygon3D::distFarClip

Distance for near clipping.

Definition at line 87 of file vpPolygon3D.h.

Referenced by computePolygonClipped(), and operator=().

◆ distNearClip

double vpPolygon3D::distNearClip

Distance for near clipping.

Definition at line 85 of file vpPolygon3D.h.

Referenced by computePolygonClipped(), and operator=().

◆ nbCornersInsidePrev

unsigned int vpPolygon3D::nbCornersInsidePrev

Number of corners inside the image during the last call to getNbCornerInsideImage

Definition at line 77 of file vpPolygon3D.h.

Referenced by getNbCornerInsideImage(), and operator=().

◆ nbpt

unsigned int vpPolygon3D::nbpt

◆ p

◆ polyClipped

std::vector<std::pair<vpPoint, unsigned int> > vpPolygon3D::polyClipped