32#ifndef _MARCHING_CUBES_H_
33#define _MARCHING_CUBES_H_
42#define MARCHING_CUBES_DEBUG 0
51 #include "OpenGL/gl.h"
52 #include "OpenGL/glext.h"
73 template<
typename type>
94 inline void clear(
unsigned int starting_size=1024)
110 data = (type*)realloc(
data, n*
sizeof(type));
112 for(
unsigned int i =
size; i < n; ++i)
data[i] = 0;
140 inline void mult3(
const type& v1,
const type& v2,
const type& v3)
142 for(
unsigned int i = 0; (i + 2) <
elements; i += 3 ){
163 unsigned int csize =
size;
164 while (idx >= csize ) {
401 void draw_cube(
const int x,
const int y,
const int z,
const int cur_level );
426 float get_offset(
float fValue1,
float fValue2,
float fValueDesired);
505 typedef long unsigned int U64;
509 typedef short unsigned int U16;
510 typedef unsigned char U8;
530 template<
typename type>
531 ostream&
write(ostream& os,
const type& T) {
532 os.write( (
const char*)(&T),
sizeof(type) );
Class to encapsulate an RGB color generator for marching cubes isosurface generator For now you can o...
float * getRGBColor(int x, int y, int z)
Generate a color based on pixel coords.
void set_data(EMData *data)
set the emdata
void setScale(float i, float o)
Set scaling.
ColorRGBGenerator(EMData *emdata)
Constructor.
void setNeedToRecolor(bool recolor)
void set_cmap_data(EMData *data)
Set min max data.
void setOrigin(int orix, int oriy, int oriz)
Set origin.
void generateRadialColorMap()
Generate a color map.
void setMinMax(float min, float max)
Set the mn max for cmap coloring.
bool getNeedToRecolor()
Lets us know if we need to recalculate colors.
void setRGBmode(int mode)
Set RGB mode 0 = none, 1 = color by radius, more to come :)
int getRGBmode()
Return RGB mode.
CustomVector has some trivial optimizations of the STL vector.
type * get_data()
get the underlying data as a pointer objects
void resize(const unsigned int n)
Resize Resize the data pointer using realloc In general you want to resize to a larger size....
void push_back_3(const type *const p)
Push back 3 values Potentially resizes.
unsigned int elements
The number of stored elements.
CustomVector(unsigned int starting_size=1024)
Constructor.
type * data
The data pointer.
void mult3(const type &v1, const type &v2, const type &v3)
Multiply contiguous groups of 3 by different values.
unsigned int elem()
The number of elements, is the same as STL::vector size() Should be called size() but oh well....
void clear(unsigned int starting_size=1024)
Clear clears all data and resizes.
void push_back(const type &t)
Push back a value Potentially resizes.
unsigned int size
The size of the associated memory block.
type & operator[](const unsigned int idx)
Operator[] - provide convenient set functionality (note NOT get)
Dict is a dictionary to store <string, EMObject> pair.
EMData stores an image's data and defines core image processing routines.
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,...
void set_surface_value(const float value)
Set Isosurface value.
ColorRGBGenerator rgbgenerator
Color by radius generator.
void setCmapData(EMData *data)
Sets the colormap.
void get_normal(Vector3 &normal, int fX, int fY, int fZ)
Find the gradient of the scalar field at a point.
bool calculate_min_max_vals()
Calculate the min and max value trees Stores minimum and maximum cube neighborhood values in a tree s...
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 ...
void set_data(EMData *data)
Sets Voxel data for Isosurface implementation Calls calculate_min_max_vals which generates the tree o...
vector< EMData * > 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,...
int drawing_level
The "sampling rate".
void setRGBorigin(int x, int y, int z)
Functions to control colroing mode.
float get_surface_value() const
Get the current isosurface value being used.
int getRGBmode()
Return RGB mode.
Dict get_isosurface()
Get the isosurface as dictionary Traverses the tree and marches the cubes.
int get_sampling_range()
Get the range of feasible sampling rates.
int get_edge_num(int x, int y, int z, int edge)
Get edge num needs better commenting.
CustomVector< unsigned int > ff
MarchingCubes()
Default constructor.
int get_sampling() const
Current the current sampling rate Finest sampling is -1.
void color_vertices()
Color the vertices.
void setRGBmode(int mode)
MarchingCubes(EMData *em)
Most commonly used constructor calls set_data(em)
void set_sampling(const int rate)
Set sampling rates A smaller value means a finer sampling.
void clear_min_max_vals()
Clear the minimum and maximum value search trees Frees memory in the minvals and maxvals.
vector< EMData * > minvals
Vectors for storing the search trees.
void setRGBscale(float i, float o)
CustomVector< float > pp
.Custom vectors for storing points, normals and faces
map< int, int > point_map
void setCmapMinMax(float min, float max)
Sets the colormap mix max range.
A work in progress by David Woolford.
ostream & write(ostream &)
CustomVector< unsigned int > ff
ostream & write_clod_mesh_generator_node(ostream &os)
ostream & write_header(ostream &)
int write(const string &filename)
ostream & write(ostream &os, const type &T)
unsigned int size_of_in_bytes()