00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 # ifndef shape_point_set_hpp
00013 # define shape_point_set_hpp
00014
00015 # include <realroot/Seq.hpp>
00016 # include <shape/point.hpp>
00017 # include <shape/vertex.hpp>
00018
00019 # define TMPL template<class C, int N, class V>
00020 # define TMPL1 template<class V>
00021
00022 # define SELF point_set<C,N, V>
00023 # define Viewer viewer<axel,W>
00024
00025 namespace mmx { namespace shape {
00026
00027 template<class C, int N= 3, class V=default_env>
00028 class point_set : public SHAPE_OF(V)
00029 {
00030 public:
00031 typedef typename SHAPE_OF(V) Shape;
00032 typedef point<C,N,V> Point;
00033 typedef typename Seq< Point >::iterator PointIterator;
00034 typedef typename Seq< Point >::const_iterator PointConstIterator;
00035
00036 point_set(void) ;
00037 point_set(unsigned n) ;
00038 ~point_set(void) ;
00039
00040 void push_back(const Point & p) ;
00041
00042 void pop(Point * vertex) ;
00043
00044 void clear(void) ;
00045
00046 inline Seq<Point>& vertices(void) { return m_vertices ; }
00047
00048 PointConstIterator begin() const { return m_vertices.begin() ; }
00049 PointIterator begin() { return m_vertices.begin() ; }
00050 PointConstIterator end() const { return m_vertices.end(); }
00051 PointIterator end() { return m_vertices.end(); }
00052
00053 const Point& vertex(unsigned i) const {
00054 return m_vertices[i] ;
00055 }
00056
00057 Point& vertex(unsigned i) {
00058 return m_vertices[i] ;
00059 }
00060
00061 unsigned nbv(void) const { return m_vertices.size() ; }
00062 unsigned size(void) const { return m_vertices.size() ; }
00063
00064 SELF& operator<<(const Point&p) { push_back(p); return *this; }
00065 SELF& push(const Point&p) { push_back(p); return *this; }
00066 private:
00067 Seq<Point> m_vertices ;
00068 } ;
00069
00070 TMPL SELF::point_set(void) : Shape() {}
00071
00072 TMPL SELF::point_set(unsigned n) : Shape(), m_vertices(n) {}
00073
00074 TMPL SELF::~point_set(void) {}
00075
00076 TMPL void
00077 SELF::push_back(const Point& p) {
00078 m_vertices.push_back(p) ;
00079 }
00080
00081 TMPL void
00082 SELF::pop(Point * vertex) {
00083
00084 }
00085
00086 TMPL void SELF::clear(void) {
00087 m_vertices.resize(0) ;
00088 }
00089
00090 template<class O, class V> struct viewer; struct axel;
00091
00092 template<class W, class C, int N, class V> Viewer&
00093 operator<<(Viewer& out, const SELF& ps) {
00094 using namespace shape;
00095
00096 typedef typename SELF::Point Point;
00097 typedef typename SELF::PointConstIterator PointIterator;
00098
00099 if(ps.nbv()>0) {
00100 out<<"<pointset size=\""<<ps.nbv()<<"\" color=\"rgb\">\n";
00101 for(PointIterator p= ps.begin(); p != ps.end(); p++) {
00102 use<point_def,C,V>::print_with_color(out, *p);
00103 out <<"\n";
00104 }
00105 out<<" </pointset>\n ";
00106 }
00107 return out;
00108 }
00109
00110 } ;
00111 } ;
00112
00113 # undef TMPL
00114 # undef TMPL1
00115 # undef Shape
00116 # undef SELF
00117 # undef Viewer
00118 # endif // shape_point_set_hpp