EMAN2
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
EMAN::MarchingCubes Class Reference

#include <marchingcubes.h>

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

Public Member Functions

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

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. More...
 
void clear_min_max_vals ()
 Clear the minimum and maximum value search trees Frees memory in the minvals and maxvals. More...
 
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. More...
 
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. More...
 
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) More...
 
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. More...
 
int get_edge_num (int x, int y, int z, int edge)
 Get edge num needs better commenting. More...
 
void get_normal (Vector3 &normal, int fX, int fY, int fZ)
 Find the gradient of the scalar field at a point. More...
 

Private Attributes

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

Friends

class GLUtil
 

Additional Inherited Members

- Protected Attributes inherited from EMAN::Isosurface
EMData_emdata
 
float _surf_value
 

Detailed Description

Definition at line 271 of file marchingcubes.h.

Constructor & Destructor Documentation

◆ MarchingCubes() [1/2]

EMAN::MarchingCubes::MarchingCubes ( )

Default constructor.

◆ MarchingCubes() [2/2]

EMAN::MarchingCubes::MarchingCubes ( EMData em)

Most commonly used constructor calls set_data(em)

Parameters
emthe EMData object to generate triangles and normals for

◆ ~MarchingCubes()

virtual EMAN::MarchingCubes::~MarchingCubes ( )
virtual

Member Function Documentation

◆ calculate_min_max_vals()

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

◆ calculate_surface()

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)

◆ clear_min_max_vals()

void EMAN::MarchingCubes::clear_min_max_vals ( )
private

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

◆ color_vertices()

void EMAN::MarchingCubes::color_vertices ( )

Color the vertices.

◆ draw_cube()

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

◆ get_edge_num()

int EMAN::MarchingCubes::get_edge_num ( int  x,
int  y,
int  z,
int  edge 
)
private

Get edge num needs better commenting.

◆ get_isosurface()

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.

◆ get_normal()

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

◆ get_offset()

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

◆ get_sampling()

int EMAN::MarchingCubes::get_sampling ( ) const
inlinevirtual

Current the current sampling rate Finest sampling is -1.

Implements EMAN::Isosurface.

Definition at line 315 of file marchingcubes.h.

315{ return drawing_level; }
int drawing_level
The "sampling rate".

References drawing_level.

◆ get_sampling_range()

int EMAN::MarchingCubes::get_sampling_range ( )
inlinevirtual

Get the range of feasible sampling rates.

Implements EMAN::Isosurface.

Definition at line 319 of file marchingcubes.h.

319{ return minvals.size()-1; }
vector< EMData * > minvals
Vectors for storing the search trees.

References minvals.

◆ get_surface_value()

float EMAN::MarchingCubes::get_surface_value ( ) const
inlinevirtual

Get the current isosurface value being used.

Returns
the current isosurface value

Implements EMAN::Isosurface.

Definition at line 300 of file marchingcubes.h.

300{ return _surf_value; }

References EMAN::Isosurface::_surf_value.

◆ getRGBmode()

int EMAN::MarchingCubes::getRGBmode ( )
inline

Return RGB mode.

Definition at line 351 of file marchingcubes.h.

352 {
353 return rgbgenerator.getRGBmode();
354 }
int getRGBmode()
Return RGB mode.
ColorRGBGenerator rgbgenerator
Color by radius generator.

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

◆ marching_cube()

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

◆ set_data()

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.

◆ set_sampling()

void EMAN::MarchingCubes::set_sampling ( const int  rate)
inlinevirtual

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 310 of file marchingcubes.h.

310{ drawing_level = rate; }

References drawing_level.

◆ set_surface_value()

void EMAN::MarchingCubes::set_surface_value ( const float  value)
virtual

Set Isosurface value.

Parameters
valuethe new isosurface value

Implements EMAN::Isosurface.

◆ setCmapData()

void EMAN::MarchingCubes::setCmapData ( EMData data)
inlinevirtual

Sets the colormap.

Implements EMAN::Isosurface.

Definition at line 357 of file marchingcubes.h.

358 {
360 }
void set_cmap_data(EMData *data)
Set min max data.

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

◆ setCmapMinMax()

void EMAN::MarchingCubes::setCmapMinMax ( float  min,
float  max 
)
inlinevirtual

Sets the colormap mix max range.

Implements EMAN::Isosurface.

Definition at line 363 of file marchingcubes.h.

364 {
365 rgbgenerator.setMinMax(min, max);
366 }
void setMinMax(float min, float max)
Set the mn max for cmap coloring.

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

◆ setRGBmode()

void EMAN::MarchingCubes::setRGBmode ( int  mode)
inlinevirtual

Implements EMAN::Isosurface.

Definition at line 345 of file marchingcubes.h.

346 {
348 }
void setRGBmode(int mode)
Set RGB mode 0 = none, 1 = color by radius, more to come :)

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

◆ setRGBorigin()

void EMAN::MarchingCubes::setRGBorigin ( int  x,
int  y,
int  z 
)
inlinevirtual

Functions to control colroing mode.

Implements EMAN::Isosurface.

Definition at line 335 of file marchingcubes.h.

336 {
338 }
void setOrigin(int orix, int oriy, int oriz)
Set origin.
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

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

◆ setRGBscale()

void EMAN::MarchingCubes::setRGBscale ( float  i,
float  o 
)
inlinevirtual

Implements EMAN::Isosurface.

Definition at line 340 of file marchingcubes.h.

341 {
343 }
void setScale(float i, float o)
Set scaling.

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

◆ surface_face_z()

void EMAN::MarchingCubes::surface_face_z ( )

Friends And Related Function Documentation

◆ GLUtil

friend class GLUtil
friend

Definition at line 272 of file marchingcubes.h.

Member Data Documentation

◆ _isodl

unsigned long EMAN::MarchingCubes::_isodl
private

Definition at line 370 of file marchingcubes.h.

◆ buffer

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

Definition at line 371 of file marchingcubes.h.

◆ cc

CustomVector<float> EMAN::MarchingCubes::cc
private

Definition at line 447 of file marchingcubes.h.

◆ drawing_level

int EMAN::MarchingCubes::drawing_level
private

The "sampling rate".

Definition at line 390 of file marchingcubes.h.

Referenced by get_sampling(), and set_sampling().

◆ ff

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

Definition at line 450 of file marchingcubes.h.

◆ maxvals

vector<EMData*> EMAN::MarchingCubes::maxvals
private

Definition at line 387 of file marchingcubes.h.

◆ minvals

vector<EMData*> EMAN::MarchingCubes::minvals
private

Vectors for storing the search trees.

Definition at line 387 of file marchingcubes.h.

Referenced by get_sampling_range().

◆ needtobind

bool EMAN::MarchingCubes::needtobind
private

Definition at line 455 of file marchingcubes.h.

◆ nn

CustomVector<float> EMAN::MarchingCubes::nn
private

Definition at line 449 of file marchingcubes.h.

◆ point_map

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

Definition at line 369 of file marchingcubes.h.

◆ pp

CustomVector<float> EMAN::MarchingCubes::pp
private

.Custom vectors for storing points, normals and faces

Definition at line 446 of file marchingcubes.h.

◆ rgbgenerator

ColorRGBGenerator EMAN::MarchingCubes::rgbgenerator
private

Color by radius generator.

Definition at line 453 of file marchingcubes.h.

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

◆ vv

CustomVector<int> EMAN::MarchingCubes::vv
private

Definition at line 448 of file marchingcubes.h.


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