Polygon2D.hpp
Go to the documentation of this file.
00001 // This is -*-c++-*-
00002 //
00003 
00004 #ifndef POLYGON2D_HPP
00005 #define POLYGON2D_HPP
00006 
00007 #include "../BasicDatatypes.hpp"
00008 #include "Point2D.hpp"
00009 #include <iosfwd> // for istream, ostream
00010 #include <vector>
00011 #include <sstream>
00012 
00013 
00014 namespace datatypes
00015 {
00016 
00017 class Line2D;
00018 class Ellipse2D;
00019 class Box2D;
00020 
00021 
00043 class Polygon2D : public std::vector<Point2D>,
00044                                         public BasicData
00045 {
00046 public:
00048         typedef std::vector<Point2D> base_class;
00049 
00052         typedef Point2D::value_type floatingpoint_type;
00053 
00055         Polygon2D();
00056 
00058         Polygon2D(const Point2D&);
00059 
00061         Polygon2D(const Point2D&, const Point2D&);
00062 
00064         Polygon2D(const Point2D&, const Point2D&, const Point2D&);
00065 
00067         Polygon2D(const Point2D&, const Point2D&, const Point2D&, const Point2D&);
00068 
00070         Polygon2D(const Line2D&);
00071 
00073         Polygon2D(const base_class&);
00074 
00076         Polygon2D(const std::string& polygonAsString);
00077 
00078         // Estimate the memory usage of this object
00079         inline virtual const UINT32 getUsedMemory() const {return ((sizeof(*this)) + sizeof(Point2D)*size());};
00080         
00083         static const char* getSeparatorCharacters();
00084 
00086         static Polygon2D fromCircle( const Point2D& center, const floatingpoint_type radius, const UINT32 samplingPoints = 32 );
00087 
00089         static Polygon2D fromEllipse( const Point2D& center, const floatingpoint_type a, const floatingpoint_type b, const floatingpoint_type angle, const UINT32 samplingPoints = 32 );
00090 
00092         static Polygon2D fromEllipse(const Ellipse2D& ellipse, const UINT32 samplingPoints = 32 );
00093 
00095 
00122         static Polygon2D fromArc(const Ellipse2D& ellipse,
00123                                                          const floatingpoint_type startAngle, const floatingpoint_type endAngle,
00124                                                          const UINT32 samplingPoints, const bool clockwise);
00125 
00127 
00169         static Polygon2D fromArc(const Ellipse2D& ellipse,
00170                                                          const floatingpoint_type startAngle, const floatingpoint_type endAngle,
00171                                                          const UINT32 samplingPoints = 32);
00172 
00174         static Polygon2D rhombus(const Point2D& center, const floatingpoint_type radius);
00175 
00191         static Polygon2D createRectangle(const Point2D& lowerLeft, const Point2D& upperRight);
00192 
00197         //\{
00205         Polygon2D& append(const Polygon2D& other);
00206 
00214         Polygon2D& append(const Point2D& point);
00215 
00223         Polygon2D& append(floatingpoint_type x, floatingpoint_type y);
00224         //\}
00225 
00227         //\{
00228 
00242         bool isClosed() const;
00243 
00249         double getArea() const;
00250 
00257         Point2D getCenterOfGravity() const;
00258 
00268         Polygon2D getSimplified() const;
00269 
00271 
00276         Box2D getBoundingBox() const;
00277 
00286         std::pair<floatingpoint_type, floatingpoint_type> getBoundingAngles() const;
00287 
00288         //\}
00289 
00291         //\{
00292 
00295         bool containsPoint(const Point2D& point) const;
00296 
00298 
00308         Point2D::value_type distanceToPoint(const Point2D& point) const;
00309 
00317         bool isColliding(const Polygon2D& p2) const;
00318 
00320 
00330         base_class isIntersecting(const Line2D& other) const;
00331 
00332         //\}
00333 
00334 
00336 
00340         std::string toString() const;
00341 
00342 
00343 };
00344 
00345 
00346 
00347 
00349 std::ostream& operator<<(std::ostream& os, const Polygon2D& point);
00350 
00351 
00352 }       // namespace datatypes
00353 
00354 #endif


libsick_ldmrs
Author(s): SICK AG , Martin Günther , Jochen Sprickerhof
autogenerated on Thu Jun 6 2019 21:02:36