voronoicell_base< n_option > Class Template Reference
A class encapsulating all the routines for storing and calculating a single Voronoi cell.
More...
#include <cell.hh>
Public Member Functions |
| voronoicell_base () |
| ~voronoicell_base () |
void | init (fpoint xmin, fpoint xmax, fpoint ymin, fpoint ymax, fpoint zmin, fpoint zmax) |
void | init_octahedron (fpoint l) |
void | init_tetrahedron (fpoint x0, fpoint y0, fpoint z0, fpoint x1, fpoint y1, fpoint z1, fpoint x2, fpoint y2, fpoint z2, fpoint x3, fpoint y3, fpoint z3) |
void | draw_pov (ostream &os, fpoint x, fpoint y, fpoint z) |
void | draw_pov (const char *filename, fpoint x, fpoint y, fpoint z) |
void | draw_pov (fpoint x, fpoint y, fpoint z) |
void | draw_pov_mesh (ostream &os, fpoint x, fpoint y, fpoint z) |
void | draw_pov_mesh (const char *filename, fpoint x, fpoint y, fpoint z) |
void | draw_pov_mesh (fpoint x, fpoint y, fpoint z) |
void | draw_gnuplot (ostream &os, fpoint x, fpoint y, fpoint z) |
void | draw_gnuplot (const char *filename, fpoint x, fpoint y, fpoint z) |
void | draw_gnuplot (fpoint x, fpoint y, fpoint z) |
fpoint | volume () |
fpoint | max_radius_squared () |
fpoint | total_edge_distance () |
fpoint | surface_area () |
void | centroid (fpoint &cx, fpoint &cy, fpoint &cz) |
int | number_of_faces () |
int | number_of_edges () |
void | output_vertex_orders (ostream &os) |
void | output_vertices (ostream &os) |
void | output_vertices (ostream &os, fpoint x, fpoint y, fpoint z) |
void | output_face_areas (ostream &os) |
void | output_face_orders (ostream &os) |
void | output_face_freq_table (ostream &os) |
void | output_face_vertices (ostream &os) |
void | output_face_perimeters (ostream &os) |
void | output_normals (ostream &os) |
void | output_neighbors (ostream &os, bool later=false) |
bool | nplane (fpoint x, fpoint y, fpoint z, fpoint rs, int p_id) |
bool | nplane (fpoint x, fpoint y, fpoint z, int p_id) |
bool | plane (fpoint x, fpoint y, fpoint z, fpoint rs) |
bool | plane (fpoint x, fpoint y, fpoint z) |
bool | plane_intersects (fpoint x, fpoint y, fpoint z, fpoint rs) |
bool | plane_intersects_guess (fpoint x, fpoint y, fpoint z, fpoint rs) |
void | init_test (int n) |
void | add_vertex (fpoint x, fpoint y, fpoint z, int a) |
void | add_vertex (fpoint x, fpoint y, fpoint z, int a, int b) |
void | add_vertex (fpoint x, fpoint y, fpoint z, int a, int b, int c) |
void | add_vertex (fpoint x, fpoint y, fpoint z, int a, int b, int c, int d) |
void | add_vertex (fpoint x, fpoint y, fpoint z, int a, int b, int c, int d, int e) |
void | construct_relations () |
void | check_relations () |
void | check_duplicates () |
void | print_edges () |
void | label_facets () |
void | check_facets () |
void | perturb (fpoint r) |
Data Fields |
int | current_vertices |
int | current_vertex_order |
int | current_delete_size |
int | current_delete2_size |
int | p |
int | up |
int ** | ed |
int * | nu |
fpoint * | pts |
suretest | sure |
Friends |
class | neighbor_track |
Detailed Description
template<class n_option>
class voronoicell_base< n_option >
A class encapsulating all the routines for storing and calculating a single Voronoi cell.
This class encapsulates all the routines for storing and calculating a single Voronoi cell. The cell can first be initialized by the init() function to be a rectangular box. The box can then be successively cut by planes using the plane function. Other routines exist for outputting the cell, computing its volume, or finding the largest distance of a vertex from the cell center. The cell is described by two arrays. pts[] is a floating point array which holds the vertex positions. ed[] holds the table of edges, and also a relation table that determines how two vertices are connected to one another. The relation table is redundant, but helps speed up the computation. The function check_relations() checks that the relational table is valid.
Definition at line 103 of file cell.hh.
Constructor & Destructor Documentation
template<class n_option >
Constructs a Voronoi cell and sets up the initial memory.
Definition at line 15 of file cell.cc.
template<class n_option >
The voronoicell destructor deallocates all the dynamic memory.
Definition at line 38 of file cell.cc.
Member Function Documentation
template<class n_option >
Adds an order 5 vertex to the memory structure, and specifies its edges.
- Parameters:
-
[in] | (x,y,z) | are the coordinates of the vertex. |
[in] | (a,b,c,d,e) | are the edges of this vertex. |
Definition at line 494 of file cell.cc.
template<class n_option >
Adds an order 4 vertex to the memory structure, and specifies its edges.
- Parameters:
-
[in] | (x,y,z) | are the coordinates of the vertex. |
[in] | (a,b,c,d) | are the edges of this vertex. |
Definition at line 482 of file cell.cc.
template<class n_option >
Adds an order 3 vertex to the memory structure, and specifies its edges.
- Parameters:
-
[in] | (x,y,z) | are the coordinates of the vertex. |
[in] | (a,b,c) | are the edges of this vertex. |
Definition at line 470 of file cell.cc.
template<class n_option >
Adds an order 2 vertex to the memory structure, and specifies its edges.
- Parameters:
-
[in] | (x,y,z) | are the coordinates of the vertex. |
[in] | (a,b) | are the edges of this vertex. |
Definition at line 458 of file cell.cc.
template<class n_option >
Adds an order one vertex to the memory structure, and specifies its edge.
- Parameters:
-
[in] | (x,y,z) | are the coordinates of the vertex. |
[in] | a | is the first and only edge of this vertex. |
Definition at line 446 of file cell.cc.
template<class n_option >
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. |
Definition at line 1599 of file cell.cc.
template<class n_option >
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.
Definition at line 518 of file cell.cc.
template<class n_option >
If the template is instantiated with the neighbor tracking turned on, then this routine will check that the neighbor information is consistent, by tracing around every facet, and ensuring that all the neighbor information for that facet refers to the same neighbor. If the neighbor tracking isn't turned on, this routine does nothing.
Definition at line 2206 of file cell.cc.
template<class n_option >
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.
Definition at line 506 of file cell.cc.
template<class n_option >
Constructs the relational table if the edges have been specified.
Definition at line 526 of file cell.cc.
template<class n_option >
An overloaded version of the draw_gnuplot routine, that prints to the standard output.
- Parameters:
-
[in] | (x,y,z) | a displacement vector to be added to the cell's position. |
Definition at line 1748 of file cell.cc.
template<class n_option >
An overloaded version of the draw_gnuplot routine that writes directly to a file.
- Parameters:
-
[in] | filename | The name of the file to write to. |
[in] | (x,y,z) | a displacement vector to be added to the cell's position. |
Definition at line 1736 of file cell.cc.
template<class n_option >
Outputs the edges of the Voronoi cell in gnuplot format to an output stream.
- Parameters:
-
[in] | os | a reference to an output stream to write to. |
[in] | (x,y,z) | a displacement vector to be added to the cell's position. |
Definition at line 1719 of file cell.cc.
template<class n_option >
An overloaded version of the draw_pov routine, that outputs the edges of the Voronoi cell (in POV-Ray format) to standard output.
- Parameters:
-
[in] | (x,y,z) | a displacement vector to be added to the cell's position. |
Definition at line 1710 of file cell.cc.
template<class n_option >
An overloaded version of the draw_pov routine, that outputs the edges of the Voronoi cell in POV-Ray format to a file.
- Parameters:
-
[in] | filename | the file to write to. |
[in] | (x,y,z) | a displacement vector to be added to the cell's position. |
Definition at line 1698 of file cell.cc.
template<class n_option >
Outputs the edges of the Voronoi cell in POV-Ray format to an open file stream, displacing the cell by given vector.
- Parameters:
-
[in] | os | a output stream to write to. |
[in] | (x,y,z) | a displacement vector to be added to the cell's position. |
Definition at line 1680 of file cell.cc.
template<class n_option >
An overloaded version of the draw_pov_mesh routine, that prints to the standard output.
- Parameters:
-
[in] | (x,y,z) | a displacement vector to be added to the cell's position. |
Definition at line 1820 of file cell.cc.
template<class n_option >
An overloaded version of the draw_pov_mesh routine, that writes directly to a file.
- Parameters:
-
[in] | filename | a filename to write to. |
[in] | (x,y,z) | a displacement vector to be added to the cell's position. |
Definition at line 1808 of file cell.cc.
template<class n_option >
Outputs the Voronoi cell in the POV mesh2 format, described in section 1.3.2.2 of the POV-Ray documentation. The mesh2 output consists of a list of vertex vectors, followed by a list of triangular faces. The routine also makes use of the optional inside_vector specification, which makes the mesh object solid, so the the POV-Ray Constructive Solid Geometry (CSG) can be applied.
- Parameters:
-
[in] | os | an output stream to write to. |
[in] | (x,y,z) | a displacement vector to be added to the cell's position. |
Definition at line 1762 of file cell.cc.
template<class n_option >
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. |
Definition at line 197 of file cell.cc.
template<class n_option >
Initializes a Voronoi cell as a regular octahedron.
- Parameters:
-
[in] | l | The 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). |
Definition at line 228 of file cell.cc.
template<class n_option >
Initializes an arbitrary test object using the add_vertex() and construct_relations() routines. See the source code for information about the specific objects.
- Parameters:
-
[in] | n | the number of the test object (from 0 to 9). |
Definition at line 278 of file cell.cc.
template<class n_option >
void voronoicell_base< n_option >::init_tetrahedron |
( |
fpoint |
x0, |
|
|
fpoint |
y0, |
|
|
fpoint |
z0, |
|
|
fpoint |
x1, |
|
|
fpoint |
y1, |
|
|
fpoint |
z1, |
|
|
fpoint |
x2, |
|
|
fpoint |
y2, |
|
|
fpoint |
z2, |
|
|
fpoint |
x3, |
|
|
fpoint |
y3, |
|
|
fpoint |
z3 | |
|
) |
| | [inline] |
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. |
Definition at line 256 of file cell.cc.
template<class n_option >
If the template is instantiated with the neighbor tracking turned on, then this routine will label all the facets of the current cell. Otherwise this routine does nothing.
Definition at line 2185 of file cell.cc.
template<class n_option >
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.
Definition at line 1646 of file cell.cc.
template<class n_option >
This routine calculates the modulus squared of the vector before passing it to the main nplane() routine with full arguments.
- Parameters:
-
[in] | (x,y,z) | the vector to cut the cell by. |
[in] | p_id | the plane ID (for neighbor tracking only). |
- Returns:
- False if the plane cut deleted the cell entirely, true otherwise.
Definition at line 1456 of file cell.cc.
template<class n_option >
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 .
- Parameters:
-
[in] | (x,y,z) | the normal vector to the plane. |
[in] | rsq | the distance along this vector of the plane. |
[in] | p_id | the plane ID (for neighbor tracking only). |
- Returns:
- False if the plane cut deleted the cell entirely, true otherwise.
Definition at line 547 of file cell.cc.
template<class n_option >
Counts the number of edges of the Voronoi cell.
- Returns:
- the number of edges.
Definition at line 2306 of file cell.cc.
template<class n_option >
Returns the number of faces of a computed Voronoi cell.
- Returns:
- The number of faces.
Definition at line 2004 of file cell.cc.
template<class n_option >
Calculates the areas of each face of the Voronoi cell and prints the results to an output stream.
- Parameters:
-
[in] | os | an output stream to write to. |
Definition at line 1524 of file cell.cc.
template<class n_option >
void voronoicell_base< n_option >::output_face_freq_table |
( |
ostream & |
os |
) |
[inline] |
Computes the number of edges that each face has and outputs a frequency table of the results.
- Parameters:
-
[in] | os | an open output stream to write to. |
Definition at line 2144 of file cell.cc.
template<class n_option >
Outputs a list of the number of edges in each face.
- Parameters:
-
[in] | os | an open output stream to write to. |
Definition at line 2118 of file cell.cc.
template<class n_option >
void voronoicell_base< n_option >::output_face_perimeters |
( |
ostream & |
os |
) |
[inline] |
This routine outputs the perimeters of each face.
- Parameters:
-
[in] | os | an open output stream to write to. |
Definition at line 2060 of file cell.cc.
template<class n_option >
void voronoicell_base< n_option >::output_face_vertices |
( |
ostream & |
os |
) |
[inline] |
For each face, this routine outputs a bracketed sequence of numbers containing a list of all the vertices that make up that face.
- Parameters:
-
[in] | os | an open output stream to write to. |
Definition at line 2093 of file cell.cc.
template<class n_option >
void voronoicell_base< n_option >::output_neighbors |
( |
ostream & |
os, |
|
|
bool |
later = false | |
|
) |
| | [inline] |
If the template is instantiated with the neighbor tracking turned on, then this routine will print out a list of all the neighbors of a given cell. Otherwise, this routine does nothing.
- Parameters:
-
[in] | os | an open output stream to write to. |
[in] | later | a boolean value to determine whether or not to write a space character before the first entry. |
Definition at line 2196 of file cell.cc.
template<class n_option >
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:
-
[in] | os | an output stream to write to. |
Definition at line 1923 of file cell.cc.
template<class n_option >
void voronoicell_base< n_option >::output_vertex_orders |
( |
ostream & |
os |
) |
[inline] |
Outputs the vertex orders to an open output stream.
- Parameters:
-
[in] | os | the output stream to write to. |
Definition at line 2028 of file cell.cc.
template<class n_option >
Outputs the vertex vectors to an open output stream using the global coordinate system.
- Parameters:
-
[in] | os | the output stream to write to. |
[in] | (x,y,z) | the position vector of the particle in the global coordinate system. |
Definition at line 2051 of file cell.cc.
template<class n_option >
Outputs the vertex vectors to an open output stream using the local coordinate system.
- Parameters:
-
[in] | os | the output stream to write to. |
Definition at line 2038 of file cell.cc.
template<class n_option >
Randomly perturbs the points in the Voronoi cell by an amount r.
- Parameters:
-
[in] | r | the amount to perturb each coordinate by. |
Definition at line 1827 of file cell.cc.
template<class n_option >
Cuts a Voronoi cell using the influence of a particle at (x,y,z), first calculating the modulus squared of this vector before passing it to the main nplane() routine. Zero is supplied as the plane ID, which will be ignored unless neighbor tracking is enabled.
- Parameters:
-
[in] | (x,y,z) | the vector to cut the cell by. |
- Returns:
- False if the plane cut deleted the cell entirely, true otherwise.
Definition at line 1435 of file cell.cc.
template<class n_option >
This version of the plane routine just makes up the plane ID to be zero. It will only be referenced if neighbor tracking is enabled.
- Parameters:
-
[in] | (x,y,z) | the vector to cut the cell by. |
[in] | rsq | the modulus squared of the vector. |
- Returns:
- False if the plane cut deleted the cell entirely, true otherwise.
Definition at line 1446 of file cell.cc.
template<class n_option >
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] | rsq | the distance along this vector of the plane. |
- Returns:
- False if the plane does not intersect the plane, true if it does.
Definition at line 2217 of file cell.cc.
template<class n_option >
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] | rsq | the distance along this vector of the plane. |
- Returns:
- False if the plane does not intersect the plane, true if it does.
Definition at line 2231 of file cell.cc.
template<class n_option >
Prints the vertices, their edges, the relation table, and also notifies if any memory errors are visible.
Definition at line 1902 of file cell.cc.
template<class n_option >
Calculates the total surface area of the Voronoi cell.
- Returns:
- The computed area.
Definition at line 1562 of file cell.cc.
template<class n_option >
Calculates the total edge distance of the Voronoi cell.
- Returns:
- A floating point number holding the calculated distance.
Definition at line 1659 of file cell.cc.
template<class n_option >
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.
Definition at line 1486 of file cell.cc.
Field Documentation
This sets the size of the auxiliary delete stack.
Definition at line 119 of file cell.hh.
This sets the size of the main delete stack.
Definition at line 117 of file cell.hh.
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.
Definition at line 115 of file cell.hh.
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.
Definition at line 109 of file cell.hh.
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. These are used when rearranging the memory.
Definition at line 148 of file cell.hh.
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.
Definition at line 152 of file cell.hh.
This sets the total number of vertices in the current cell.
Definition at line 122 of file cell.hh.
This in an array with size 3*current_vertices for holding the positions of the vertices.
Definition at line 155 of file cell.hh.
This is a class used in the plane routine for carrying out reliable comparisons of whether points in the cell are inside, outside, or on the current cutting plane.
Definition at line 159 of file cell.hh.
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.
Definition at line 130 of file cell.hh.
The documentation for this class was generated from the following files: