#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 78 of file marchingcubes.h.
|
Constructor.
Definition at line 84 of file marchingcubes.h.
|
|
Definition at line 89 of file marchingcubes.h. 00090 { 00091 if(data) {free(data); data=0;} 00092 }
|
|
Clear clears all data and resizes.
Definition at line 98 of file marchingcubes.h. 00099 { 00100 if (data) {free(data); data = 0;} 00101 size = 0; 00102 elements = 0; 00103 resize(starting_size); 00104 }
|
|
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 159 of file marchingcubes.h. 00159 { return elements; }
|
|
get the underlying data as a pointer objects
Definition at line 178 of file marchingcubes.h. 00178 { return data; }
|
|
Multiply contiguous groups of 3 by different values.
Definition at line 144 of file marchingcubes.h. 00145 { 00146 for(unsigned int i = 0; (i + 2) < elements; i += 3 ){ 00147 data[i] *= v1; 00148 data[i+1] *= v2; 00149 data[i+2] *= v3; 00150 } 00151 }
|
|
Operator[] - provide convenient set functionality (note NOT get).
Definition at line 165 of file marchingcubes.h. 00166 { 00167 unsigned int csize = size; 00168 while (idx >= csize ) { 00169 csize *= 2; 00170 } 00171 if ( csize != size ) resize(csize); 00172 return data[idx]; 00173 }
|
|
Push back a value Potentially resizes.
Definition at line 124 of file marchingcubes.h. 00125 { 00126 if ( elements == size ) resize(2*size); 00127 data[elements] = t; 00128 ++elements; 00129 }
|
|
Push back 3 values Potentially resizes.
Definition at line 135 of file marchingcubes.h. 00136 { 00137 if ( elements+2 >= size ) resize(2*size); 00138 memcpy( &data[elements], p, 3*sizeof(type)); 00139 elements = elements + 3; 00140 }
|
|
Resize Resize the data pointer using realloc In general you want to resize to a larger size...
Definition at line 112 of file marchingcubes.h. 00113 { 00114 data = (type*)realloc(data, n*sizeof(type)); 00115 00116 for(unsigned int i = size; i < n; ++i) data[i] = 0; 00117 size = n; 00118 }
|
|
The data pointer.
Definition at line 182 of file marchingcubes.h. |
|
The number of stored elements.
Definition at line 186 of file marchingcubes.h. |
|
The size of the associated memory block.
Definition at line 184 of file marchingcubes.h. |