#include <mesher3d.hpp>
Definition at line 67 of file mesher3d.hpp.
typedef Output::Edge Edge |
Reimplemented in mesher3d_dual< C, V, Cell >.
Definition at line 76 of file mesher3d.hpp.
typedef Cell Input |
Reimplemented in mesher3d_dual< C, V, Cell >.
Definition at line 71 of file mesher3d.hpp.
typedef use<mesh3d_def,C,V>::Mesh Output |
Reimplemented in mesher3d_dual< C, V, Cell >.
Definition at line 72 of file mesher3d.hpp.
typedef Output::Point Point |
Reimplemented in mesher3d_dual< C, V, Cell >.
Definition at line 75 of file mesher3d.hpp.
typedef subdivision<C,V,Cell> Subdivisor |
Definition at line 69 of file mesher3d.hpp.
typedef use<topology3d_def,C,V> Topology |
Definition at line 73 of file mesher3d.hpp.
mesher3d | ( | double | e1 = 0.1 , |
|
double | e2 = 0.01 | |||
) | [inline] |
Definition at line 105 of file mesher3d.hpp.
00105 : m_smooth(e1), m_prec(e2) 00106 { 00107 m_output = new Output; 00108 }
~mesher3d | ( | void | ) | [inline] |
Definition at line 110 of file mesher3d.hpp.
void clear | ( | void | ) | [inline] |
Definition at line 309 of file mesher3d.hpp.
Input* get_input | ( | void | ) | [inline] |
Definition at line 90 of file mesher3d.hpp.
Referenced by mesher3d< C, V, Cell >::run().
Output* get_output | ( | void | ) | [inline] |
Definition at line 91 of file mesher3d.hpp.
Referenced by mesher3d< C, V, Cell >::run().
double get_precision | ( | void | ) | [inline] |
Definition at line 87 of file mesher3d.hpp.
Referenced by mesher3d_dual< C, V, Cell >::run().
double get_smoothness | ( | void | ) | [inline] |
Definition at line 86 of file mesher3d.hpp.
Referenced by mesher3d_dual< C, V, Cell >::run().
void run | ( | void | ) | [inline] |
Reimplemented in mesher3d_dual< C, V, Cell >.
Definition at line 114 of file mesher3d.hpp.
References Cell, use< mesher3d_def, C, V >::edge_points(), mesher3d< C, V, Cell >::get_input(), mesher3d< C, V, Cell >::get_output(), subdivision< C, V, Cell >::get_output(), marching_cube::index(), mmx::max(), marching_cube::polygonize(), subdivision< C, V, Cell >::run(), and subdivision< C, V, Cell >::set_input().
00114 { 00115 00116 std::cout<< ">> Prec "<< m_smooth <<" " << m_prec<<"\n"; 00117 00118 Subdivisor* sbd = new Subdivisor(m_smooth,m_prec); 00119 sbd->set_input(this->get_input()); 00120 sbd->run(); 00121 00122 std::cout<< ">> leaves = "<< sbd->get_output()->m_leaves.size()<<"\n"; 00123 00124 typedef dualize<C,V,Cell> Dualize; 00125 Dualize* dl = new Dualize; 00126 dl->set_input(sbd->get_output()); 00127 dl->run(); 00128 00129 std::cout<< "\n>> Cells = "<< sbd->get_output()->m_leaves.size()<<"\n"; 00130 std::cout<< ">> Dual edges = "<< dl->get_output()->m_edges.size()/2<<"\n"; 00131 std::cout<< ">> Dual faces = "<< dl->get_output()->m_faces.size()/4<<"\n"; 00132 std::cout<< ">> Dual cells = "<< dl->get_output()->m_cells.size()/8<<"\n"; 00133 00134 00135 Point points[8]; 00136 Point edges[12]; 00137 C values[8]; 00138 int idx; 00139 00140 for(unsigned i=0; i< dl->get_output()->m_edges.size(); i+=2) { 00141 00142 Cell* c1= dl->get_output()->m_edges[i]; 00143 Cell* c2= dl->get_output()->m_edges[i+1]; 00144 00145 //std::cout <<"center value "<< c1->center_value()<< " " <<c2->center_value()<< std::endl; 00146 00147 //Edge* e= new Edge(new Point(c1->center()), new Point(c2->center())); 00148 //this->get_output()->insert_face(new Point(c1->center()), new Point(c2->center()), new Point(c1->center())); 00149 00150 if (c1 != c2) { 00151 C xm=std::max(c1->xmin(),c2->xmin()), xM=std::min(c1->xmax(),c2->xmax()), 00152 ym=std::max(c1->ymin(),c2->ymin()), yM=std::min(c1->ymax(),c2->ymax()), 00153 zm=std::max(c1->zmin(),c2->zmin()), zM=std::min(c1->zmax(),c2->zmax()); 00154 00155 if (zm == zM) { 00156 points[0].x()= xm; points[0].y()=ym; points[0].z()=zm; values[0]= c1->value(xm,ym,zm); 00157 points[1].x()= xM; points[1].y()=ym; points[1].z()=zm; values[1]= c1->value(xM,ym,zm); 00158 points[2].x()= xM; points[2].y()=yM; points[2].z()=zm; values[2]= c1->value(xM,yM,zm); 00159 points[3].x()= xm; points[3].y()=yM; points[3].z()=zm; values[3]= c1->value(xm,yM,zm); 00160 00161 //this->get_output()->insert_face(new Point(points[0]),new Point(points[1]),new Point(points[2]),new Point(points[3])); 00162 if(c1->is_active()) { 00163 for(unsigned j=4; j<8; j++) { 00164 points[j] = c1->center(); 00165 values[j] = c1->center_value(); 00166 } 00167 00168 idx = marching_cube::index(values); 00169 //marching_cube::edge_points(edges, points, values, idx); 00170 use<mesher3d_def,C,V>::edge_points(edges, points, c1, idx); 00171 marching_cube::polygonize(*this->get_output(), edges, idx); 00172 } 00173 00174 if (c2->is_active()) { 00175 for(unsigned j=4; j<8; j++) { 00176 points[j] = c2->center(); 00177 values[j] = c2->center_value(); 00178 } 00179 00180 idx = marching_cube::index(values); 00181 //marching_cube::edge_points(edges, points, values, idx); 00182 use<mesher3d_def,C,V>::edge_points(edges, points, c2, idx); 00183 marching_cube::polygonize(*this->get_output(), edges, idx); 00184 } 00185 00186 } else if (ym == yM) { 00187 points[0].x()= xm; points[0].y()=ym; points[0].z()=zm; values[0]= c1->value(xm,ym,zm); 00188 points[1].x()= xM; points[1].y()=ym; points[1].z()=zm; values[1]= c1->value(xM,ym,zm); 00189 points[2].x()= xM; points[2].y()=ym; points[2].z()=zM; values[2]= c1->value(xM,ym,zM); 00190 points[3].x()= xm; points[3].y()=ym; points[3].z()=zM; values[3]= c1->value(xm,ym,zM); 00191 00192 //this->get_output()->insert_face(new Point(points[0]),new Point(points[1]),new Point(points[2]),new Point(points[3])); 00193 if(c1->is_active()) { 00194 for(unsigned j=4; j<8; j++) { 00195 points[j] = c1->center(); 00196 values[j] = c1->center_value(); 00197 } 00198 00199 idx = marching_cube::index(values); 00200 //marching_cube::edge_points(edges, points, values, idx); 00201 use<mesher3d_def,C,V>::edge_points(edges, points, c1, idx); 00202 marching_cube::polygonize(*this->get_output(), edges, idx); 00203 // marching_cube::polygonize(*this->get_output(), points, values); 00204 } 00205 00206 if(c2->is_active()) { 00207 for(unsigned j=4; j<8; j++) { 00208 points[j] = c2->center(); 00209 values[j] = c2->center_value(); 00210 } 00211 idx = marching_cube::index(values); 00212 //marching_cube::edge_points(edges, points, values, idx); 00213 use<mesher3d_def,C,V>::edge_points(edges, points, c2, idx); 00214 marching_cube::polygonize(*this->get_output(), edges, idx); 00215 // marching_cube::polygonize(*this->get_output(), points, values); 00216 } 00217 } else if (xm == xM ) { 00218 points[0].x()= xm; points[0].y()=ym; points[0].z()=zm; values[0]= c1->value(xm,ym,zm); 00219 points[1].x()= xm; points[1].y()=yM; points[1].z()=zm; values[1]= c1->value(xm,yM,zm); 00220 points[2].x()= xm; points[2].y()=yM; points[2].z()=zM; values[2]= c1->value(xm,yM,zM); 00221 points[3].x()= xm; points[3].y()=ym; points[3].z()=zM; values[3]= c1->value(xm,ym,zM); 00222 00223 //this->get_output()->insert_face(new Point(points[0]),new Point(points[1]),new Point(points[2]),new Point(points[3])); 00224 if(c1->is_active()) { 00225 for(unsigned j=4; j<8; j++) { 00226 points[j] = c1->center(); 00227 values[j] = c1->center_value(); 00228 } 00229 00230 idx = marching_cube::index(values); 00231 //marching_cube::edge_points(edges, points, values, idx); 00232 use<mesher3d_def,C,V>::edge_points(edges, points, c1, idx); 00233 marching_cube::polygonize(*this->get_output(), edges, idx); 00234 } 00235 // marching_cube::polygonize(*this->get_output(), points, values); 00236 00237 if(c2->is_active()) { 00238 for(unsigned j=4; j<8; j++) { 00239 points[j] = c2->center(); 00240 values[j] = c2->center_value(); 00241 } 00242 idx = marching_cube::index(values); 00243 //marching_cube::edge_points(edges, points, values, idx); 00244 use<mesher3d_def,C,V>::edge_points(edges, points, c2, idx); 00245 marching_cube::polygonize(*this->get_output(), edges, idx); 00246 } 00247 // marching_cube::polygonize(*this->get_output(), points, values); 00248 } 00249 } 00250 //bool mc = true; bool ctr = false; 00251 //bool mc = false; bool ctr = true; 00252 00253 // typedef polygonizer<C,V, Seq<Cell*>, Output > Polygonizer; 00254 // Polygonizer* plg = new Polygonizer; 00255 00256 // if(mc) { 00257 // plg->set_input(&sbd->get_output()->m_leaves); 00258 // plg->set_output(this->get_output()); 00259 // plg->run(); 00260 // } 00261 00262 // if(ctr) { 00263 // plg->set_input(&dl->get_output()->m_cells); 00264 // plg->set_output(this->get_output()); 00265 // plg->run(); 00266 // } 00267 00268 // if (ctr) { 00269 // foreach(Cell * cl, sbd->output()->m_leaves) { 00270 // //marching_cube::centralise(*cl, *cl); 00271 // Point* p= new Point(cl->center()); 00272 // // std::cout<<"center "<<p->x()<<" "<<p->y()<<" "<<p->z() <<std::endl; 00273 // cl->insert(p); 00274 // foreach(Point* p, cl->m_points) this->output()->insert(p); 00275 00276 // for(unsigned i=0; i< dl->output()->m_faces.size();i+=4){ 00277 // Face* f1=new Face; 00278 // if(dl->output()->m_faces[i]->m_points.size()>0) 00279 // f1->insert(dl->output()->m_faces[i]->m_points[0]); 00280 // if(dl->output()->m_faces[i+1]->m_points.size()>0) 00281 // f1->insert(dl->output()->m_faces[i+1]->m_points[0]); 00282 // if(dl->output()->m_faces[i+2]->m_points.size()>0) 00283 // f1->insert(dl->output()->m_faces[i+2]->m_points[0]); 00284 // if(f1->size()>2) 00285 // this->output()->insert(f1); 00286 // else 00287 // std::cout<<"Face 1 with "<<f1->size()<<" element"<<std::endl; 00288 00289 // Face* f2=new Face; 00290 // if(dl->output()->m_faces[i]->m_points.size()>0) 00291 // f2->insert(dl->output()->m_faces[i]->m_points[0]); 00292 // if(dl->output()->m_faces[i+2]->m_points.size()>0) 00293 // f2->insert(dl->output()->m_faces[i+2]->m_points[0]); 00294 // if(dl->output()->m_faces[i+3]->m_points.size()>0) 00295 // f2->insert(dl->output()->m_faces[i+3]->m_points[0]); 00296 // if(f2->size()>2) 00297 // this->output()->insert(f2); 00298 // else 00299 // std::cout<<"Face 2 with "<<f2->size()<<" element"<<std::endl; 00300 // } 00301 // } 00302 // std::cout<< "Triangles = "<< this->output()->m_faces.size()<<"\n"; 00303 // }// ctr 00304 00305 } 00306 }
void set_input | ( | Cell * | cl | ) | [inline] |
Definition at line 81 of file mesher3d.hpp.
void set_precision | ( | double | e | ) | [inline] |
Definition at line 84 of file mesher3d.hpp.
void set_smoothness | ( | double | e | ) | [inline] |
Definition at line 83 of file mesher3d.hpp.