Main MRPT website > C++ reference for MRPT 1.5.7
List of all members | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes

Detailed Description

A wrapper of a TPolygon2D class, implementing CSerializable.

Definition at line 25 of file CPolygon.h.

#include <mrpt/math/CPolygon.h>

Inheritance diagram for mrpt::math::CPolygon:
Inheritance graph

Public Member Functions

voidoperator new (size_t size)
 
voidoperator new[] (size_t size)
 
void operator delete (void *ptr) throw ()
 
void operator delete[] (void *ptr) throw ()
 
void operator delete (void *memory, void *ptr) throw ()
 
voidoperator new (size_t size, const std::nothrow_t &) throw ()
 
void operator delete (void *ptr, const std::nothrow_t &) throw ()
 
 CPolygon ()
 Default constructor (empty polygon, 0 vertices) More...
 
void AddVertex (double x, double y)
 Add a new vertex to polygon. More...
 
double GetVertex_x (size_t i) const
 Methods for accessing the vertices. More...
 
double GetVertex_y (size_t i) const
 
size_t verticesCount () const
 Returns the vertices count in the polygon: More...
 
void setAllVertices (const std::vector< double > &x, const std::vector< double > &y)
 Set all vertices at once. More...
 
void setAllVertices (size_t nVertices, const double *xs, const double *ys)
 Set all vertices at once. More...
 
void setAllVertices (size_t nVertices, const float *xs, const float *ys)
 Set all vertices at once. More...
 
void getAllVertices (std::vector< double > &x, std::vector< double > &y) const
 Get all vertices at once. More...
 
void Clear ()
 Clear the polygon, erasing all vertices. More...
 
bool PointIntoPolygon (double x, double y) const
 Check if a point is inside the polygon. More...
 
virtual mxArraywriteToMatlab () const
 Introduces a pure virtual method responsible for writing to a mxArray Matlab object, typically a MATLAB struct whose contents are documented in each derived class. More...
 
mrpt::utils::CObjectPtr duplicateGetSmartPtr () const
 Returns a copy of the object, indepently of its class, as a smart pointer (the newly created object will exist as long as any copy of this smart pointer). More...
 
CObjectclone () const
 Cloning interface for smart pointers. More...
 
double distance (const TPoint2D &point) const
 Distance to a point (always >=0) More...
 
bool contains (const TPoint2D &point) const
 Check whether a point is inside (or within geometryEpsilon of a polygon edge). This works for concave or convex polygons. More...
 
void getAsSegmentList (std::vector< TSegment2D > &v) const
 Gets as set of segments, instead of points. More...
 
void generate3DObject (TPolygon3D &p) const
 Projects into 3D space, zeroing the z. More...
 
void getCenter (TPoint2D &p) const
 Polygon's central point. More...
 
bool isConvex () const
 Checks whether is convex. More...
 
void removeRepeatedVertices ()
 Erase repeated vertices. More...
 
void removeRedundantVertices ()
 Erase every redundant vertex from the polygon, saving space. More...
 
void getPlotData (std::vector< double > &x, std::vector< double > &y) const
 Gets plot data, ready to use on a 2D plot. More...
 
void getBoundingBox (TPoint2D &min_coords, TPoint2D &max_coords) const
 Get polygon bounding box.

Exceptions
Onempty polygon.
More...
 

Static Public Member Functions

static voidoperator new (size_t size, void *ptr)
 
static void createRegularPolygon (size_t numEdges, double radius, TPolygon2D &poly)
 Static method to create a regular polygon, given its size and radius. More...
 
static void createRegularPolygon (size_t numEdges, double radius, TPolygon2D &poly, const mrpt::poses::CPose2D &pose)
 Static method to create a regular polygon from its size and radius. More...
 

Public Attributes

elements
 STL member. More...
 

Static Public Attributes

static const mrpt::utils::TRuntimeClassId classCObject
 
RTTI stuff
static const mrpt::utils::TRuntimeClassId classCSerializable
 

Protected Member Functions

CSerializable virtual methods
void writeToStream (mrpt::utils::CStream &out, int *getVersion) const
 Introduces a pure virtual method responsible for writing to a CStream. More...
 
