marching_square Struct Reference

#include <marching_cube.hpp>

List of all members.

Public Member Functions

Static Public Member Functions


Detailed Description

Definition at line 30 of file marching_cube.hpp.


Constructor & Destructor Documentation

marching_square ( void   )  [inline]

Definition at line 34 of file marching_cube.hpp.

00034 {};

~marching_square ( void   )  [inline]

Definition at line 35 of file marching_cube.hpp.

00035 {};


Member Function Documentation

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

Definition at line 43 of file marching_cube.hpp.

References Edge, mmx::shape::mc_interpolate(), and Point.

Referenced by polygonizer< C, default_2d, Input, Output >::run().

00043                                                                                        {
00044 
00045     typedef typename Mesh::Point       Point;
00046     typedef typename Mesh::Edge        Edge;
00047 
00048     Point pt[4];
00049 
00050     int nrPoint=0;
00051 
00052     if(val[0]>lvl)
00053     {
00054         if(val[1]<=lvl)
00055         {
00056             mc_interpolate(pt[nrPoint++], P[0], P[1], val[0], val[1], lvl);
00057         }
00058 
00059         if(val[3]<=lvl)
00060         {
00061             mc_interpolate(pt[nrPoint++], P[0], P[3], val[0], val[3], lvl);
00062         }
00063     }
00064 
00065     if(val[1]>lvl)
00066     {
00067         if(val[0]<=lvl)
00068         {
00069             mc_interpolate(pt[nrPoint++],  P[1], P[0], val[1], val[0], lvl);
00070         }
00071 
00072         if(val[2]<=lvl)
00073         {
00074             mc_interpolate(pt[nrPoint++],  P[1], P[2], val[1], val[2], lvl);
00075         }
00076     }
00077 
00078 
00079     if(val[2]>lvl)
00080     {
00081         if(val[1]<=lvl)
00082         {
00083             mc_interpolate(pt[nrPoint++],  P[2], P[1], val[2], val[1], lvl);
00084         }
00085 
00086         if(val[3]<=lvl)
00087         {
00088             mc_interpolate(pt[nrPoint++],  P[2], P[3], val[2], val[3],lvl);
00089         }
00090     }
00091 
00092     if(val[3]>lvl)
00093     {
00094         if(val[2]<=lvl)
00095         {
00096             mc_interpolate(pt[nrPoint++],  P[3], P[2], val[3], val[2], lvl);
00097         }
00098 
00099         if(val[0]<=lvl)
00100         {
00101             mc_interpolate(pt[nrPoint++],  P[3], P[0], val[3], val[0], lvl);
00102         }
00103     }
00104 
00105     Point* p1, *p2;
00106     for (int i=0;i < nrPoint;i+=2) {
00107         p1 = new Point(pt[i]);
00108         res.insert_vertex(p1);
00109         p1->set_index(res.vertices().size()-1);
00110         p2 = new Point(pt[i+1]);
00111         res.insert_vertex(p2);
00112         p2->set_index(res.vertices().size()-1);
00113         Edge* e= new Edge(p1, p2);
00114         res.insert_edge(e);
00115     }
00116     return true;
00117 }


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

Generated on 6 Dec 2012 for shape by  doxygen 1.6.1