Graphite
Version 3
An experimental 3D geometry processing program
|
An allocator for points that are created from intersections in GenericVoronoiDiagram. More...
#include <geogram/voronoi/generic_RVD_vertex.h>
Public Member Functions | |
PointAllocator (coord_index_t dim) | |
Creates a new empty PointAllocator. More... | |
double * | new_item () |
Allocates a new point. More... | |
void | clear () |
Clears this PointAllocator. | |
~PointAllocator () | |
PointAllocator destructor. More... | |
coord_index_t | dimension () const |
Gets the dimension of the points stored in this PointAllocator. | |
Protected Types | |
enum | { CHUNK_SHIFT = 8 , CHUNK_SIZE = 1 << CHUNK_SHIFT , CHUNK_MASK = CHUNK_SIZE - 1 } |
Constants that determine the size of a chunk. | |
Protected Member Functions | |
void | grow () |
Allocates a new chunk of memory. | |
double * | item (index_t i) |
Gets a pointer to one of the allocated points from its index. More... | |
An allocator for points that are created from intersections in GenericVoronoiDiagram.
Implementation is an array of chunk. We do not use std::deque since we want to control the chunk size, and we want to clear it without deallocating memory to avoid many calls to memory allocator (which would probably slow down the Windows version a lot, there seems to be a global multithreading lock on malloc()).
In most cases, only the first chunk is used (but some degenerate cases may use more). There seems to be no measurable overhead as compared to a contiguous array in our scenario.
Definition at line 668 of file generic_RVD_vertex.h.
|
inline |
Creates a new empty PointAllocator.
[in] | dim | dimension of the points to be allocated |
Definition at line 674 of file generic_RVD_vertex.h.
|
inline |
PointAllocator destructor.
This releases all allocated chunks.
Definition at line 704 of file generic_RVD_vertex.h.
|
inlineprotected |
Gets a pointer to one of the allocated points from its index.
[in] | i | the index of the point in this PointAllocator |
Definition at line 747 of file generic_RVD_vertex.h.
|
inline |
Allocates a new point.
Definition at line 685 of file generic_RVD_vertex.h.