void readFromStream (mrpt::utils::CStream &in, int version)
 Introduces a pure virtual method responsible for loading from a CStream This can not be used directly be users, instead use "stream >> object;" for reading it from a stream or "stream >> object_ptr;" if the class is unknown apriori. More...
 

RTTI stuff

typedef CPolygonPtr Ptr
 
typedef CPolygonPtr ConstPtr
 
static mrpt::utils::CLASSINIT _init_CPolygon
 
static mrpt::utils::TRuntimeClassId classCPolygon
 
static const mrpt::utils::TRuntimeClassIdclassinfo
 
static const mrpt::utils::TRuntimeClassId_GetBaseClass ()
 
virtual const mrpt::utils::TRuntimeClassIdGetRuntimeClass () const
 Returns information about the class of an object in runtime. More...
 
virtual mrpt::utils::CObjectduplicate () const
 Returns a copy of the object, indepently of its class. More...
 
static mrpt::utils::CObjectCreateObject ()
 
static CPolygonPtr Create ()
 

Member Typedef Documentation

typedef CPolygonPtr mrpt::math::CPolygon::ConstPtr

Definition at line 28 of file CPolygon.h.

typedef CPolygonPtr mrpt::math::CPolygon::Ptr

A typedef for the associated smart pointer

Definition at line 28 of file CPolygon.h.

Constructor & Destructor Documentation

mrpt::math::CPolygon::CPolygon ( )
inline

Default constructor (empty polygon, 0 vertices)

Definition at line 32 of file CPolygon.h.

Member Function Documentation

static const mrpt::utils::TRuntimeClassId* mrpt::math::CPolygon::_GetBaseClass ( )
staticprotected
void mrpt::math::CPolygon::AddVertex ( double  x,
double  y 
)
inline
void mrpt::math::CPolygon::Clear ( )
inline

Clear the polygon, erasing all vertices.

Definition at line 58 of file CPolygon.h.

References mrpt::utils::clear().

CObject* mrpt::utils::CObject::clone ( ) const
inlineinherited

Cloning interface for smart pointers.

Definition at line 143 of file CObject.h.

bool mrpt::math::TPolygon2D::contains ( const TPoint2D point) const
inherited
static CPolygonPtr mrpt::math::CPolygon::Create ( )
static
static mrpt::utils::CObject* mrpt::math::CPolygon::CreateObject ( )
static
void mrpt::math::TPolygon2D::createRegularPolygon ( size_t  numEdges,
double  radius,
TPolygon2D poly 
)
staticinherited

Static method to create a regular polygon, given its size and radius.

Exceptions
std::logic_errorif radius is near zero or the number of edges is less than three.

Definition at line 780 of file lightweight_geom_data.cpp.

References mrpt::math::geometryEpsilon, and M_PI.

Referenced by mrpt::math::TPolygon2D::createRegularPolygon().

void mrpt::math::TPolygon2D::createRegularPolygon ( size_t  numEdges,
double  radius,
TPolygon2D poly,
const mrpt::poses::CPose2D pose 
)
inlinestaticinherited

Static method to create a regular polygon from its size and radius.

The center will correspond to the given pose.

Exceptions
std::logic_errorif radius is near zero or the number of edges is less than three.

Definition at line 788 of file lightweight_geom_data.cpp.

References mrpt::math::TPolygon2D::createRegularPolygon().

double mrpt::math::TPolygon2D::distance ( const TPoint2D point) const
inherited

Distance to a point (always >=0)

Definition at line 640 of file lightweight_geom_data.cpp.

References mrpt::math::distance(), and THROW_EXCEPTION.

virtual mrpt::utils::CObject* mrpt::math::CPolygon::duplicate ( ) const
virtual

Returns a copy of the object, indepently of its class.

Implements mrpt::utils::CObject.

mrpt::utils::CObjectPtr mrpt::utils::CObject::duplicateGetSmartPtr ( ) const
inlineinherited

Returns a copy of the object, indepently of its class, as a smart pointer (the newly created object will exist as long as any copy of this smart pointer).

Definition at line 140 of file CObject.h.

Referenced by mrpt::obs::CRawlog::addActions(), mrpt::slam::CIncrementalMapPartitioner::addMapFrame(), and mrpt::obs::CRawlog::addObservations().

