00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 # ifndef shape_mesher3d_dual_hpp
00012 # define shape_mesher3d_dual_hpp
00013
00014 # include <shape/mesher3d.hpp>
00015 # include <shape/dualize.hpp>
00016 # include <shape/tpl3d.hpp>
00017
00018 # define TMPL template<class C,class V,class Cell>
00019 # define TMPL1 template<class V>
00020 # define Viewer viewer<W>
00021 # define SELF mesher3d_dual<C,V,Cell>
00022
00023 namespace mmx {
00024 namespace shape {
00025
00026 template<class C,class V=default_env,class Cell=bcell<C,V> >
00027 struct mesher3d_dual : public mesher3d<C,V,Cell>
00028 {
00029
00030 typedef Cell Input;
00031 typedef tpl3d<C,V> Output;
00032 typedef typename Output::Point Point;
00033 typedef typename Output::Edge Edge;
00034 typedef typename Output::Face Face;
00035
00036 mesher3d_dual(double e1= 0.1, double e2=0.01);
00037 ~mesher3d_dual(void) ;
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 void run(void);
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 };
00059
00060 TMPL SELF::mesher3d_dual(double e1, double e2): mesher3d<C,V,Cell>(e1,e2)
00061
00062 {
00063
00064 }
00065
00066 TMPL SELF::~mesher3d_dual(void) {
00067
00068 }
00069
00070 TMPL void SELF::run(void) {
00071
00072 typedef subdivision<C,V,Cell> Subdivisor;
00073 Subdivisor* sbd = new Subdivisor(this->get_smoothness(),this->get_precision());
00074 sbd->set_input(this->input());
00075 sbd->run();
00076
00077 std::cout<< "leaves = "<< sbd->output()->m_leaves.size()<<"\n";
00078
00079 typedef dualize<C,V,Cell> Dualize;
00080 Dualize* dl = new Dualize;
00081 dl->set_input(sbd->output());
00082 dl->run();
00083
00084
00085 std::cout<< "Dual edges= "<< dl->output()->m_edges.size()/2<<"\n";
00086 std::cout<< "Dual faces= "<< dl->output()->m_faces.size()/4<<"\n";
00087
00088 bool ctr = false;
00089 if (ctr) foreach(Cell * cl, sbd->output()->m_leaves) {
00090 marching_cube::centralise(*cl, *cl);
00091 foreach(Point* p, cl->m_points) this->output()->insert(p);
00092
00093
00094 }
00095
00096 if (ctr) for(unsigned i=0; i< dl->output()->m_edges.size();i+=2){
00097 Edge* e=new Edge(dl->output()->m_edges[i]->get_cell()->m_points[0],
00098 dl->output()->m_edges[i+1]->get_cell()->m_points[0]);
00099 this->output()->insert(e);
00100 }
00101
00102 if (ctr)
00103 for(unsigned i=0; i< dl->output()->m_faces.size();i+=4){
00104 Face* f=new Face;
00105 f->insert(dl->output()->m_faces[i]->get_cell()->m_points[0]);
00106 f->insert(dl->output()->m_faces[i+1]->get_cell()->m_points[0]);
00107 f->insert(dl->output()->m_faces[i+2]->get_cell()->m_points[0]);
00108 this->output()->insert(f);
00109 }
00110
00111 if (!ctr)
00112 foreach(Cell * cl, sbd->output()->m_leaves) {
00113 marching_cube::polygonise(*cl, *cl);
00114 foreach(Point* p, cl->m_points) this->output()->insert(p);
00115 foreach(Face* f, cl->m_faces) this->output()->insert(f);
00116 std::cout<<"MC"<<std::endl;
00117 }
00118
00119 }
00120
00121
00122
00123
00124
00125
00126 } ;
00127 } ;
00128
00129 # undef TMPL
00130 # undef TMPL1
00131 # undef Shape
00132 # undef Viewer
00133 # undef Graphic
00134 # undef SELF
00135 # endif