Points.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef POINTS_POINT_H
00025 #define POINTS_POINT_H
00026
00027 #include <vector>
00028 #include <iterator>
00029
00030 #include <Base/Vector3D.h>
00031 #include <Base/Matrix.h>
00032 #include <Base/Reader.h>
00033 #include <Base/Writer.h>
00034
00035 #include <App/PropertyStandard.h>
00036 #include <App/PropertyGeo.h>
00037
00038 namespace Points
00039 {
00040
00041
00044 class PointsExport PointKernel : public Data::ComplexGeoData
00045 {
00046 TYPESYSTEM_HEADER();
00047
00048 public:
00049 PointKernel(void)
00050 {
00051 }
00052 PointKernel(unsigned long size)
00053 {
00054 resize(size);
00055 }
00056 virtual ~PointKernel()
00057 {
00058 }
00059
00060 void operator = (const PointKernel&);
00061
00068 virtual std::vector<const char*> getElementTypes(void) const;
00069 virtual unsigned long countSubElements(const char* Type) const;
00071 virtual Data::Segment* getSubElement(const char* Type, unsigned long) const;
00073
00074 inline void setTransform(const Base::Matrix4D& rclTrf){_Mtrx = rclTrf;}
00075 inline Base::Matrix4D getTransform(void) const{return _Mtrx;}
00076 std::vector<Base::Vector3f>& getBasicPoints()
00077 { return this->_Points; }
00078 const std::vector<Base::Vector3f>& getBasicPoints() const
00079 { return this->_Points; }
00080 void getFaces(std::vector<Base::Vector3d> &Points,std::vector<Facet> &Topo,
00081 float Accuracy, uint16_t flags=0) const;
00082
00083 virtual void transformGeometry(const Base::Matrix4D &rclMat);
00084 virtual Base::BoundBox3d getBoundBox(void)const;
00085
00088
00089 unsigned int getMemSize (void) const;
00090 void Save (Base::Writer &writer) const;
00091 void SaveDocFile (Base::Writer &writer) const;
00092 void Restore(Base::XMLReader &reader);
00093 void RestoreDocFile(Base::Reader &reader);
00094 void save(const char* file) const;
00095 void save(std::ostream&) const;
00096 void load(const char* file);
00097 void load(std::istream&);
00099
00100 private:
00101 Base::Matrix4D _Mtrx;
00102 std::vector<Base::Vector3f> _Points;
00103
00104 public:
00105 typedef std::vector<Base::Vector3f>::difference_type difference_type;
00106 typedef std::vector<Base::Vector3f>::size_type size_type;
00107
00109 size_type size(void) const {return this->_Points.size();}
00110 void resize(unsigned int n){_Points.resize(n);}
00111 void reserve(unsigned int n){_Points.reserve(n);}
00112 inline void erase(unsigned long first, unsigned long last) {
00113 _Points.erase(_Points.begin()+first,_Points.begin()+last);
00114 }
00115
00116 void clear(void){_Points.clear();}
00117
00118
00120 inline const Base::Vector3d getPoint(const int idx) const {
00121 return transformToOutside(_Points[idx]);
00122 }
00124 inline void setPoint(const int idx,const Base::Vector3d& point) {
00125 _Points[idx] = transformToInside(point);
00126 }
00128 inline void push_back(const Base::Vector3d& point) {
00129 _Points.push_back(transformToInside(point));
00130 }
00131
00132 class PointsExport const_point_iterator
00133 {
00134 public:
00135 typedef std::vector<Base::Vector3f>::const_iterator iter_type;
00136 typedef iter_type::difference_type difference_type;
00137 typedef iter_type::iterator_category iterator_category;
00138 typedef const Base::Vector3d* pointer;
00139 typedef const Base::Vector3d& reference;
00140 typedef Base::Vector3d value_type;
00141
00142 const_point_iterator(const PointKernel*, std::vector<Base::Vector3f>::const_iterator index);
00143 const_point_iterator(const const_point_iterator& pi);
00144
00145
00146 const_point_iterator& operator=(const const_point_iterator& fi);
00147 const Base::Vector3d& operator*();
00148 const Base::Vector3d* operator->();
00149 bool operator==(const const_point_iterator& fi) const;
00150 bool operator!=(const const_point_iterator& fi) const;
00151 const_point_iterator& operator++();
00152 const_point_iterator operator++(int);
00153 const_point_iterator& operator--();
00154 const_point_iterator operator--(int);
00155 const_point_iterator operator+ (difference_type off) const;
00156 const_point_iterator operator- (difference_type off) const;
00157 const_point_iterator& operator+=(difference_type off);
00158 const_point_iterator& operator-=(difference_type off);
00159 difference_type operator- (const const_point_iterator& right) const;
00160 private:
00161 void dereference();
00162 const PointKernel* _kernel;
00163 Base::Vector3d _point;
00164 std::vector<Base::Vector3f>::const_iterator _p_it;
00165 };
00166
00167 typedef const_point_iterator const_iterator;
00168 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
00169
00172 const_point_iterator begin() const
00173 { return const_point_iterator(this, _Points.begin()); }
00174 const_point_iterator end() const
00175 { return const_point_iterator(this, _Points.end()); }
00176 const_reverse_iterator rbegin() const
00177 { return const_reverse_iterator(end()); }
00178 const_reverse_iterator rend() const
00179 { return const_reverse_iterator(begin()); }
00181 };
00182
00183 }
00184
00185
00186 #endif // POINTS_POINTPROPERTIES_H