MRPT  2.0.4
List of all members | Public Member Functions | Static Public Member Functions | Public Attributes

Detailed Description

A wrapper of a TPolygon2D class, implementing CSerializable.

Definition at line 19 of file CPolygon.h.

#include <mrpt/math/CPolygon.h>

Inheritance diagram for mrpt::math::CPolygon:

Public Member Functions

 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...
 
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). 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. More...
 

Static Public Member Functions

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::math::TPose2D &pose)
 Static method to create a regular polygon from its size and radius. More...
 

Public Attributes

elements
 STL member. More...
 

Protected Member Functions

CSerializable virtual methods
uint8_t serializeGetVersion () const override
 Must return the current versioning number of the object. More...
 
void serializeTo (mrpt::serialization::CArchive &out) const override
 Pure virtual method for writing (serializing) to an abstract archive. More...
 
void serializeFrom (mrpt::serialization::CArchive &in, uint8_t serial_version) override
 Pure virtual method for reading (deserializing) from an abstract archive. More...
 

RTTI stuff


using Ptr = std::shared_ptr< mrpt::math ::CPolygon >
 
using ConstPtr = std::shared_ptr< const mrpt::math ::CPolygon >
 
using UniquePtr = std::unique_ptr< mrpt::math ::CPolygon >
 
using ConstUniquePtr = std::unique_ptr< const mrpt::math ::CPolygon >
 
static const mrpt::rtti::TRuntimeClassId runtimeClassId
 
static constexpr const char * className = "mrpt::math" "::" "CPolygon"
 
static const mrpt::rtti::TRuntimeClassId_GetBaseClass ()
 
static constexpr auto getClassName ()
 
static const mrpt::rtti::TRuntimeClassIdGetRuntimeClassIdStatic ()
 
static std::shared_ptr< CObjectCreateObject ()
 
template<typename... Args>
static Ptr Create (Args &&... args)
 
template<typename Alloc , typename... Args>
static Ptr CreateAlloc (const Alloc &alloc, Args &&... args)
 
template<typename... Args>
static UniquePtr CreateUnique (Args &&... args)
 
virtual const mrpt::rtti::TRuntimeClassIdGetRuntimeClass () const override
 Returns information about the class of an object in runtime. More...
 
virtual mrpt::rtti::CObjectclone () const override
 Returns a deep copy (clone) of the object, indepently of its class. More...
 

Member Typedef Documentation

◆ ConstPtr

using mrpt::math::CPolygon::ConstPtr = std::shared_ptr<const mrpt::math :: CPolygon >

Definition at line 22 of file CPolygon.h.

◆ ConstUniquePtr

using mrpt::math::CPolygon::ConstUniquePtr = std::unique_ptr<const mrpt::math :: CPolygon >

Definition at line 22 of file CPolygon.h.

◆ Ptr

using mrpt::math::CPolygon::Ptr = std::shared_ptr< mrpt::math :: CPolygon >

A type for the associated smart pointer

Definition at line 22 of file CPolygon.h.

◆ UniquePtr

using mrpt::math::CPolygon::UniquePtr = std::unique_ptr< mrpt::math :: CPolygon >

Definition at line 22 of file CPolygon.h.

Constructor & Destructor Documentation

◆ CPolygon()

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

Default constructor (empty polygon, 0 vertices)

Definition at line 26 of file CPolygon.h.

Member Function Documentation

◆ _GetBaseClass()

static const mrpt::rtti::TRuntimeClassId* mrpt::math::CPolygon::_GetBaseClass ( )
staticprotected

◆ AddVertex()

void mrpt::math::CPolygon::AddVertex ( double  x,
double  y 
)
inline

◆ Clear()

void mrpt::math::CPolygon::Clear ( )
inline

Clear the polygon, erasing all vertices.

Definition at line 61 of file CPolygon.h.

References mrpt::containers::clear().

◆ clone()

virtual mrpt::rtti::CObject* mrpt::math::CPolygon::clone ( ) const
overridevirtual

Returns a deep copy (clone) of the object, indepently of its class.

Implements mrpt::rtti::CObject.

◆ contains()

bool TPolygon2D::contains ( const TPoint2D point) const
inherited

◆ Create()

template<typename... Args>
static Ptr mrpt::math::CPolygon::Create ( Args &&...  args)
inlinestatic

Definition at line 22 of file CPolygon.h.

◆ CreateAlloc()

template<typename Alloc , typename... Args>
static Ptr mrpt::math::CPolygon::CreateAlloc ( const Alloc &  alloc,
Args &&...  args 
)
inlinestatic

