EMAN2
Public Member Functions | Private Member Functions | Private Attributes | Friends
EMAN::MarchingCubes Class Reference

#include <marchingcubes.h>

Inheritance diagram for EMAN::MarchingCubes:
Inheritance graph
[legend]
Collaboration diagram for EMAN::MarchingCubes:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MarchingCubes ()
 Default constructor.
 MarchingCubes (EMData *em)
 Most commonly used constructor calls set_data(em)
virtual ~MarchingCubes ()
void set_data (EMData *data)
 Sets Voxel data for Isosurface implementation Calls calculate_min_max_vals which generates the tree of data.
void set_surface_value (const float value)
 Set Isosurface value.
float get_surface_value () const
 Get the current isosurface value being used.
void set_sampling (const int rate)
 Set sampling rates A smaller value means a finer sampling.
int get_sampling () const
 Current the current sampling rate Finest sampling is -1.
int get_sampling_range ()
 Get the range of feasible sampling rates.
void color_vertices ()
 Color the vertices.
Dict get_isosurface ()
 Get the isosurface as dictionary Traverses the tree and marches the cubes.
void surface_face_z ()
void setRGBorigin (int x, int y, int z)
 Functions to control colroing mode.
void setRGBscale (float i, float o)
void setRGBmode (int mode)
int getRGBmode ()
 Return RGB mode.
void setCmapData (EMData *data)
 Sets the colormap.
void setCmapMinMax (float min, float max)
 Sets the colormap mix max range.

Private Member Functions

bool calculate_min_max_vals ()
 Calculate the min and max value trees Stores minimum and maximum cube neighborhood values in a tree structure

Exceptions:
NullPointerExceptionif _emdata is null...

void clear_min_max_vals ()
 Clear the minimum and maximum value search trees Frees memory in the minvals and maxvals.
void draw_cube (const int x, const int y, const int z, const int cur_level)
 The main cube drawing function To start the process of generate triangles call with draw_cube(0,0,0,minvals.size()-1) Once cur_level becomes drawing_level marching_cube is called.
void marching_cube (int fX, int fY, int fZ, const int cur_level)
 Function for managing cases where a triangles can potentially be rendered Called by draw_cube.
void calculate_surface ()
 Calculate and generate the entire set of vertices and normals using current states Calls draw_cube(0,0,0,minvals.size()-1)
float get_offset (float fValue1, float fValue2, float fValueDesired)
 Find the approximate point of intersection of the surface between two points with the values fValue1 and fValue2.
int get_edge_num (int x, int y, int z, int edge)
 Get edge num needs better commenting.
void get_normal (Vector3 &normal, int fX, int fY, int fZ)
 Find the gradient of the scalar field at a point.

Private Attributes

map< int, int > point_map
unsigned long _isodl
GLuint buffer [4]
vector< EMData * > minvals
 Vectors for storing the search trees.
vector< EMData * > maxvals
int drawing_level
 The "sampling rate".
CustomVector< float > pp
 .Custom vectors for storing points, normals and faces
CustomVector< float > cc
CustomVector< int > vv
CustomVector< float > nn
CustomVector< unsigned int > ff
ColorRGBGenerator rgbgenerator
 COlor by radius generator.
bool needtobind

Friends

class GLUtil

Detailed Description

Definition at line 275 of file marchingcubes.h.


Constructor & Destructor Documentation

EMAN::MarchingCubes::MarchingCubes ( )

Default constructor.

EMAN::MarchingCubes::MarchingCubes ( EMData em)

Most commonly used constructor calls set_data(em)

Parameters:
emthe EMData object to generate triangles and normals for
virtual EMAN::MarchingCubes::~MarchingCubes ( ) [virtual]

Member Function Documentation

bool EMAN::MarchingCubes::calculate_min_max_vals ( ) [private]

Calculate the min and max value trees Stores minimum and maximum cube neighborhood values in a tree structure

Exceptions:
NullPointerExceptionif _emdata is null...

