00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 # ifndef shape_subdivision_with_tpl3d_hpp
00013 # define shape_subdivision_with_tpl3d_hpp
00014
00015 # include <shape/subdivision.hpp>
00016 # include <shape/tpl3d.hpp>
00017
00018 # define TMPL template<class C,class V,class CELL>
00019 # define TMPL1 template<class K>
00020 # define SELF subdivision<C, with_tpl3d<V>,CELL>
00021
00022
00023 namespace mmx {
00024 namespace shape {
00025
00026 TMPL1 struct with_tpl3d {};
00027 TMPL1 DECLARE_REF_OF(with_tpl3d<K>,REF_OF(K));
00028
00029 template<class FF, class VV> struct use<FF,with_tpl3d<VV> >: public use<FF,VV> {};
00030
00031 TMPL1 struct use<subdivision_def, with_tpl3d<K> >
00032 : public use<subdivision_def, K>
00033 {
00034
00035 template<class Self, class CELL> static bool
00036 process_singular(Self* tpl3d, CELL* cl) {
00037 #if 0
00038 BoundingBox* bx=tpl3d;
00039 Point
00040 *p0= new Point(bx->xmin(),bx->ymin(),bx->zmin()),
00041 *p1= new Point(bx->xmin(),bx->ymax(),bx->zmin()),
00042 *p2= new Point(bx->xmax(),bx->ymax(),bx->zmin()),
00043 *p3= new Point(bx->xmax(),bx->ymin(),bx->zmin());
00044 tpl3d->insert(p0);tpl3d->insert(p1); tpl3d->insert(new Edge(p0,p1));
00045 tpl3d->insert(p1);tpl3d->insert(p2); tpl3d->insert(new Edge(p1,p2));
00046 tpl3d->insert(p2);tpl3d->insert(p3); tpl3d->insert(new Edge(p2,p3));
00047 tpl3d->insert(p3);tpl3d->insert(p0); tpl3d->insert(new Edge(p3,p0));
00048
00049 Point
00050 *q0= new Point(bx->xmin(),bx->ymin(),bx->zmax()),
00051 *q1= new Point(bx->xmin(),bx->ymax(),bx->zmax()),
00052 *q2= new Point(bx->xmax(),bx->ymax(),bx->zmax()),
00053 *q3= new Point(bx->xmax(),bx->ymin(),bx->zmax());
00054 tpl3d->insert(q0);tpl3d->insert(q1); tpl3d->insert(new Edge(q0,q1));
00055 tpl3d->insert(q1);tpl3d->insert(q2); tpl3d->insert(new Edge(q1,q2));
00056 tpl3d->insert(q2);tpl3d->insert(q3); tpl3d->insert(new Edge(q2,q3));
00057 tpl3d->insert(q3);tpl3d->insert(q0); tpl3d->insert(new Edge(q3,q0));
00058
00059 tpl3d->insert(p0);tpl3d->insert(q0);tpl3d->insert(new Edge(p0,q0));
00060 tpl3d->insert(p1);tpl3d->insert(q1);tpl3d->insert(new Edge(p1,q1));
00061 tpl3d->insert(p2);tpl3d->insert(q2);tpl3d->insert(new Edge(p2,q2));
00062 tpl3d->insert(p3);tpl3d->insert(q3);tpl3d->insert(new Edge(p3,q3));
00063 #endif
00064 return true;
00065 }
00066
00067
00068 template<class Self, class CELL> static bool
00069 process_regular(Self* tpl3d, CELL* cl) {
00070
00071
00072
00073
00074 tpl3d->m_leaves <<cl;
00075
00076 marching_cube::polygonise(*tpl3d,*cl);
00077
00078
00079
00080
00081
00082 #if 0
00083 process_singular(tpl3d,cl);
00084 #endif
00085
00086
00087 return true;
00088 }
00089 };
00090
00091 TMPL1 struct adapt_tpl3d {};
00092 template<class FF, class VV> struct use<FF,adapt_tpl3d<VV> >: public use<FF,with_tpl3d<VV> > {
00093
00094 template<class Self, class CELL> static bool
00095 process_regular(Self* tpl3d, CELL* cl) {
00096 typedef typename Self::Scalar C;
00097 typedef subdivision<C,with_tpl3d<VV>,typename Self::Cell> Subdivision;
00098 return use<subdivision_def,with_tpl3d<VV> >::process_regular(dynamic_cast<Subdivision*>(tpl3d),cl);
00099 }
00100
00101 template<class Self, class CELL> static bool
00102 process_singular(Self* tpl3d, CELL* cl) {
00103 typedef typename Self::Scalar C;
00104 typedef subdivision<C,with_tpl3d<VV>,typename Self::Cell> Subdivision;
00105 return use<subdivision_def,with_tpl3d<VV> >::process_singular(dynamic_cast<Subdivision*>(tpl3d),cl);
00106 }
00107
00108 };
00109
00110 template<class C, class V,class CELL>
00111 struct subdivision<C,with_tpl3d<V>,CELL>
00112 : public subdivision<C,adapt_tpl3d<V>,CELL>
00113 , public tpl3d<C,V> {
00114 public:
00115
00116 typedef subdivision<C,adapt_tpl3d<V>,CELL> Subdivision;
00117 typedef tpl3d<C,V> Topology3d;
00118 typedef topology<C,V> Topology;
00119
00120 typedef typename Topology::Point Point;
00121 typedef typename Topology::Edge Edge;
00122 typedef typename Topology::Face Face;
00123
00124 typedef CELL Cell;
00125 typedef typename Subdivision::Node Node;
00126 typedef typename Cell::BoundingBox BoundingBox;
00127
00128 subdivision(double e1= 0.1, double e2=0.01);
00129
00130 ~subdivision(void) ;
00131
00132 void clear(void);
00133
00134
00135 void set_precision (double e){ this->Subdivision::set_precision(e); }
00136 void set_smoothness(double e){ this->Subdivision::set_smoothness(e);}
00137
00138
00139
00140
00141
00142
00143
00144
00145 };
00146
00147 TMPL SELF::subdivision(double e1, double e2): Subdivision(e1, e2) {
00148
00149 }
00150
00151
00152 TMPL SELF::~subdivision(void) {
00153
00154 }
00155
00156
00157 TMPL void SELF::clear() {
00158 this->Topology3d::clear();
00159 }
00160
00161 } ;
00162 } ;
00163
00164 # undef TMPL1
00165 # undef TMPL
00166 # undef SELF
00167 # endif