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