00001 // This is -*-c++-*- 00002 // 00003 // 00004 // Polygon3d.hpp 00005 // 00006 00007 #ifndef POLYGON3D_HPP 00008 #define POLYGON3D_HPP 00009 00010 #include "../BasicDatatypes.hpp" 00011 #include <iosfwd> // for istream, ostream 00012 #include <vector> 00013 #include "Point3D.hpp" 00014 00015 00016 namespace datatypes 00017 { 00018 00019 // 00020 // A polygon of 3D-points. 00021 // 00022 // The points can be accessed through the std::vector interface. 00023 class Polygon3D : public std::vector<Point3D>, 00024 public BasicData 00025 { 00026 public: 00028 typedef std::vector<Point3D> base_class; 00029 00032 typedef Point3D::floatingpoint_type floatingpoint_type; 00033 00035 Polygon3D(); 00036 00038 Polygon3D(const Point3D&); 00039 00041 Polygon3D(const Point3D&, const Point3D&); 00042 00044 Polygon3D(const Point3D&, const Point3D&, const Point3D&); 00045 00047 Polygon3D(const base_class&); 00048 00049 // Estimate the memory usage of this object 00050 inline virtual const UINT32 getUsedMemory() const {return ((sizeof(*this)) + sizeof(Point3D)*size());}; 00051 00052 void sortForAngleXYPlane(); 00053 00055 bool operator==(const Polygon3D& other) const 00056 { 00057 return static_cast<const base_class&>(*this) 00058 == static_cast<const base_class&>(other); 00059 } 00060 00070 Polygon3D getMovedPath(double dist) const; 00071 00073 //\{ 00074 00075 std::istream& read (std::istream& is, UINT32 version); 00076 void read (const BYTE*& buf, UINT32 version); 00077 std::ostream& write (std::ostream& os, UINT32 version) const; 00078 void write (BYTE*& buf, UINT32 version) const; 00079 std::streamsize getSerializedSize(UINT32 version) const; 00080 std::string toString() const; 00081 00099 void fromString(const std::string& polyString); 00100 00101 //\} 00102 }; 00103 00104 std::ostream& operator<<(std::ostream& os, const Polygon3D& point); 00105 00106 } // namespace datatypes 00107 00108 #endif