shape_doc 0.1
|
00001 /***************************************************************************** 00002 * M a t h e m a g i x 00003 ***************************************************************************** 00004 * Curve_piecewise_linear 00005 * 2008-03-28 00006 * Julien Wintz 00007 ***************************************************************************** 00008 * Copyright (C) 2006 INRIA Sophia-Antipolis 00009 ***************************************************************************** 00010 * Comments : 00011 ****************************************************************************/ 00012 00013 # ifndef shape_edge_set_hpp 00014 # define shape_edge_set_hpp 00015 00016 # include <realroot/Seq.hpp> 00017 # include <shape/point_set.hpp> 00018 # include <shape/edge.hpp> 00019 # include <shape/bounding_box.hpp> 00020 # include <shape/curve.hpp> 00021 00022 # define TMPL template<class C, class V> 00023 # define TMPL1 template<class V> 00024 # define SELF edge_set<C,V> 00025 # define REF REF_OF(V) 00026 # define Viewer viewer<axel,V> 00027 //==================================================================== 00028 namespace mmx { 00029 namespace shape { 00030 //==================================================================== 00031 template<class C, class V=default_env> 00032 class edge_set : public curve<REF>, public point_set<C,REF> 00033 { 00034 public: 00035 typedef curve<REF> Curve; 00036 typedef point_set<C,REF> PointSet; 00037 typedef point<C,REF> Point; 00038 typedef bounding_box<C,REF> BoundingBox; 00039 typedef edge<C,V> Edge; 00040 00041 edge_set(void) ; 00042 edge_set(unsigned np, unsigned ne=0) ; 00043 edge_set(const BoundingBox& box) ; 00044 ~edge_set(void) ; 00045 00046 bool closed(void) ; 00047 bool opened(void) ; 00048 00049 void sort(void) ; 00050 void link(void) ; 00051 00052 void push_edge(Edge* e) ; 00053 00054 void pop(Point * vertex) ; 00055 void pop(Edge * edge) ; 00056 00057 void clear(void) ; 00058 00059 00060 inline Seq<Edge*>& edges(void) { 00061 return m_edges ; 00062 } 00063 00064 Seq<Edge*> edges(void) const { 00065 return m_edges ; 00066 } 00067 00068 const Edge& get_edge(unsigned i) const { return *(m_edges[i]) ; } 00069 Edge& get_edge(unsigned i) { return *(m_edges[i]) ; } 00070 00071 SELF& operator<< (Edge * e) {m_edges.push_back(e); return *this;} 00072 00073 inline unsigned nbe(void) const { 00074 return m_edges.size() ; 00075 } 00076 Seq<Point *> criticalpoints(void) ; 00077 Seq<Point *> extremalpoints(void) ; 00078 Seq<Point *> singularpoints(void) ; 00079 00080 private: 00081 Seq<Edge*> m_edges ; 00082 } ; 00083 00084 TMPL SELF::edge_set(void) : PointSet() {} 00085 TMPL SELF::edge_set(unsigned np, unsigned ne) : PointSet(np), m_edges(ne) {} 00086 00087 TMPL SELF::edge_set(const BoundingBox & box) : Curve(box), PointSet() {} 00088 00089 TMPL SELF::~edge_set(void) {} 00090 00091 TMPL bool 00092 SELF::closed(void) { return false ; } 00093 00094 TMPL bool 00095 SELF::opened(void) { return false ; } 00096 00097 TMPL void 00098 SELF::link(void) { 00099 // for(unsigned int i = 0 ; i < m_vertices.size()-1 ; i++) 00100 // push(new Edge(at(m_vertices, i), at(m_vertices, i+1))) ; 00101 } 00102 00103 TMPL void 00104 SELF::push_edge(Edge* e) { 00105 m_edges.push_back(e) ; 00106 } 00107 00108 TMPL void 00109 SELF::pop(Point * vertex) { 00110 // remove(m_vertices, vertex) ; 00111 } 00112 00113 TMPL void 00114 SELF::pop(Edge * edge) { 00115 // remove(m_edges, edge) ; 00116 } 00117 00118 TMPL void 00119 SELF::clear(void) { 00120 this->PointSet::clear() ; 00121 m_edges.resize(0); 00122 } 00123 00124 // Seq<Point *> SELF::criticalPoints(void) 00125 // { 00126 // Seq<Point *> l ; 00127 // // ... 00128 // return l ; 00129 // } 00130 00131 // Seq<Point *> SELF::extremalPoints(void) 00132 // { 00133 // Seq<Point *> l ; 00134 // // ... 00135 // return l ; 00136 // } 00137 00138 // Seq<Point *> SELF::singularPoints(void) 00139 // { 00140 // Seq<Point *> l ; 00141 // // ... 00142 // return l ; 00143 // } 00144 //-------------------------------------------------------------------- 00145 TMPL struct viewer; struct axel; 00146 TMPL Viewer& 00147 operator<<(Viewer& out, const SELF& s) { 00148 typedef typename SELF::Edge Edge; 00149 out<<" <curve type=\"mesh\">\n<vect>\nVECT\n"; 00150 out<<s.nbe()<<" " 00151 <<2*s.nbe()<<" " 00152 <<s.nbe()<<"\n"; 00153 for(unsigned i=0; i<s.nbe();i++) out<<"2 "; 00154 out<<"\n"; 00155 for(unsigned i=0; i<2*s.nbe();i++) out<<"1 "; 00156 out<<"\n"; 00157 foreach(Edge* e, s.edges()) { 00158 out <<e->source()->x()<<" " 00159 <<e->source()->y()<<" " 00160 <<e->source()->z()<<" " 00161 <<e->destination()->x()<<" " 00162 <<e->destination()->y()<<" " 00163 <<e->destination()->z()<<"\n"; 00164 } 00165 for(unsigned i=0; i<s.nbe();i++) 00166 out<< "0.98 0.05 0.05 1\n"; 00167 out<<" </vect>\n </curve>\n"; 00168 return out; 00169 } 00170 //==================================================================== 00171 } ; // namespace shape 00172 } ; // namespace mmx 00173 //==================================================================== 00174 # undef TMPL 00175 # undef TMPL1 00176 # undef SELF 00177 # undef REF 00178 # endif // shape_edge_set_hpp