A wrapper of a TPolygon2D class, implementing CSerializable.
Definition at line 22 of file CPolygon.h.
#include <mrpt/math/CPolygon.h>
Public Member Functions | |
void * | operator new (size_t size) |
void * | operator new[] (size_t size) |
void | operator delete (void *ptr) noexcept |
void | operator delete[] (void *ptr) noexcept |
void | operator delete (void *memory, void *ptr) noexcept |
void * | operator new (size_t size, const std::nothrow_t &) noexcept |
void | operator delete (void *ptr, const std::nothrow_t &) noexcept |
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 mxArray * | writeToMatlab () 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... | |
RTTI classes and functions | |
mrpt::utils::CObject::Ptr | 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... | |
Static Public Member Functions | |
static void * | operator 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 | |
T | elements |
STL member. More... | |
Protected Member Functions | |
CSerializable virtual methods | |
void | writeToStream (mrpt::utils::CStream &out, int *getVersion) const override |
Introduces a pure virtual method responsible for writing to a CStream. More... | |
void | readFromStream (mrpt::utils::CStream &in, int version) override |
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 | |
using | Ptr = std::shared_ptr< CPolygon > |
using | ConstPtr = std::shared_ptr< const CPolygon > |
static mrpt::utils::CLASSINIT | _init_CPolygon |
static const mrpt::utils::TRuntimeClassId | runtimeClassId |
static constexpr const char * | className = "CPolygon" |
static const mrpt::utils::TRuntimeClassId * | _GetBaseClass () |
static const mrpt::utils::TRuntimeClassId & | GetRuntimeClassIdStatic () |
static mrpt::utils::CObject * | CreateObject () |
template<typename... Args> | |
static Ptr | Create (Args &&... args) |
virtual const mrpt::utils::TRuntimeClassId * | GetRuntimeClass () const override |
Returns information about the class of an object in runtime. More... | |
virtual mrpt::utils::CObject * | clone () const override |
Returns a deep copy (clone) of the object, indepently of its class. More... | |
using mrpt::math::CPolygon::ConstPtr = std::shared_ptr<const CPolygon > |
Definition at line 25 of file CPolygon.h.
using mrpt::math::CPolygon::Ptr = std::shared_ptr< CPolygon > |
A typedef for the associated smart pointer
Definition at line 25 of file CPolygon.h.
|
inline |
Default constructor (empty polygon, 0 vertices)
Definition at line 29 of file CPolygon.h.
|
staticprotected |
|
inline |
Add a new vertex to polygon.
Definition at line 31 of file CPolygon.h.
References push_back().
Referenced by mrpt::nav::CReactiveNavigationSystem::loadConfigFile(), mrpt::nav::CReactiveNavigationSystem3D::loadConfigFile(), mrpt::nav::CPTG_RobotShape_Polygonal::loadDefaultParams(), mrpt::nav::CPTG_RobotShape_Polygonal::loadShapeFromConfigFile(), and mrpt::math::RectanglesIntersection().
|
inline |
Clear the polygon, erasing all vertices.
Definition at line 64 of file CPolygon.h.
References mrpt::utils::clear().
|
overridevirtual |
Returns a deep copy (clone) of the object, indepently of its class.
Implements mrpt::utils::CObject.
|
inherited |
Check whether a point is inside (or within geometryEpsilon of a polygon edge).
This works for concave or convex polygons.
Definition at line 938 of file lightweight_geom_data.cpp.
References mrpt::math::isLeft(), mrpt::math::size(), and mrpt::math::TPoint2D::y.
Referenced by mrpt::math::TPolygon3D::contains(), mrpt::math::TPolygon2D::distance(), mrpt::nav::CPTG_DiffDrive_CollisionGridBased::internal_initialize(), mrpt::math::intersect(), intersect(), mrpt::nav::CPTG_RobotShape_Polygonal::isPointInsideRobotShape(), myTestPolygonContainsPoint(), and PointIntoPolygon().
|
inlinestatic |
Definition at line 25 of file CPolygon.h.
|
static |
|
staticinherited |
Static method to create a regular polygon, given its size and radius.
std::logic_error | if radius is near zero or the number of edges is less than three. |
Definition at line 1050 of file lightweight_geom_data.cpp.
References mrpt::math::getEpsilon(), and M_PI.
Referenced by mrpt::math::TPolygon2D::createRegularPolygon().
|
inlinestaticinherited |
Static method to create a regular polygon from its size and radius.
The center will correspond to the given pose.
std::logic_error | if radius is near zero or the number of edges is less than three. |
Definition at line 1063 of file lightweight_geom_data.cpp.
References mrpt::math::TPolygon2D::createRegularPolygon().
|
inherited |
Distance to a point (always >=0)
Definition at line 890 of file lightweight_geom_data.cpp.
References mrpt::math::TPolygon2D::contains(), mrpt::math::TPolygon2D::getAsSegmentList(), and THROW_EXCEPTION.
Referenced by mrpt::math::TPolygon3D::distance().
|
inherited |
Projects into 3D space, zeroing the z.
Definition at line 975 of file lightweight_geom_data.cpp.
void CPolygon::getAllVertices | ( | std::vector< double > & | x, |
std::vector< double > & | y | ||
) | const |
Get all vertices at once.
Definition at line 171 of file CPolygon.cpp.
References mrpt::utils::operator[]().
|
inherited |
Gets as set of segments, instead of points.
Definition at line 966 of file lightweight_geom_data.cpp.
References mrpt::math::size().
Referenced by mrpt::math::TPolygon2D::distance(), and mrpt::math::TPolygon2D::isConvex().
|
inherited |
Get polygon bounding box.
On | empty polygon |
Definition at line 910 of file lightweight_geom_data.cpp.
References ASSERTMSG_, empty(), mrpt::mrpt::utils::keep_max(), mrpt::mrpt::utils::keep_min(), mrpt::math::size(), mrpt::math::TPoint2D::x, and mrpt::math::TPoint2D::y.
Polygon's central point.
Definition at line 994 of file lightweight_geom_data.cpp.
References begin(), and mrpt::math::size().
|
inherited |
Gets plot data, ready to use on a 2D plot.
Definition at line 1030 of file lightweight_geom_data.cpp.
References mrpt::utils::operator[](), and mrpt::math::size().
Referenced by mrpt::nav::PlannerTPS_VirtualBase::internal_initialize_PTG().
|
overridevirtual |
Returns information about the class of an object in runtime.
Reimplemented from mrpt::utils::CSerializable.
|
static |
|
inline |
Methods for accessing the vertices.
Definition at line 37 of file CPolygon.h.
References ASSERT_, and mrpt::utils::operator[]().
Referenced by mrpt::nav::CPTG_DiffDrive_CollisionGridBased::internal_initialize(), and mrpt::nav::CReactiveNavigationSystem::loggingGetWSObstaclesAndShape().
|
inline |
Definition at line 42 of file CPolygon.h.
References ASSERT_, and mrpt::utils::operator[]().
Referenced by mrpt::nav::CPTG_DiffDrive_CollisionGridBased::internal_initialize(), and mrpt::nav::CReactiveNavigationSystem::loggingGetWSObstaclesAndShape().
|
inherited |
Checks whether is convex.
Definition at line 1001 of file lightweight_geom_data.cpp.
References mrpt::math::TLine2D::evaluatePoint(), mrpt::math::TPolygon2D::getAsSegmentList(), mrpt::math::getEpsilon(), and mrpt::math::size().
Referenced by myTestPolygonContainsPoint().
Definition at line 25 of file CPolygon.h.
Definition at line 25 of file CPolygon.h.
Definition at line 25 of file CPolygon.h.
Definition at line 25 of file CPolygon.h.
Definition at line 25 of file CPolygon.h.
|
inlinenoexcept |
Definition at line 25 of file CPolygon.h.
|
inline |
Definition at line 25 of file CPolygon.h.
|
inline |
Definition at line 25 of file CPolygon.h.
|
inline |
Check if a point is inside the polygon.
Definition at line 66 of file CPolygon.h.
References mrpt::math::TPolygon2D::contains().
Referenced by mrpt::maps::CPointsMap::internal_insertObservation(), and mrpt::math::RectanglesIntersection().
|
overrideprotectedvirtual |
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.
in | The input binary stream where the object data must read from. |
version | The version of the object stored in the stream: use this version number in your code to know how to read the incoming data. |
std::exception | On any error, see CStream::ReadBuffer |
Implements mrpt::utils::CSerializable.
Definition at line 50 of file CPolygon.cpp.
References MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION, and mrpt::utils::operator[]().
|
inherited |
Erase every redundant vertex from the polygon, saving space.
Definition at line 1025 of file lightweight_geom_data.cpp.
References mrpt::math::TPolygon2D::removeRepeatedVertices(), and mrpt::math::removeUnusedVertices().
Referenced by mrpt::math::splitInConvexComponents().
|
inherited |
Erase repeated vertices.
Definition at line 1024 of file lightweight_geom_data.cpp.
References mrpt::math::removeRepVertices().
Referenced by mrpt::math::TPolygon2D::removeRedundantVertices().
void CPolygon::setAllVertices | ( | const std::vector< double > & | x, |
const std::vector< double > & | y | ||
) |
Set all vertices at once.
Definition at line 134 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 144 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 159 of file CPolygon.cpp.
References mrpt::utils::operator[]().
|
inline |
Returns the vertices count in the polygon:
Definition at line 49 of file CPolygon.h.
Referenced by mrpt::nav::CReactiveNavigationSystem::changeRobotShape(), mrpt::nav::CReactiveNavigationSystem3D::changeRobotShape(), and mrpt::nav::CPTG_DiffDrive_CollisionGridBased::internal_initialize().
|
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.
mxArray
(caller is responsible of memory freeing) or nullptr is class does not support conversion to MATLAB. Definition at line 89 of file CSerializable.h.
|
overrideprotectedvirtual |
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.
out | The output binary stream where object must be dumped. |
getVersion | If nullptr, 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. |
std::exception | On any error, see CStream::WriteBuffer |
Implements mrpt::utils::CSerializable.
Definition at line 27 of file CPolygon.cpp.
|
staticprotected |
Definition at line 25 of file CPolygon.h.
|
static |
Definition at line 25 of file CPolygon.h.
|
inherited |
STL member.
|
staticprotected |
Definition at line 25 of file CPolygon.h.
Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019 |