marching_cube Struct Reference

#include <marching_cube.hpp>

List of all members.

Public Member Functions

Static Public Member Functions


Detailed Description

Definition at line 122 of file marching_cube.hpp.


Constructor & Destructor Documentation

marching_cube ( void   )  [inline]

Definition at line 126 of file marching_cube.hpp.

00126 {};

~marching_cube ( void   )  [inline]

Definition at line 127 of file marching_cube.hpp.

00127 {};


Member Function Documentation

bool centralise ( Mesh &  res,
const Cell &  grid 
) [inline, static]

Definition at line 265 of file marching_cube.hpp.

References Face, mmx::shape::marching_cube_edge_table, mmx::shape::marching_cube_tri_table, and Point.

Referenced by mesher3d_dual< C, V, Cell >::run().

00265                                                       {
00266 
00267     typedef typename Mesh::Point       Point;
00268     typedef typename Mesh::Face        Face;
00269 
00270     int CubeIndex=bcell.mc_index();
00271     //  std::cout<<CubeIndex<<std::endl;
00272     if (marching_cube_edge_table[CubeIndex] == 0) return false;
00273 
00274     Point* CELL[12];
00275 
00276     if(bcell.edge_point(CELL, marching_cube_edge_table[CubeIndex])) {
00277         Point* c=new Point(0,0,0);
00278         unsigned ntr=0;
00279         for (int i=0;marching_cube_tri_table[CubeIndex][i]!=-1;i+=3)
00280             ntr++;
00281         ntr/=2;
00282 
00283         for(int j=0;j<3;j++) {
00284             Point* p=CELL[marching_cube_tri_table[CubeIndex][3*ntr+j]];
00285             c->x()+= p->x();
00286             c->y()+= p->y();
00287             c->z()+= p->z();
00288         }
00289         c->x()/=3.;
00290         c->y()/=3.;
00291         c->z()/=3.;
00292         //   c->x()=(bcell.xmin()+bcell.xmax())/2;
00293         //   c->y()=(bcell.ymin()+bcell.ymax())/2;
00294         //   c->z()=(bcell.zmin()+bcell.zmax())/2;
00295         //std::cout<<*c<<std::endl;
00296         res.insert(c);
00297         return true;
00298     } else
00299         return false;
00300 }

bool edge_points ( POINT *  edges,
const POINT *  points,
const VALUES &  values,
int  idx 
) [inline, static]

Definition at line 193 of file marching_cube.hpp.

References mmx::shape::marching_cube_edge_table, and mmx::shape::mc_interpolate().

Referenced by marching_cube::polygonize().

00193                                                                                                  {
00194 
00195     //Point* edges[12];
00196 
00197     //int cubeindex=marching_cube::index(values);
00198     //  std::cout<< cubeindex <<std::endl;
00199     if (marching_cube_edge_table[cubeindex] == 0) return false;
00200 
00201     if (marching_cube_edge_table[cubeindex] & 1)
00202         mc_interpolate(edges[0], points[0],points[1],values[0],values[1]);
00203     if (marching_cube_edge_table[cubeindex] & 2)
00204         mc_interpolate(edges[1], points[1],points[2],values[1],values[2]);
00205     if (marching_cube_edge_table[cubeindex] & 4)
00206         mc_interpolate(edges[2],  points[2],points[3],values[2],values[3]);
00207     if (marching_cube_edge_table[cubeindex] & 8)
00208         mc_interpolate(edges[3],  points[3],points[0],values[3],values[0]);
00209     if (marching_cube_edge_table[cubeindex] & 16)
00210         mc_interpolate(edges[4],  points[4],points[5],values[4],values[5]);
00211     if (marching_cube_edge_table[cubeindex] & 32)
00212         mc_interpolate(edges[5],  points[5],points[6],values[5],values[6]);
00213     if (marching_cube_edge_table[cubeindex] & 64)
00214         mc_interpolate(edges[6],  points[6],points[7],values[6],values[7]);
00215     if (marching_cube_edge_table[cubeindex] & 128)
00216         mc_interpolate(edges[7],  points[7],points[4],values[7],values[4]);
00217     if (marching_cube_edge_table[cubeindex] & 256)
00218         mc_interpolate(edges[8],  points[0],points[4],values[0],values[4]);
00219     if (marching_cube_edge_table[cubeindex] & 512)
00220         mc_interpolate(edges[9],  points[1],points[5],values[1],values[5]);
00221     if (marching_cube_edge_table[cubeindex] & 1024)
00222         mc_interpolate(edges[10],  points[2],points[6],values[2],values[6]);
00223     if (marching_cube_edge_table[cubeindex] & 2048)
00224         mc_interpolate(edges[11],  points[3],points[7],values[3],values[7]);
00225     return true;
00226 }

