00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 # ifndef TOPOLOGY_H
00014 # define TOPOLOGY_H
00015 #include <realroot/Seq.hpp>
00016 #include <shape/point_with_idx.hpp>
00017 #include <shape/face.hpp>
00018 #include <shape/edge.hpp>
00019 #include <shape/bcell.hpp>
00020 #include <shape/bounding_box.hpp>
00021
00022 # define TMPL template<class C, class V>
00023 # define SHAPE geometric<V>
00024 # define SELF topology<C,V>
00025
00026
00027 namespace mmx {
00028 namespace shape {
00029
00030
00031 TMPL class topology;
00032
00033
00034 struct topology_def {};
00035
00036 template<>struct use<topology_def>
00037 :public use<vertex_def>
00038 {
00039 typedef use<scalar_def>::Scalar Scalar;
00040 typedef use<shape_def>::Shape Shape;
00041
00042 typedef with_idx<double> W;
00043 typedef vertex<Scalar> Point;
00044 typedef edge<Scalar,default_env,Point> Edge;
00045 typedef face<Scalar,default_env,Point> Face;
00046
00047 typedef use<bcell_def>::BoundingBox BoundingBox;
00048 typedef use<bcell_def>::Cell Cell;
00049
00050 typedef topology<Scalar,double> Topology;
00051 };
00052
00053
00054 struct topology2d_def {};
00055
00056 template<>struct use<topology2d_def>
00057 :public use<vertex_def>
00058 {
00059 typedef use<scalar_def>::Scalar Scalar;
00060 typedef use<shape_def>::Shape Shape;
00061
00062 typedef with_idx<double> W;
00063 typedef vertex<Scalar,2> Point;
00064 typedef edge<Scalar,default_env,Point> Edge;
00065 typedef face<Scalar,default_env,Point> Face;
00066
00067 typedef use<bcell_def>::BoundingBox BoundingBox;
00068 typedef use<bcell_def>::Cell Cell;
00069 };
00070
00071
00072 template<class C, class V=default_env>
00073 class topology : public SHAPE_OF(V) {
00074
00075 public:
00076 typedef typename SHAPE_OF(V) Shape;
00077 typedef with_idx<V> W;
00078 typedef vertex<C,3,V> Point;
00079 typedef edge<C,V, Point> Edge;
00080 typedef face<C,V, Point> Face;
00081
00082 typedef bounding_box<C,REF_OF(V)> BoundingBox;
00083 typedef bcell<C,REF_OF(V)> Cell;
00084
00085 topology(){};
00086 topology(const BoundingBox& bx);
00087 virtual ~topology(void) ;
00088
00089
00090 virtual void insert(Point*) = 0 ;
00091 virtual void insert_edge(Point*, Point*) = 0 ;
00092 virtual void insert(Edge *) = 0 ;
00093 virtual void insert(Face *) {};
00094 virtual void insert(BoundingBox*,bool);
00095 virtual void insert_singular(Point*) = 0 ;
00096
00097
00098
00099 void set_precision (double);
00100 void set_smoothness(double);
00101
00102
00103
00104
00105
00106
00107 public:
00108
00109
00110
00111
00112
00113
00114
00115 };
00116
00117
00118
00119 TMPL SELF::topology(const typename SELF::BoundingBox& bx)
00120 {
00121
00122 }
00123
00124 TMPL SELF::~topology(void) {}
00125
00126 TMPL void SELF::set_smoothness(double eps) {
00127
00128 }
00129
00130 TMPL void SELF::set_precision(double eps) {
00131
00132 }
00133
00134 TMPL void SELF::insert(BoundingBox *bx, bool cross = false) {
00135 Point
00136 *p0= new Point(bx->xmin(),bx->ymin(),bx->zmin()),
00137 *p1= new Point(bx->xmin(),bx->ymax(),bx->zmin()),
00138 *p2= new Point(bx->xmax(),bx->ymax(),bx->zmin()),
00139 *p3= new Point(bx->xmax(),bx->ymin(),bx->zmin());
00140
00141 this->insert(p0);this->insert(p1); this->insert(new Edge(p0,p1));
00142 this->insert(p1);this->insert(p2); this->insert(new Edge(p1,p2));
00143 this->insert(p2);this->insert(p3); this->insert(new Edge(p2,p3));
00144 this->insert(p3);this->insert(p0); this->insert(new Edge(p3,p0));
00145
00146 Point
00147 *q0= new Point(bx->xmin(),bx->ymin(),bx->zmax()),
00148 *q1= new Point(bx->xmin(),bx->ymax(),bx->zmax()),
00149 *q2= new Point(bx->xmax(),bx->ymax(),bx->zmax()),
00150 *q3= new Point(bx->xmax(),bx->ymin(),bx->zmax());
00151
00152 this->insert(q0);this->insert(q1); this->insert(new Edge(q0,q1));
00153 this->insert(q1);this->insert(q2); this->insert(new Edge(q1,q2));
00154 this->insert(q2);this->insert(q3); this->insert(new Edge(q2,q3));
00155 this->insert(q3);this->insert(q0); this->insert(new Edge(q3,q0));
00156
00157 this->insert(p0);this->insert(q0);this->insert(new Edge(p0,q0));
00158 this->insert(p1);this->insert(q1);this->insert(new Edge(p1,q1));
00159 this->insert(p2);this->insert(q2);this->insert(new Edge(p2,q2));
00160 this->insert(p3);this->insert(q3);this->insert(new Edge(p3,q3));
00161
00162 if(cross) {
00163 Point
00164 *r0= new Point(bx->xmin(),bx->ymin(),bx->zmax()),
00165 *r1= new Point(bx->xmin(),bx->ymax(),bx->zmax()),
00166 *r2= new Point(bx->xmax(),bx->ymax(),bx->zmax()),
00167 *r3= new Point(bx->xmax(),bx->ymin(),bx->zmax());
00168
00169 this->insert(r0);this->insert(r2);this->insert(new Edge(r0,r2));
00170 this->insert(r1);this->insert(r3);this->insert(new Edge(r1,r3));
00171 }
00172 }
00173
00174 } ;
00175 } ;
00176
00177 # undef TMPL
00178 # undef Shape
00179 # undef SELF
00180 # endif