00001
00002
00003
00004
00005
00006
00008 #ifndef synaps_topology_point_set_H
00009 #define synaps_topology_point_set_H
00010
00011
00012 #include <iostream>
00013 #include <vector>
00014 #include "synaps/init.h"
00015 #include "synaps/topology/point.h"
00016
00017 __BEGIN_NAMESPACE_SYNAPS
00018
00019 namespace topology
00020 {
00022 template <class C, class Point= topology::point<C> >
00023 struct point_set
00024 {
00025 typedef std::vector<Point> rep_t;
00026 typedef Point value_type;
00027 typedef Point point_t;
00028 typedef unsigned size_type;
00029 typedef typename rep_t::iterator iterator;
00030 typedef typename rep_t::const_iterator const_iterator;
00031
00033 typedef typename Point::coeff_t coeff_t;
00034
00035 rep_t rep_;
00036
00037 point_set():rep_() {}
00038
00040 point_set( const point_set& S ): rep_(S.rep_){}
00041
00043 point_set( const Point & p1): rep_()
00044 {
00045 rep_.push_back(p1);
00046 }
00047
00049 point_set<C,Point>& insert( const Point & p1)
00050 {
00051 rep_.push_back(p1); return *this;
00052 }
00053
00054 iterator begin() {return rep_.begin();}
00055 const_iterator begin() const {return rep_.begin();}
00056 iterator end() {return rep_.end();}
00057 const_iterator end() const {return rep_.end();}
00058
00059 unsigned size() const {return rep_.size();}
00060
00061 void resize(int n) {return rep_.resize(n);}
00062
00063 Point & operator[] (unsigned i) {return rep_[i];}
00064 Point operator[] (unsigned i) const {return rep_[i];}
00065
00066 };
00067
00068
00072 template <class C, class R>
00073 std::ostream&
00074 print( std::ostream& os, const topology::point_set<C,R>& s )
00075 {
00076 typedef typename topology::point_set<C,R>::const_iterator const_iterator;
00077 const_iterator it=s.begin();
00078 os <<(*it); ++it;
00079 for( ; it !=s.end(); it++) os<<","<<*it;
00080 return os;
00081 }
00082
00084 template <class Point>
00085 std::ostream &
00086 operator<<( std::ostream& os, const topology::point_set<Point>& s )
00087 {
00088 os << "PointSet("; topology::print(os,s);os << ")";
00089 return os;
00090 }
00091
00096 template<class Point>
00097 std::istream &
00098 operator>>(std::istream & is, topology::point_set<Point>& s)
00099 {
00100 is >> s.a >> s.b;
00101 return is;
00102 }
00103 }
00104
00105
00106 __END_NAMESPACE_SYNAPS
00107 #endif // synaps_topology_point_set_H