int index ( C *  t,
iso = 0 
) [inline, static]

Definition at line 151 of file marching_cube.hpp.

Referenced by marching_cube::polygonize(), and mesher3d< C, V, Cell >::run().

00151                                      {
00152     int CubeIndex=0;
00153     int s=1;
00154     for (unsigned i=0; i< 8; i++) {
00155         if (t[i] < iso) CubeIndex |= s;
00156         s*=2;
00157     }
00158     return CubeIndex;
00159 }

bool polygonise ( Mesh &  res,
const Cell &  grid 
) [inline, static]

Definition at line 164 of file marching_cube.hpp.

References Face, mmx::shape::marching_cube_edge_table, mmx::shape::marching_cube_tri_table, and Point.

Referenced by use< subdivision_def, with_tpl3d< K > >::process_regular(), and mesher3d_dual< C, V, Cell >::run().

00164                                                       {
00165 
00166     typedef typename Mesh::Point       Point;
00167     typedef typename Mesh::Face        Face;
00168 
00169     int CubeIndex=bcell.mc_index();
00170 
00171     if (marching_cube_edge_table[CubeIndex] == 0) return false;
00172 
00173     Point* CELL[12];
00174     if(bcell.edge_point(CELL, marching_cube_edge_table[CubeIndex])) {
00175         for (int i=0;marching_cube_tri_table[CubeIndex][i]!=-1;i+=3) {
00176             Face* F= new Face;
00177             for(int j=0;j<3;j++) {
00178                 Point* p=CELL[marching_cube_tri_table[CubeIndex][i+j]];
00179                 res.insert(p);
00180                 F->insert(p);
00181             }
00182             res.insert(F);
00183         }
00184         return true;
00185     } else
00186         return false;
00187 }

bool polygonize ( Mesh &  res,
const POINTS &  points,
const VALUES &  values 
) [inline, static]

Definition at line 249 of file marching_cube.hpp.

References marching_cube::edge_points(), Face, marching_cube::index(), Point, and marching_cube::polygonize().

00249                                                                                {
00250 
00251     typedef typename Mesh::Point       Point;
00252     typedef typename Mesh::Face        Face;
00253 
00254     int cubeindex=marching_cube::index(values);
00255     Point edges[12];
00256     marching_cube::edge_points(edges, points, values, cubeindex);
00257     marching_cube::polygonize(res, edges, cubeindex);
00258     return true;
00259 }

bool polygonize ( Mesh &  res,
const POINTS &  edges,
int  cubeindex 
) [inline, static]

Definition at line 232 of file marching_cube.hpp.

References mmx::shape::marching_cube_tri_table, and Point.

Referenced by marching_cube::polygonize(), polygonizer< C, V, Input, Output >::run(), and mesher3d< C, V, Cell >::run().

00232                                                                        {
00233 
00234     typedef typename Mesh::Point Point;
00235     for (int i=0;marching_cube_tri_table[cubeindex][i]!=-1;i+=3) {
00236 //        Face* F= new Face;
00237 //        for(int j=0;j<3;j++) {
00238 //            Point* p=edges[marching_cube_tri_table[cubeindex][i+j]];
00239 //            res.insert_vertex(edges[marching_cube_tri_table[cubeindex][i+j]]);
00240 //        }
00241         res.insert_face(new Point(edges[marching_cube_tri_table[cubeindex][i]]),
00242                         new Point(edges[marching_cube_tri_table[cubeindex][i+1]]),
00243                         new Point(edges[marching_cube_tri_table[cubeindex][i+2]]));
00244     }
00245     return true;
00246 }


The documentation for this struct was generated from the following file:

Generated on 6 Dec 2012 for shape by  doxygen 1.6.1