shape_doc 0.1
|
00001 /***************************************************************************** 00002 * M a t h e m a g i x 00003 ***************************************************************************** 00004 * 2011-04-26 00005 * Bernard Mourrain 00006 ***************************************************************************** 00007 * Copyright (C) 2011 INRIA Sophia-Antipolis 00008 ***************************************************************************** 00009 * Comments : 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 Shape, class Cell> 00019 # define TMPL1 template<class V> 00020 # define Viewer viewer<W> 00021 # define SELF mesher3d_dual<C,V,Shape,Cell> 00022 //==================================================================== 00023 namespace mmx { 00024 namespace shape { 00025 //==================================================================== 00026 template<class C,class V=default_env, class Shape=typename SHAPE_OF(V), class Cell=cell<C,V> > 00027 struct mesher3d_dual : public mesher3d<C,V,Shape,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 // void set_input (Cell* cl) { m_input= cl; } 00040 00041 // void set_smoothness(double e) { m_smooth = e; } 00042 // void set_precision (double e) { m_prec = e; } 00043 00044 // Input* input (void) { return m_input; } 00045 // Output* output (void) { return m_output; } 00046 00047 void run(void); 00048 // void clear(void); 00049 00050 // //private: 00051 // double m_smooth ; 00052 // double m_prec ; 00053 00054 // private: 00055 // Cell* m_input; 00056 // Output* m_output; 00057 00058 }; 00059 //-------------------------------------------------------------------- 00060 TMPL SELF::mesher3d_dual(double e1, double e2): mesher3d<C,V,Shape,Cell>(e1,e2) 00061 //m_smooth(e1), m_prec(e2) 00062 { 00063 // m_output = new Output; 00064 } 00065 00066 TMPL SELF::~mesher3d_dual(void) { 00067 // delete m_output; 00068 } 00069 //-------------------------------------------------------------------- 00070 TMPL void SELF::run(void) { 00071 00072 typedef subdivision<C,V,Shape,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,Shape,Cell> Dualize; 00080 Dualize* dl = new Dualize; 00081 dl->set_input(sbd->output()); 00082 dl->run(); 00083 00084 // this->get_adjacency(); 00085 std::cout<< "Dual edges= "<< dl->output()->m_edges.size()/2<<"\n"; 00086 std::cout<< "Dual faces= "<< dl->output()->m_faces.size()/3<<"\n"; 00087 00088 foreach(Cell * cl, sbd->output()->m_leaves) { 00089 marching_cube::centralise(*cl, *cl); 00090 // marching_cube::polygonise(*cl, *cl); 00091 foreach(Point* p, cl->m_points) this->output()->insert(p); 00092 } 00093 00094 for(unsigned i=0; i< dl->output()->m_edges.size();i+=2){ 00095 Edge* e=new Edge(dl->output()->m_edges[i]->get_cell()->m_points[0], 00096 dl->output()->m_edges[i+1]->get_cell()->m_points[0]); 00097 this->output()->insert(e); 00098 } 00099 00100 for(unsigned i=0; i< dl->output()->m_faces.size();i+=3){ 00101 Face* f=new Face; 00102 f->insert(dl->output()->m_faces[i]->get_cell()->m_points[0]); 00103 f->insert(dl->output()->m_faces[i+1]->get_cell()->m_points[0]); 00104 f->insert(dl->output()->m_faces[i+2]->get_cell()->m_points[0]); 00105 this->output()->insert(f); 00106 } 00107 00108 // foreach(Cell * cl, this->m_leaves) { 00109 // marching_cube::polygonise(*cl, *cl); 00110 // foreach(Point* p, cl->m_points) m_output.insert(p); 00111 // foreach(Face* f, cl->m_faces) m_output.insert(f); 00112 // } 00113 00114 } 00115 00116 //-------------------------------------------------------------------- 00117 // TMPL void SELF::clear(void) { 00118 // this->output()->clear(); 00119 // } 00120 //==================================================================== 00121 } ; // namespace shape 00122 } ; // namespace mmx 00123 //==================================================================== 00124 # undef TMPL 00125 # undef TMPL1 00126 # undef Shape 00127 # undef Viewer 00128 # undef Graphic 00129 # undef SELF 00130 # endif