#include <marchingcubes.h>
Inheritance diagram for EMAN::CustomVector< type >:
Public Member Functions | |
CustomVector (unsigned int starting_size=1024) | |
Constructor. | |
~CustomVector () | |
void | clear (unsigned int starting_size=1024) |
Clear clears all data and resizes. | |
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 (const type &t) |
Push back a value Potentially resizes. | |
void | push_back_3 (const type *const p) |
Push back 3 values Potentially resizes. | |
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. | |
type & | operator[] (const unsigned int idx) |
Operator[] - provide convenient set functionality (note NOT get). | |
type * | get_data () |
get the underlying data as a pointer objects | |
Private Attributes | |
type * | data |
The data pointer. | |
unsigned int | size |
The size of the associated memory block. | |
unsigned int | elements |
The number of stored elements. |
It has get_data() functionality, which gives direct access to the underlying data, which is necessary for handing OpenGL vertex and normal arrays - the native STL vector does not give straightforward access to the data pointers. This class also has a push_back_3 function which does a memcpy of 3 elements - this can be used instead of 3 push_back function calls. Although it wasn't rigorously tested it should save some time by virtue of less function calls. Although the savings may be trivial, I just haven't tested it.
This class was not written for general use because- it is designed specifically for use in conjunction with the MarchingCubes class only.
Definition at line 70 of file marchingcubes.h.
EMAN::CustomVector< type >::CustomVector | ( | unsigned int | starting_size = 1024 |
) | [inline, explicit] |
EMAN::CustomVector< type >::~CustomVector | ( | ) | [inline] |
void EMAN::CustomVector< type >::clear | ( | unsigned int | starting_size = 1024 |
) | [inline] |
Clear clears all data and resizes.
starting_size | the starting size of the underlying data |
Definition at line 90 of file marchingcubes.h.
Referenced by EMAN::MarchingCubes::calculate_surface().
00091 { 00092 if (data) {free(data); data = 0;} 00093 size = 0; 00094 elements = 0; 00095 resize(starting_size); 00096 }
unsigned int EMAN::CustomVector< type >::elem | ( | ) | [inline] |
The number of elements, is the same as STL::vector size() Should be called size() but oh well.
.. This is the actual number of stored floating point numbers not the number of 'groups of 3'
Definition at line 151 of file marchingcubes.h.
Referenced by EMAN::MarchingCubes::get_isosurface(), EMAN::MarchingCubes::marching_cube(), EMAN::MarchingCubes::surface_face_z(), and EMAN::U3DWriter::write_clod_mesh_generator_node().
00151 { return elements; }
type* EMAN::CustomVector< type >::get_data | ( | ) | [inline] |
get the underlying data as a pointer objects
Definition at line 170 of file marchingcubes.h.
Referenced by EMAN::MarchingCubes::get_isosurface(), EMAN::MarchingCubes::surface_face_z(), and EMAN::U3DWriter::write_clod_mesh_generator_node().
00170 { return data; }
void EMAN::CustomVector< type >::mult3 | ( | const type & | v1, | |
const type & | v2, | |||
const type & | v3 | |||
) | [inline] |
type& EMAN::CustomVector< type >::operator[] | ( | const unsigned int | idx | ) | [inline] |
Operator[] - provide convenient set functionality (note NOT get).
idx | the index to access for setting purposes potentially resizes |
Definition at line 157 of file marchingcubes.h.
00158 { 00159 unsigned int csize = size; 00160 while (idx >= csize ) { 00161 csize *= 2; 00162 } 00163 if ( csize != size ) resize(csize); 00164 return data[idx]; 00165 }
void EMAN::CustomVector< type >::push_back | ( | const type & | t | ) | [inline] |
void EMAN::CustomVector< type >::push_back_3 | ( | const type *const | p | ) | [inline] |
Push back 3 values Potentially resizes.
p | a pointer to 3 contiguous values |
Definition at line 127 of file marchingcubes.h.
Referenced by EMAN::MarchingCubes::marching_cube().
00128 { 00129 if ( elements+2 >= size ) resize(2*size); 00130 memcpy( &data[elements], p, 3*sizeof(type)); 00131 elements = elements + 3; 00132 }
void EMAN::CustomVector< type >::resize | ( | const unsigned int | n | ) | [inline] |
Resize Resize the data pointer using realloc In general you want to resize to a larger size.
..
n | the new size of the underlying data |
Definition at line 104 of file marchingcubes.h.
Referenced by EMAN::CustomVector< unsigned int >::clear(), EMAN::CustomVector< unsigned int >::CustomVector(), EMAN::CustomVector< unsigned int >::operator[](), EMAN::CustomVector< unsigned int >::push_back(), and EMAN::CustomVector< unsigned int >::push_back_3().
00105 { 00106 data = (type*)realloc(data, n*sizeof(type)); 00107 00108 for(unsigned int i = size; i < n; ++i) data[i] = 0; 00109 size = n; 00110 }
type* EMAN::CustomVector< type >::data [private] |
The data pointer.
Definition at line 174 of file marchingcubes.h.
Referenced by EMAN::CustomVector< unsigned int >::clear(), EMAN::CustomVector< unsigned int >::get_data(), EMAN::CustomVector< unsigned int >::mult3(), EMAN::CustomVector< unsigned int >::operator[](), EMAN::CustomVector< unsigned int >::push_back(), EMAN::CustomVector< unsigned int >::push_back_3(), EMAN::CustomVector< unsigned int >::resize(), and EMAN::CustomVector< unsigned int >::~CustomVector().
unsigned int EMAN::CustomVector< type >::elements [private] |
The number of stored elements.
Definition at line 178 of file marchingcubes.h.
Referenced by EMAN::CustomVector< unsigned int >::clear(), EMAN::CustomVector< unsigned int >::elem(), EMAN::CustomVector< unsigned int >::mult3(), EMAN::CustomVector< unsigned int >::push_back(), and EMAN::CustomVector< unsigned int >::push_back_3().
unsigned int EMAN::CustomVector< type >::size [private] |
The size of the associated memory block.
Definition at line 176 of file marchingcubes.h.
Referenced by EMAN::CustomVector< unsigned int >::clear(), EMAN::CustomVector< unsigned int >::operator[](), EMAN::CustomVector< unsigned int >::push_back(), EMAN::CustomVector< unsigned int >::push_back_3(), and EMAN::CustomVector< unsigned int >::resize().