Definition at line 22 of file CPolygon.h.

◆ CreateObject()

static std::shared_ptr<CObject> mrpt::math::CPolygon::CreateObject ( )
static

◆ createRegularPolygon() [1/2]

void 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 166 of file TPolygon2D.cpp.

References mrpt::math::getEpsilon(), and M_PI.

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

◆ createRegularPolygon() [2/2]

void TPolygon2D::createRegularPolygon ( size_t  numEdges,
double  radius,
TPolygon2D poly,
const mrpt::math::TPose2D 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 180 of file TPolygon2D.cpp.

References mrpt::math::TPose2D::composePoint(), and mrpt::math::TPolygon2D::createRegularPolygon().

◆ CreateUnique()

template<typename... Args>
static UniquePtr mrpt::math::CPolygon::CreateUnique ( Args &&...  args)
inlinestatic

Definition at line 22 of file CPolygon.h.

◆ distance()

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

Distance to a point (always >=0)

Definition at line 22 of file TPolygon2D.cpp.

References mrpt::math::TPolygon2D::contains(), mrpt::math::TPolygon2D::getAsSegmentList(), and THROW_EXCEPTION.

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

◆ duplicateGetSmartPtr()

mrpt::rtti::CObject::Ptr CObject::duplicateGetSmartPtr ( ) const
inlineinherited

Makes a deep copy of the object and returns a smart pointer to it.

Definition at line 204 of file CObject.h.

References mrpt::rtti::CObject::clone().

Referenced by mrpt::obs::CRawlog::insert().

◆ generate3DObject()

void TPolygon2D::generate3DObject ( TPolygon3D p) const
inherited

Projects into 3D space, zeroing the z.

Definition at line 106 of file TPolygon2D.cpp.

◆ getAllVertices()

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

Get all vertices at once.

Definition at line 158 of file CPolygon.cpp.

References mrpt::containers::operator[](), and mrpt::math::size().

◆ getAsSegmentList()

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

Gets as set of segments, instead of points.

Definition at line 97 of file TPolygon2D.cpp.

References mrpt::math::size().

Referenced by mrpt::math::TPolygon2D::distance(), and mrpt::math::TPolygon2D::isConvex().

◆ getBoundingBox()

void TPolygon2D::getBoundingBox ( TPoint2D min_coords,
TPoint2D max_coords 
) const
inherited

Get polygon bounding box.

Exceptions
Onempty polygon

Definition at line 41 of file TPolygon2D.cpp.

References ASSERTMSG_, mrpt::containers::empty(), mrpt::keep_max(), mrpt::keep_min(), mrpt::math::size(), mrpt::math::TPoint2D_data< T >::x, and mrpt::math::TPoint2D_data< T >::y.

◆ getCenter()

void TPolygon2D::getCenter ( TPoint2D p) const
inherited

◆ getClassName()

static constexpr auto mrpt::math::CPolygon::getClassName ( )
inlinestaticconstexpr

Definition at line 22 of file CPolygon.h.

◆ getPlotData()

void TPolygon2D::getPlotData ( std::vector< double > &  x,
std::vector< double > &  y 
) const
inherited

Gets plot data, ready to use on a 2D plot.

See also
mrpt::gui::CDisplayWindowPlots

Definition at line 146 of file TPolygon2D.cpp.

References mrpt::containers::operator[](), and mrpt::math::size().

Referenced by mrpt::nav::PlannerTPS_VirtualBase::internal_initialize_PTG().

◆ GetRuntimeClass()

virtual const mrpt::rtti::TRuntimeClassId* mrpt::math::CPolygon::GetRuntimeClass ( ) const
overridevirtual

Returns information about the class of an object in runtime.

Reimplemented from mrpt::serialization::CSerializable.

◆ GetRuntimeClassIdStatic()

static const mrpt::rtti::TRuntimeClassId& mrpt::math::CPolygon::GetRuntimeClassIdStatic ( )
static

◆ GetVertex_x()

double mrpt::math::CPolygon::GetVertex_x ( size_t  i) const
inline

◆ GetVertex_y()

double mrpt::math::CPolygon::GetVertex_y ( size_t  i) const
inline

◆ isConvex()

bool TPolygon2D::isConvex ( ) const
inherited

Checks whether is convex.

Definition at line 117 of file TPolygon2D.cpp.

References mrpt::math::TPolygon2D::getAsSegmentList(), mrpt::math::getEpsilon(), and mrpt::math::size().

Referenced by myTestPolygonContainsPoint().

◆ PointIntoPolygon()

bool mrpt::math::CPolygon::PointIntoPolygon ( double  x,
double  y 
) const
inline

Check if a point is inside the polygon.

Definition at line 63 of file CPolygon.h.

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

Referenced by mrpt::maps::CPointsMap::internal_insertObservation(), and mrpt::math::RectanglesIntersection().

◆ removeRedundantVertices()

void TPolygon2D::removeRedundantVertices ( )
inherited

Erase every redundant vertex from the polygon, saving space.

See also
removeRepeatedVertices

Definition at line 141 of file TPolygon2D.cpp.

References mrpt::math::TPolygon2D::removeRepeatedVertices(), and mrpt::math::removeUnusedVertices().

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

◆ removeRepeatedVertices()

void TPolygon2D::removeRepeatedVertices ( )
inherited

Erase repeated vertices.

See also
removeRedundantVertices

Definition at line 140 of file TPolygon2D.cpp.

References mrpt::math::removeRepVertices().

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

◆ serializeFrom() [1/2]

virtual void mrpt::serialization::CSerializable::serializeFrom ( CSchemeArchiveBase in)
inlineprotectedvirtualinherited

Virtual method for reading (deserializing) from an abstract schema based archive.

Definition at line 74 of file CSerializable.h.

References mrpt::serialization::CSerializable::GetRuntimeClass(), and THROW_EXCEPTION.

◆ serializeFrom() [2/2]

void CPolygon::serializeFrom ( mrpt::serialization::CArchive in,
uint8_t  serial_version 
)
overrideprotectedvirtual

Pure virtual method for reading (deserializing) from an abstract archive.

Users don't call this method directly. Instead, use stream >> object;.

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 I/O error

Implements mrpt::serialization::CSerializable.

Definition at line 37 of file CPolygon.cpp.

References MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION, mrpt::containers::operator[](), mrpt::serialization::CArchive::ReadBufferFixEndianness(), and resize().

◆ serializeGetVersion()

uint8_t CPolygon::serializeGetVersion ( ) const
overrideprotectedvirtual

Must return the current versioning number of the object.

Start in zero for new classes, and increments each time there is a change in the stored format.

Implements mrpt::serialization::CSerializable.

Definition at line 22 of file CPolygon.cpp.

◆ serializeTo() [1/2]

virtual void mrpt::serialization::CSerializable::serializeTo ( CSchemeArchiveBase out) const
inlineprotectedvirtualinherited

Virtual method for writing (serializing) to an abstract schema based archive.

Definition at line 64 of file CSerializable.h.

References mrpt::serialization::CSerializable::GetRuntimeClass(), and THROW_EXCEPTION.

◆ serializeTo() [2/2]

void CPolygon::serializeTo ( mrpt::serialization::CArchive out) const
overrideprotectedvirtual

Pure virtual method for writing (serializing) to an abstract archive.

Users don't call this method directly. Instead, use stream << object;.

Exceptions
std::exceptionOn any I/O error

Implements mrpt::serialization::CSerializable.

Definition at line 23 of file CPolygon.cpp.

References out, and mrpt::math::size().

◆ setAllVertices() [1/3]

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

Set all vertices at once.

Definition at line 121 of file CPolygon.cpp.

References ASSERT_.

Referenced by mrpt::nav::PlannerTPS_VirtualBase::internal_initialize_PTG(), and mrpt::maps::CPointsMap::internal_insertObservation().

◆ setAllVertices() [2/3]

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 131 of file CPolygon.cpp.

References mrpt::containers::operator[](), and resize().

◆ setAllVertices() [3/3]

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 146 of file CPolygon.cpp.

References mrpt::containers::operator[](), and resize().

◆ verticesCount()

size_t mrpt::math::CPolygon::verticesCount ( ) const
inline

◆ writeToMatlab()

virtual mxArray* mrpt::serialization::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 nullptr is class does not support conversion to MATLAB.

Definition at line 90 of file CSerializable.h.

Member Data Documentation

◆ className

constexpr const char* mrpt::math::CPolygon::className = "mrpt::math" "::" "CPolygon"
staticconstexpr

Definition at line 22 of file CPolygon.h.

◆ elements

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

STL member.

◆ runtimeClassId

const mrpt::rtti::TRuntimeClassId mrpt::math::CPolygon::runtimeClassId
staticprotected

Definition at line 22 of file CPolygon.h.




Page generated by Doxygen 1.8.17 for MRPT 2.0.4 at Sun Jul 19 17:54:30 UTC 2020