this should not happen but is left for clarity for programmers

void EMAN::MarchingCubes::calculate_surface ( ) [private]

Calculate and generate the entire set of vertices and normals using current states Calls draw_cube(0,0,0,minvals.size()-1)

void EMAN::MarchingCubes::clear_min_max_vals ( ) [private]

Clear the minimum and maximum value search trees Frees memory in the minvals and maxvals.

void EMAN::MarchingCubes::color_vertices ( )

Color the vertices.

void EMAN::MarchingCubes::draw_cube ( const int  x,
const int  y,
const int  z,
const int  cur_level 
) [private]

The main cube drawing function To start the process of generate triangles call with draw_cube(0,0,0,minvals.size()-1) Once cur_level becomes drawing_level marching_cube is called.

Parameters:
xthe current x value, relative to cur_level
ythe current y value, relative to cur_level
zthe current z value, relative to cur_level
cur_levelthe current tree traversal level
int EMAN::MarchingCubes::get_edge_num ( int  x,
int  y,
int  z,
int  edge 
) [private]

Get edge num needs better commenting.

Dict EMAN::MarchingCubes::get_isosurface ( ) [virtual]

Get the isosurface as dictionary Traverses the tree and marches the cubes.

Returns:
a dictionary object containing to float pointers (to vertex and normal data), and an int pointer (to face data)

Implements EMAN::Isosurface.

void EMAN::MarchingCubes::get_normal ( Vector3 normal,
int  fX,
int  fY,
int  fZ 
) [private]

Find the gradient of the scalar field at a point.

This gradient can be used as a very accurate vertx normal for lighting calculations.

THIS FUNCTION IS NO LONGER CALLED - d.woolford but is retained because it may be useful, perhaps even for saving time

Parameters:
normalwhere to store the normal
fX
fY
fZ
float EMAN::MarchingCubes::get_offset ( float  fValue1,
float  fValue2,
float  fValueDesired 
) [private]

Find the approximate point of intersection of the surface between two points with the values fValue1 and fValue2.

Parameters:
fValue1
fValue2
fValueDesired
Returns:
offset
int EMAN::MarchingCubes::get_sampling ( ) const [inline, virtual]

Current the current sampling rate Finest sampling is -1.

Implements EMAN::Isosurface.

Definition at line 319 of file marchingcubes.h.

References drawing_level.

{ return drawing_level; }
int EMAN::MarchingCubes::get_sampling_range ( ) [inline, virtual]

Get the range of feasible sampling rates.

Implements EMAN::Isosurface.

Definition at line 323 of file marchingcubes.h.

References minvals.

{ return minvals.size()-1; }
float EMAN::MarchingCubes::get_surface_value ( ) const [inline, virtual]

Get the current isosurface value being used.

Returns:
the current isosurface value

Implements EMAN::Isosurface.

Definition at line 304 of file marchingcubes.h.

References EMAN::Isosurface::_surf_value.

{ return _surf_value; }
int EMAN::MarchingCubes::getRGBmode ( ) [inline]

Return RGB mode.

Definition at line 355 of file marchingcubes.h.

References EMAN::ColorRGBGenerator::getRGBmode(), and rgbgenerator.

                {
                        return rgbgenerator.getRGBmode();
                }
void EMAN::MarchingCubes::marching_cube ( int  fX,
int  fY,
int  fZ,
const int  cur_level 
) [private]

Function for managing cases where a triangles can potentially be rendered Called by draw_cube.

Generates vertices, normals, and keeps track of common points

Parameters:
fXthe current x coordinate, relative to cur_level
fYthe current y coordinate, relative to cur_level
fZthe current z coordinate, relative to cur_level
cur_level
void EMAN::MarchingCubes::set_data ( EMData data) [virtual]

Sets Voxel data for Isosurface implementation Calls calculate_min_max_vals which generates the tree of data.

Parameters:
datathe emdata object to be rendered in 3D
Exceptions:
ImageDimensionExceptionif the image z dimension is 1