void mrpt::math::TPolygon2D::generate3DObject ( TPolygon3D p) const
inherited

Projects into 3D space, zeroing the z.

Definition at line 719 of file lightweight_geom_data.cpp.

References mrpt::math::TPolygon3D.

void CPolygon::getAllVertices ( std::vector< double > &  x,
std::vector< double > &  y 
) const

Get all vertices at once.

Definition at line 154 of file CPolygon.cpp.

References mrpt::utils::operator[]().

void mrpt::math::TPolygon2D::getAsSegmentList ( std::vector< TSegment2D > &  v) const
inherited

Gets as set of segments, instead of points.

Definition at line 712 of file lightweight_geom_data.cpp.

References mrpt::math::TPose3DQuat::size().

void mrpt::math::TPolygon2D::getBoundingBox ( TPoint2D min_coords,
TPoint2D max_coords 
) const
inherited
void mrpt::math::TPolygon2D::getCenter ( TPoint2D p) const
inherited

Polygon's central point.

Definition at line 734 of file lightweight_geom_data.cpp.

References begin(), mrpt::math::TPose3DQuat::size(), mrpt::math::TPoint2D::x, and mrpt::math::TPoint2D::y.

void mrpt::math::TPolygon2D::getPlotData ( std::vector< double > &  x,
std::vector< double > &  y 
) const
inherited
virtual const mrpt::utils::TRuntimeClassId* mrpt::math::CPolygon::GetRuntimeClass ( ) const
virtual

Returns information about the class of an object in runtime.

Reimplemented from mrpt::utils::CSerializable.

double mrpt::math::CPolygon::GetVertex_x ( size_t  i) const
inline
double mrpt::math::CPolygon::GetVertex_y ( size_t  i) const
inline
bool mrpt::math::TPolygon2D::isConvex ( ) const
inherited
void mrpt::math::CPolygon::operator delete ( void memory,
void ptr 
)
throw (
)
inline

Definition at line 28 of file CPolygon.h.

void mrpt::math::CPolygon::operator delete ( void ptr)
throw (
)
inline

Definition at line 28 of file CPolygon.h.

void mrpt::math::CPolygon::operator delete ( void ptr,
const std::nothrow_t &   
)
throw (
)
inline

Definition at line 28 of file CPolygon.h.

void mrpt::math::CPolygon::operator delete[] ( void ptr)
throw (
)
inline

Definition at line 28 of file CPolygon.h.

void* mrpt::math::CPolygon::operator new ( size_t  size,
const std::nothrow_t &   
)
throw (
)
inline

Definition at line 28 of file CPolygon.h.

static void* mrpt::math::CPolygon::operator new ( size_t  size,
void ptr 
)
inlinestatic

Definition at line 28 of file CPolygon.h.

void* mrpt::math::CPolygon::operator new ( size_t  size)
inline

Definition at line 28 of file CPolygon.h.

void* mrpt::math::CPolygon::operator new[] ( size_t  size)
inline

Definition at line 28 of file CPolygon.h.

bool mrpt::math::CPolygon::PointIntoPolygon ( double  x,
double  y 
) const
inline
void CPolygon::readFromStream ( mrpt::utils::CStream in,
int  version 
)
protectedvirtual

Introduces a pure virtual method responsible for loading from a CStream This can not be used directly be users, instead use "stream >> object;" for reading it from a stream or "stream >> object_ptr;" if the class is unknown apriori.

Parameters
inThe input binary stream where the object data must read from.
versionThe version of the object stored in the stream: use this version number in your code to know how to read the incoming data.
Exceptions
std::exceptionOn any error, see CStream::ReadBuffer
See also
CStream

Implements mrpt::utils::CSerializable.

Definition at line 53 of file CPolygon.cpp.

References MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION, mrpt::utils::operator[](), and mrpt::utils::CStream::ReadBufferFixEndianness().

void mrpt::math::TPolygon2D::removeRedundantVertices ( )
inherited

Erase every redundant vertex from the polygon, saving space.

See also
removeRepeatedVertices

Definition at line 760 of file lightweight_geom_data.cpp.

