3.2 Data Structures
3.2.1 Generation of Basic Primitives
3.2.1.1 Voxelized Structures (Voxelmaps)
The first step for creating the voxelmap consists in placing the triangle mesh T in the voxelmap V, which represents a 3D regular grid yet to be filled (Figure 3.2(a)). All voxels store a voxel value v ∈ N (initialized with v = −1), and they are contained in the set
V = {v1, . . . , vi, . . . , vNV} = {vi} NV
being NV the total amount of voxels or voxel values v. This number can be factorized in
the number of voxels or cells per axis:
NV = NxNyNz. (3.2)
The bounding box of the voxelmap bV is determined by the bounding box of the
mesh bT = (bx, by, bz)T and the voxel edge length or voxel size s is chosen by the user;
usually, the value of s is such that the largest bounding box axis i of the triangle mesh T is divided in a maximum number of Ni ≤ 300 cells, given the memory limits of current
computers: max{Nx, Ny, Nz} = ¢ max{bx, by, bz} s • ≤ 300. (3.3)
After this parametrization and the creation of all sets and values with the correct sizes, all triangles of the mesh are visited and the voxels which intersect with them are marked with the surface voxel value v = 0 (Figure 3.2(b)). This process requires (i) selecting candidate voxels within the bounding box of each triangle that might collide with the triangle and (ii) performing collision checks between voxels (cubes) and trian- gles. Selection is performed by observing the projection of the triangle on each of the orthogonal planes of the coordinate axes. If the voxel is clearly above or below the pro- jections, its collision is automatically discarded for the sake of performance. Otherwise, an accurate intersection check must be carried out.
Those collision checks between candidate voxels and the triangles are computed using the Separating Axis Theorem (SAT), already introduced in Section 2.3.2.2. To recall, the SAT states that two convex objects collide with each other if and only if there is an axis on which their projections overlap. If no such axis exists, both objects are disjoint. In 3D space, the axes to be checked for collision are the normal vectors of the faces and the cross products between each pair of edges. As displayed in Figure 3.2 (b), for each triangle composed of vertices {T1, T2, T3}, its edge and normal vectors can be defined as:
v1 = T2− T1, v2 = T3− T2, v3= T1− T3, nT =
v1× v2
kv1× v2k. (3.4) On the other hand, the voxel is determined with its center C (considered to be the origin during each check) and its voxel size s. Altogether, there are 13 axes to be checked for overlap [AM01], which can be classified into three groups:
1. The three coordinate axes {s1, s2, s3}, representing the normal vectors to the faces
of the voxel. The three vertices of the triangle are projected on each axis to check whether the projection of the triangle overlaps with the projection of the voxel, which is a region of width s centered in the origin.
2. The normal vector of the triangle nT. The vertices of the voxel that define the
vector which is aligned with nT are checked for their relative position against the
plane of the triangle.
3. The nine pij axes that result from performing the cross product between the edges
of the voxel and the triangle: pij = si× vj, ∀i, j ∈ {1, 2, 3}. A detailed explanation
of the procedure is given in [Sag08].
A triangle-voxel pair is not colliding if and only if all the tests in the 13 axes yield no overlap. As soon as an overlap between a projected triangle-voxel pair on one of the 13 axes is detected, the voxel is marked as surface-voxel.
After having traversed all the objects detecting each surface-voxel, the inner and outer parts of the model are recognized on the voxmap using the Scanline [KS87] algorithm extended to 3D [Ott05]. The algorithm works with a Last In First Out (LIFO) stack that speeds up the filling process and starts at a corner-voxel of the virtual model. Afterwards, layers are added to the voxelized surface: the first outer layer is formed by voxels with value v = −1, whereas the first inner layer is created with voxels of value v = 1. The absolute voxel value increases linearly according to the number of layers away from the surface, as shown in Figure 3.2(c) and (d). The voxel connectivity can be chosen to be 6-connected (default), 18-connected, or 26-connected. Note, additionally, that the number of inner and outer layers can be selected; in that case, the initial computation of the voxelmap bounding volume bV must be accordingly modified at the beginning of
the computation.
An important feature of the voxelmaps consists in the fast access they provide to specific space regions, and therefore, also concrete geometry parts. This property is essential for creating pointshell structures or enhanced signed distance fileds, and even for online collision and proximity queries. Targeted voxelmap regions can be scanned by accessing the neighborhood NV given seed or voxel of interest. In practice, this
neighborhood consists in a cube of width of 2n + 1 voxels, with n being the number of layers outwards from that first seed voxel. This results in a family of n neighborhoods, NV,n, therefore, composed of (2n + 1)3− 1voxels each. Usually NV,1 and NV,2are used,
depending on the desired accuracy. For instance, if P is a point in space which lies in a voxel with center C and discrete voxelmap coordinates X, Y, Z, the neighborhood NV,n=1(P ) = NV,n=1(C)is the set of voxels with the following discrete coordinates:
NV,n=1(P ) : { (X − 1, Y − 1, Z − 1), (X − 1, Y − 1, Z), (X − 1, Y − 1, Z + 1), (X − 1, Y, Z − 1), (X − 1, Y, Z), (X − 1, Y, Z + 1), (X − 1, Y + 1, Z − 1), (X − 1, Y + 1, Z), (X − 1, Y + 1, Z + 1), (X, Y − 1, Z − 1), (X, Y − 1, Z), (X, Y − 1, Z + 1), (X, Y, Z − 1), (X, Y, Z + 1), (X, Y + 1, Z − 1), (X, Y + 1, Z), (X, Y + 1, Z + 1), (X + 1, Y − 1, Z − 1), (X + 1, Y − 1, Z), (X + 1, Y − 1, Z + 1), (X + 1, Y, Z − 1), (X + 1, Y, Z), (X + 1, Y, Z + 1), (X + 1, Y + 1, Z − 1), (X + 1, Y + 1, Z), (X + 1, Y + 1, Z + 1) }. (3.5)
The generation complexity of the primitive voxelmap is worst case O(n + m), with n being the number voxels and m the number of triangles. The factor m is negligible in regular situations, but it must be considered in case the object has large amounts of triangles and the chosen resolution is very low (e. g., a unique voxel containing thou- sands of triangles). Using a resolution of about s = 5 mm, usual generation times range from few seconds for desktop-sized objects to few minutes for car-sized objects. The data structures can be saved into files for later use; file size ranges from few kilobytes for desktop-sized objects and few hundreds of megabytes for car-sized objects. Exem- plary computation time, file size and snapshots with varied resolutions are provided
in [SHPH08] and in Figure 3.16.