UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
voro::voronoicell_base Class Reference

A class representing a single Voronoi cell. More...

#include <cell.hh>

+ Inheritance diagram for voro::voronoicell_base:

Public Member Functions

 voronoicell_base ()
 
virtual ~voronoicell_base ()
 
void init_base (double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
 
void init_octahedron_base (double l)
 
void init_tetrahedron_base (double x0, double y0, double z0, double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3)
 
void translate (double x, double y, double z)
 
double volume ()
 
double max_radius_squared ()
 
double total_edge_distance ()
 
double surface_area ()
 
void centroid (double &cx, double &cy, double &cz)
 
int number_of_faces ()
 
int number_of_edges ()
 
void vertex_orders (std::vector< int > &v)
 
void vertices (std::vector< double > &v)
 
void vertices (double x, double y, double z, std::vector< double > &v)
 
void face_areas (std::vector< double > &v)
 
void face_orders (std::vector< int > &v)
 
void face_freq_table (std::vector< int > &v)
 
void face_vertices (std::vector< int > &v)
 
void face_perimeters (std::vector< double > &v)
 
void normals (std::vector< double > &v)
 
template<class vc_class >
bool nplane (vc_class &vc, double x, double y, double z, double rsq, int p_id)
 
bool plane_intersects (double x, double y, double z, double rsq)
 
bool plane_intersects_guess (double x, double y, double z, double rsq)
 
void construct_relations ()
 
void check_relations ()
 
void check_duplicates ()
 
void print_edges ()
 
virtual void neighbors (std::vector< int > &v)
 
virtual void print_edges_neighbors (int i)
 
int cycle_up (int a, int vertexIndex)
 
int cycle_down (int a, int vertexIndex)
 

Public Attributes

int current_vertices
 
int current_vertex_order
 
int current_delete_size
 
int current_delete2_size
 
int p
 
int up
 
int ** ed
 
int * nu
 
doublepts
 

Protected Member Functions

void reset_edges ()
 
template<class vc_class >
void check_memory_for_copy (vc_class &vc, voronoicell_base *vb)
 
void copy (voronoicell_base *vb)
 

Protected Attributes

int * mem
 
int * mec
 
int ** mep
 

Friends

class voronoicell
 
class voronoicell_neighbor
 

Detailed Description

A class representing a single Voronoi cell.

This class represents a single Voronoi cell, as a collection of vertices that are connected by edges. The class contains routines for initializing the Voronoi cell to be simple shapes such as a box, tetrahedron, or octahedron. It the contains routines for recomputing the cell based on cutting it by a plane, which forms the key routine for the Voronoi cell computation. It contains numerous routine for computing statistics about the Voronoi cell, and it can output the cell in several formats.

This class is not intended for direct use, but forms the base of the voronoicell and voronoicell_neighbor classes, which extend it based on whether neighboring particle ID information needs to be tracked.

Constructor & Destructor Documentation

◆ voronoicell_base()

voro::voronoicell_base::voronoicell_base ( )

Constructs a Voronoi cell and sets up the initial memory.

◆ ~voronoicell_base()

voro::voronoicell_base::~voronoicell_base ( )
virtual

The voronoicell destructor deallocates all the dynamic memory.

Member Function Documentation

◆ centroid()

void voro::voronoicell_base::centroid ( double cx,
double cy,
double cz 
)

Calculates the centroid of the Voronoi cell, by decomposing the cell into tetrahedra extending outward from the zeroth vertex.

Parameters
[out](cx,cy,cz)references to floating point numbers in which to pass back the centroid vector.

◆ check_duplicates()

void voro::voronoicell_base::check_duplicates ( )

This routine checks for any two vertices that are connected by more than one edge. The plane algorithm is designed so that this should not happen, so any occurrences are most likely errors. Note that the routine is O(p), so running it every time the plane routine is called will result in a significant slowdown.

◆ check_memory_for_copy()

template<class vc_class >
template void voro::voronoicell_base::check_memory_for_copy ( vc_class vc,
voronoicell_base vb 
)
protected

Ensures that enough memory is allocated prior to carrying out a copy.

Parameters
[in]vca reference to the specialized version of the calling class.
[in]vba pointered to the class to be copied.

◆ check_relations()

void voro::voronoicell_base::check_relations ( )

Checks that the relational table of the Voronoi cell is accurate, and prints out any errors. This algorithm is O(p), so running it every time the plane routine is called will result in a significant slowdown.

◆ construct_relations()

void voro::voronoicell_base::construct_relations ( )

Constructs the relational table if the edges have been specified.

◆ copy()

void voro::voronoicell_base::copy ( voronoicell_base vb)
protected

Copies the vertex and edge information from another class. The routine assumes that enough memory is available for the copy.

Parameters
[in]vba pointer to the class to copy.

◆ cycle_down()

int voro::voronoicell_base::cycle_down ( int  a,
int  vertexIndex 
)
inline

This is a simple inline function for picking out the index of the next edge clockwise from the current vertex.

Parameters
[in]athe index of an edge of the current vertex.
[in]pthe number of the vertex.
Returns
nu[p]-1 if a=0, or a-1 otherwise.

◆ cycle_up()

int voro::voronoicell_base::cycle_up ( int  a,
int  vertexIndex 
)
inline

This is a simple inline function for picking out the index of the next edge counterclockwise at the current vertex.

Parameters
[in]athe index of an edge of the current vertex.
[in]pthe number of the vertex.
Returns
0 if a=nu[p]-1, or a+1 otherwise.

◆ face_areas()

void voro::voronoicell_base::face_areas ( std::vector< double > &  v)

Calculates the areas of each face of the Voronoi cell and prints the results to an output stream.

Parameters
[out]vthe vector to store the results in.

◆ face_freq_table()

void voro::voronoicell_base::face_freq_table ( std::vector< int > &  v)

Computes the number of edges that each face has and outputs a frequency table of the results.

Parameters
[out]vthe vector to store the results in.

◆ face_orders()

void voro::voronoicell_base::face_orders ( std::vector< int > &  v)

Outputs a list of the number of edges in each face.

Parameters
[out]vthe vector to store the results in.

◆ face_perimeters()

void voro::voronoicell_base::face_perimeters ( std::vector< double > &  v)

This routine returns the perimeters of each face.

Parameters
[out]vthe vector to store the results in.

◆ face_vertices()

void voro::voronoicell_base::face_vertices ( std::vector< int > &  v)

For each face, this routine outputs a bracketed sequence of numbers containing a list of all the vertices that make up that face.

Parameters
[out]vthe vector to store the results in.

◆ init_base()

void voro::voronoicell_base::init_base ( double  xmin,
double  xmax,
double  ymin,
double  ymax,
double  zmin,
double  zmax 
)

Initializes a Voronoi cell as a rectangular box with the given dimensions.

Parameters
[in](xmin,xmax)the minimum and maximum x coordinates.
[in](ymin,ymax)the minimum and maximum y coordinates.
[in](zmin,zmax)the minimum and maximum z coordinates.

◆ init_octahedron_base()

void voro::voronoicell_base::init_octahedron_base ( double  l)

Initializes a Voronoi cell as a regular octahedron.

Parameters
[in]lThe distance from the octahedron center to a vertex. Six vertices are initialized at (-l,0,0), (l,0,0), (0,-l,0), (0,l,0), (0,0,-l), and (0,0,l).

◆ init_tetrahedron_base()

void voro::voronoicell_base::init_tetrahedron_base ( double  x0,
double  y0,
double  z0,
double  x1,
double  y1,
double  z1,
double  x2,
double  y2,
double  z2,
double  x3,
double  y3,
double  z3 
)

Initializes a Voronoi cell as a tetrahedron. It assumes that the normal to the face for the first three vertices points inside.

Parameters
(x0,y0,z0)a position vector for the first vertex.
(x1,y1,z1)a position vector for the second vertex.
(x2,y2,z2)a position vector for the third vertex.
(x3,y3,z3)a position vector for the fourth vertex.

◆ max_radius_squared()

double voro::voronoicell_base::max_radius_squared ( )

Computes the maximum radius squared of a vertex from the center of the cell. It can be used to determine when enough particles have been testing an all planes that could cut the cell have been considered.

Returns
The maximum radius squared of a vertex.

◆ neighbors()

virtual void voro::voronoicell_base::neighbors ( std::vector< int > &  v)
inlinevirtual

Returns a list of IDs of neighboring particles corresponding to each face.

Parameters
[out]va reference to a vector in which to return the results. If no neighbor information is available, a blank vector is returned.

Reimplemented in voro::voronoicell_neighbor.

◆ normals()

void voro::voronoicell_base::normals ( std::vector< double > &  v)

For each face of the Voronoi cell, this routine prints the out the normal vector of the face, and scales it to the distance from the cell center to that plane.

Parameters
[out]vthe vector to store the results in.

◆ nplane()

template<class vc_class >
template bool voro::voronoicell_base::nplane ( vc_class vc,
double  x,
double  y,
double  z,
double  rsq,
int  p_id 
)

Cuts the Voronoi cell by a particle whose center is at a separation of (x,y,z) from the cell center. The value of rsq should be initially set to $x^2+y^2+z^2$.

Parameters
[in]vca reference to the specialized version of the calling class.
[in](x,y,z)the normal vector to the plane.
[in]rsqthe distance along this vector of the plane.
[in]p_idthe plane ID (for neighbor tracking only).
Returns
False if the plane cut deleted the cell entirely, true otherwise.

◆ number_of_edges()

int voro::voronoicell_base::number_of_edges ( )

Counts the number of edges of the Voronoi cell.

Returns
the number of edges.

◆ number_of_faces()

int voro::voronoicell_base::number_of_faces ( )

Returns the number of faces of a computed Voronoi cell.

Returns
The number of faces.

◆ plane_intersects()

bool voro::voronoicell_base::plane_intersects ( double  x,
double  y,
double  z,
double  rsq 
)

This routine tests to see whether the cell intersects a plane by starting from the guess point up. If up intersects, then it immediately returns true. Otherwise, it calls the plane_intersects_track() routine.

Parameters
[in](x,y,z)the normal vector to the plane.
[in]rsqthe distance along this vector of the plane.
Returns
False if the plane does not intersect the plane, true if it does.

◆ plane_intersects_guess()

bool voro::voronoicell_base::plane_intersects_guess ( double  x,
double  y,
double  z,
double  rsq 
)

This routine tests to see if a cell intersects a plane. It first tests a random sample of approximately sqrt(p)/4 points. If any of those are intersect, then it immediately returns true. Otherwise, it takes the closest point and passes that to plane_intersect_track() routine.

Parameters
[in](x,y,z)the normal vector to the plane.
[in]rsqthe distance along this vector of the plane.
Returns
False if the plane does not intersect the plane, true if it does.

◆ print_edges()

void voro::voronoicell_base::print_edges ( )

Prints the vertices, their edges, the relation table, and also notifies if any memory errors are visible.

◆ print_edges_neighbors()

virtual void voro::voronoicell_base::print_edges_neighbors ( int  i)
inlinevirtual

This a virtual function that is overridden by a routine to print the neighboring particle IDs for a given vertex. By default, when no neighbor information is available, the routine does nothing.

Parameters
[in]ithe vertex to consider.

Reimplemented in voro::voronoicell_neighbor.

◆ reset_edges()

void voro::voronoicell_base::reset_edges ( )
inlineprotected

Several routines in the class that gather cell-based statistics internally track their progress by flipping edges to negative so that they know what parts of the cell have already been tested. This function resets them back to positive. When it is called, it assumes that every edge in the routine should have already been flipped to negative, and it bails out with an internal error if it encounters a positive edge.

◆ surface_area()

double voro::voronoicell_base::surface_area ( )

Calculates the total surface area of the Voronoi cell.

Returns
The computed area.

◆ total_edge_distance()

double voro::voronoicell_base::total_edge_distance ( )

Calculates the total edge distance of the Voronoi cell.

Returns
A floating point number holding the calculated distance.

◆ translate()

void voro::voronoicell_base::translate ( double  x,
double  y,
double  z 
)

Translates the vertices of the Voronoi cell by a given vector.

Parameters
[in](x,y,z)the coordinates of the vector.

◆ vertex_orders()

void voro::voronoicell_base::vertex_orders ( std::vector< int > &  v)

Returns a vector of the vertex orders.

Parameters
[out]vthe vector to store the results in.

◆ vertices() [1/2]

void voro::voronoicell_base::vertices ( double  x,
double  y,
double  z,
std::vector< double > &  v 
)

Returns a vector of the vertex vectors in the global coordinate system.

Parameters
[out]vthe vector to store the results in.
[in](x,y,z)the position vector of the particle in the global coordinate system.

◆ vertices() [2/2]

void voro::voronoicell_base::vertices ( std::vector< double > &  v)

Returns a vector of the vertex vectors using the local coordinate system.

Parameters
[out]vthe vector to store the results in.

◆ volume()

double voro::voronoicell_base::volume ( )

Calculates the volume of the Voronoi cell, by decomposing the cell into tetrahedra extending outward from the zeroth vertex, whose volumes are evaluated using a scalar triple product.

Returns
A floating point number holding the calculated volume.

Friends And Related Symbol Documentation

◆ voronoicell

friend class voronoicell
friend

◆ voronoicell_neighbor

Member Data Documentation

◆ current_delete2_size

int voro::voronoicell_base::current_delete2_size

This sets the size of the auxiliary delete stack.

◆ current_delete_size

int voro::voronoicell_base::current_delete_size

This sets the size of the main delete stack.

◆ current_vertex_order

int voro::voronoicell_base::current_vertex_order

This holds the current maximum allowed order of a vertex, which sets the size of the mem, mep, and mec arrays. If a vertex is created with more vertices than this, the arrays are dynamically extended using the add_memory_vorder routine.

◆ current_vertices

int voro::voronoicell_base::current_vertices

This holds the current size of the arrays ed and nu, which hold the vertex information. If more vertices are created than can fit in this array, then it is dynamically extended using the add_memory_vertices routine.

◆ ed

int** voro::voronoicell_base::ed

This is a two dimensional array that holds information about the edge connections of the vertices that make up the cell. The two dimensional array is not allocated in the usual method. To account for the fact the different vertices have different orders, and thus require different amounts of storage, the elements of ed[i] point to one-dimensional arrays in the mep[] array of different sizes.

More specifically, if vertex i has order m, then ed[i] points to a one-dimensional array in mep[m] that has 2*m+1 entries. The first m elements hold the neighboring edges, so that the jth edge of vertex i is held in ed[i][j]. The next m elements hold a table of relations which is redundant but helps speed up the computation. It satisfies the relation ed[ed[i][j]][ed[i][m+j]]=i. The final entry holds a back pointer, so that ed[i+2*m]=i. The back pointers are used when rearranging the memory.

◆ mec

int* voro::voronoicell_base::mec
protected

This is a one dimensional array that holds the current number of vertices of order p that are stored in the mep[p] array.

◆ mem

int* voro::voronoicell_base::mem
protected

This a one dimensional array that holds the current sizes of the memory allocations for them mep array.

◆ mep

int** voro::voronoicell_base::mep
protected

This is a two dimensional array for holding the information about the edges of the Voronoi cell. mep[p] is a one-dimensional array for holding the edge information about all vertices of order p, with each vertex holding 2*p+1 integers of information. The total number of vertices held on mep[p] is stored in mem[p]. If the space runs out, the code allocates more using the add_memory() routine.

◆ nu

int* voro::voronoicell_base::nu

This array holds the order of the vertices in the Voronoi cell. This array is dynamically allocated, with its current size held by current_vertices.

◆ p

int voro::voronoicell_base::p

This sets the total number of vertices in the current cell.

◆ pts

double* voro::voronoicell_base::pts

This in an array with size 3*current_vertices for holding the positions of the vertices.

◆ up

int voro::voronoicell_base::up

This is the index of particular point in the cell, which is used to start the tracing routines for plane intersection and cutting. These routines will work starting from any point, but it's often most efficient to start from the last point considered, since in many cases, the cell construction algorithm may consider many planes with similar vectors concurrently.


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