Reimplemented from EMAN::Isosurface.

void EMAN::MarchingCubes::set_sampling ( const int  rate) [inline, virtual]

Set sampling rates A smaller value means a finer sampling.

The finest sampling level is -1 Sampling values increment in steps of 1, and a single increment is interpreted as one step up or down the tree stored in minvals and maxvals

Parameters:
ratethe tree level to render

Implements EMAN::Isosurface.

Definition at line 314 of file marchingcubes.h.

References drawing_level.

{ drawing_level = rate; }
void EMAN::MarchingCubes::set_surface_value ( const float  value) [virtual]

Set Isosurface value.

Parameters:
valuethe new isosurface value

Implements EMAN::Isosurface.

void EMAN::MarchingCubes::setCmapData ( EMData data) [inline, virtual]

Sets the colormap.

Implements EMAN::Isosurface.

Definition at line 361 of file marchingcubes.h.

References rgbgenerator, and EMAN::ColorRGBGenerator::set_cmap_data().

                {
                        rgbgenerator.set_cmap_data(data);
                }
void EMAN::MarchingCubes::setCmapMinMax ( float  min,
float  max 
) [inline, virtual]

Sets the colormap mix max range.

Implements EMAN::Isosurface.

Definition at line 367 of file marchingcubes.h.

References rgbgenerator, and EMAN::ColorRGBGenerator::setMinMax().

                {
                        rgbgenerator.setMinMax(min, max);
                }
void EMAN::MarchingCubes::setRGBmode ( int  mode) [inline, virtual]

Implements EMAN::Isosurface.

Definition at line 349 of file marchingcubes.h.

References rgbgenerator, and EMAN::ColorRGBGenerator::setRGBmode().

                {
                        rgbgenerator.setRGBmode(mode);
                }
void EMAN::MarchingCubes::setRGBorigin ( int  x,
int  y,
int  z 
) [inline, virtual]

Functions to control colroing mode.

Implements EMAN::Isosurface.

Definition at line 339 of file marchingcubes.h.

References rgbgenerator, and EMAN::ColorRGBGenerator::setOrigin().

                {
                        rgbgenerator.setOrigin(x, y, z);
                }
void EMAN::MarchingCubes::setRGBscale ( float  i,
float  o 
) [inline, virtual]

Implements EMAN::Isosurface.

Definition at line 344 of file marchingcubes.h.

References rgbgenerator, and EMAN::ColorRGBGenerator::setScale().

                {
                        rgbgenerator.setScale(i, o);
                }
void EMAN::MarchingCubes::surface_face_z ( )

Friends And Related Function Documentation

friend class GLUtil [friend]

Definition at line 276 of file marchingcubes.h.


Member Data Documentation

unsigned long EMAN::MarchingCubes::_isodl [private]

Definition at line 374 of file marchingcubes.h.

GLuint EMAN::MarchingCubes::buffer[4] [private]

Definition at line 375 of file marchingcubes.h.

Definition at line 451 of file marchingcubes.h.

The "sampling rate".

Definition at line 394 of file marchingcubes.h.

Referenced by get_sampling(), and set_sampling().

CustomVector<unsigned int> EMAN::MarchingCubes::ff [private]

Definition at line 454 of file marchingcubes.h.

Definition at line 391 of file marchingcubes.h.

Vectors for storing the search trees.

Definition at line 391 of file marchingcubes.h.

Referenced by get_sampling_range().

Definition at line 459 of file marchingcubes.h.

Definition at line 453 of file marchingcubes.h.

map<int, int> EMAN::MarchingCubes::point_map [private]

Definition at line 373 of file marchingcubes.h.

.Custom vectors for storing points, normals and faces

Definition at line 450 of file marchingcubes.h.

COlor by radius generator.

Definition at line 457 of file marchingcubes.h.

Referenced by getRGBmode(), setCmapData(), setCmapMinMax(), setRGBmode(), setRGBorigin(), and setRGBscale().

Definition at line 452 of file marchingcubes.h.


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