voronoi3d class
This is a class that describes the 3d voronoi polyhedron, several member variables and functions are attached. The first variable is Nodes, it is the coordinates of nodes neccessary to construct the whole voronoi cells. Then Faces provides the connectivity list of nodes for each face. Voronois gives the list of faces that belong to each voronoi cell. FaceNormals are the unit normal vector of each face. Volumes and Centroids are the volume and centroid of each cell respectively.
voronoi3d
This function can generate an empty voronoi3d object if no input is provided, e.g.
voronoi3d_obj = voronoi3d();
If you want construct a non-empty polyhedron or voronoi object, Input like Nodes, Faces and Voronois are necessary, e.g.
Nodes = [0,0,0; 2,0,0; 1,1.5,0; 1,1,1.5; 1,0,1];
Faces = {[1,2,3];[2,3,4];[3,1,4];[1,2,4];[1,2,5];[2,4,5];[4,1,5]};
Voronois = {[1,2,3,4];[4,5,6,7]};
voronoi3d_obj = voronoi3d(Nodes, Faces, Voronois);
createVoronoi3dFromMesh
The function uses tetrahedron(C3D4 or C3D10) mesh to generate voronoi cells. C3D4 or C3D8 mesh must not be abnormal, viz. quite tetrahedral. To use this function, empty voronoi3d object must be generate first. Example like
Nodes = [0,0,0; 2,0,0; 1,1.5,0; 1,1,1.5; 1,0,1];
Elements = [1,2,3,4; 1,2,4,5];
obj = voronoi3d;
obj = createVoronoi3dFromMesh(obj, Nodes, Elements);
voronoiPatch(obj,'bycell');
Then we have the figure of this example
createVoronoi3dFromMesh
This function is to some extent, the same as createVoronoi3dFromMesh, but the geometry can be regenerated meshes, Example like
myGeo3d = multicylinder(1,3);
obj = voronoi3d;
edgeSize = 0.5;
obj = createVoronoi3dFromGeometry(obj, myGeo3d, edgeSize);
voronoiPatch(obj,'bycell');
The final picture
voronoiPatch
This function is for the visualization of voronoi class. There are two options of visualization type. One is 'bycell', the other is 'nodal'. Using 'bycell', colors of cells are generated randomly, whilst the utilization of 'nodal' should provide the corresponding nodal field variables of all the nodes. Examlpe can be seen as follows
Nodes = [
0,0,0;
2,0,0;
1,1.5,0;
1,1,1.5;
1,0,1;
];
Faces = {
[1,2,3];[2,3,4];[3,1,4];[1,2,4];
[1,2,5];[2,4,5];[4,1,5];
};
Voronois = {[1,2,3,4];[4,5,6,7]};
v3dCell = voronoi3d(Nodes, Faces, Voronois);
voronoiPatch(v3dCell,'bycell');
v3dCell.voronoiPatch('nodal',Nodes(:,3));
bycell
nodalOther functions like icosohedron.m, surfaceReduction.m, specialVoronoi3d.m, simplifyVoronoi3d.m, renumber.m, buckyballs.m are functions that are necessary for the examples or voronoi3d class.
Here many thanks to linear2quad.m and Polyhedron_VAC.m