References mrpt::math::removeUnusedVertices().

Referenced by mrpt::math::splitInConvexComponents().

void mrpt::math::TPolygon2D::removeRepeatedVertices ( )
inherited

Erase repeated vertices.

See also
removeRedundantVertices

Definition at line 757 of file lightweight_geom_data.cpp.

References mrpt::math::removeRepVertices().

Referenced by mrpt::math::TPolygon3D::removeRedundantVertices().

void CPolygon::setAllVertices ( const std::vector< double > &  x,
const std::vector< double > &  y 
)

Set all vertices at once.

Definition at line 119 of file CPolygon.cpp.

References ASSERT_.

Referenced by mrpt::maps::CPointsMap::internal_insertObservation().

void CPolygon::setAllVertices ( size_t  nVertices,
const double *  xs,
const double *  ys 
)

Set all vertices at once.

Please use the std::vector version whenever possible unless efficiency is really an issue

Definition at line 128 of file CPolygon.cpp.

References mrpt::utils::operator[]().

void CPolygon::setAllVertices ( size_t  nVertices,
const float *  xs,
const float *  ys 
)

Set all vertices at once.

Please use the std::vector version whenever possible unless efficiency is really an issue

Definition at line 143 of file CPolygon.cpp.

References mrpt::utils::operator[]().

size_t mrpt::math::CPolygon::verticesCount ( ) const
inline
virtual mxArray* mrpt::utils::CSerializable::writeToMatlab ( ) const
inlinevirtualinherited

Introduces a pure virtual method responsible for writing to a mxArray Matlab object, typically a MATLAB struct whose contents are documented in each derived class.

Returns
A new mxArray (caller is responsible of memory freeing) or NULL is class does not support conversion to MATLAB.

Definition at line 79 of file CSerializable.h.

References BASE_IMPEXP, DEFINE_MRPT_OBJECT_POST, mrpt::utils::ObjectToOctetVector(), mrpt::utils::ObjectToRawString(), mrpt::utils::ObjectToString(), mrpt::utils::OctetVectorToObject(), mrpt::utils::RawStringToObject(), and mrpt::utils::StringToObject().

Referenced by mrpt::poses::operator<<(), mrpt::utils::TCamera::readFromStream(), mrpt::obs::CObservationImage::readFromStream(), mrpt::obs::CObservationStereoImages::readFromStream(), mrpt::obs::CObservation2DRangeScan::readFromStream(), and mrpt::utils::CImage::readFromStream().

void CPolygon::writeToStream ( mrpt::utils::CStream out,
int getVersion 
) const
protectedvirtual

Introduces a pure virtual method responsible for writing to a CStream.

This can not be used directly be users, instead use "stream << object;" for writing it to a stream.

Parameters
outThe output binary stream where object must be dumped.
getVersionIf NULL, the object must be dumped. If not, only the version of the object dump must be returned in this pointer. This enables the versioning of objects dumping and backward compatibility with previously stored data.
Exceptions
std::exceptionOn any error, see CStream::WriteBuffer
See also
CStream

Implements mrpt::utils::CSerializable.

Definition at line 30 of file CPolygon.cpp.

Member Data Documentation

mrpt::utils::CLASSINIT mrpt::math::CPolygon::_init_CPolygon
staticprotected

Definition at line 28 of file CPolygon.h.

const mrpt::utils::TRuntimeClassId mrpt::utils::CObject::classCObject
staticinherited

Definition at line 128 of file CObject.h.

mrpt::utils::TRuntimeClassId mrpt::math::CPolygon::classCPolygon
static

Definition at line 28 of file CPolygon.h.

const mrpt::utils::TRuntimeClassId mrpt::utils::CSerializable::classCSerializable
staticinherited

Definition at line 42 of file CSerializable.h.

const mrpt::utils::TRuntimeClassId* mrpt::math::CPolygon::classinfo
static

Definition at line 28 of file CPolygon.h.

T std::vector< T >::elements
inherited

STL member.




Page generated by Doxygen 1.8.11 for MRPT 1.5.7 Git: 2190203 Tue May 15 02:01:15 2018 +0200 at miƩ may 16 12:40:16 CEST 2018