Consistent Mesh Partitioning using Tetrahedral Meshes - Studierstube

0 downloads 0 Views 3MB Size Report
by a closed surface or by an object homeomorphic to an open disc. • A single tetrahedron of the ...... (a) Model: sphere (resolution: 21k tetras). (b) Model: cube ...

Consistent Mesh Partitioning using Tetrahedral Meshes Philipp F¨ urnstahl Institute for Computer Graphics and Vision Graz University of Technology Inffeldgasse 16 A-8010 Graz, Austria

Master’s Thesis Advisor: Dipl.-Ing. Bernhard Reitinger Supervisor: Univ.-Prof. Dipl.-Ing. Dr.techn. Dieter Schmalstieg 2005

Contents 1 Introduction 1.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 Contribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Related Work 2.1 Partitioning, Subdivision, and Cutting 2.2 Intersection . . . . . . . . . . . . . . . 2.3 Collision Detection . . . . . . . . . . . 2.4 Mesh Optimization . . . . . . . . . . . 2.5 Floating Point Calculations . . . . . . 3 Mesh Representation 3.1 Formal Mesh Model . 3.2 Entities . . . . . . . 3.3 Boundary Extraction 3.4 Rendering . . . . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

2 2 4 5

. . . . .

6 6 8 9 10 12

. . . .

13 13 15 17 19

4 Plane Partitioning 4.1 Intersection . . . . . . . . . . . . . . . . . 4.2 Consistent Intersection Point Propagation 4.3 Subdivision . . . . . . . . . . . . . . . . . 4.4 Node Snapping . . . . . . . . . . . . . . . 4.5 Algorithm Outline . . . . . . . . . . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

20 20 23 24 29 32

5 Shape Partitioning 5.1 Method of Separating Axes . . . . . . . . 5.2 Collision Detection . . . . . . . . . . . . . 5.3 Intersection . . . . . . . . . . . . . . . . . 5.4 Consistent Intersection Point Propagation 5.5 Subdivision . . . . . . . . . . . . . . . . . 5.5.1 Edge Iterator . . . . . . . . . . . . 5.5.2 Iterative Subdivision . . . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

34 35 37 40 45 48 48 51

i

CONTENTS 5.6 5.7

CONTENTS

Region Detection - Inside/Outside Determination . . . . . . . . . . . . . . Algorithm Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

6 Mesh Improvement 6.1 Floating Point Consistency . . . . . . . . 6.1.1 Exact Floating Point Arithmetic 6.1.2 Adaptive Precision Floating Point 6.1.3 Implementation . . . . . . . . . . 6.2 Mesh Optimization . . . . . . . . . . . . 6.2.1 Mesh Smoothing . . . . . . . . . 6.2.2 Mesh Simplification . . . . . . . .

57 59

. . . . . . .

61 61 62 67 68 69 69 73

7 Results 7.1 Data Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

83 83 86

8 Conclusion and Future Work

98

. . . . . . . . . . . . . . Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

9 Appendix

101

Bibliography

103

ii

List of Tables 4.1 4.2 4.3 4.4

Subdivisions of a tetrahedron intersected by a plane. . . . . . . . Partitioning of tetrahedron vertices for each particular subdivision Subdivision of a pyramid into tetrahedra. . . . . . . . . . . . . . . Subdivision of a prism into tetrahedra. . . . . . . . . . . . . . . .

. . . .

26 27 27 29

5.1

Possible intersections of a tetrahedron and a partitioning shape. . . . . . .

57

7.1 7.2 7.3 7.4 7.5

Performance Performance Performance Performance Performance

94 95 95 96 97

and and and and and

quality quality quality quality quality

measurements measurements measurements measurements measurements

iii

of of of of of

the the the the the

algorithms algorithms algorithms algorithms algorithms

. . . case. . . . . . .

. . . .

(cube model). . (sphere model). (head model). . (troll model). . (liver model). .

. . . . .

List of Figures 1.1

Outline of the partitioning technique. . . . . . . . . . . . . . . . . . . . . .

3

3.1 3.2 3.3

14 16

3.4

Examples of incorrectly and properly connected simplices. . . . . . . . . . Example of a binary tree storing a sequence of partitioning operations. . . Example of a mesh whereon a sequence of partitioning operations is applied to. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Example of a mesh showing a sequence of partitioning operations. . . . . .

4.1 4.2 4.3 4.4

Intersections of a tetrahedron and a plane. . . . . Intersection of a line segment and a plane. . . . . Orthogonal projection of a point onto a plane. . . Robust floating point calculations can be achieved

. . . . . . . . . . . . . . . . . . snapping.

21 23 30 32

5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9

An example of the method of separating axes. . . . . . . . . . . . . . . . . Example of an octree. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Example of a quadtree subdivision. . . . . . . . . . . . . . . . . . . . . . . Outline of the “point in triangle” test. . . . . . . . . . . . . . . . . . . . . Example of a hash table organized in buckets. . . . . . . . . . . . . . . . . Possible cases, if splitting a tetrahedron face with a partitioning shape face. Simplified iterative tetrahedra subdivision. . . . . . . . . . . . . . . . . . . Assignment of subdivided triangles to entities. . . . . . . . . . . . . . . . . Outline of the region detection algorithm. . . . . . . . . . . . . . . . . . .

36 38 39 41 47 49 51 53 59

6.1 6.2 6.3

Work flows of the fast-expansion sum and scale-expansion algorithm. . . . Classification of degenerated tetrahedra with given edge collapsing strategy. Examples of a valid and an invalid edge collapse concerning topological correctness. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

66 75

Models used for performance and quality tests. . . . . . . . . . . . . . . . . Runtime analyses of the plane and shape partitioning algorithms. . . . . . Comparison of the mesh optimization algorithms. . . . . . . . . . . . . . . Comparison of the plane partitioning algorithm with and without node snapping. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

85 87 88

7.1 7.2 7.3 7.4

iv

. . . . . . . . . . . . . . . by using

. . . . . . . . . node

16 18

76

89

LIST OF FIGURES 7.5

LIST OF FIGURES

7.9

Example of various resection strategies using plane and shape partitioning operations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Example of the hierarchical mesh data structure, showing the benefits for surgical planning. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Limitations of the shape partitioning algorithm. . . . . . . . . . . . . . . . The subdivision algorithm can also be used to partition a liver into its segments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Visualization of the mesh quality. . . . . . . . . . . . . . . . . . . . . . . .

9.1

Local numbering of vertices of tetrahedra, pyramids, and prisms. . . . . . . 102

7.6 7.7 7.8

91 92 92 93 93

v

Abstract This thesis presents partitioning techniques which classify a volumetric mesh into different regions while preserving the mesh connectivity (consistency). A mesh is partitioned by applying a plane partitioning technique which is geometrically exact, and a novel approach for approximate partitioning where triangular surface meshes are used as partitioning shapes. In both methods, the propagation of intersection points to adjacent faces is performed by using a hash table. The subdivision of the plane partitioning technique relies on existing methods while the shape partitioning algorithm requires an extension of these subdivision methods to identify correct partitions and handle multiple intersection points per edge. Therefore, a subdivision technique is introduced which splits tetrahedra in an iterative way. In order to partition the volumetric mesh after splitting, a strategy is introduced which assigns subdivided and initial tetrahedra to the corresponding region in a robust way. A labeled hierarchical mesh model is used which is able to store consecutive partitioning operation, and to perform an efficient boundary extraction for visualization. A known problem of subdivision algorithms is the generation of badly shaped tetrahedra due to subdivision. In order to avoid degenerated primitives, several optimization and node snapping techniques are presented. Finally, the problem of floating point roundoff errors, which can cause inconsistency, is covered in the thesis as well. Index words: partition, consistency, shape partitioning, plane partitioning, tetrahedral mesh, subdivision, mesh optimization, degeneracies, floating point errors

Acknowledgments The first person I would like to thank is my advisor Bernhard Reitinger for his great support and the pleasant collaboration. Thank you for introducing me to this interesting topic. I would also like to thank my supervisor Dieter Schmalstieg for giving me the possibility to write this thesis at the Institute for Computer Graphics and Vision. I would like to thank Thomas Fuchs, Florian Mendel, and Daniel Nebel for perusing my thesis. Special thanks go to my colleagues Ramin Dalkouhi, Thomas Fuchs, Mark Klostermann, and Florian Mendel who completed almost any course and examination with me. Thank you all for being my colleagues and friends. I want to express my gratitude to Roland Perko who introduced me to the Institute for Computer Graphics and Vision. Thanks to all my friends for their help and appreciation. Particularly, Peter Baldi, Sandra Burghard, Robert Hoffmann, and Georg Pessler. I am very grateful for the encouragement from my family and relatives, especially for my parents and my sister. My parents always gave me the necessary support, required to complete this degree. Finally, thanks to all people who cannot see their name in these lines but think it should be there.

1

Chapter 1 Introduction 1.1

Motivation

In computer-aided medical visualization systems such as the virtual liver surgery planning system [8], analysis tools are required for planning surgical interventions such as liver tumor removal. In contrast to surgical simulation environments which focus on the training aspect of surgical procedures, our aim is to produce quantitative information for analysis and planning. For this reason, physically-based models, deformation, or photo-realistic rendering techniques are not useful since physicians are only interested in the quantitative outcome of the planning procedure. In the case of liver surgery, surgeons have to find out which parts of the liver must be resected (removed). This is done by performing a sequence of partitioning operations in order to isolate the diseased part of the tissue in an iterative way. Each region can then be individually analyzed and gives important indices (e.g. volume) to the surgeon. The typical planning procedure for a surgical intervention starts by locating the tumor in the liver data set. Then, the data set is partitioned using a plane in order to uncover the tumor. Subsequently, a suitable shape is used to apply a more specific partitioning operation for removing the residual. Finally, the volumes of the resected parts are measured which gives important quantitative indices for the actual surgical intervention. By using our data structures, several intervention strategies can be explored and stored in the model. Analysis of such variants is often necessary if surgeons want to find a trade off between minimal tissue removal and oncological requirements. In particular, the surgeon may want to revisit and alter operations done earlier. For a procedure explained above, partitioning tools are required for classifying the liver tissue in healthy/diseased or removed/remaining regions, while measuring certain aspects, such as removed volume. These tools are similar to constructive solid geometry (CSG) operations which are often used in the field of computer-aided engineering. A mesh is decomposed by either applying a plane or a shape partitioning operation which divides the mesh into disjoint regions. A partitioning plane is specified analytically, whereas a 2

1.1. Motivation

Introduction

partitioning shape requires an explicit geometrical (i.e. a triangular mesh) representation of the shape. Both partitioning methods are applied globally to the mesh, in contrast to cutting techniques used in surgery simulation which aim at local mesh modification (e.g. simulation of scalpel cutting). In addition, a cutting operation usually deletes part of the mesh geometry. However, for surgical planning procedures, all existing model information must be preserved. Therefore, our proposed partitioning operations add additional partitioning information to the data structure rather than deleting a part of the mesh. The storage of consecutive partitioning operations is archived in a labeled hierarchical data structure based on a binary tree. A partitioning operation introduces a new level in the tree. Figure 1.1 sketches an example where two consecutive partitioning operations are stored in the according binary tree. plane partitioning

shape partitioning (a) The sequence of the partitioning operations stored in a binary tree.

(b) Each partitioning operation decomposes the mesh into regions.

Figure 1.1: Outline of the partitioning technique.

While the binary tree is only responsible for handling different partitioning results, the input mesh is stored as volumetric data. Tetrahedral meshes are often the data structure of choice if volumetric information (e.g. type of tissue) must be processed. Although traditional medical planning systems often use either voxel-based or surface-based models, tetrahedral meshes are more flexible than both data structures, because complex volumetric data sets can be represented with few primitives. Moreover, the properties of simplicial

3

1.2. Contribution

Introduction

complexes used in our tetrahedral mesh implementation guarantee a consistent mesh topology. This thesis aims at discussing the technical aspects of the partitioning methods outlined above. The plane partitioning technique relies on existing methods while the shape partitioning algorithm requires several extensions in order to identify correct splits and handle multiple intersection points per edge. Taking into account that the partitioning methods operate globally on a potentially large mesh model, an acceptable runtime of under one second should be achieved.

1.2

Contribution

Apart from the application-specific contribution, this thesis also provides the following list of contributions:

Plane Partitioning Partitioning using an infinite plane will be a fundamental feature in our surgical planning system. Although intersection point calculation is built upon basic vector algebra, several problems must be solved: • Adjacent tetrahedra sharing an intersection point have to refer to the same vertex index. A hash table is used for fast intersection point propagation which is able to store additional information maintaining consistent mesh topology. • Another challenge concerning plane partitioning is a consistent subdivision being able to split each tetrahedron according to the plane. Subdivision is a technique where objects are split into smaller mesh primitives. Although a lot of work was done concerning subdivision, a detailed and explicit description of subdivision is not given in existing publications. Therefore, the subdivision cases which arise if intersecting a tetrahedron with a plane, including the required subdivision of pyramids and prisms are discussed in detail.

Shape Partitioning Dividing volumetric meshes by using a partitioning shape is a complex task. Techniques like collision detection and consistent intersection point calculations must be combined. The collision detection has to be fast enough for interactivity (i.e. less than 10 ms to detect 1000 collisions). In addition, extensibility to handle collisions of deformable objects should be considered for future work.

4

1.3. Overview

Introduction

Beside collision detection and intersection calculations, the actual shape partitioning algorithm is the most challenging part: • Similar to the plane partitioning algorithm, a hash table is used for the propagation of shared intersection points. • The propagation algorithm of the shape partitioning technique relies on geometric tests which use floating point arithmetic. Exact results can be achieved by using an exact floating point arithmetic. • Existing subdivision methods are extended by a new data structure which is able to handle multiple intersection points per edge and to separate the mesh into two partitions. Thus, the so-called iterative subdivision is introduced. • Additionally, a region detection algorithm is described which efficiently assigns the partitioning result to the corresponding entity.

1.3

Overview

In Chapter 2 an overview of existing partitioning, cutting, and subdivision methods is given. In addition, required techniques like collision detection or mesh simplification algorithms are compared. The mesh model, used to guarantee consistency, is presented in Chapter 3. The partitioning algorithms are described in detail in Chapter 4 and Chapter 5. The problem of floating point roundoff errors, which can negatively affect consistent partitioning, is discussed in Chapter 6. In addition, two mesh optimization techniques to improve the quality of partitioning results are presented in Chapter 6. Finally, the results including runtime analyses of the algorithms and the quality of partitioning results are stated in Chapter 7.

5

Chapter 2 Related Work 2.1

Partitioning, Subdivision, and Cutting

Since each partitioning operation divides the tetrahedra of the volumetric mesh into disjoint parts, the presented partitioning algorithms are related to existing cutting techniques. In addition, most cutting algorithms use subdivision techniques in order to split tetrahedra. Interactive volume-based partitioning and cutting is an active research field. A survey and classification of different cutting techniques can be found in [10], where a simple framework for building a generalized cutting scheme is described as well. Partitioning and cutting techniques can be divided into methods which remove intersected primitives and methods which perform remeshing of intersected primitives. The latter technique results in more accurate cuts and gives more precise results for coarser meshes. Although the volumetric mesh size increases and more complex algorithms have to be applied, it is the method of choice for surgical applications. Further, cutting can be classified based on the cutting tool. Recently, a lot of research was done in cutting with a moving tool (e.g. a scalpel) [5, 64, 50], frequently in conjunction with haptic feedback devices and soft tissue simulations [51, 49]. Bielser et al. [7] were one of the first presenting a generalized subdivision schema which is able to handle partially cut tetrahedra. The actual subdivision is reduced to five basic topological cases. Two cases represent complete splits while the other three are applied to partially cut tetrahedra. A tetrahedron is divided into a fixed number of 17 smaller simplices by adding one vertex to each face and one vertex to the middle of each edge (so-called 17:1 splitting schema). The generalized subdivision schema introduced in [7] was improved by Bielser and Gross [6]. Cut-specific subdivision patterns were introduced by subdividing only faces and edges which are part of the cut surface. The algorithm subdivides tetrahedra consistently while correct neighborhood is guaranteed. In addition, surface and volume collision detection, relaxation using a mass-spring system, and a haptic scalpel model are described. 6

2.1. Partitioning, Subdivision, and Cutting

Related Work

Bielser et al. [4, 5] extended the approach described in [6], using a progressive subdivision method (but no progressive cutting is performed). The subdivision is built incrementally from an undivided tetrahedron up to a complex subdivision. A state machine handles arbitrary progressive subdivisions and updates in an efficient way. Algorithms which handle cases where the direction of the cut tool is changing or trembling are also presented. Nienhuys [51] introduced novel cutting algorithms for deformable objects where deformations are based on physical forces using the finite element method (FEM). The FEM is a popular method for computing solutions to partial differential equations defined on irregularly shaped objects. Objects are subdivided into elements (e.g. triangles or tetrahedra) which are deformed in elementary ways. Physical laws, defined by the material, specify how neighboring elements interact. Applying the FEM to a mesh, leads to a complex system of equations which can be solved with numerical methods. Nienhuys presented three cutting methods: the first method which is also described in [52], simulates cuts without increasing mesh size (in contrast to a subdivision approach). However, this technique can produce degenerated tetrahedra. Therefore, algorithms like node snapping and mesh simplification (using a heuristic edge collapsing algorithm) are provided to avoid badly shaped tetrahedra. The second approach covers interactive cutting in triangulated surfaces based on Delaunay triangulation (see also [53]). The algorithm produces measurably smaller and better results than previous methods but cannot be used for tetrahedral meshes. The third algorithm presented, is a needle insertion technique for deformable objects. Additionally, the underlying mesh representation used in all algorithms is discussed in detail. Mor [49] also addressed the problem of cutting tissue within a physically-based surgical simulator. The actual cutting is performed by subdividing tetrahedra which are intersected by the cutting tool. Based on the five basic intersection cases introduced by Biesler et al. [7], a minimal set of new elements is generated (only four to nine elements for each cut element). The subdivisions were examined by hand to find the minimal set of new elements. A lookup table is used to determine how to rotate or flip the vertices to fit the default orientation. In order to allow for progressive cutting, the described subdivision schema was extended to a temporary subdivision technique for the currently cut element. In contrast to usual node snapping approaches for avoiding degeneracies, Mor introduced an algorithm where snapping is only done if the current subdivision is instable (i.e. degenerated tetrahedra are detected according to a certain metric). Subsequently, a list of all possible permutations of snapped vertices is created. These permutations consist of all possible combinations of moving one or more intersection points to their closest feature. Test subdivisions are performed until a stable subdivision is found. Ganovelli et al. [27, 26] presented a technique in order to enable cuts using a cut shape on multi-resolution representations where the multi-resolution data representation is updated on-the-fly. The actual subdivision case is determined by generating a code based on the edges being intersected. The corresponding tetrahedralization is stored in a lookup table. 7

2.2. Intersection

Related Work

Simplicial complex properties are always preserved due to the introduction of a consistent subdivision. In contrast to the shape partitioning algorithm introduced in this thesis, the technique of Ganovelli et al. supports partially split tetrahedra, thus being more exact, but has the drawback of a limitation to convex and planar shapes. A different cutting approach using a deformable plane which is generated by userdefined lines was introduced in [42]. Instead of subdividing tetrahedra, mesh nodes are displaced to fit the original set of points. Forest et al. [25] presented an algorithm to partially or completely remove tetrahedra using an ultrasound cautery. In addition, mesh representation, and updates which keep the mesh consistent after tetrahedra removal are discussed. Concerning subdivision, Ferrant et al. [46] provides ten subdivision cases based on intersection points per edge where one to all six tetrahedral edges are split (ignoring symmetrical identities). Multiple intersection points per edge or partially cut tetrahedra are not considered. The resulting subdivision contains tetrahedra, pyramids and prisms which must be subdivided further. Splitting prisms according to their diagonals, is outlined in [46]. Quadrilateral faces are split by the shortest diagonal. The splitting rule is mentioned as being consistent which is only guaranteed if exact arithmetic is used. In addition, the case where the two diagonals are of equal length cannot be handled. Tetrahedral subdivision and subsequent splitting of pyramids and prisms were presented in [20]. Quadrilateral faces are split by the diagonal which contains the smallest vertex index. Therefore, this subdivision schema is consistent and independent of floating point calculations. Our subdivision is based on this consistency criterion due to the simplicity and efficiency of this algorithm. Up to our knowledge, partitioning or cutting with arbitrary shapes represented by triangular meshes was not yet addressed. Although intersection point calculation and existing subdivision strategies can be used for this purpose, additional algorithms and data structures are required for preserving a consistent mesh. Additionally, none of these papers provides algorithms for identifying different regions after applying a sequence of partitioning or cutting operations. This is an important issue for visualizing partitioning results in real-time.

2.2

Intersection

Intersection calculations are fundamental for the partitioning algorithms but basically consist of mathematical methods. Therefore, most techniques are well known and a fast implementation is the only difficult part. Additionally, most calculations rely on floating point arithmetic where roundoff errors may occur which have to be avoided or minimized.

8

2.3. Collision Detection

Related Work

Determination whether a point lies inside a convex polyhedron is straight-forward and achieved by testing if the point lies on the negative side of each face plane (see [23, p. 708 ]). Rewriting the point in barycentric coordinates relative to the convex polyhedron is another fast technique [23, p. 708 ]. In addition, line segment and plane intersections are implementations of ordinary mathematical equations, for a detailed description see Eberly [23, p. 481 et sqq. ]. The efficient and consistent intersection point calculation of triangular faces is a nontrivial task. Several publications present efficient approaches: most of them use techniques where projected intervals are tested for overlapping. State of the art, due to their efficiency, are the algorithms by M¨oller [48] and Held [37]. M¨oller starts by comparing the intersection of each triangle with the supporting plane of the other. If all vertices of one triangle lie on the same side of the plane, then the intersection is rejected. Otherwise, the triangles intersect the line of intersection of the two planes. These intersections form intervals on the line of intersection, and the triangles overlap iff these intervals overlap as well. The last part of the algorithm determines the intervals where the line of intersection lies inside the triangle. A derived method is introduced by Guige et al. [35] where the complete algorithm only relies on the sign of 4 × 4 determinants. Therefore, an orientation test, where predicates guarantee exact arithmetic, can be applied (described in Section 6.1).

2.3

Collision Detection

Effective collision detection is an essential tool in order to overcome the problem of testing each tetrahedron against each partitioning shape face (resulting in O(n2 ) asymptotic runtime). Although our objects are rigid and stationary, collision detection algorithms of moving or deformable objects are discussed which can be important for future work. Collision detection is a well researched topic and thus only a few techniques are mentioned. A general description of 3D collision detection can be found in [40]. Teschner et al. [62] provide a detailed survey for collision detection of deformable objects. Eberly [22, p. 487 et sqq. ] discusses basic collision detection and intersection calculations for stationary and moving objects. At the lowest level these techniques are divided in intersection-based methods and distance-based methods. The intersection-based method chooses, equates, and solves representations of two objects (e.g. equating the algebraic representation of a plane with the parametric representation of a line segment) whereas a distance-based method uses parametric representation of all objects, trying to minimize the distance function for all parameters.

9

2.4. Mesh Optimization

Related Work

Bounding-volume hierarchies have proven to be the most efficient data structures for collision detection [62]. Generally, a discussion of bounding-volume hierarchies is found in [67]. Several bounding volumes like spheres [39], axis-aligned bounding boxes (AABB ) [63, 43], oriented bounding boxes (OBB ) [32], discrete oriented polytopes (DOP ) [65], and boxtrees [66] were explored. OBB and k-DOPs are the most adequate approaches for our requirements. OBB trees give good approximation of the object’s boundary and k-DOPs approximate the convex hull arbitrarily by increasing k. AABB trees and octrees are special cases of k-DOPs. An octree is generated efficiently and the collision detection is fast enough for our requirements (i.e. less than 10 ms to detect 1000 collisions). Octrees can easily be extended to bucket trees, an octree enhancement for deformable objects proposed by Ganovelli et al. [28], if collision detection for deformable objects is required. Usually, a bounding-volume tree is built in a top-down fashion. Subsequently, a collision test between two objects is accomplished by traversing the bounding-volume trees top-down and testing pairs of nodes. If the overlapping nodes are leaves, an exact overlap test is performed. If only one node is a leaf, it is tested against each child of the internal node. Otherwise, if both nodes are internal nodes, the node with the smaller volume is tested against the children of the other node [63]. Spatial subdivision is a simple but efficient technique to accelerate collision detection. Algorithms based on spatial subdivision are independent of topology changes of objects. The difficulty using spatial techniques lies in the choice of the appropriate data structure. Zhang et al. [68] proposed a method based on uniform grids and Melax [47] used a binary space partitioning (BSP ) approach. In [61], a hash-table is used for efficient collision detection of deformable tetrahedral meshes. Image-space techniques do not require any preprocessing and are commonly implemented using graphics hardware. Lombardo et al. [44] introduced an image-space collision detection approach in a medical system. Heidelberger et al. [36] computes a layered deep image of an object to approximate its volume. The approach can be applied to arbitrarily shaped deformable objects and also detects self intersections. Several methods mentioned in [62] are not applicable for interactive partitioning. In order to ensure consistency, all potentially overlapping objects must be determined. Stochastic algorithms are not exact (the error depends on the method) and only useful in real-time applications where exact collision detection is not required. Distance fields specify the minimum distance to closed surfaces for all points in the field. However, the generation of distance fields is not fast enough for interactive applications.

2.4

Mesh Optimization

Splitting tetrahedra close to original vertices can produce degeneracies. In order to improve the quality of the mesh, optimization algorithms are applied which remove badly shaped elements by modification of the mesh geometry or topology. 10

2.4. Mesh Optimization

Related Work

An introduction of mesh optimization techniques can be found in [3]. Optimization techniques can be divided into mesh smoothing algorithms which adjust the vertex positions while the mesh connectivity is preserved whereas mesh simplification and refinement algorithms change the connectivity of the primitives to improve mesh quality. According to a survey by Owen [54], smoothing methods can generally be classified as follows: • Averaging methods move the current vertex to the average position of adjacent vertices. The most common technique is Laplacian smoothing which is efficient but heuristic. An overview over a variety of the most common averaging methods is provided in [11]. • Optimization-based methods are more expensive than averaging methods but better results are achieved. Vertices are repositioned based on a gradient of element quality to minimize a given distortion metric. Several optimization-based methods rely on optimal Delaunay triangulation or Voronoi tessellation (see [12, 21]). A combination of averaging and the more expensive optimization algorithms is recommended. As demonstrated in [11], the optimization-based smoother is only used if the mesh quality drops below a certain threshold. • Physical-based methods move vertices based on physically attraction or repulsion forces (see [69, 58]). Most effective algorithms for improving the mesh quality are based on either refinement strategies or decimation strategies. Decimation strategies (simplification) remove primitives or edges from the mesh whereas refinement strategies add points to improve the mesh quality. Detailed descriptions of existing simplification and refinement methods can be found in several publications [30, 17, 45, 15]. A technique based on Delaunay refinement was proposed by Cignogni et al. [16]. Grosso et al. [34, 33] introduced a different approach: starting from a coarse triangulation covering the domain, a hierarchical representation of volume approximations is created by a sequence of adaptive mesh refinement steps. Clustering techniques can also be categorized as refinement strategies [18, 9]. All algorithms based on a refinement strategy share a common problem: the domain of the data set has to be convex or it has to be defined as a warping of a regular grid [16]. Decimation algorithms are usually based on edge collapsing techniques which are described in detail by Cignogni et al. [15, 14]: a general framework for mesh simplification is provided and various techniques to evaluate simplification errors are discussed. 11

2.5. Floating Point Calculations

Related Work

Staadt and Gross [60] introduced various cost functions to control the edge collapsing process. Additionally, a technique to avoid self intersections of the mesh boundary was presented. Cignogni et al. [16] use an error metric to control the domain error. Based on [16], the strategy was enhanced in [14], providing efficient error estimators for the domain and the field error. Ganovelli and O’Sullivan [29] presented a method which is also based on an edge collapsing strategy to improve the primitive quality on-the-fly during scalpel cutting. An approach mainly focusing on efficiency, was presented by Chopra and Meyer [13]. The algorithm is based on iteratively collapsing tetrahedra whereas the mesh boundary is not simplified.

2.5

Floating Point Calculations

Geometrical tests and computations may require exact results. For instance, orientation tests determine the position of a point relative to a plane or line segment based on the sign of a determinant. Several former algorithms providing techniques for exact arithmetic were based on integers or fixed point numbers (using integer hardware units). Modern processors and graphics cards are highly optimized for floating point arithmetic where the performance is faster compared to fixed point arithmetic [57]. Floating point computations use the IEEE floating point standard which provides 16 decimal bits accuracy. Due to the finite representation of the standard, roundoff errors can occur. A complete survey of the floating point theory, including detailed description of the IEEE standard and the problem of roundoff errors, can be found in [31]. Additionally, an overview of up-to-date high precision floating point arithmetic libraries and techniques in scientific computation is given by Bailey et al. [2]. Methods which achieve exact floating point calculations are classified in multiple-digit and multiple-term algorithms. In multiple-digit formats, numbers are stored as a sequence of digits and a single exponent. In the multiple-term format, a number is expressed as a sum of ordinary floating point numbers. Usually, multiple-term algorithms are more efficient. Priest [55] was one of the first introducing efficient techniques for arbitrary precision floating point arithmetic. The algorithms are based on ordinary floating point operations and are designed to run on a wide range of architectures. Shewchuk [56, 57] enhanced the methods of Priest, providing a simplified and more efficient algorithm for exact and adaptive floating point calculations. Additionally, geometric predicates were introduced in order to demonstrate that the technique is well suited for geometric algorithms. Although robust floating point computations are well researched, different techniques may be used dependent on the area of application. 12

Chapter 3 Mesh Representation Efficient data structures for representing 2-dimensional triangular meshes and 3-dimensional tetrahedral meshes are required by the partitioning algorithms. Therefore, a generic data structure is used, able to represent n-dimensional meshes where modifications can be performed efficiently. Storage and visualization of different partitions is a non-trivial task. A hierarchical labeling schema is presented where a single mesh can store consecutive partitioning operations. A boundary extraction algorithm is described which is able to visualize the hierarchical mesh data structure. Basic bit vector arithmetic allows for fast rendering of different partitions. The hierarchical approach has several features like the ability to group partitions, toggling between boundaries interactively, or combining different surfaces.

3.1

Formal Mesh Model

The mesh model relies on so-called simplices and further on the definition of simplicial complexes. Simplices are also used to describe triangulations in the field of algebraic topology. The topology of a mesh is given by a set of n-simplices where n is called the dimension of the simplex. A simplex Sn is defined by the convex hull of affinely independent vertices p1 , . . . , pn+1 ∈ R3 : conv{p1 , . . . , pn+1 }, where n is the dimension of Sn . Less formally, a simplex is the generalization of a tetrahedral region of space to n dimensions and represents the simplest possible polytope in any given space. A one-dimensional simplex is called edge, a 2-simplex is a triangle, and a 3-simplex is a tetrahedron.

13

3.1. Formal Mesh Model

Mesh Representation

The boundary of an n-simplex Sn has n + 1 faces. A face fj , j ∈ {1, . . . , n + 1} of a simplex Sn = conv{p1 , . . . , pn+1 } is defined as fj = conv{p1 , . . . , pj−1 , pj+1 , . . . pn+1 }. An explicit definition of the mesh connectivity gives the possibility to specify the correctness of the data structure: Definition of two properly connected simplices: Two n-dimensional simplices Pn and Qn with corresponding vertices p1 . . . pn+1 ∈ R3 and q1 . . . qn+1 ∈ R3 are properly connected iff conv{p1 , . . . , pn+1 } ∩ conv{q1 , . . . , qn+1 } = conv C, where conv C is a face of Pn and Qn . Examples of incorrectly and properly joined simplices are shown in Figure 3.1. Properly connected simplices are characterized by their set of vertices. It is sufficient to consider these discrete sets of vertices and disregard the continuity of convex sets (the type and value of the vertices itself are not relevant). Therefore, it will be assumed that points are stored in a vertex buffer V and the type of the vertices is unspecified.

(a) Two properly connected simplices.

(b) Incorrectly connected simplices.

Figure 3.1: Examples of incorrectly and properly connected simplices.

An n-simplex has an orientation based on the permutation of its vertices [51]. For instance, a 2-simplex is oriented based on the normal of the supporting plane. The orientation relies on the order of the vertices (e.g. if two vertices of a 2-simplex are swapped, the normal vector is flipped and the orientation changes). Formally, the orientation of an n-simplex is defined as: Orientation of a simplex: Let p1 , . . . , pn+1 be a sequence of n + 1 vertices of a simplex Sn . A permutation π(p1 , . . . , pn+1 ) of the vertices may be decomposed into a number of swaps. If the number of swaps is even, then π is an even permutation, otherwise it is an odd permutation and thus Sn is called positive or negative oriented, respectively. 14

3.2. Entities

Mesh Representation

Based on a set of simplices which are properly connected, a simplicial complex (cf. [24]) is introduced which defines the overall topology of a mesh: Definition of a simplicial complex: A simplicial complex K of Rn is a collection of simplices in Rn such that • Every face of a simplex of K is in K. • The intersection of any two simplices of K is a face of each of them. • Each simplex K has the same, valid orientation. Thus, a mesh is defined by a simplicial complex forming the mesh topology and a set of vertices representing the geometry of the mesh. More precisely, an n-dimensional mesh is a tuple Mn = (K, V) where K is a simplicial complex of Rn and V is a vertex buffer which stores the vertices of Mn . In order to provide connections between V and K, two additional mapping functions are used: VSC : V → Ksub ⊂ K, where each vertex p ∈ V is mapped to a subset Ksub of K containing all simplices wherein p is part of the convex hull of each simplex. SSC : S → Ksub ⊂ K, where each simplex s is mapped to a subset Ksub of K, containing all adjacent simplices of s.

3.2

Entities

Since each performed partitioning divides the underlying volumetric mesh into two disjoint parts (by definition), a data structure is introduced which allows for efficient storage and visualization of partitions. Assuming that a tetrahedral mesh M3 covers a certain volume Ω1 ⊂ R3 , a partitioning operator γ can be defined which divides a volume Ωi into two disjoint parts (i.e. Ω2i , Ω2i+1 ). If applying a sequence of partitioning operations Γ = γ0 , . . . , γn , this sequence can be represented by a binary tree with depth n. A sub-volume Ωi is denoted by a node in the binary tree (see Figure 3.2). By definition, the first operation γ0 generates the tetrahedral mesh itself which represents the volume Ω1 (the root node of the binary tree). If γ1 is applied to Ω1 , two additional nodes (Ω2 , Ω3 ) are created, splitting the volume into two disjoint parts (shown in Figure 3.2). If further partitioning operations are performed, an additional tree level is created by splitting each leaf node Ωi into two child nodes Ω2i and Ω2i+1 . The path of the binary tree from the root node to a given leaf node is encoded into its index and represents the complete sequence Γ (so-called location code). For efficiency, the index is stored in binary representation in form of a bit vector where each bit corresponds to either a left or right 15

3.2. Entities

Mesh Representation 1

initial tetrahedral mesh

Ω1

2 new subvolumes

10

11

Ω2

Ω3

γ

1

γ 100

4 new subvolumes

Ω4

101

110

Ω5

Ω6

111

2

Ω7

Figure 3.2: Example of a binary tree storing γ, a sequence of partitioning operations. Each leaf node Ωi is divided into two child nodes by partition operations γ1 and γ2 .

link in the tree. Additionally, each tetrahedron of the mesh contains the index of the corresponding leaf node, storing its relation to different partitions. A node in the binary tree with index i at depth bd = ln(i)c, belonging to the partitions γ0 , . . . , γd , is called entity. For efficient rendering, each leaf node contains the indices of its associated tetrahedra. An example of an object which contains different partitions is shown in Figure 3.3: the initial model consists of one entity representing the tetrahedral mesh itself. After the first partitioning operation, two leaf nodes are created, splitting the domain into two pieces. The indices of the newly created entities are 2 and 3 (10 and 11 in binary representation). If applying a second partitioning operation, the algorithm is repeated which results in 7 entities with 4 leaf node entities. Ω1 e=1

Ω2 e=10

Ω4 e=100

Ω3 e=11 (a) Initial mesh

(b) A plane partitioning (denoted by the red line) divides the mesh into two entities.

Ω7 e=111

Ω5 e=101

Ω6 e=110

(c) Additionally, a shape partitioning is applied, creating four entities.

Figure 3.3: Example of a mesh whereon a sequence of partitioning operations is applied to. Each partitioning operation creates further entities.

16

3.3. Boundary Extraction

3.3

Mesh Representation

Boundary Extraction

A mesh M3 , covering the volume Ω1 , is defined by a set of tetrahedra. As mentioned above, a partitioning operation splits M3 into further entities and creates additional leaf nodes. Each tetrahedron of M3 contains the index of the corresponding leaf node in the tree. This index is represented by a bit vector e called entity bit vector. The entity bit vector e corresponds to the according leaf node index and is defined as e = (e0 , . . . , en ), where n denotes the depth of the binary tree. For visualization, boundaries between entities are target for rendering, because they represent the actual information being shown. For each entity Ωk of M3 , an interface ∂Ωk denoting its boundary can be extracted. The interface is described by a surface mesh M2 containing a set of properly connected triangles which are the faces of the tetrahedral mesh M3 . An operator is introduced which is required for the boundary extraction: let len(a) be the length of a given bit vector a and len(b) the length of a bit vector b, where len(a) ≤ len(b). A trim-to-equal operator can be defined as tr(a, b) = b Àlen(b)−len(a) , removing the most-right bits of b. Further, ⊕ is defined as a bit-wise XOR operation of two equally sized bit vectors. The ˆ0 bit vector represents the bit vector which only contains zero bits. Assuming that an entity, specified by its index r, should be extracted: the binary tree is traversed by comparing the trimmed node index tr(r, i) (where i is the binary representation of the current index). If the compared bit masks are equal and r is an intermediate node, all its child leaf nodes are target for extraction. For each tetrahedron, stored in a target leaf, the face diff vectors to the neighboring tetrahedra are calculated in order to extract the correct boundary of intermediate entities: A face diff vector dj is defined as dj = tr(r, ej ) ⊕ r, ∀j : 1 ≤ j ≤ 4, where each ej specifies the entity bit vector of an adjacent tetrahedron. The face diff vector denotes the bit difference to adjacent simplices. If dj 6= ˆ0, the corresponding face must be extracted as triangle which will be part of the interface ∂Ωi . An example is shown in Figure 3.4, including a triangular mesh which contains the result after two different partitioning operations γ0 and γ1 . The currently inspected triangle is colored yellow (see Figure 3.4(a)). Assuming that the entity, specified by r = 111, should be visualized: if applying the previous bit operations, the face diff vectors of adjacent triangles d1 = 001, d2 = 000, and d3 = 101 are calculated. The example shows that two faces are extracted which are part of the specified entity. Since only bit operations are required for extracting interfaces, the algorithm works efficiently and fast. This allows integration into a real-time environment, enabling interactively toggling between several partitions. 17

3.3. Boundary Extraction

Mesh Representation

110

d1=001

110

1

100

Ω1

101 111 d2 =000

111 111

101

γ

d3=010

101

10

11

Ω2

Ω3

1

γ

101 100

Ω4

101

Ω5

110

Ω6

111

2

Ω7

target for rendering (a) Entity 111 should be visualized. Therefore, face diff vectors d1 , d2 , and d3 are used to extract the boundary.

(b) Binary tree representation of the mesh shown in Figure (a).

Figure 3.4: Example of a mesh showing the boundary extraction technique. The triangular mesh is outlined in Figure (a) and the corresponding binary tree is shown in Figure (b). Two partitioning operations γ0 and γ1 are performed, creating seven entities. Entity 111 is target for rendering and d1 , d2 , and d3 denote the face diff vectors.

By using a binary tree as representation of entities in the model, some restrictions must be taken into account. Since links of the tree only split current entities of the model into two regions, no high level information can be added. Let us assume that two specific entities should form a separate entity due to high level knowledge (e.g. a tumor which was divided into two pieces), and the boundary between these two entities should not be extracted. The current model is not able to handle such situations because this would contradict the concept of a binary tree. Therefore, a data structure called clustered entity is introduced: it permits the creation of “meta entities” which are not explicitly stored in the tree. These meta entities are stored in the mesh data structure and group single entities of the binary tree. In order to extract the joint boundary of clustered entities, the simplices of these cluster are traversed. Each adjacent face which is not part of the cluster is extracted, being a target for rendering. Boundary Extraction Algorithm extract( Binary tree T, entity id r ) //let F be a triangular mesh storing a set of face for ( ∀ leaf nodes li ∈ T being child of r ) for ( ∀ simplex sj ∈ li ) for ( ∀ simplex bk ∈ sj )

18

3.4. Rendering

Mesh Representation

if ( r is intermediate node ) if ( r is parent of li and bk 6= r ) //add fjk to F F.add( fjk ) else //r is leaf node if ( bk 6= r ) //add fjk to F F.add( fjk ) endif endif endif endfor endfor endfor return F end

3.4

Rendering

By using the extraction algorithm explained above, a triangular mesh is generated for each entity with shared vertices (using the vertex buffer V from the parent tetrahedral mesh). This mesh can be rendered using standard surface rendering techniques. In common meshes a lot of attributes are associated with a single vertex position (e.g. normals (nx , ny , nz ), texture coordinates (u, v), or color (r, g, b, a)) which specify the local parameters for rendering. However, this leads to problems if vertices are shared between adjacent faces which are colored differently. Therefore, the corner concept is used [38]: a corner acts as a wrapper for vertices and has additional local parameters associated with exactly one primitive. This has the benefit of allocating multiple corners, each indexing a similar vertex but storing additional attributes (e.g. different color and normal vector information for each vertex).

19

Chapter 4 Plane Partitioning In this chapter an efficient plane partitioning algorithm is presented. The algorithm is a combination of well known techniques which are extended in order to ensure consistency of the mesh model described in Chapter 3. When the algorithm is applied to a volumetric model, the mesh is partitioned into two disjoint entities separated by the plane while the connectivity is preserved. A hash table is used to propagate intersection points to adjacent tetrahedra. Therefore, the partitioning operation can be performed on-the-fly without being dependent on any precalculations or neighboring information. Partitioning using a plane generates a geometrically exact subdivision of the tetrahedral mesh.

4.1

Intersection

The algorithm requires a linear traversal of all tetrahedra of the mesh and determines for each tetrahedron whether it is intersected by the plane. Tetrahedra which are not split, are assigned to an entity immediately (corresponding to the side of the plane). Otherwise the tetrahedron is intersected by the plane and techniques must be applied to decompose the tetrahedron into parts which are separable by the plane. The intersection of a tetrahedron and a plane only affects tetrahedron edges: a tetrahedron T ∈ M3 is intersected by an infinite plane P in an intersection point pk (assuming no coplanarity) iff there exists an edge of T , where P intersects this edge in pk . The intersection detection is accomplished by calculating the signed distance between the plane and each vertex of the tetrahedron. If calculated distances have different signs, then the corresponding edge contains an intersection point: Intersection test of a line segment and a plane: A tetrahedron edge (pi , pj ) is intersected by a plane P (assuming no coplanarity) iff → − sgn [h− n , pi i − d] 6= sgn [h→ n , pj i − d] ,

(4.1)

− where → n represents the normal vector of P and d denotes the minimum distance between P and the origin of the coordinate system. 20

4.1. Intersection

Plane Partitioning

If Equation 4.1 is satisfied for a tetrahedron edge, then the corresponding tetrahedron is split by the plane and target for subdivision. The intersection of a tetrahedron and an infinite plane can be reduced to four basic, symmetric different cases shown in Figure 4.1.

V4

V4

V3

V3

V2

V1

(a) Case 1

(b) Case 2 V4

V4

V3

V3

V2

V1

V2

V1

V2

V1

(c) Case 3

(d) Case 4

Figure 4.1: Possible intersections of a tetrahedron and a plane (ignoring symmetric cases). Yellow colored vertices denote tetrahedron points lying on the plane; intersection points are marked green.

The actual intersection point of a line segment and a plane is easily calculated using basic vector algebra (see Figure 4.2). Plane P is represented as: nx x + ny y + nz z + d = 0,

(4.2)

− where nx , ny and nz denote the coordinates of the plane’s normal vector → n , while |d| represents the minimum distance between P and the origin of the coordinate system. 21

4.1. Intersection

Plane Partitioning

The intersection of a line segment (pi , pj ) and P is in point pk = pi + t(pj − pi ) for some t (using parametric representation). Since pk is a point on P, it has to satisfy Equation 4.2. Substituting the parametric representation of pk in Equation 4.2 leads to: nx (pix + t(pjx − pix )) + ny (piy + t(pjy − piy )) + nz (piz + t(pjz − piz )) + d = 0. Viewing the equation as operations on vectors, it is solved for t: → h− n , pi + t(pj − pi )i + d = 0 − → → h n , pi i + h− n , t(pj − pi )i = −d → → th− n , (pj − pi )i = −d − h− n , pi i − → h n , pi i + d t = − − . h→ n , pj − pi i

(4.3)

Calculating t under the use of Equation 4.3 and inserting the result into the parametric representation of the line equation leads to a possibility for calculating an intersection point pk of an edge (pi , pj ): pk = pi + t(pj − pi ) = pi − t · pi + t · pj = (1 − t)pi + t · pj → h− n , pi i + d t = − → − h n , pj − p i i → h− n , pj i + d = − → − → h n , pj i − h − n , pi i → h− n , pj i + d 1−t = 1+ → − → h n , pj i − h − n , pi i − → − → → h n , p j i − h n , pi i h− n , pi i + d = − + − → − → → → h n , p j i − h n , pi i h n , p j i − h − n , pi i − → h n , pj i + d = − → → h n , p j i − h− n , pi i → − h− n , pj i + d h→ n , pj i + d pk = pi · → − pj · − . − − → → → hn,p i − hn,p i h n , p i − h− n,p i j

i

j

(4.4)

i

Degeneracies, where line end-points lie exactly on the plane, should not be considered as an intersection and must be handled separately. A detailed description of the intersection of a line segment and a plane can be found in [23, p. 482 et sqq. ]. Computing the signed distances between edge end-points and the plane and comparing their signs is an easy method to identify tetrahedron edges where an intersection with the 22

4.2. Consistent Intersection Point Propagation

Plane Partitioning

pi

n

q=pi +t(pj - pi )

p

j

Figure 4.2: Intersection of a line segment (represented by points pi and pj ) and a plane defined → by the normal vector − n.

plane occurs (and the appropriate intersection case). The plane partitioning algorithm traverses all tetrahedra of the mesh and calculates the signed distance between the vertices and the partitioning plane for every tetrahedron. The distances are computed separately for each tetrahedron. Therefore, calculating the distance of vertices which lie close to the partitioning plane can result in different signs if floating point roundoff errors occur. In this case, incorrect intersection points are calculated and the subdivision is inconsistent. In order to ensure consistency concerning the detected intersection case, a hash table is introduced.

4.2

Consistent Intersection Point Propagation

In order to keep the mesh consistent while assuring uniqueness of each vertex in the vertex buffer V, shared intersection points of adjacent tetrahedra have to be computed only once. Therefore, a calculated intersection point is stored in a hash table according to the following hash function: hash(Vi , Vj ) := [ xor(Vi , prime0 ) + xor(Vj , prime1 ) ] mod n, where the key value (Vi , Vj ) specifies the indices of the two corresponding vertices spanning the edge and containing the intersection point. Additionally, Vi < Vj has to be satisfied for each key value. prime0 and prime1 are large prime numbers (i.e. prime0 = 82, 954, 987 and prime1 = 21, 204, 949) and n denotes the hash table size. The hash table stores items which are hashed to equivalent values in linked lists in order to avoid hash collisions if the 23

4.3. Subdivision

Plane Partitioning

hash table size n is too small. The rule that Vi < Vj must be fulfilled for each key value ensures that tetrahedron edges (Vi , Vj ) and (Vj , Vi ) are hashed to identical values. For each edge of the current tetrahedron which is intersected by the plane, the hash table is examined for an existing entry. Following configurations can arise due to the fact that a plane intersects each tetrahedron edge only once: • If no value is found in the hash table for the current tetrahedron edge, the appropriate intersection point is calculated and appended to the vertex buffer V. The according index is stored in the hash table. • Otherwise, if the edge is located in the hash table, the existing vertex index is retrieved and its intersection point is used. Due to hash collisions, several edges can be hashed to the same key value. Therefore, every edge which is stored in the linked list of the current key value has to be examined for a matching edge index. This simple and efficient method with less overhead ensures a unique intersection point detection independent of floating point calculations and therefore consistency according to the definition of a simplicial complex.

4.3

Subdivision

Dividing a tetrahedron using a plane, splits the tetrahedron into two disjoint parts. The parts consist of convex polyhedra (i.e. tetrahedra, pyramids and prisms) which must be subsequently subdivided into tetrahedra. This is a non-trivial task if the mesh consistency has to be preserved. Definition of a consistent subdivision: A mesh M3 is consistently subdivided iff • Each tetrahedron T containing intersection points is replaced by tetrahedra ti where [ conv{Ti } = conv{ ti } is fulfilled and all former intersection points of T become points of the tetrahedra ti . • After subdividing all tetrahedra, M3 is a simplicial complex (see Section 3.1). Based on the arrangement of the calculated intersection points, a correct subdivision is performed using the appropriate splitting case (see Table 4.1). Assuming the white colored part of the tetrahedra (in the figures of Table 4.1) is on the positive side of plane P, then Table 4.2 gives a partitioning of the tetrahedron vertices according to their positions relative to P. A lookup table is generated based on the signs of the distances between the vertices and P. The number of points with distances less than, greater than, and equal to zero are encoded into a bit vector which is used to determine the correct subdivision case. The symmetric identical cases where the red colored part of the tetrahedra is on the positive 24

4.3. Subdivision

Plane Partitioning

side of the plane are handled as individual cases in the lookup table (leading to eight cases finally, but gaining efficiency). Otherwise, the normal vector of P has to be inverted and each decision based on the normal vector, e.g. setting entity bits based on the position of the tetrahedron, must be reversed. Each tetrahedron is subdivided according to the recognized case, providing adequate splitting corresponding to the plane. As mentioned above, splitting generates new primitives, either prisms, pyramids, or tetrahedra which are specified for each configuration in Table 4.1. In order to guarantee that adjacent tetrahedra are properly connected, each prism or pyramid must be subdivided into tetrahedra in a consistent way. Pyramids and prisms consist of quadrilateral faces, each leading to two possibilities for the subdivision into tetrahedra. If choosing diagonals of quadrilateral faces shared by two mesh primitives inconsistently, two tetrahedra may not be properly connected. This violates the definition of simplicial complexes. Therefore, a method analog to Dompierre et al. [20] is used to split quadrilateral faces consistently: Consistent split criterion for quadrilateral faces: A quadrilateral face is split consistently into two triangular faces by choosing the diagonal which contains the smallest vertex index of the face. This criterion can be applied locally without the requirement of any information on adjacent tetrahedra. It ensures that two adjacent primitives will split their shared quadrilateral face identically as long as the vertices have unique and constant indices in the vertex buffer V. This is the case for any properly connected mesh. By using this criterion, the subdivision of a pyramid into two tetrahedra is straight forward as stated in Table 4.3: the pyramid contains only one quadrilateral face f = (V1 , V2 , V3 , V4 ), thus it is subdivided by choosing the diagonal of f which contains the smallest vertex index (i.e. diag = V1 V3 or diag = V2 V4 ). A prism contains three quadrilateral faces, consequently, eight different configurations are possible (shown in Table 4.4). In six of eight cases, the prisms can be subdivided into three tetrahedra. The remaining two cases are named Sch¨ onhart polyhedra and can only be tetrahedralized if a Steiner point is added inside of the prism [46]. The Steiner point is calculated by computing the average of all prism vertices.

25

4.3. Subdivision

Plane Partitioning

V4

Case 1 Subdivisions on positive side of plane 44 (V1 , V2 , V4 , I(V 3,V 4) ) Subdivisions on negative side of plane 44 (V1 , V2 , V3 , I(V 3,V 4) )

V3

V2

V1 V4

Case 2 Subdivisions on positive side of plane 44 (V1 , V4 , I(V 2,V 4) , I(V 3,V 4) ) Subdivisions on negative side of plane 45 (V2 , I(V 2,V 4) , I(V 3,V 4) , V3 , V1 )

V3

V2

V1 V4

Case 3 Subdivisions on positive side of plane 44 (I(V 1,V 4) , I(V 2,V 4) , I(V 3,V 4) , V4 ) Subdivisions on negative side of plane 46 (V1 , V2 , V3 , I(V 1,V 4) , I(V 2,V 4) , I(V 3,V 4) )

V3

V2

V1 V4

Case 4 Subdivisions on positive side of plane 46 (V1 , I(V 1,V 3) , I(V 1,V 2) , V4 , I(V 3,V 4) , I(V 2,V 4) ) Subdivisions on negative side of plane 46 (I(V 1,V 2) , I(V 2,V 4) , V2 , I(V 1,V 3) , I(V 3,V 4) , V3 )

V3

V1

V2

Table 4.1: Possible subdivisions of a tetrahedron with vertices V1 , . . . , V4 intersected by a plane. Subdivisions into primitives for each side of the plane are given. I(V i,V j) denotes the intersection point on edge (Vi , Vj ). The white and red colored sections of the figures denote the two different parts of the tetrahedra, split by the plane. Yellow color denotes tetrahedron points lying on the plane; intersection points are marked green. Naming conventions for prisms and pyramids are defined in Chapter 9.

26

4.3. Subdivision

Plane Partitioning

Case 1 (+ − 00)

2 (+ − −0)

3 (+ − −−)

4 (+ + −−)

Vertex indices V4 V1 , V2 , I(V 3,V 4) V3 V4 V1 , I(V 2,V 4) , I(V 3,V 4) V2 , V3 V4 I(V 1,V 4) , I(V 2,V 4) , I(V 3,V 4) V1 , V2 , V3 V1 , V4 I(V 1,V 2) , I(V 1,V 3) , I(V 2,V 4) , I(V 3,V 4) V2 , V3

Side of plane + 0 – + 0 – + 0 – + 0 –

Table 4.2: Partitioning of tetrahedron vertices V1 , . . . , V4 according to their positions relative to the partitioning plane for each particular subdivision case. Vertex indices with corresponding side of plane are given. I(V i,V j) denotes the intersection point on edge (Vi , Vj ). Naming conventions of tetrahedra are defined in Chapter 9.

Case min (V1 , V3 ) < min (V2 , V4 ) min (V2 , V4 ) < min (V1 , V3 )

Subdivisions 44 (V1 , V2 , V3 , 44 (V1 , V3 , V4 , 44 (V2 , V3 , V4 , 44 (V1 , V2 , V4 ,

V5 ) V5 ) V5 ) V5 )

Table 4.3: Subdivision of a pyramid with vertices V1 , . . . , V5 into tetrahedra. Case differentiation depending on the smallest vertex index of the quadrilateral face and corresponding subdivision are given. Naming conventions of pyramids and tetrahedra are defined in Chapter 9.

27

4.3. Subdivision Case min (V2 , V4 ) < min (V1 , V5 ) and min (V1 , V6 ) < min (V3 , V4 ) and min (V3 , V5 ) < min (V2 , V6 )

Plane Partitioning Subdivisions 44 (V1 , V2 , V3 , 44 (V1 , V2 , V4 , 44 (V2 , V4 , V5 , 44 (V2 , V3 , V5 , 44 (V3 , V5 , V6 , 44 (V1 , V3 , V6 , 44 (V1 , V4 , V6 , 44 (V4 , V5 , V6 ,

V7 ) V7 ) V7 ) V7 ) V7 ) V7 ) V7 ) V7 )

Case min (V2 , V4 ) < min (V1 , V5 ) and min (V1 , V6 ) < min (V3 , V4 ) and min (V3 , V5 ) > min (V2 , V6 )

Subdivisions 44 (V1 , V2 , V4 , V6 ) 44 (V2 , V4 , V5 , V6 ) 44 (V1 , V2 , V3 , V6 )

Case min (V2 , V4 ) < min (V1 , V5 ) and min (V1 , V6 ) > min (V3 , V4 ) and min (V3 , V5 ) < min (V2 , V6 )

Subdivisions 44 (V1 , V2 , V3 , V4 ) 44 (V2 , V3 , V4 , V5 ) 44 (V3 , V4 , V5 , V6 )

Case min (V2 , V4 ) < min (V1 , V5 ) and min (V1 , V6 ) > min (V3 , V4 ) and min (V3 , V5 ) > min (V2 , V6 )

Subdivisions 44 (V1 , V2 , V3 , V4 ) 44 (V2 , V4 , V5 , V6 ) 44 (V2 , V3 , V4 , V6 )

Case min (V2 , V4 ) > min (V1 , V5 ) and min (V1 , V6 ) < min (V3 , V4 ) and min (V3 , V5 ) < min (V2 , V6 )

Subdivisions 44 (V1 , V4 , V5 , V6 ) 44 (V1 , V2 , V3 , V5 ) 44 (V1 , V3 , V5 , V6 )

Case min (V2 , V4 ) > min (V1 , V5 ) and min (V1 , V6 ) < min (V3 , V4 ) and min (V3 , V5 ) > min (V2 , V6 )

Subdivisions 44 (V1 , V4 , V5 , V6 ) 44 (V1 , V2 , V5 , V6 ) 44 (V1 , V2 , V3 , V6 )

Case min (V2 , V4 ) > min (V1 , V5 ) and min (V1 , V6 ) > min (V3 , V4 ) and min (V3 , V5 ) < min (V2 , V6 )

Subdivisions 44 (V1 , V3 , V4 , V5 ) 44 (V1 , V2 , V3 , V5 ) 44 (V3 , V4 , V5 , V6 )

V4

V6 V5

V1

V3 V2

28

4.4. Node Snapping Case min (V2 , V4 ) > min (V1 , V5 ) and min (V1 , V6 ) > min (V3 , V4 ) and min (V3 , V5 ) > min (V2 , V6 )

Plane Partitioning Subdivisions 44 (V1 , V2 , V3 , 44 (V1 , V4 , V5 , 44 (V1 , V2 , V5 , 44 (V2 , V5 , V6 , 44 (V2 , V3 , V6 , 44 (V3 , V4 , V6 , 44 (V1 , V3 , V4 , 44 (V4 , V5 , V6 ,

V7 ) V7 ) V7 ) V7 ) V7 ) V7 ) V7 ) V7 )

V4

V6 V5

V1

V3 V2

Table 4.4: Subdivision of a prism with vertices V1 , . . . , V6 into tetrahedra. Case differentiation depending on the smallest vertex index of the quadrilateral face and corresponding subdivision are given. V7 denotes the vertex index of the additionally added Steiner point. Naming conventions of prisms, pyramids and tetrahedra are defined in Chapter 9.

Subdivision can lead to incorrectly oriented tetrahedra. Before subdivided tetrahedra are added to the simplex container S of the mesh data structure, the orientation has to be verified . Each tetrahedron of the volumetric mesh must have the same, valid orientation. The orientation of a simplex can be determined by calculating the determinant yielding the signed volume of a simplex [23, p. 824 ]: a tetrahedron T ∈ M3 is oriented in counterclockwise order iff   ax ay az 1  bx by bz 1   (4.5) det   cx cy cz 1  dx dy dz 1 is positive, where a, b, c, and d are the points which define the tetrahedron. The orientation is reversed by swapping two arbitrary vertices of the simplex which inverts the sign of the determinate.

4.4

Node Snapping

Degenerated primitives may be created by the subdivision process if intersection points lie close to initial vertices. These tetrahedra have either short edges, short height or large dihedral angles (angle between two supporting planes). Node snapping is a technique where tetrahedron vertices which lie close to the plane are snapped onto the plane in order to avoid short edges. As mentioned in Chapter 2, several node snapping methods were published [52, 51, 49]. Node snapping primarily improves the mesh quality by simplifying the partitioning operation. In the first step the absolute value of the distances between the tetrahedron vertices and the plane P are sorted in ascending order. The snapping process starts, using the 29

4.4. Node Snapping

Plane Partitioning

point with the smallest distance to P within a predefined ²-environment (heuristically chosen). The vertices are moved by projecting them orthogonally onto the partitioning plane P. The orthogonal projection of a point p onto a plane is outlined in Figure 4.3 and → → is computed as follows: let q be a point on P, − v = q − p, and − n the normal vector which − → − → → defines P. v is projected onto n to get the orthogonal projection T (− v ): → → → T (− v) = − v −− vn

→ − n − → → − . v n = h− v ,→ ni − → → hn,− ni

(4.6)

Therefore, the projection of a direction vector is calculated using Equation 4.6 and the orthogonal projection T (p) of a point p onto the plane P is computed as follows: − → n → T (p) = hp − q, − ni − , → → hn,− ni

(4.7)

→ where − n is the normal vector which defines P, and q is a point on P. If the signed distance distp between p and the plane is known, we arrive at the equation: → distp − n T (p) = p − − . → − → hn, ni u p vu v vu q T( v )

T(p)

Figure 4.3: Orthogonal projection T (p) of a point p onto a plane. q represents a point on the → plane and − n denotes the normal vector of the plane.

Before a snapping candidate is projected onto P, it is required to ensure that no degenerated cases arise. Snapping is only applied if no tetrahedra exist where all four vertices are coplanar after the projection of the candidate vertex onto P. The verification of the current tetrahedron is straight forward: the vertices of a tetrahedron are coplanar if Equation 4.5 is equal to zero. Remaining tetrahedra, sharing the vertex to snap, are checked for coplanarity as well (determined using the VSC). The snapping process stops if either no 30

4.4. Node Snapping

Plane Partitioning

more snapping candidates are found in the ²-environment or a projection of a remaining vertex is causing degeneracy. Snapping of vertices which belong to the object boundary (i.e. mesh or entity boundary) must be handled separately to avoid modification of the object’s boundary. Boundary vertices are identified in a precalculated step using the simplex-simplex connection SSC. All vertices of tetrahedron faces without a neighbor belong to the mesh boundary. Either no snapping is applied to these points which is most efficient; or a more complex technique proposed by Nienhuys et al. [52] is used. The algorithm works as follows: for each face fi which contains a boundary vertex p, p is orthogonally projected onto the line of intersection of fi and the partitioning plane. A projection is valid if the projected point lies on any face fi , for some i. The projection with the smallest distance to the initial point is used if existing, otherwise no node snapping is applied. As mentioned above, node snapping can be used to improve the robustness of floating point calculations. For instance, floating point roundoff errors can occur if distances between tetrahedron vertices and the partitioning plane are computed separately for each tetrahedron (outlined in Figure 4.4(a)). Contrary, a point close to the partitioning plane (i.e. in an ²-environment of arbitrary size; bounding the floating point error) is snapped onto the plane if the node snapping technique is applied. Therefore, the point lies in the center of the ²-environment after the first traversed tetrahedron and is detected correctly as a point on the plane subsequently (stated in Figure 4.4(b)). If a point lies outside but close to the ²-environment, the vertex is pushed slightly away from the ²-environment to ensure consistency. Generally, similar techniques are called snap rounding in literature.

31

4.5. Algorithm Outline

Plane Partitioning

g p1

g

p2 plane

p1 p2 p3

p3

plane

q g q (a) Different results with opposite signs can occur due to floating point roundoff errors.

(b) Consistent calculations are accomplished by snapping p to the center of the ²-environment which results in equal values p1 , p2 , and p3 . In order to ensure consistency, q is pushed slightly away from the plane.

Figure 4.4: Robust floating point calculations can be achieved by using node snapping. p1 , p2 , and p3 represent different results of signed distance calculations between a point p and the plane. q represents a different point which lies close but outside the ²-environment.

4.5

Algorithm Outline

After calculating the signed distance between each vertex of a tetrahedron T and the plane P in order to detect possible intersections, a node snapping algorithm can be applied to enhance the quality of the subdivision. Subsequently, intersected tetrahedra are subdivided in arbitrary sequence. Before adding newly created tetrahedra to the simplex container S, invalid orientations have to be corrected by swapping vertices. Additionally, a further entity bit is appended to the entity bit vector. An entity, intersected by the plane P, is always divided into two disjoint entities after a partitioning operation. The position of a subdivided tetrahedron relative to P is easily determined by the fact that the tetrahedron consists only of vertices which lie on P (intersection points) and vertices of the initial tetrahedron which lie on the same side of P. Therefore, after assigning original and split tetrahedra to the positive or negative side of P, the appropriate entity bit is added. The complete algorithm is outlined as follows: Plane Partitioning Algorithm plane_cut() //simplex container S contains all //tetrahedra of the volumetric mesh M3 . for ( ∀ tetrahedra T ∈ S )

32

4.5. Algorithm Outline

Plane Partitioning

//determine side of plane for each vertex Vi of T //by calculating the signed distance side_of_plane(V0 , . . . , V4 ) = determine_side( T , P ) //optionally apply node snapping nodesnap( vertices of T , P ) //intersection test if ( T intersects P ) subdivision_case = lookup_table( side_of_plane(V0 , . . . , V4 ) ) for ( ∀ edges edgeT of T ) if ( !hash.has_value( edgeT ) ) intersection_point[edgeT ] = calc_intersection( edgeT ) hash.set_value( edgeT , intersection_point[edgeT ] ) else intersection_point[edgeT ] = hash.get_value( edgeT ) endif endfor subdivide( T , subdivision_case ) //mark original tetrahedron as deleted S.delete( T ) for ( ∀ created tetrahedra Ti ) //check counter-clockwise orientation if ( !ccw( Ti ) ) orient( Ti ) endif //determine side of vertices V0 , . . . , V4 //relative to P and set the entity bits Ti .entity = side_of_plane(V0 , . . . , V4 ) S.add( Ti ) endfor else //determine side of vertices V0 , . . . , V4 //to P and set the entity bits T .entity = side_of_plane(V0 , . . . , V4 ) endif endfor remove deleted tetrahedra from M3 end

33

Chapter 5 Shape Partitioning This chapter describes methods for partitioning a volumetric mesh with a shape which is represented as a triangular mesh. Shape partitioning provides a more flexible way than plane partitioning because almost any shape like deformable grids or analytical shapes can be used to remove specific parts of the tetrahedral mesh. Up to our knowledge, the approach of partitioning a volumetric mesh with an almost arbitrary triangular mesh is a novel one, especially the subdivision of tetrahedra with multiple intersection points per edge and the assignment of partitions to entities. In contrast to the plane partitioning algorithm, the presented shape partitioning method is approximative because partially split tetrahedra are not considered (e.g. partitioning shape faces poking inside tetrahedra). Exact shape partitioning can be accomplished by creating split planes for each partitioning shape face which intersects a tetrahedron. Boolean operations (i.e. constructive solid geometry) can be applied, if the partitioning shape and the volumetric mesh are of equal dimension. However, both approaches are runtime-expensive, lead to complex data structures and produce a fast increase in mesh size. Shape partitioning comprises a more complex algorithm than plane partitioning, since intersection point handling is not trivial. As mentioned above, a partitioning shape is defined as a triangular mesh consisting of 2-simplices. Arbitrary partitioning shapes can be used by the presented iterative subdivision algorithm. However, if assigning partitions to entities, two conditions must be fulfilled: • The partitioning shape divides the tetrahedral mesh into two disjoint regions either by a closed surface or by an object homeomorphic to an open disc. • A single tetrahedron of the volumetric mesh has to be intersected by the partitioning shape in a convex way if multiple intersections occur. For clarity, the intersection of a single tetrahedron by the partitioning shape in a convex way does not presume that the partitioning shape has to be convex. The condition is 34

5.1. Method of Separating Axes

Shape Partitioning

introduced to avoid the requirement of additional data structures for determining the location of intersection points relative to the partitioning shape (e.g. distance functions or binary space partition trees). Examples of correctly defined partitioning shapes are deformed grids or 2-manifold surfaces. In the first step, the algorithm computes all intersection points between the tetrahedral mesh and the partitioning shape. A hierarchical data structure is introduced for efficient intersection tests (i.e. an octree) and a hash table is used to store the intersection information and to maintain a consistent mesh topology. Existing subdivision methods are extended by a new data structure which is able to handle multiple intersection points per edge. Finally, the tetrahedral mesh is split into two entities. For simplicity, these entities are called inside and outside of the partitioning shape: Definition of the inside and outside entity: Let M3 be a volumetric mesh and C a partitioning shape, both oriented counter-clockwise. A subset Mout ⊂ M3 is called outside if → h− n , pi ≥ d (5.1) → is fulfilled for each point p ∈ M and for all partitioning shape faces f . − n represents out

C

the normal vector of fC ’s supporting plane and d the distance to the origin. Respectively, Min ⊂ M3 is called inside if Equation 5.1 is not satisfied for any point q ∈ Min .

5.1

Method of Separating Axes

This section outlines the method of separating axes – a technique for determining if two stationary convex objects intersect. The method of separating axes is required for efficient bounding-box and exact intersection tests and is therefore frequently used by the shape partitioning algorithm. Detailed information can be found in [22, 23], for convex polygons [23, p. 265 et sqq. ] and convex polyhedra [23, p. 611 et sqq. ]. A non-intersection test of two convex polyhedra is simply stated: two convex polyhedra − → do not intersect if there exists a separating line with direction d such that the projections of the polyhedra onto that line do not intersect. Since the translation of a separating line is a separating line as well, it is sufficient to consider only lines which contain the origin of → − the coordinate system. Given a line represented by a vector d containing the origin, the − → projection of a convex set Ci onto d is the interval − → − → − → → (i) − I = [λmin ( d ), λ(i) max ( d )] = [min{h d , pi : p ∈ Ci }, max{h d , qi : q ∈ Ci }],

(5.2)

where p and q are points of Ci . Two convex sets are separated if there exists a direction where the projection intervals do not intersect.

35

5.1. Method of Separating Axes

Shape Partitioning

− → Specifically, two convex sets C0 and C1 are separated if there exists a direction d → (0) − → − → (0) − (1) → (1) − where the projection intervals I0 = [λmin ( d ), λmax ( d )] and I1 = [λmin ( d ), λmax ( d )] defined by Equation 5.2 do not intersect: → − → → → (0) − (1) − (0) − λmin ( d ) > λ(1) max ( d ) or λmax ( d ) < λmin ( d ).

(5.3)

The use of the method of separating axes on two convex polygons A and B is shown → − in Figure 5.1: in Figure 5.1(a) an axis d is found which separates A and B. Equation 5.2 is satisfied (maxA < minB ) and therefore the two convex objects do not intersect. Otherwise A and B overlap as shown in Figure 5.1(b).

d

A

A B

B

projection(A)

d minA

maxA

projection(B)

min B

maxB

separating axis (a) A separating axis is found. A and B do not intersect.

d minA

min B maxA maxB

no separation on any axis (b) If no separating axis is found then A and B overlap.

Figure 5.1: An example of the method of separating axes, testing two convex polygons A and → − B. d represents the direction vector of the current separating axis.

For a pair of convex polyhedra only a finite set of direction vectors must be considered for separation tests. This set consists of face normals of the two polyhedra and vectors computed from the cross product of all polyhedra edges, one edge from each polygon. A 2-D proof, showing that the introduced finite set is sufficient to detect all intersections, is presented in [23, p. 267 ]. The number of required tests for convex polyhedra C0 and C1 is defined by F0 + F1 + E0 · E1 , where F0 and F1 are the number of faces and E0 and E1 the number of edges in the corresponding polyhedron.

36

5.2. Collision Detection

Shape Partitioning

→ − Given a separating axis d , the calculation of the projection intervals and the overlap tests are outlined in pseudo-code as follows: Separating Axes Tests //see Equation 5.2 − → compute_interval( convex set of points C, separat. axis d , min, max) for ( ∀ points p of C ) − → if ( min > h d , pi ) → − min = h d , pi endif − → if ( max < h d , pi ) → − max = h d , pi endif endfor end //see Equation 5.3 interval_overlap( constant, mina , maxa ) if ( constant < mina ) return no overlap; if ( constant > maxa ) return no overlap; return overlap end interval_overlap( mina , maxa , minb , maxb ) if ( mina > maxb ) return no overlap; if ( maxa < minb ) return no overlap; return overlap end

5.2

Collision Detection

In order to avoid testing each tetrahedron face against each face of the partitioning shape, a collision detection algorithm is required. An overview of collision detection systems was given in Section 2.3. Since no progressive splitting is currently performed, volumetric meshes are rigid, and complex collision detection methods for deformable objects are not required. Therefore, any appropriate algorithm for stationary objects can be used. The decision was made to build up the collision detection system based on an octree, a well known and proven hierarchical data structure. Although an octree can be generated efficiently for each partitioning operation, the collision detection is fast enough for our requirements (i.e. less than 10 ms to detect 1000 collisions). In addition, an octree can easily be extended to a bucket tree (proposed by Ganovelli et al. [28]) for supporting deformable objects. 37

5.2. Collision Detection

Shape Partitioning

Initially, the octree root node is represented by the axis-aligned box which covers the partitioning mesh. Each node has the ability to store eight child nodes. The axis-aligned box of the root is partitioned into eight equally sized parts which are stored in the child nodes. A triangular face of the partitioning mesh is assigned to each child node where an intersection with the axis-aligned box occurs (see Figure 5.3). The creation of child nodes and the corresponding axis-aligned box subdivision are repeated until a defined criterion is satisfied (i.e. number of primitives per node, depth of tree). Finally, the leaves of the octree store the appropriate indices of the partitioning shape faces. An example of an octree with a depth of two is shown in Figure 5.2(a) and the corresponding subdivision of the octants is outlined in Figure 5.2(b). According to Figure 5.3, a simplified subdivision (for the 2-D case represented as a quadtree) works as follows: let us assume that the quadtree is subdivided until at most one primitive is contained in each quadrant (stop criterion). In the first subdivision step the bounding box which surrounds all primitives is divided into four quadrants (see Figure 5.3(a)). Quadrants 1 and 2 do not contain any primitives, thus no further subdivision is required. Quadrant 0 fulfills the stop criterion of the tree as well and contains only triangle A. Quadrant 3 is intersected by both triangles and therefore subdivided (see Figure 5.3(b)). Subsequently, the subdivision process is finished and triangle A is stored in quadrants 0, 3, 4, and 5 whereas triangle B is only contained in quadrant 6.

(a) Tree representation

(b) Subdivision of octants according to Figure (a).

Figure 5.2: Example of an octree with a depth of two. Tree representation and corresponding subdivision of the octants are given.

The break-even point for number of mesh primitives versus tree depth can be determined heuristically based on the data and target platform. On a standard PC (2 to 3 GHz), a good choice is that once the tree depth of a binary tree becomes eight or nine, the tree approach is no longer cost-effective [22]. Based on that rule it is important to keep the tree depth down for the octree.

38

5.2. Collision Detection

Shape Partitioning

0

3

0

3

6 B

B A

1

A

2

(a) In the first subdivision step the bounding box which surrounds the primitives is divided into four quadrants. Quadrant 3 is further subdivided as stated in Figure (b).

1

4

5

2

(b) Final subdivision: Triangle indices are stored in quadrants 0, 3, 4 and 5.

Figure 5.3: An example of a quadtree subdivision. Green quadrants represent leaves where triangle indices are stored.

An intersection test has to be applied in order to determine the octants which are intersected by partitioning shape faces. An octant is represented as an axis-aligned box which is in fact a convex object. Therefore, a triangle – axis-aligned bounding box test is performed using a method presented by M¨oller [1] which is based on the method of separating axes (described in detail in Section 5.1): Intersection test of a triangle and an axis-aligned box: A triangle A is intersected by an axis-aligned box B if no separating axis is found for all of the following tests: 1. Test separation where the supporting plane normal of A is used as the direction vector for the separation test. → → → 2. Test separation where normals − n0 , − n1 and − n2 of B (axes of the coordinate system) are used as the direction vectors for the separation tests. → ∀ i, j, k : i = 0, 1; j = 1, 2; k = 3. Test separation where edges (pi , pj ) × − n k 0, 1, 2 and j > i are used as the direction vectors for the separation tests (p0 , p1 , p2 are points of A). By using this test, a maximum of 13 tests is required to determine correctly whether a triangle intersects an axis-aligned bounding box. After octree generation, the tree is used to find potential intersection candidates of the two meshes (i.e. of the volumetric mesh and the partitioning shape). An efficient method 39

5.3. Intersection

Shape Partitioning

by Bergen [63] can be applied where nodes of two trees are tested against each other (the method is outlined in Section 2.3). Otherwise, the octree representing the partitioning shape must be tested against each tetrahedron face which seems less efficient. The latter technique was implemented because efficiency loss is equalized by the missing overhead of building a second octree. Regardless of the used method, an overlap test of two bounding boxes is required. The intersection of two axis-aligned bounding boxes is simply stated because the faces are perpendicular to their frame’s basis vectors [23, p. 637 et sqq. ]: Intersection test of two axis-aligned boxes: An axis-aligned box A is intersected by an axis-aligned box B iff maxb < mina

and

maxa < minb ,

where mina , minb represent the minimum points and maxa , maxb denote the maximum points of the corresponding bounding boxes. Since a primitive is potentially stored in more than one octant (cf. Figure 5.3(b)), the octree must provide methods to return intersection candidates uniquely. A way to achieve this consists in the use of a linked list which is ordered by primitive indices. Therefore, equal identifiers can be removed efficiently. This technique avoids multiple exact intersection tests of a single primitive which are runtime-expensive tasks.

5.3

Intersection

After possible intersection candidates were found by the collision detection algorithm, exact intersection point calculations are performed. The intersection of C ∩ M3 can be reduced to an intersection between faces of C and faces of M3 . Since partitioning shape faces which poke inside tetrahedra are ignored, the presented algorithm is approximative. This has the benefit that no additional vertices inside tetrahedra are added and less subdivisions are required. Additionally, no intersection points are calculated if: • a partitioning shape face lies completely inside a tetrahedron or • a partitioning shape face is coplanar to a tetrahedron face. Therefore, coplanar faces are not considered as intersections. In fact, coplanar cases are not relevant for tetrahedra splitting but important to identify relationships of subdivided tetrahedra to entities. Tetrahedron vertices which lie on partitioning shape faces are called marked vertices. Intersection points which are used to split intersected tetrahedra fulfill the requirements of being marked vertices. Since marked vertices are used to identify the affiliation of subdivided tetrahedra to entities (i.e. inside or outside), the supporting plane of the corresponding face of the partitioning shape is stored in the corner structure of each marked vertex (see Section 3.4). The so-called shape partitioning attribute is introduced 40

5.3. Intersection

Shape Partitioning

which is an extended corner attribute and able to store a plane. The normal vector information is used to determine the position of tetrahedra vertices relative to the partitioning shape. The verification whether a point lies on a triangular face of C is achieved by testing if the point lies on the negative side of each edge line (outlined in Figure 5.4): Point in triangle test: A point p lies on a triangular face represented by vertices q0 , q1 , and q2 (assuming counter-clockwise orientation) iff p lies on the supporting plane of the face and → hp − q0 , − n × (q1 − q0 )i ≤ 0 − → hp − q1 , n × (q2 − q1 )i ≤ 0 → hp − q2 , − n × (q2 − q0 )i ≤ 0

(5.4)

→ are satisfied, where − n is the normal vector of the triangle’s supporting plane. Alternatively, barycentric coordinates could be used to determine the location of a point relative to a convex polygon [23, p. 696 ].

n n2

q2 n1 p

q0

n0

q1

Figure 5.4: A point p lies on a triangular face (represented by vertices q0 , q1 , q2 ) iff p lies on the → negative side of each edge line defined by edge normals − ni .

The exact intersection test C ∩ M3 is performed using a triangle – triangle intersection test where a face fC of the partitioning shape is tested against each face fT of the corresponding tetrahedron. The trivial approach is to test each edge of fC against fT and vice versa. Several other methods are notably faster like the algorithm provided by M¨oller [48]. The implemented algorithm is based on the algorithm of M¨oller but also uses the method of separating axes (presented in Section 5.1) to detect intersections: in the first step a quick check is done, testing if fT intersects the supporting plane of fC . After an intersection with the plane was detected, a coplanarity test must be performed. Coplanarity is verified by comparing if the supporting planes of fC and fT coincide in an ²-environment which is a relative bound of the floating point roundoff error. The supporting planes are defined by → → normal vectors − n fC and − n fT , respectively. 41

5.3. Intersection

Shape Partitioning

The ²-environment is dependent on the value of the squared sine of the angle between the two normal vectors, based on the identity → → → → ||− n fC × − n fT || = ||− n fC || · ||− n fT || · sin(θ), where θ is the angle between the two vectors (see [23, p. 614 ]). ² represents a relative error bound to avoid floating point roundoff errors: → → ² = ||− n fC || · ||− n fT || · ²sin · ²m , where ²m denotes the machine-² (cf. Section 6.1) whereas the choice of ²sin is applicationdependent. Finally, one of the following tests are used to determine exact intersection: if no coplanarity is detected, the following intersection test is used: Intersection test of two non-coplanar triangles: A triangle A is intersected by a triangle B (A and B are not coplanar) if no separating axis is found for all of the following tests: 1. Test separation where the supporting plane normal of A is used as the direction vector for the separation test. 2. Test separation where the supporting plane normal of B is used as the direction vector for the separation test. 3. Test separation where (pi , pj ) × (qk , ql ) ∀ i, j, k, l : i, k = 0, 1; j, l = 1, 2 and j > i, l > k are used as the direction vectors for the separation tests (p0 , p1 , p2 are points of A; q0 , q1 , q2 are points of B). The normal vector of each supporting plane is not a separating direction, if both triangular faces are coplanar. The cross product of any pair of edges is again a normal vector of the plane, thus it cannot separate the two triangles. In this case, potential separating directions are vectors which lie on the supporting plane and are perpendicular to the appropriate edge: Intersection test of two coplanar triangles: A triangle A is intersected by a triangle B (A and B are coplanar) if no separating axis is found for all of the following tests: 1. Test separation where − n→ A × (pi , pj ) ∀ i, j : i = 0, 1; j = 1, 2 and j > i are used as the direction vectors for the separation tests (p0 , p1 , p2 are points of A; − n→ A is the normal vector of the supporting plane of A). 2. Test separation where − n→ B × (qi , qj ) ∀ i, j : i = 0, 1; j = 1, 2 and j > i are used as the direction vectors for the separation tests (q0 , q1 , q2 are points of B; − n→ A is the normal vector of the supporting plane of B) . 42

5.3. Intersection

Shape Partitioning

If no coplanarity is detected, the intersection points are calculated by computing the signed distance between each vertex of fT and the supporting plane of fC . Subsequently, tetrahedron edges which contain intersection points are identified by applying the techniques of Section 4.1. The intersection points are calculated using Equation 4.4. Since only the intersection with the supporting plane of fC was calculated, it has to be verified whether intersection points lie on the face fC . This is accomplished using Equation 5.4. The pseudo-code below illustrates the complete method: Triangle Intersection compute_intersection_noncoplanar( part. shape face fC , tetra face fT ) PC = plane( fC ) //determine side of plane for each vertex Vi of fT //by calculating the signed distances side_of_plane(V0 , . . . , V3 ) = determine_side( fT , PC ) for( ∀ edges edgefT of fT ) if ( edgefT is not split by PC ) //no intersection points but marked vertices which //lie on fC can occur if intersection points //coincide with tetrahedron vertices for( ∀ vertices VedgeT of edgefT ) //check if Vi lies on fC //using Equation 5.4 if ( inside( VedgeT , fC ) ) mark vertex and store supporting plane of the partitioning shape face in the shape partitioning attribute of the vertex endif endfor else //no coplanarity - intersection point //calculations are performed pk = calculate_intersection( edgefT , PC ) check if intersection points are already calculated which is described in Section 5.4. Otherwise pk is inserted into the hash table endif endfor end

43

5.3. Intersection

Shape Partitioning

compute_intersection_coplanar( part. shape face fC , tetra face fT ) PC = plane( fC ) for( ∀ vertices Vi of fT ) //check if VedgeT lies on fC //using Equation 5.4 if ( inside( Vi , fC ) ) mark vertex and store supporting plane of the partitioning shape face in the shape partitioning attribute of the vertex endif endfor end overlap( part. shape face fC , tetrahedron face fT ) PC = plane( fC ) //Separating axes test (cf. Section 5.1) → compute_interval( PC .− n , minT , maxT ) //quick check if ( !interval_overlap( PC .const, minT , maxT ) ) return no overlap endif //test coplanarity inside ²-environment PT = plane( fT ) − → → → → → → if ( h PT .→ n × PC .− n , PC .− n i < h PC .− n , PC .− n i · hPT .− n , PT .− n i · ²m ) //not coplanar //Separating axes test → compute_interval( fC , PT .− n , minC , maxC ) if ( !interval_overlap( PT .const, minC , maxC ) ) return no overlap endif for( ∀ edges edgeC , edgeT of fT , fC ) //Separating axes test compute_interval( fC , edgeC × edgeT , minC , maxC ) compute_interval( fT , edgeC × edgeT , minT , maxT ) if ( !interval_overlap( minC , maxC , minT , maxT ) ) return no overlap endif endfor compute_intersection_noncoplanar( fC , fT ) return overlap

44

5.4. Consistent Intersection Point Propagation

Shape Partitioning

else //coplanar for( ∀ edges edgeC of fC ) //Separating axes test → compute_interval( fC , PC .− n × − → compute_interval( fT , PC . n × if ( !interval_overlap( minC , return no overlap endif endfor for( ∀ edges edgeT of fT ) //Separating axes test → compute_interval( fT , PT .− n × if ( !interval_overlap( minC , return no overlap endif endfor

edgeC , minC , maxC ) edgeC , minT , maxT ) maxC , minT , maxT ) )

edgeT , minT , maxT ) maxC , minT , maxT ) )

compute_intersection_coplanar( fC , fT ) return overlap endif end

5.4

Consistent Intersection Point Propagation

In contrast to the plane partitioning algorithm, the intersection point calculations of the shape partitioning algorithm are more complex. Since a partitioning shape can intersect a single tetrahedron several times, different configurations arise which must be verified in order to guarantee mesh consistency. Therefore, the hash table described in Section 4.2 has to be extended, being able to store additional information and handle multiple intersection points per tetrahedron edge. The hash function introduced in Section 4.2 is used and extended by the following values: • An identifier of the partitioning shape face fC which intersects a tetrahedron edge (pi , pj ) in the current intersection point pk . This is usually an integer value which represents the simplex index. • The vertex indices of the edge of fC if the intersection point lies on this edge. • The vertex index of the point of fC if pk coincides with this vertex. 45

5.4. Consistent Intersection Point Propagation

Shape Partitioning

• A corner with shape partitioning attributes where the vertex index of the intersection point and the supporting plane of fC are stored. • The parameter t given by the parametric representation of pk : pk = pi + t(pj − pk ). An ordinary hash table with the ability to store objects which are hashed to equal values in the table, is organized in buckets (usually implemented by using a linked list). The buckets are extended to so-called sorted bucket where entries of a single tetrahedron edge, which are always hashed to the same bucket, are sorted in ascending order by the stored parameter t (i.e. multiple intersection points per edge). The buckets are kept in correct order using insertion sort with the following sort criteria: 1. Ui < Vi 2. Uj < Vj 3. tU < tV where (Ui , Uj ) and (Vi , Vj ) are the key values of two items being compared. tU and tV denote the parameters defined by the parametric representation of the intersection points. Assuming no numerical errors, the sort criteria can always identify the smaller object uniquely since parameters tU and tV cannot be equal if Ui = Vi and Uj = Vj (two different intersection points which share an edge cannot have equal parameters). The edge indices Vi and Vj must be swapped if Vi < Vj is not fulfilled (cf. Section 4.2). In this case, parameter t has to be inverted (i.e. t = 1 − t) since the start- and end-point of the edge are swapped. An example where an edge with multiple intersection points is added to the hash table is given in Figure 5.5: in Figure 5.5(a) a tetrahedron face is intersected by partitioning shape faces. Tetrahedron edge (0, 1) contains three intersection points. This edge is hashed to a bucket which already contains a tetrahedron edge (16, 17), hashed to the same value through hash collision (see Figure 5.5(b)). Based on the sort criteria, edge (0, 1) is inserted before edge (16, 17) in the linked list of the bucket. In addition, the entries of (0, 1) are sorted in ascending order by the parameter t.

46

5.4. Consistent Intersection Point Propagation

Shape Partitioning

2

1

t = 0.7 t = 0.4

0 t = 0.2

(a) Tetrahedron face (0, 1, 2) is intersected by partitioning shape faces (represented as red lines). Intersection points of edge (0, 1) with corresponding parameter t are given.

hash entry hash(0,1)

sorted bucket

collision

hash(16,17) edge = (0,1) corner storing cut shape face plane t = 0.2

edge = (0,1) corner storing cut shape face plane t = 0.4

edge = (0,1) corner storing cut shape face plane t = 0.7

edge = (16,17) corner storing cut shape face plane t = 0.4

same edge, sorted by parameter t (b) Each hash entry consists of a sorted bucket, storing items which are hashed to the same value. Edge (0, 1) contains three intersection points according to Figure (a), thus the entries for edge (0, 1) are sorted in ascending order by the parameter t.

Figure 5.5: An example of a tetrahedron face which is intersected by the partitioning shape is shown in Figure (a). The corresponding hash table is organized in buckets and shown in Figure (b).

47

5.5. Subdivision

Shape Partitioning

In order to ensure mesh consistency and to avoid degeneracies, each intersection point must be inserted in the hash table only once. Three possible cases can arise if splitting a tetrahedron face with a partitioning shape face (concerning the propagation of intersection points to adjacent faces): • If a new intersection point pk lies on a single partitioning shape face (see Figure 5.6(a)), then pk is only shared by adjacent tetrahedra faces. A comparison of the partitioning shape face identifier with stored hash table values of the current tetrahedron edge is sufficient to verify that pk was already calculated. If no appropriate value is found, the intersection point and the partitioning shape face identifier are stored in the hash table. • If the intersection point pk lies on an edge shared by two partitioning shape faces (see Figure 5.6(b)) then additionally, the vertex indices of the affected partitioning shape edge must be compared with corresponding hash table values. Storing the indices of the partitioning shape edge which contains pk in the hash table is sufficient to determine that the intersection point was already calculated for a specific tetrahedron edge. • Otherwise, if pk coincides with a vertex of the partitioning shape face, then this vertex index is stored in the hash table as well. Subsequently, the stored index is compared to indices of coinciding vertices of partitioning shape faces (for the current tetrahedron edge) to determine that the intersection point was already calculated. Currently, relative error bounds are used to avoid floating point inconsistency during the propagation (the relative error scales with the values of the operands). Since the verifications described above can be implemented by using orientation tests, geometric predicates can be used to ensure exact calculations (see Section 6.1).

5.5

Subdivision

After calculating all intersection points for each tetrahedron, a data structure which provides comfortable intersection point management for the subdivision is required. Additionally, the subdivision has to be extended since ten symmetrical different cases can arise when a tetrahedron is intersected by a partitioning shape. Finally, a technique is introduced which is able to assign subdivided tetrahedra to the inside or outside entity in a robust way.

5.5.1

Edge Iterator

Since a subdivision of a tetrahedron which contains multiple intersection points per edge can be performed in an iterative way, an edge iterator is introduced: the edge iterator uses hash table information to store an arbitrary number of edges and provides the correct intersection points in each iteration. The initial intersection point for an edge (Vi , Vj ) is 48

5.5. Subdivision

Shape Partitioning

(a) The intersection point lies on a single partitioning shape face.

(b) The intersection point lies on an edge shared by two partitioning shape faces.

(c) The intersection point coincides with an edge end-point of the partitioning shape face.

Figure 5.6: Three possible cases can arise if splitting a tetrahedron face with a partitioning shape face (concerning the propagation of intersection points to adjacent faces).

found by determining the first occurrence of (Vi , Vj ) in the sorted bucket of the hash table. Since all intersection points of (Vi , Vj ) are sorted in ascending order by the parameter t, this method chooses the point with minimal t. This intersection point represents the vertex with the minimum distance to the start-point Vi . The edge iterator E works as follows: given a tetrahedron defined by vertices V0 , . . . , V3 (see Figure 5.7(a)), E creates edges (Vi , Vj ) ∀ i, j : i = 0, 1, 2; j = 1, 2, 3 and j > i. The initial state of E shown in Figure 5.7(d) stores the original edge information of the tetrahedron and provides the intersection point with minimal distance to the start-point of the edge. A bit vector is used to determine edges which contain current intersection points. According to the bit vector, reflecting the current splitting case, the subdivision is accomplished as stated in Figure 5.7(c). Subsequently, E is iterated in order to provide new edge information (i.e. new intersection points). Each former intersection point becomes the new start-point of the edge. The new intersection point is easily determined by increasing the previous positions in the hash table (see Figure 5.7(e)). For the subdivision, outlined in Figure 5.7(c), either completely new edges (i.e. former diagonals) or edges which are specified by iterating E are created. Therefore, E has the ability to return a new edge iterator which is based on a subdivided tetrahedron: it consists of a subset of current edges in E and new edges which are defined by the tetrahedron (see Figure 5.7(f)). Subsequently, each new edge iterator is used for further subdivisions. The iteration is repeated until no edge iterators with existing intersection points are found, i.e. the bit vector is empty. Formally, the edge iterator is defined as follows: An edge iterator E acts as a state machine and provides state-specific hash table information for a given tetrahedron. Let V0 , . . . , V3 be the indices of the tetrahedron points 49

5.5. Subdivision

Shape Partitioning

and Sl the l-th state: l = 0, . . . , n where n = max(Ni,j ) ∀ i, j : i = 0, 1, 2; j = 1, 2, 3 and j > i. Ni,j denotes the number of intersection points of edge (Vi , Vj ). • The edges of the initial state S0 are defined as: edge(V i,V j) (S0 ) = (Vi , Vj ) ∀ i, j : i = 0, 1, 2; j = 1, 2, 3 and j > i. • The state transition Sl → Sl+1 is defined as: edge(V i,V j) (Sl+1 ) = (I(V i,V j) (Sl ), Vj ) ∀ i, j : i = 0, 1, 2; j = 1, 2, 3 and j > i, if I(V i,V j) (Sl ) exists. • The edge iterator provides the following functions in each state Sl : Bitvector returns a bit vector required to determine edges which contain intersection points in the current state. A bit is set, if the corresponding edge contains an intersection point. Intersection point[ (Ui , Uj ) ] returns the intersection point of edge (Ui , Uj ) with minimal distance to the current start-point Ui . For clarity, this start-point is not the initial start-point of the tetrahedron edge but the start-point in the current state. Iterate iterates each edge of E, i.e. the state transition Sl → Sl+1 is performed. Subset[ tetrahedron T ] creates a new edge iterator based on the edges of T . Iterator positions of the current edge iterator E are inherited for those edges which are found in E.

50

5.5. Subdivision

Shape Partitioning

V3

V3

V3

I3 V2

V2

I1

I5 I2

V1

(a) Original triangle to subdivide.

V2

I1

I2 V1

I3

I4

V1

(b) The edge iterator of Figure (d) is used to subdivide the original triangle.

(c) Final subdivision after two steps. The iterators of Figure (f) were used.

V3 I3

V3

V3 V2

I4 I3

I3

I4

V2

I1

I5 I2

V1 (d) Initial state of the edge iterator according to the triangle of Figure (a).

V2

I1

(e) Schema of the edge iterator state transition from state 0 to state 1.

I5 I2 (f) New edge iterators, which consist of existing iterator edges and new edges, are provided for each triangle of Figure (b).

Figure 5.7: Iterative tetrahedra subdivision with multiple intersection points per edge, simplified shown as a triangle subdivision. Figure (a) to Figure (c) show the iterative subdivision and Figure (d) to Figure (f) the corresponding edge iterator state. Red edges are currently contained in the edge iterator data structure and current intersection points are marked green.

5.5.2

Iterative Subdivision

Assuming one intersection point per edge, ten symmetrical different cases are required for the subdivision (shown in Table 5.1). Depending on the faces which intersect the tetrahedron, four of the ten configurations are divided into sub-cases. However, similar to plane partitioning, only prisms, pyramids and tetrahedra are created by the subdivision. Methods for consistent splitting of prisms and pyramids into tetrahedra are detailed in Section 4.3. The complete subdivision of a tetrahedron is initialized by setting up the edge iterator. By using the bit vector of the edge iterator, the first subdivision case is identified. A lookup table is used to determine how to rotate or flip the vertices to fit the default orientation. 51

5.5. Subdivision

Shape Partitioning

This lookup table maps the bit vector, which can represent 26 subdivision cases, to one of the ten symmetrical different subdivision configurations. Therefore, the vertex indices and edges of each tetrahedron are re-ordered according to the default orientation of the specific case. During the subdivision process the regularity regarding the assignment of subdivided tetrahedra to the correct entity has to be preserved. A tetrahedron which is created during the subdivision is regular if its vertices are marked according to the current subdivision case of Table 5.1 and the corners of the tetrahedron permit a unique assignment to the inside or outside of the partitioning shape. A unique assignment is possible if all unmarked vertices of the tetrahedron lie on the same side of the partitioning shape’s supporting plane. Let us assume that the original tetrahedron is regular: thus, the subdivided tetrahedra can be correctly assigned to the appropriate entity in the first iteration. Subsequently, subdivided tetrahedra are assigned to the entities according to the plane which is stored in the marked vertices (and intersection points), until regularity is violated. All newly created tetrahedra are then assigned to the entity of the last regular tetrahedron. The case where no assignment is possible is handled correctly as well (e.g. a tetrahedron with only marked vertices). In contrast, another strategy to find correspondences has to be chosen if the initial tetrahedron violates regularity: the complete iterative subdivision is performed without the assignment of subdivided tetrahedra to entities. In this case, the affiliation to an entity is determined by the region detection algorithm of Section 5.6 which classifies all remaining tetrahedra of the volumetric mesh. This is a simple approach for gaining robustness concerning the assignment of subdivided tetrahedra to the correct entity. Techniques for improved robustness yield more exact partitions. Examples of the regularity verification process can be observed in Figure 5.8 (for the triangle case): the first example shows an exact assignment of subdivided triangles to the inside and outside entity of the partitioning shape (see Figure 5.8(a) to Figure 5.8(c)). The initial triangle, which is intersected by the partitioning shape, is shown in Figure 5.8(a)). After the first subdivision step, triangles 41 = (V1 , V2 , I1 ), 42 = (V2 , I1 , I2 ), and 43 = (I1 , I2 , V3 ) are created (shown in Figure 5.8(b)). The normal vectors of the partitioning shape faces, which are stored in corners I1 and I2 , permit a unique assignment of each created triangle to the green or blue entity. Triangle 43 contains additional intersection points and therefore another subdivision is applied (see Figure 5.8(c)). Finally, triangles 44 = (I1 , I2 , I3 ), 45 = (I2 , I3 , I4 ), and 46 = (I3 , I4 , V3 ) are assigned to the appropriate entities. Triangle 46 is regular and assigned to the outside entity according to the normal vectors stored in I3 and I4 . Triangles 44 and 45 only consist of marked vertices, thus no unique assignment to an entity can be accomplished. Therefore, 44 and 45 are assigned to the entity of the last regular triangle 42 . Cases can arise where no exact assignment to entities is possible at all (see Figure 5.8(d) to Figure 5.8(f)): according to the intersection of the partitioning shape in Figure 5.8(d), 52

5.5. Subdivision

Shape Partitioning

triangles 41 = (V1 , I1 , I2 ), 42 = (I2 , V2 , V3 ), and 43 = (I1 , I2 , V3 ) are created after the first subdivision (shown in Figure 5.8(e)). In the final subdivision, triangles 44 = (I1 , I2 , I3 ), 45 = (I2 , I3 , V3 ), 46 = (I2 , V4 , V3 ), and 47 = (I4 , V2 , V3 ) are created. Whereas triangle 44 and 47 are assigned correctly according to the stored normal vectors, 45 and 46 violate regularity since unmarked tetrahedron points lie on different sides of the stored plane. Therefore, 45 and 46 are assigned to the inside entity according to the last regular triangles 42 and 43 , resulting in a more approximative partitioning operation. V3

V3 V2

V3 V2

I3

V2 I1

I4

I1 I2

I2

V1

V1

(a) The initial triangle which is intersected by the partitioning shape.

V

(b) Assignment to entities after the first subdivision.

V3

(c) Assignment to entities after the second (final) subdivision.

V3

I3

V3 I4

I1

I1

V1

I2

V1

V2 (d) The initial triangle which is intersected by the partitioning shape.

V2

(e) Assignment to entities after the first subdivision.

I2

V1 V2

(f) Assignment to entities after the second (final) subdivision.

Figure 5.8: A subdivided triangle is assigned to two different entities according to the partitioning shape normals (denoted as green and blue colored triangles). Figure (a) to Figure (c) show an exact assignment whereas Figure (d) to Figure (f) outline a case where irregular subdivisions occur.

The iterative subdivision is initialized for each original tetrahedron which contains intersection points. Tetrahedra which require further subdivision are added to a temporary container data structure L. The container is processed iteratively until all tetrahedra are completely split. This approach is more efficient than a recursive algorithm.

53

5.5. Subdivision

Shape Partitioning

The iterative subdivision method is outlined as follows: Iterative Subdivision subdivide_iterative( tetrahedron T , edge iterator E ) subdivision_case = lookup_table( E.bitset() ) subdivide T according to subdivision_case into Ti for ( ∀ subdivided tetrahedra Ti ) //determine entity of Ti only if the // partitioning operation is regular if ( tetrahedron of the first iteration is regular ) if ( current tetrahedron T is regular ) //check if the subdivision is correct using //the supporting planes of the partitioning shape faces //which are stored in the shape partitioning attributes //of the marked vertices. if ( Ti is regular ) //determine the side of Ti Ti .entity = determine_side( Ti ) else //assign the last regular entity Ti .entity = T .entity endif else //otherwise the entity of T is used Ti .entity = T .entity Ti .regular = false endif else Ti .regular = false endif

//create the new edge iterator subset = E.subset( Ti ) //increment iterator subset.increment_state() if ( subset contains edges with intersection points ) //add Ti for further subdivision to //the temporary container L L.add( Ti , subset ) else if ( tetrahedron of the first iteration is regular ) //mark seed vertices (see Section 5.6)

54

5.5. Subdivision

Shape Partitioning

if ( Ti is assigned to inside ) for ( ∀ unmarked vertices Vi ) Vi .seedVertex = true endfor endif endif orient( Ti ) //add to simplex container S S.add( Ti ) endif endfor end

V4

Case 1 Marked vertices of tetrahedron: V1 , V2 Subdivisions: 44 (V1 , V2 , V4 , I(V 3,V 4) ) 44 (V1 , V2 , V3 , I(V 3,V 4) )

V3

V2

V1 V4

Case 2 Marked vertices of tetrahedron: V1 Subdivisions: 44 (V1 , V2 , V4 , I(V 3,V 4) ) 45 (V2 , I(V 2,V 4) , I(V 3,V 4) , V3 , V1 )

V3

V2

V1 V4

Case 3 Subdivisions: 44 (I(V 1,V 4) , I(V 2,V 4) , I(V 3,V 4) , V4 ) 46 (V1 , V2 , V3 , I(V 1,V 4) , I(V 2,V 4) , I(V 3,V 4) )

V3

V1

V2

55

5.5. Subdivision

Shape Partitioning V4

Case 4 Subdivisions: 46 (V1 , I(V 1,V 3) , I(V 1,V 2) , V4 , I(V 3,V 4) , I(V 2,V 4) ) 46 (I(V 1,V 2) , I(V 2,V 4) , V2 , I(V 1,V 3) , I(V 3,V 4) , V3 )

V3

V2

V1 V4

Case 5 Marked vertices of tetrahedron: V2 , V1 (yellow), V3 (green) Subdivisions: 44 (V1 , V2 , I(V 1,V 3) , I(V 2,V 4) ) 44 (V2 , V3 , I(V 1,V 3) , I(V 2,V 4) ) 44 (V1 , V4 , I(V 1,V 3) , I(V 2,V 4) ) 44 (V3 , V4 , I(V 1,V 3) , I(V 2,V 4) )

V3

V2

V1 V4

Case 6 Subdivisions: 44 (V1 , V2 , I(V 2,V 3) , I(V 2,V 4) ) 44 (V1 , I(V 2,V 3) , I(V 2,V 4) , I(V 3,V 4) ) 44 (V1 , V3 , I(V 2,V 3) , I(V 3,V 4) ) 44 (V1 , V4 , I(V 2,V 4) , I(V 3,V 4) )

V3

V2

V1 V4

Case 7 Marked vertices of tetrahedron: V2 (yellow), V4 (green) Subdivisions: 44 (V2 , V4 , I(V1 ,V2 ) , I(V 3,V 4) ) 45 (I(V1 ,V4 ) , V1 , V3 , I(V3 ,V4 ) , I(V1 ,V2 ) ) 45 (I(V1 ,V4 ) , V4 , V2 , I(V1 ,V2 ) , I(V3 ,V4 ) )

V3 V1

V2

56

5.6. Region Detection - Inside/Outside Determination

Shape Partitioning V4

Case 8 Subdivisions: 44 (I(V 1,V 4) , I(V 2,V 3) , I(V 2,V 4) , I(V 3,V 4) ) 44 (V4 , I(V 1,V 4) , I(V 2,V 4) , I(V 3,V 4) ) 45 (I(V 1,V 4) , V1 , V3 , I(V 3,V 4) , I(V 2,V 3) ) 45 (I(V 1,V 4) , I(V 2,V 4) , V1 , V2 , I(V 2,V 3) )

V3

V2

V1 V4

Case 9 Subdivisions: 44 (V1 , I(V 1,V 2) , I(V 1,V 3) , I(V 1,V 4) ) 44 (V4 , I(V 1,V 4) , I(V 2,V 4) , I(V 3,V 4) ) 45 (I(V 1,V 2) , I(V 2,V 4) , I(V 3,V 4) , I(V 1,V 3) , I(V 1,V 4) ) 46 (I(V 1,V 2) , I(V 2,V 4) , V2 , I(V 1,V 3) , I(V 3,V 4) , V3 )

V3

V2

V1 V4

Case 10 Subdivisions: 44 (V1 , I(V 1,V 2) , I(V 1,V 3) , I(V 1,V 4) ) 44 (V2 , I(V 1,V 2) , I(V 2,V 3) , I(V 2,V 4) ) 44 (V3 , I(V 1,V 3) , I(V 2,V 3) , I(V 3,V 4) ) 44 (V4 , I(V 1,V 4) , I(V 2,V 4) , I(V 3,V 4) ) 45 (I(V 1,V 3) , I(V 2,V 3) , I(V 2,V 4) , I(V 1,V 4) , I(V 1,V 2) ) 45 (I(V 1,V 4) , I(V 2,V 4) , I(V 2,V 3) , I(V 1,V 3) , I(V 3,V 4) )

V3

V1

V2

Table 5.1: Possible intersections of a tetrahedron and a partitioning shape are shown. Marked vertices and subdivisions into primitives for each case are given. Intersection points are colored red; red-black points denote tetrahedron vertices which lie on a partitioning shape face. Red colored faces denote partitioning shape faces which are required according to the configuration of the intersection points. Either yellow or green colored faces are required in some cases to guarantee that the tetrahedron is split completely. Respectively, yellow-black or green-black points must lie on the partitioning shape face.

5.6

Region Detection - Inside/Outside Determination

Since a partitioning shape divides the tetrahedral mesh into two parts, intersected tetrahedra form a connected border which separates the mesh. Tetrahedra which were created during the subdivision are already assigned to the correct entity. Therefore, so-called seed vertices can be set for a complete assignment (see Figure 5.9(a)). A seed vertex is a point 57

5.6. Region Detection - Inside/Outside Determination

Shape Partitioning

of a ”touched” (coplanar case) or completely subdivided tetrahedron which is assigned to the inside entity and is not marked. Since it is not marked, a seed vertex is located in the inside of the partitioning shape and does not lie on a partitioning shape face. After the subdivision is completed (which stores potential seed vertices as well), a propagation algorithm is applied to assign appropriate tetrahedra to the inside entity. The vertex-simplex connection VSC is used to locate all tetrahedra which do not belong to the border but contain seed vertices. Based on seed tetrahedra, adjacent tetrahedra, which are not assigned to any entity at all, are propagated using the simplex-simplex connection SSC and are assigned to the inside entity (see Figure 5.9(b)). The propagation is implemented using a stack data structure where all unassigned neighbors of the currently processed tetrahedron are pushed on the stack for further propagation. Each tetrahedron, which is not assigned to the inside entity after the propagation and does not belong to the border, corresponds to the outside entity (see Figure 5.9(c)). Therefore, this approach assigns every tetrahedron of the mesh to an entity in O(n) time.

58

5.7. Algorithm Outline

Shape Partitioning

(a) Border simplices are assigned to the correct entities and seed vertices (marked red) are stored.

(b) The seed vertices are used to assign adjacent simplices, which do not belong to the border, to the inside entity.

(c) Finally, simplices which do not belong to any entity are assigned to the outside entity.

Figure 5.9: Outline of the region detection algorithm. For simplicity, the tetrahedral mesh is shown as a triangular mesh and the partitioning shape is represented as red lines. The inside and outside entities are colored blue and green.

5.7

Algorithm Outline

The shape partitioning algorithm is divided into several parts, corresponding to the sections before. In the first step the octree is set up which is used for the collision detection of partitioning shape faces and tetrahedra. After identifying overlapping faces, exact intersection point calculations are applied. Subsequently, all tetrahedra are subdivided in an iterative way. Possible seed points of subdivided tetrahedra are stored for later use. In the last step remaining tetrahedra are assigned to the inside or outside entity. The overall runtime of the algorithm is O(n · log m), where n and m denote the sizes of the volumetric mesh and the partitioning shape, respectively. The pseudo-code is given as follows: Shape Partitioning Algorithm shape_cut( volumetric mesh M3 , cut shape M2 ) octree.build( M2 ) //test all tetrahedra against the octree

59

5.7. Algorithm Outline

Shape Partitioning

for ( ∀ tetrahedra T ∈ M3 ) candidates = octree.find_candidates( T ) for ( ∀ candidates ci ) //The intersection points are calculated //if an exact overlap is detected. if ( exact intersection of T and ci ) calculate_intersection( T , ci ) endif endfor endfor for ( ∀ tetrahedra T ∈ M3 ) //mark T as deleted delete( T ) //initialize edge iterator E E.initialize( T ) if ( E contains edges with intersection points ) //required for region detection: //add T to the border which separates //the inside and outside entity. border.add( T ) //start iterative subdivision subdivide_iterative( T , E ) else //Potentially, an assignment to an entity is possible //if marked vertices occur (coplanar cases) if ( a vertex of T is marked ) if ( T can be assigned to the inside entity ) for ( ∀ unmarked vertices Vi ) //mark as seed vertices (see Section 5.6) Vi .seedVertex = true endfor endif endif endif endfor Find inside and outside entities for the remaining tetrahedra by applying the region detection algorithm end

60

Chapter 6 Mesh Improvement Several algorithms related to the topic of partitioning and cutting volumetric meshes can be employed to improve the quality of partitioning results. The presented partitioning algorithms use robust floating point arithmetic based on relative error bounds or similar techniques in order to avoid roundoff errors and mesh inconsistency. In contrast to absolute error bounds, the relative error scales with the values of the operands. However, the calculations are not exact. The first section of this chapter describes an exact floating point arithmetic. In addition, the calculation of error bounds to determine whether exact arithmetic has to be used, is covered (so-called adaptive method). The second problem is concerned with mesh quality. Badly shaped tetrahedra are potentially generated by the subdivision process. Therefore, mesh smoothing or simplification techniques may be performed in a post-processing step in order to remove degeneracies.

6.1

Floating Point Consistency

The propagation algorithm of the shape partitioning technique is based on geometric tests which use vector algebra. For instance, orientation tests determine the position of a point relative to a plane or line segment based on the sign of a determinant. The IEEE 64-bit floating point standard provides 16 decimal bits accuracy. Due to the finite representation of the standard, roundoff errors can occur. These roundoff errors can lead to incorrect results and furthermore to mesh inconsistency if ordinary floating point precision is used. Using exact arithmetic for all calculations is runtime-expensive and unacceptable for interactive partitioning operations. Therefore, an adaptive algorithm is the best choice, using ordinary floating point computations while switching to exact arithmetic if the roundoff error exceeds an error bound. Shewchuk [56, 57] provides fast algorithms for exact addition, subtraction, and multiplication of arbitrary precision floating point values which rely on the multiple-term format (cf. Section 2.5). Additionally, a technique for adaptive precision calculation, which has

61

6.1. Floating Point Consistency

Mesh Improvement

to satisfy an error bound, is introduced. Adaptive algorithms improve the runtime significantly. Both methods are described below.

6.1.1

Exact Floating Point Arithmetic

Most modern processors support floating point numbers of the form ±significant × 2exp where significant is a binary number of length l. One additional bit is stored, representing the sign. Exact arithmetic requires a format which is able to store more than l bits. Therefore, Shewchuk introduced a multiple-term format where the sum of multiple floating point numbers is used to achieve arbitrary precision. An arbitrary precision value is expressed as an expansion x = xn + · · · + x2 + x1 , where each xi is called a component and is represented by a floating point value with a l-bit significant. Components of an expansion have to be non-overlapping and ordered by magnitude (x1 smallest, xn largest). Two floating point values x and y are non-overlapping if the least significant non-zero bit of x is more significant than the most significant nonzero bit of y. For instance, binary representation of floating point numbers 1100 and −10.1 are non-overlapping whereas 101 and 10 overlap. Zero does not overlap any number. An expansion is non-overlapping if no pairwise overlapping of components occurs. Nonoverlapping expansions have several advantages: it is efficient to determine the sign of the expansion (use the sign of the largest component), and approximative results can easily be calculated (use the component with the largest magnitude). In contrast to multiple-digit algorithms which avoid roundoff errors, the described algorithms do permit roundoff errors which are corrected after the actual computation. Additionally, the conversion of floating point numbers to an internal representation is not required. Therefore, the presented algorithms rely on floating point operations with exact rounding: if rounding is required, the result is rounded to the nearest l-bit floating point number. For instance, the product 111 × 101 = 100011 is rounded to 1.001 × 25 in 4 bit arithmetic. If a value falls precisely between two l-bit values, another rule is used to guarantee consistent rounding. The IEEE floating point standard specifies the round-to-even rule where the value is rounded to the nearest l-bit value with an even significant. The symbols ⊕, ª, and ⊗ denote addition, subtraction and multiplication with exact rounding. error(a ◦ b) denotes the roundoff error of a given operation on a and b. ² represents an error bound of the relative error error(a◦b) and is called machine-². a◦b 6.1.1.1

Addition

The addition of two l-bit values (forming an expansion of length two) is an important operation and is used for performing additions and multiplications of expansions.

62

6.1. Floating Point Consistency

Mesh Improvement

Let a and b be l-bit floating point numbers where l ≥ 3. Then the following algorithm, introduced by Knuth [41], will produce a non-overlapping expansion x+y such that a+b = x + y: Two-Term Addition two_sum( a, b ) x = a ⊕ b bvirtual = x ª a avirtual = x ª bvirtual broundof f = b ª bvirtual aroundof f = a ª avirtual y = aroundof f ⊕ broundof f return (x, y) end

Similarly, the two-term subtraction is introduced. The following algorithm will produce a non-overlapping expansion x − y such that a − b = x − y: Two-Term Subtraction two_diff( a, b ) x = a ª b bvirtual = a ª x avirtual = x ⊕ bvirtual broundof f = bvirtual ª b aroundof f = a ª avirtual y = aroundof f ⊕ broundof f return (x, y) end

In the two-term addition algorithm x = a ⊕ b computes a + b with a possible rounding error error(a ⊕ b). Calculations of avirtual and bvirtual , the values which are added to a and b in fact, are exact according to the proof by Shewchuk [57, p. 8 ]. Additionally, it is proven that aroundof f and broundof f are calculated without a rounding error. Therefore, y = −error(a ⊕ b), x = a + b + error(a ⊕ b), and a + b = x + y. Finally, Shewchuk [57] presented three algorithms with different asymptotic runtime for adding an m-component expansion to an n-component expansion.

63

6.1. Floating Point Consistency

Mesh Improvement

The algorithm is able to accomplish the addition in O(n + m) time (outlined in Figure 6.1(a)): Pm Pn Let e = i=1 ei and f = i=1 fi be non-overlapping expansions of m and n l-bit components (ordered by ascending magnitude).PThen the following algorithm will produce m+n a non-overlapping expansion h such that h = i=1 hi = e + f , where the components hi are also ordered by ascending magnitude except that any of the hi may be zero. Fast Expansion-Sum fast_expansion_sum( e, f ) //merge e and f into a sequence g //in order of non-descending magnitude. while ( i != n + 1 and j != m + 1 ) gk = min(|ei |, |fj |) increment indices according to the chosen value endwhile ( Q2 , h1 ) = two_sum( g2 , g1 ) for ( i = 3 to m + n ) ( Qi , hi−1 ) = two_sum( Qi−1 , gi ) endfor hm+n = Qm+n return h end

Qi is an approximative sum (with possible roundoff errors) of the first i elements of g. |xi | denotes the magnitude of a component xi . A shared characteristic of the algorithms is the presence of zero components in the output expansion even if no zeros occur in the input expansion. Since zero terms, which can occur in expansions, slow down the computations significantly, it is important to perform zero elimination. 6.1.1.2

Multiplication

Similarly to the addition, a non-overlapping expansion equal to the multiplication of two l-bit values is required. The multiplication is performed by splitting each value into two equal parts with half precision and by applying four exact multiplications on the partitions.

64

6.1. Floating Point Consistency

Mesh Improvement

Let a be a l-bit floating point number, where l ≥ 3. The following algorithm will produce a b 2l c-bit value ahigh and a (d 2l e − 1)-bit value alow such that |ahigh | ≥ |alow | and a = ahigh + alow . Splitting Algorithm split(a) l c = (2d 2 e + 1) ⊗ a abig = c ª a ahigh = c ª abig alow = a ª ahigh return( ahigh , alow ) end

The length of ahigh and alow is l − 1 although the initial value had a significant of length l. This can be achieved by using the sign bit of alow . For instance, the seven-bit number 1001001 is split into ahigh = 1010000 and alow = −111. Therefore, even if l is odd, a can always be split into two values ahigh and alow of length b 2l c (for a complete proof see [57, p. 18 ]). The two-term multiplication is performed by splitting a and b into the high- and lowparts according to the splitting algorithm and computing ahigh · bhigh , ahigh · blow , alow · bhigh , and alow · blow which are calculated exactly by the floating point unit. By subtracting them from a ⊗ b in a specific order, the result is the roundoff error. The algorithm is outlined as follows: Let a and b be l-bit floating point numbers, where l ≥ 4. The following algorithm will produce a non-overlapping expansion x + y such that ab = x + y. Two-Term Product two_product( a, b ) x = a ⊗ b ( ahigh , alow ) = split( a ) ( bhigh , blow ) = split( b ) error1 = x ª (ahigh ⊗ bhigh ) error2 = error1 ª (alow ⊗ bhigh ) error3 = error2 ª (ahigh ⊗ blow ) y = (alow ⊗ blow ) ª error3 return( x, y ) end

65

6.1. Floating Point Consistency

Mesh Improvement

By calculating x = a ⊗ b, possible rounding errors can occur and thus x = ab + error(a ⊗ b). Further multiplications are exact (no factor has more than b 2l c bits). Therefore, y = −error(a ⊗ b) and x + y = ab. Finally, an algorithm, which is able to multiply an expansion by a floating point number, is introduced (outlined in Figure 6.1(b)): P Let e = m i=1 ei be a non-overlapping expansion of m l-bit components and let b be an l-bit floating point number, where l ≥ 4. Suppose the components of e are ordered by ascending magnitude (except any Pei is zero). Then the following algorithm will produce a non-overlapping expansion h = 2m i=1 hi = b · e, where the components hi are also ordered by ascending magnitude except that any of the hi may be zero. Scale-Expansion Algorithm scale_expansion( e, b ) ( Q2 , h1 ) = two_product( e1 , b ) for ( i = 2 to m ) ( Ti , ti ) = two_product( ei , b ) ( Q2i−1 , h2i−2 ) = two_sum( Q2i−2 , ti ) ( Q2i , h2i−1 ) = two_sum( Ti , Q2i−1 ) endfor h2m = Q2m return h end

e2

g3

g2 T2

Q2

two sum h2

Q1

two sum

g1

h1

(a) The fast-expansion sum algorithm

Q4

two prod

e1

b

two prod

b

t2

two Q3 two sum sum h2

Q2

h1

(b) The scale-expansion algorithm

Figure 6.1: Work flows of the fast-expansion sum and scale-expansion algorithms.

66

6.1. Floating Point Consistency

6.1.2

Mesh Improvement

Adaptive Precision Floating Point Arithmetic

The two-term algorithms for addition and multiplication can be broken into two parts: one part which performs the actual operation with possible roundoff errors, and a part where the roundoff error is calculated and a correction is applied. This technique, combined with methods which decide whether exact arithmetic is required, improve the runtime significantly. Error analysis or stochastic models can be used for calculating correct error bounds. Computing adaptive error bounds of floating point calculations in geometric tests is a non-trivial task and has to be done specifically for each test (examples are shown in [57, p. 27 et sqq. ]). Any expression can be represented by a so-called expression tree where internal nodes denote operations and leaves consist of floating point operands. Starting at the leaves, the roundoff error of basic floating point operations is estimated and subsequently, an error bound of the expression can be determined. Shewchuk [57] demonstrated this technique by means of four common geometric tests where two are outlined as follows: 6.1.2.1

Orient2D and Orient3D

Three points x = (a0 , a1 , a2 ), y = (b0 , b1 , b2 ) and z = (c0 , c1 , c2 ) are oriented counterclockwise iff the determinant   ax ay 1 det  bx by 1  (6.1) cx cy 1 is positive (see [23, p. 816 ]). A more common interpretation is that Equation 6.1 is positive iff c lies on the left of the directed line segment (a, b). A first error bound, verifying the sign of Equation 6.1, is introduced: let A = α1 ⊕ α2 be the result of Equation 6.1 calculated using ordinary floating point numbers, where α1 = (ax ª cx ) ⊗ (by ª cy ) and α2 = (ay ª cy ) ⊗ (bx ª cx ). Then the sign of Equation 6.1 is correct if |A| ≥ (3² + 16²2 ) ⊗ (|α1 | ⊕ |α2 |) holds, where ² denotes the machine-². Otherwise exact arithmetic has to be applied. Two additional bounds are provided by Shewchuk [57, p. 39 et sqq. ] in order to determine if intermediate results are already exact. Similarly to the 2D-case, the determinant, defined by Equation 4.5, is used to determine the orientation of four points a, b, c, and d (i.e. a tetrahedron). The sign of the determinant is positive iff d lies on the positive side of a plane defined by a, b, and c. The error bound,

67

6.1. Floating Point Consistency

Mesh Improvement

verifying that the calculated sign is correct, is given as follows: let A = α1 ⊕ α2 ⊕ α3 be the result given by Equation 4.5 and calculated using ordinary floating point numbers, where α1 = |az ª dz | ⊗ (|(bx ª dx ) ⊗ (cy ª dy )| ⊕ |(by ª dy ) ⊗ (cx ª dx )|) α2 = |bz ª dz | ⊗ (|(cx ª dx ) ⊗ (ay ª dy )| ⊕ |(cy ª dy ) ⊗ (ax ª dx )|) α3 = |cz ª dz | ⊗ (|(ax ª dx ) ⊗ (by ª dy )| ⊕ |(ay ª dy ) ⊗ (bx ª dx )|). Then the sign of the determinant is correct if |A| ≥ (7² + 56²2 ) ⊗ (α1 ⊕ α2 ⊕ α3 ) holds, where ² denotes the machine-².

6.1.3

Implementation

The most critical parts of the partitioning algorithms concerning consistency are the detection of the correct subdivision case and the propagation of intersection points via the hash table. These methods rely on orientation tests. For this reason, consistency can be achieved by using the geometric predicates introduced by Shewchuk [57]. The plane partitioning algorithm performs a linear traversal of all tetrahedra and determines for each tetrahedron whether it is split by the plane. Based on the position of the tetrahedron vertices relative to the partitioning plane, the corresponding subdivision case is detected and intersection points are calculated. This is accomplished using an orientation test where each tetrahedron vertex is tested against the partitioning plane. Hence, the error bound of Orient3D can be used to determine if exact arithmetic has to be applied. In contrast to plane partitioning, the shape partitioning algorithm calculates all intersection points between the partitioning shape and the volumetric mesh before the tetrahedra are subdivided. Therefore, the correct subdivision case is determined without the use of exact arithmetic. However, the propagation of intersection points is based on floating point calculations. In order to ensure mesh consistency, each intersection point has to be inserted into the hash table only once. Therefore, the algorithm has to detect if the intersection point lies inside a triangular face or on an edge of the triangle. In the first step, Orient3D is used to determine whether an intersection point p lies on the supporting plane of the triangle t. Subsequently, t and p are projected on a primary plane (i.e. xy-, xz-, or yz-plane) to eliminate one dimension, being able to perform 2D orientation tests. However, if the triangle is perpendicular to a primary plane, its projection onto that plane is a line. In order to avoid this case, the primary plane which has the maximum size of projection has to be chosen: thus, the triangle is projected onto the primary plane which is perpendicular to the dominant axis of the triangle’s supporting plane normal vector. The dominant axis is the axis of the coordinate system whose coordinate is the largest → absolute value of the normal vector. For instance, let us assume − n = (1, −2, 0) is the normal vector of t. Therefore, the y-axis is dominant and t and p are projected on the xz-plane. Subsequently, the orientation test Orient2D is applied in order to determine the position of p relative to the faces of the triangle. 68

6.2. Mesh Optimization

6.2

Mesh Improvement

Mesh Optimization

Splitting tetrahedra close to original vertices can lead to flat element creation with either short height, short edges, or large dihedral angles (angle between two supporting planes). Removing these degenerated tetrahedra is important in order to improve the quality of the mesh for further processing or visualization. Two techniques are presented in this section for removing degenerated primitives in a post-processing step after a partitioning operation. The first method is a smoothing technique whereas the second one is based on mesh simplification. Additionally, methods are provided which detect and classify degenerated tetrahedra (see Figure 6.2).

6.2.1

Mesh Smoothing

Most smoothing techniques use an iterative approach which repositions individual vertices to improve the quality of primitives locally. As described in Section 2.4, the most efficient smoothing algorithm is the Laplacian smoother. 6.2.1.1

Laplacian Smoothing

The Laplacian smoothing algorithm, the simplest inexpensive smoother, moves each vertex xi to the arithmetic average x∗i of the neighboring points in each iteration: x∗i =

n X 1 xj , n x ∈Ω , x 6=x j

i

j

(6.2)

i

where Ωi is the set of all 2-simplices which contain xi , determined by using VSC(xi ). n denotes the number of neighboring points. Explicit checks have to be done if inverted or overlapping simplices are generated after the repositioning. 6.2.1.2

Constrained Laplacian Smoothing

Since most averaging methods are heuristic techniques, they can degrade the quality of mesh elements. The Laplacian smoother has the tendency to invert primitives or create degenerated elements especially near concavities. Additionally, if a vertex is part of the mesh boundary (or entity boundary) the movement has to be limited. Therefore, constraints are introduced to control the movement of vertices. Cannan et al. [11] presented a Laplacian smoother which controls the repositioning of vertices based on a given quality metric. This approach is extended in order to smooth tetrahedral meshes.

69

6.2. Mesh Optimization

Mesh Improvement

Distortion metrics are used to determine the quality of mesh primitives. The algorithm is using the following distortion metric to verify the variation of mesh quality locally [11]: Definition of a distortion metric for triangles: The distortion metric µ, used for triangular primitives (i.e. tetrahedron faces), is defined as − → → √ ||− ac × bc|| µ(abc) = I · 2 3 · → − − → , → || ab||2 + ||− ac||2 + || bc||2 where

½ I=

→ 1, hac × bc, − ni ≥ 0 − → −1, hac × bc, n i < 0

− and → n denotes the normal vector of the supporting plane defined by the triangle points a, b, and c. This metric is basically the √area of the triangle 4(a, b, c) divided by the sum of the squared edge lengths.The factor 2 3 is used to normalize µ to 1 if the triangle is equilateral. In order to verify if a repositioning of a vertex xi is acceptable, the following quantities are computed for each triangle of Ωi : • µ: Distortion metrics for the elements of Ωi before (µα ) and after (µβ ) repositioning of xi . • N ↑: Number of elements whose metric increases. • N ↓: Number of elements whose metric decreases. P

• ∆µ: Average metric change N∆µi where ∆µi is the distortion metric change of triangle 4i ∈ Ωi and N is the cardinality of Ωi . • N ↑↑: Number of elements whose metric increases significantly: – Ninv ↑↑: The sign of µ changes from negative to positive (µα < 0 and µβ ≥ 0). – µβ is becoming less negative (µα < µβ < 0). – µβ moves above the minimal acceptable quality limit (µα ≤ µmin and µβ > µmin ). • N ↓↓: Number of elements whose metric decreases significantly: – Ninv ↓↓: The sign of µ changes from positive to negative (µα ≥ 0 and µβ < 0). – µβ becomes more negative (µβ < µα < 0). – µβ drops below the minimal acceptable quality limit (µα > µmin and µβ ≤ µmin ). • θ: The largest angle between any two edges in the element. 70

6.2. Mesh Optimization

Mesh Improvement

Values which are not modified during iteration steps can be cached in order to improve the algorithm’s efficiency. In each iteration the algorithm decides to accept or rule out the movement of each vertex by using the following acceptance test [11, p. 6 et sqq. ]: A repositioning of a vertex xi to x∗i is ruled out if any of the following conditions are true: • Each element has a decreasing metric (N = N ↓). • At least one element is inverted (Ninv ↓↓> 0). • There exist more elements with a significantly decreasing than with a significantly increasing metric (N ↓↓> N ↑↑). • The average metric change is poor (∆µ < µmin ). • At least one element contains an angle greater than a predefined angle (θ > θmax ). If xi is not ruled out, it is accepted if: • Each element has an increasing metric (N = N ↑). • No element has a significantly decreasing metric and at least one element has a significantly increasing metric (N ↓↓= 0, N ↑↑> 0). • There exist more elements with a significantly increasing than with a significantly decreasing metric and the average metric change is sufficient (N ↑↑> N ↓↓, ∆µ > µmin ). Otherwise xi is not accepted and the acceptance test is repeated after the distance ||x∗i −xi || has been halved. The acceptance test is performed until the distance ||x∗i −xi || drops below a certain threshold. If a vertex xi belongs to the mesh or entity boundary, the newly calculated position x∗i is projected onto the boundary of the mesh using Equation 4.7. The normal vector of the projection plane is the average normal vector of the supporting planes in Ωi . The constrained Laplacian smoothing algorithm can be combined with any appropriate optimization-based smoothing technique to improve the refinement. However, according to Cannan et al. [11], only one percent of all vertices require further optimization after Laplacian smoothing was applied. The algorithm, which is applied to the tetrahedral mesh M3 , is outlined as follows: Constrained Laplacian Smoother smooth( set of tetrahedra Msub ⊂ M3 ) //generate vertex list L of Msub L = initialize_list( Msub )

71

6.2. Mesh Optimization

Mesh Improvement

− //precalculate average normal vector → ni //for each vertex defined by the normal vectors //of adjacent faces for ( ∀ vertices xi ∈ L ) − NV.add( xi , → ni ) endfor for ( arbitrary iteration steps ) for ( ∀ vertices xi ∈ L ) //calculate Ωi which is the set of all 2-simplices //containing xi (adjacent faces) Ωi = calculate_faces( VSC(xi ) ) //calculate x∗i according to Equation 6.2 x∗i = laplace( xi , Ωi ) if ( xi belongs to the boundary ) → x∗i = project_on_boundary( x∗i , NV.get( xi , − ni ) ) endif for ( arbitrary iteration steps ) for ( ∀ 2-simplices Si ∈ Ωi ) µi = compute_µ( Si ) endfor //acceptance test if ( ruled out( x∗i ) ) ruled_out = true break out of loop else if ( acceptable( x∗i ) ) accepted = true break out of loop else //halve distance and retry x∗i = xi + 12 (x∗i − xi ) endif endfor if ( ruled_out ) break out of loop else if ( accepted ) if ( distance( xi , x∗i ) < move tolerance δ ) L.remove( xi ) else move( xi , x∗i ) //insert neighbors of xi in L if // not already contained for ( ∀ neighbors xj of xi )

72

6.2. Mesh Optimization

Mesh Improvement

L.add( xj ) endfor endif max_distance = max( max_distance, ||xi , x∗i || ) ) endif endfor if ( max_distance < arbitrary tolerance ) break out of loop if ( is_empty( L ) ) break out of loop endfor end

6.2.2

Mesh Simplification

As mentioned in Section 2.4, optimization algorithms which modify the mesh connectivity are based on either refinement or decimation strategies. Decimation techniques remove points from the mesh while refinement strategies add points. Thus, decimation techniques are more adequate to keep the mesh size small. Most decimation algorithms are based on edge collapsing techniques where specific edges are collapsed to improve the mesh quality. Techniques to identify degenerated tetrahedra and the edges to collapse, a description of several error metrics to control the order of collapses, and an outline of the simplification algorithm are given below. 6.2.2.1

Detection of Degeneracies

Several different measures can be used to evaluate the quality of tetrahedra. Since degenerated tetrahedra either have flat faces, short edges, or large dihedral angles (angle between two supporting planes), the flatness of elements can be quantified by their aspect ratio. Most commonly used is the ratio of the radii of the circumscribed sphere to the inscribed sphere of a tetrahedron [3]. A more appropriate choice concerning efficiency, is to define the aspect ratio as the minimum distance of a tetrahedron point to the opposite face divided by the maximum edge length [51, 49]: Definition of a tetrahedron quality measure: Let T be a tetrahedron defined by vertices p1 , . . . , p4 and Fi be the i − th face of T (Fi = T \ pi ). The supporting plane of Fi is → defined by the normal vector − ni and the distance to the origin di . Then, the aspect ratio is defined as: → minpi ∈T (h− ni , pi i − di ) ratio(T ) = . (6.3) maxpi ,pj ∈T ||pi − pj ||2

73

6.2. Mesh Optimization

Mesh Improvement

The strategy to collapse an edge of a degenerated tetrahedron is determined by the number of large dihedral angles contained [51]: • In elements with a single small solid angle but without any large dihedral angles, so-called needles, the shortest edge is collapsed (see Figure 6.2 (a) to (c)). • In elements containing a single large dihedral angle, so-called spindles, the edge opposite to the large angle is split and the shortest edge is collapsed (see Figure 6.2 (d) to (f)). • In elements with two large dihedral angles, so-called slivers, both edges, where the adjacent faces with large angles meet, are split. The resulting short edge is collapsed (see Figure 6.2 (g) to (i)). • In elements with three large dihedral angles, so-called caps, a new vertex is created on the face opposite to the large angles. The shortest edge is collapsed (see Figure 6.2 (j) to (l)). Otherwise the tetrahedron is either a round tetrahedron or a wedge. However, it is not degenerated and therefore, no edge collapse is required. The dihedral angle between two tetrahedron faces is the angle of the corresponding supporting planes and is calculated as follows: let Pi and Pj be the supporting planes of tetrahedron faces Fi and Fj , respectively. The dihedral angle Θ between Pi and Pj is then defined as: → → cos Θ = h− ni , − nj i → − Θ = cos−1 h− ni , → nj i, → − where − ni and → nj represent the normal vectors of Pi and Pj . 6.2.2.2

Iterative Simplification Algorithm

The mesh simplification algorithm which uses an edge collapsing technique can be divided into the following parts. In the first step, degenerated tetrahedra and their edges to collapse are identified. The degenerated primitives are inserted into the priority queue which is sorted according to a chosen error metric. Several tetrahedra have to be subdivided before the shortest edge is collapsed. Without subdivision, the edge collapse will not improve the element quality of these tetrahedra. The actual subdivision is postponed until the edge collapse is performed. Therefore, a test subdivision applied in order to determine the error before the undivided tetrahedra are added to the queue. Starting with the minimal element in the queue, the edges are collapsed until the error exceeds a predefined errorbound. If the minimal queue element requires subdivision, the splitting is performed and the generated tetrahedra are added to the queue again.

74

6.2. Mesh Optimization

Mesh Improvement

(a) Needle: no large dihedral angle.

(b) Needle: the shortest edge is collapsed (colored red).

(c) Needle: result after the edge collapse.

(d) Spindle: one large dihedral angle (denoted by the red arrow).

(e) Spindle: the edge opposite to the large angle is split and the shortest edge is collapsed (colored red).

(f) Spindle: result after the edge collapse.

(g) Sliver: two large dihedral angles (denoted by the red arrows).

(h) Sliver: both edges containing the large angles are split and the resulting edge is collapsed (colored red).

(i) Sliver: result after the edge collapse.

(j) Cap: three large dihedral angles (denoted by the red arrows).

(k) Cap: the face opposite to the angles is subdivided and the shortest edge is collapsed (colored red).

(l) Cap: result after the edge collapse.

Figure 6.2: Classification of degenerated tetrahedra into needles (Figure (a) to Figure (c)), spindles (Figure (d) to Figure (f)), slivers (Figure (g) to Figure (i)), and caps (Figure (j) to Figure (m)) with given edge collapsing strategy.

75

6.2. Mesh Optimization

Mesh Improvement

Several tasks have to be performed during the edge collapsing process. Topological and geometrical correctness of an edge collapse must be verified. Geometrical correctness is achieved by testing for correct orientation and boundary self-intersection after an edge collapse. An algorithm to avoid local self-intersections is presented in [60]. However, boundary self-intersection is not very frequent [15]. Topological correctness is checked by using a theorem by Dey et al. [19]: let M3 be a tetrahedral mesh without boundary. Dey et al. define the face τ of a n-dimensional simplex σ (specified by the convex hull of n + 1 affinely independent points) as an m-dimensional simplex (0 ≤ m ≤ n), defined by a non-empty subset of the n + 1 points. If τ is a face of a tetrahedron σ, then σ is called co-face of τ . The closure B of a subset B ⊂ M3 is the set of all faces of the simplices in B. The star St(B) of B is the set of all co-faces of the elements in B: St(B) = {σ|τ is a face of σ and τ ∈ B}. The link Lk(B) of B consists of all faces of St(B) that are disjoint from simplices in B: Lk(B) = St(B) − St(B). According to Dey et al. [19], the following theorem is sufficient to verify the topological correctness: Topological correctness of an edge collapse: Let M3 be a tetrahedral mesh without a boundary and M3∗ the corresponding mesh after an edge collapse of edge e = (pi , pj ). Then M3 and M3∗ are homeomorphic iff Lk(pi ) ∩ Lk(pj ) = Lk(e). In order to use this theorem for meshes with boundary, a dummy vertex has to be introduced: for each boundary face of the mesh, a temporary tetrahedron, which is specified by this face and the dummy vertex, is added to the mesh. Examples of a valid and invalid edge collapse concerning topological correctness are shown in Figure 6.3.

b

b y

x

x

z

y

a

a

(a) Topological correctness test: Lk(a) ∩ Lk(b) = {x, y} = Lk(ab) indicates a valid collapse.

(b) Conversely, Lk(a) ∩ Lk(b) = {x, y, z, zx} 6= Lk(ab) and thus an invalid collapse is detected.

Figure 6.3: Examples of a valid (a) and an invalid edge collapse (b) concerning topological correctness. Both figures show triangular meshes before the edge (a, b) is collapsed.

76

6.2. Mesh Optimization

Mesh Improvement

The algorithm is implemented efficiently using hash tables to represent the sets Lk(pi ), Lk(pj ), and Lk(e): Topological Correctness Check check_topology( edge(pi pj ) ) hash_table pointsa , pointsa hash_table edgesa , edgesa ∩

∩ b b

for ( ∀ tetrahedra Ti of VSC(pi ) ) if ( Ti has boundary face ) add dummy tetrahedra endif for ( ∀ vertices Vi of Ti ) if ( Vi != pi ) pointsa .insert( Vi ) endif endfor for ( ∀ edges ei of Ti ) if ( pi is not contained in ei ) edgesa .insert( Vi ) endif endfor endfor for ( ∀ tetrahedra Ti of VSC(pj ) ) if ( Ti has boundary face ) add dummy tetrahedra endif for ( ∀ vertices Vi of Ti ) if ( Vi != pj ) if ( pointsa .hasEntry( Vi ) ) pointsa ∩ b .insert( Vi ) endif endif endfor for ( ∀ edges ei of Ti ) if ( pj is not contained in ei ) if ( edgesa .hasEntry( ei ) ) edgesa ∩ b .insert( ei ) endif endif endfor endfor

77

6.2. Mesh Optimization

Mesh Improvement

for ( ∀ tetrahedra Ti of VSC(pi ) ∩ VSC(pj ) ) get vertices qi , qj ∈ Ti where qi , qj 6∈ {pi , pj } if ( pointsa ∩ b .hasEntry( qi and qj ) ) erase entries else return check_failed endif if ( edgesa ∩ b .hasEntry( edge( qi , qj ) ) ) erase entry else return check_failed endif endif if ( !pointsa ∩ b .empty() or !edgesa return check_failed endif

∩ b .empty()

)

return check_successful end

The complete iterative simplification algorithm is outlined as follows: Edge Collapse //collapse pj → pi collapse( edge(pi , pj ), boundary vertices B, timestamps T ) //mark tetrahedra incident to pi using the VSC for ( ∀ tetrahedra Ti ∈ VSC(pi ) ) mark( Ti ) endfor for ( ∀ tetrahedra Tj ∈ VSC(pj ) ) if ( marked( Tj ) ) delete( Tj ) else //substitute pj with pi replace( Tj , pj , pi ) orient( Tj ) //update timestamps T.update( Tj ) endif update boundary vertices B

78

6.2. Mesh Optimization

Mesh Improvement

endfor check self intersection update VSC locally update SSC locally end simplify( list L of degenerated tetrahedra ) //precalculate boundary vertices boundary vertices B for ( ∀ tetrahedra Ti of L ) //add Ti to the queue Q which is sorted //according to a certain error metric Q.add( Ti ) //initialize timestamps T for each tetrahedron T.initialize( Ti ) endfor while ( !Q.empty() ) if ( Q.top() is deleted ) Q.pop() continue while loop endif if ( T.get_timestamp( Ti ) is not up-to-date ) Q.pop() continue while loop endif //get minimum element if ( error of Q.top() is above a user-defined threshold ) break out of while loop endif //determine type according to Figure 6.2 type = determine_type( Q.top() ) if ( type is needle ) if ( topology_check ) collapse( edge of Q.top(), B, T ) else //according to Figure 6.2 subdivide Q.top() and adjacent tetrahedra into tetrahedra Ti //delete original tetrahedra delete( Q.top() and affected neighbors ) for ( ∀ tetrahedra Ti )

79

6.2. Mesh Optimization

Mesh Improvement

//initialize timestamps T.initialize( Ti ) //add Q.add( Ti ) endfor //update boundary B.update() endif endif Q.pop() endwhile end

The deletion of tetrahedra can be implemented by marking them as removed while the actual deletion is performed later in a separate thread (so-called lazy deletion). As described above, collapses must be performed in correct order, sorted by a measured error metric. Therefore, a priority queue is used which contains all possible collapses ordered by a chosen error metric. The queue has to be updated after an edge collapse by recalculating the error for all tetrahedra which were affected by the current collapse. In order to avoid storing references from the volumetric mesh to elements in the queue, collapses which require an update are added to the queue again. Therefore, duplicate or out-dated collapses may occur in the queue. When extracting the tetrahedron with the minimum error from the queue, it is decided whether if the collapse is up-to-date. This is accomplished by storing a time-mark for each tetrahedron. As mentioned above, a similar technique is used for tetrahedra which require subdivision. The subdivision is performed and the created tetrahedra are inserted into the queue again. 6.2.2.3

Error metric

If mesh simplification is performed, edge collapses have to be applied in a specific order. Using a heuristic method, e.g. performing an edge collapse only if the mesh quality improves, is a possible approach. Better results are achieved if using techniques which consider not only the quality improvement but also potential errors (e.g. the domain error of the volumetric mesh). Several techniques to evaluate various errors are presented and compared by Cignogni et al. [14]. In each iteration a new mesh M∗3 is generated from M3 . Usually the measured error increases during simplification. Two measures are introduced, describing the following errors: the domain error and the field error. 80

6.2. Mesh Optimization

Mesh Improvement

The collapse of an edge, which lies on the boundary ∂M3 of the mesh, can modify the visual appearance (i.e. M3 and M∗3 span different domains). A correct measure of this difference, the so-called domain error, is obtained by measuring the symmetric Hausdorff distance between the boundary surfaces ∂M3 and ∂M∗3 . Let us first define the Hausdorff distance d(p, ∂M∗3 ) between a point p belonging to ∂M3 and the boundary ∂M∗3 as: 0

d(p, ∂M∗3 ) = 0min ||p − p || p ∈∂M∗3

0

, where p is a point of ∂M∗3 . Using this definition, the Hausdorff distance between ∂M3 and ∂M∗3 , denoted by d(∂M3 , ∂M∗3 ), is given by: d(∂M3 , ∂M∗3 ) = max d(p, ∂M∗3 ), p∈∂M3

where p is a point of ∂M3 . Finally, the symmetric Hausdorff distance ds (∂M3 , ∂M∗3 ) between the two boundaries is defined as follows: ds (∂M3 , ∂M∗3 ) = max[d(∂M3 , ∂M∗3 ), d(∂M∗3 , ∂M3 )]. A more efficient metric, approximating the domain error, relies on the locality of the simplification and is presented by Cignogni et al. [14]: Estimate of the domain error: A sufficient good estimate of the domain error is obtained by using the following approximation of the Hausdorff distance: ²∗d (∂M3 , ∂M∗3 ) =

max

p∈∂M3 \∂M∗3

d(p, ∂M∗3 ),

where p is a point of ∂M3 and p 6∈ ∂M∗3 . This estimator is evaluated for all removed vertices which are external to the domain ∂M∗3 . The approximation is computed efficiently by storing the list of removed vertices for each boundary face of M∗3 . The approximation of the original scalar field Φ (defined in M3 ) with the under-sampled field Φ∗ (defined in M∗3 ) generates another type of error. Assuming that the two domains ∂M3 and ∂M∗3 are equal, then the field error ²f can be measured: ²f (Φ, Φ∗ ) = max (|Φ(p) − Φ∗ (p)|), p∈∂M3

where p is a point of ∂M3 . Additionally, in order to improve accuracy, the average square error over the whole domain can be calculated [14]. In contrast to several approaches, the underlying tetrahedral mesh data structure which is used in this thesis stores scalar values per tetrahedron rather than per vertex. Therefore, most metrics which measure the field error are not applicable (e.g. Cignoni et al. [14]). 81

6.2. Mesh Optimization

Mesh Improvement

Let us assume edge (pi , pj ) is collapsed (collapsing pj → pi ). Ω is the set of the tetrahedra which are deleted after the collapse and Ω∗ is the set of tetrahedra where vertex pj is substituted by pi (cf. Section 6.2.2.2). Φ(Ω) and Φ(Ω∗ ) are the average scalar values of the tetrahedra in sets Ω and Ω∗ , respectively. We estimate the field error by evaluating the difference of Φ(Ω) and Φ(Ω∗ ): Estimate of the field error: Let edge (pi , pj ) be the edge to collapse (collapsing pj → pi ). Ω is defined as the set of all tetrahedra T ∈ M3 where pi , pj ∈ T , T 6∈ M∗3 . Ω∗ is defined as the set of all tetrahedra T ∈ M3 where pj ∈ T , pi 6∈ T . Then an estimate of the field error is obtained by using the following approximation: ²∗f = Φ(Ω) − Φ(Ω∗ ). The estimation can be improved by weighting the scalar values of Ω and Ω∗ . Since tetrahedra with edges to collapse are stored in a priority queue, a single error value is required to determine the edge collapse with the minimal error instead of an error pair (²d , ²f ). Giving priority to edges with either minimal domain errors or field errors my be a mistake. Similarly, solutions which are based on a weighted sum of the particular errors have drawbacks[14]. Therefore, Cignogni et al. [14] introduced the following strategy: let wd and wf be weights corresponding to predefined thresholds of the maximum domain error ²max and the maximum field error ²max (heuristically chosen), respectively. Given a d f normalized error space such that wd ²max = wf ²max , d f then the tetrahedron T with smallest error ² is defined as: ² = min max[wd ²d (T ), wf ²f (T )]. T ∈queue

Thus, a 2-dimensional error space is specified where the edge collapse with the smallest error is chosen.

82

Chapter 7 Results 7.1

Data Sets

The presented methods are embedded into a template-based C++ framework. Entities are rendered using a scene-graph based library on top of OpenGL. We carried out several performance tests and quality measurements on nine meshes (five models in different resolutions): two analytical objects (Figure 7.1(a), Figure 7.1(b)), two meshes created from surface models by a tetrahedral mesh generator [59] (Figure 7.1(c), Figure 7.1(d)), and a real-world liver data set which is based on computed tomography images (Figure 7.1(e)). Table 7.1 to Table 7.5 summarize all experiments which are specified by the experiment type P Ci for a plane partitioning operation or SCij for a shape partitioning operation, respectively. i represents the i-th resolution of the current model and j denotes the j-th partitioning shape. Basically, four partitioning shapes of different sizes were used. Additionally, the partitioning shapes were deformed during the experiments to achieve different results. All timings were measured using a standard PC (Pentium 4, 2.2 GHz) and include the overall runtime for the plane and shape partitioning algorithms. In addition, timings for the octree generation, the collision detection and intersection point calculations, the subdivision, and the region detection are given for shape partitioning. Finally, two charts compare the runtime of the algorithms in relation to the initial mesh size and the number of intersected tetrahedra (see Figure 7.2). The mesh quality is determined by calculating the minimum aspect ratio rmin of all mesh primitives (see Equation 6.3). Let us assume that the original mesh is of good quality (this is correct for the test models). Therefore, a tetrahedron with an aspect ratio less than rmin · ² is badly shaped (² is determined heuristically). The number of degeneracies after the partitioning operation is given for each experiment. The effect of the optimization methods, described in Section 6.2, is measured by calculating the number of degenerated tetrahedra after applying each technique. Two tests are performed for the edge collapsing algorithm: the first test collapses all tetrahedron edges which produce no error, whereas 83

7.1. Data Sets

Results

the second test tolerates potential errors. The error defines the permitted boundary modification for a collapse according to a specified error metric (see Section 6.2.2.3 for details). In addition, the constrained Laplacian smoother is used in combination with the edge collapsing algorithm, denoted as fully optimized in the tables. The chart of Figure 7.3 shows the efficiency of the different optimization methods. The node snapping technique of the plane partitioning algorithm can be used to reduce the number of degeneracies as well. Partitioning with node snapping is compared to ordinary plane partitioning in Figure 7.4. In Figure 7.5, a typical intervention is simulated: the patient suffers from two liver tumors. Three different resection strategies are examined in order to remove the minimal amount of tissue. Subsequently, after applying the partitioning operations, the hierarchical mesh data structure is used to analyze the removed liver parts (see Figure 7.6). As mentioned above, flat elements can be created by the partitioning algorithms. Therefore, the mesh quality of an entire cut surface after a typical partitioning operation can be examined in Figure 7.9. Beside surgical planning, the presented algorithms may be useful in various fields of application. For instance, 2-manifolds can be used for modeling the interior of a model (i.e. a tumor). In addition, the algorithms give possibilities to generate partitions based on various data sets (shown in Figure 7.8). Several experiments showed the limitations of the shape partitioning algorithm (see Figure 7.7), discussed in detail in Section 7.2.

84

7.1. Data Sets

(a) Model: sphere (resolution: 21k tetras)

Results

(b) Model: cube (resolutions: 10k and 64k tetras)

(d) Model: troll (resolutions: 9k and 289k tetras)

(c) Model: head (resolution: 144k tetras)

(e) Model: liver (resolutions: 11k, 67k, and 80k tetras)

Figure 7.1: Five models in different resolutions are used for performance and quality tests.

85

7.2. Discussion

7.2

Results

Discussion

The presented results can be classified into four relevant parts which are further discussed: algorithm runtime, generation of degeneracies and efficiency of the optimization techniques, comparison of plane partitioning with and without node snapping, and limitations of the shape partitioning algorithm. The charts of Figure 7.2 show the runtime of the plane and shape partitioning algorithms in relation to the mesh size (blue) and the number of intersected tetrahedra (green). Although the chart of Figure 7.2(a) shows almost identical runtime graphs, the runtime of the plane partitioning algorithm depends primarily on the initial size of the volumetric mesh. Since the algorithm performs a linear traversal of all tetrahedra (where the subdivision is performed in constant time for a tetrahedron), the blue graph in Figure 7.2(a) will approximate to a line for an increasing number of experiments. The overall runtime did not exceed 500 ms (160 ms average runtime over all experiments), even for high-quality meshes (up to 300k tetras, see Table 7.4). Contrary, the shape partitioning algorithm’s runtime depends on the number of intersected tetrahedra as well, because the consistent intersection point calculation of triangular faces is a runtime-expensive task. However, the most remarkable characteristics of the runtime graphs in Figure 7.2(b) is the significant increase in execution time in the last three experiments where the mesh size is large (286k tetras, see Table 7.4). This observation indicates the bottleneck of the shape partitioning algorithm: the collision detection and intersection point calculations. As mentioned in Section 5.2, an octree is only generated from the partitioning shape in order to avoid the octree creation from the usually larger volumetric mesh. During experiments, we observed that this collision approach worked well for mesh sizes under 100k tetrahedra (100−400 ms for the octree generation; less than 1 second overall runtime on average). However, this method is no longer efficient if the mesh resolution is too high (cf. Table 7.4). In this case, the collision detection is inefficient, since a huge amount of tetrahedra faces have to be tested against an octree which contains only a small number of partitioning shape faces. Several approaches are possible to solve these problems. The efficiency of the octree approach could be improved by building a second octree from the volumetric mesh. This octree must be precalculated, since the generation time takes too long for on-the-fly creation. In addition, the octree of the partitioning shape may be precalculated (this depends on the application). Subsequently, the nodes of the trees are tested against each other, which would improve the runtime significantly (see Section 5.2). During a typical planning process, the partitioning shape and the volumetric mesh are modified. In this case, precalculation is not sufficient and efficient updating techniques have to be performed after each modification (cf. Section 2.3 and Section 5.2). The runtime of the iterative subdivision and the region detection algorithm is acceptably fast.

86

7.2. Discussion

(a) Runtime of the plane partitioning algorithm in relation to the initial mesh size (blue) and intersected tetrahedra (green).

Results

(b) Runtime of the shape partitioning algorithm in relation to the initial mesh size (blue) and intersected tetrahedra (green).

Figure 7.2: Runtime analyses of the plane (a) and shape (b) partitioning algorithms are given.

A known problem of subdivision is the generation of degeneracies. In the iterative subdivision approach the number of degenerated tetrahedra is not constant and depends on the partitioning shape, the number of iterations, and the initial tetrahedral mesh quality. However, compared to ordinary subdivision (which is equivalent to a single iteration) more degenerated tetrahedra are created. A comparison of the optimization techniques used for removing degeneracies is shown in Figure 7.3. The combination of both methods, constrained Laplacian smoothing and edge collapsing, led to better results in all experiments compared to the improvement contributed by each individual technique. The combined approach should be preferred if efficiency is not of major concern. Especially for partitioning operations, the preservation of object and entity boundaries is important. The green graph in Figure 7.3 indicates that the edge collapsing algorithm improves the mesh quality marginally if no boundary modification is allowed. Therefore, the assumption can be made that almost any degenerated tetrahedron (i.e. the shortest edge to collapse) lies on the cut surface which is in fact a new entity boundary. In this case, the method of choice is the constrained Laplacian smoother, since boundary vertices are projected back onto the boundary (see blue graph in Figure 7.3). The edge collapsing technique is the most effective method in order to remove degeneracies if we take a small boundary error value into account (see red graph in Figure 7.3). Thus, collapsing of degeneracies which lie on the cut surface goes along with a modification of the object boundary.

87

7.2. Discussion

Results

Figure 7.3: Comparison of the mesh optimization algorithms.

During experiments, several configurations arose where the shape partitioning algorithm failed to assign the partitioning results to the corresponding entities. A direct cause is that the partitioning shape does not separate the tetrahedral mesh into two parts. However, even if the partitioning shape is correctly defined, the algorithm may fail: irregular split tetrahedra (i.e. tetrahedra which are not split completely by the partitioning shape) cannot be assigned to an entity during subdivision and are assigned by the region detection algorithm (cf. Section 5.5 and Section 5.6). The region detection algorithm requires a connected border of already assigned tetrahedra in order to divide the initial volumetric mesh. Leaks can occur in the border, caused by incorrect split tetrahedra. In this case, the algorithm is not able to separate the entities (an example is shown in Figure 7.7). Irregularly split tetrahedra usually occur if the mesh resolution is too low, thus large tetrahedra are not split completely. Unfortunately, the resolution of volumetric meshes is typically high on its boundary and decreases in its interior in order to keep the mesh size small. If the shape partitioning algorithm fails to complete the partitioning operation, the resolution of the volumetric mesh has to be increased, either by remeshing or by adding additional vertices on-the-fly. The resolution of the initial volumetric mesh has an effect on the accuracy of the partitioning results as well: since the algorithm is approximative, coarse partitions and artefacts can occur if the resolution is too low.

88

7.2. Discussion

Results

Plane partitioning with node snapping should be preferred if a performance loss is acceptable (i.e. an average of 50% in our experiments). As mentioned above, the runtime of the plane partitioning algorithm depends on the initial mesh size. Node snapping can increase the runtime significantly (e.g. see Table 7.2 or Table 7.3): 160 ms average runtime for plane partitioning without node snapping compared to 350 ms with node snapping. However, plane partitioning with node snapping performed considerably better in the experiments regarding the generation of new primitives and degeneracies as shown in Figure 7.4.

(a) Generated degeneracies after a plane partitioning operation.

(b) Increase of the mesh size after a plane partitioning operation.

Figure 7.4: Comparison of the plane partitioning algorithm with (green) and without (blue) node snapping. Figure (a) shows the number of generated degeneracies and Figure (b) the increase of the mesh size after a plane partitioning operation.

89

(b) A plane is positioned in order to uncover the tumors.

(e) Therefore, a sphere is used for applying a shape partitioning operation.

(a) Inside the transparent liver, two tumors (shown in green and red) are located and target for resection.

(d) Strategy 1: the surgeon plans to remove each tumor separately.

(f) The shape partitioning is performed, removing the first tumor completely.

(c) The data set is partitioned using the plane partitioning algorithm and the left part of the liver is removed.

7.2. Discussion Results

90

(k) Strategy 3: Similarly to strategy 2, a single tissue part is removed. Contrary, a deformable grid is used.

(j) Both tumors are removed completely after the partitioning operation.

(l) The shape partitioning is performed, removing both tumors.

(i) Strategy 2: the surgeon plans the resection of both tumors by removing a single tissue part.

Figure 7.5: During a surgical planning procedure, various resection strategies can be examined. Planes, analytical shapes, and deformable grids are used in order to partition the volumetric mesh and resect the tumors. The removed tissue part of Figure (c), (f), (h), (j), and (l) are rotated in order to show the tumor.

(h) The resection of the second tumor is successful.

(g) Another sphere is placed, covering the second tumor.

7.2. Discussion Results

91

7.2. Discussion

(a) Removed strategy 1.

Results

tissue

of

(b) Removed strategy 2.

tissue

of

(c) Removed strategy 3.

tissue

of

Figure 7.6: In order to remove the minimal amount of tissue, the labeled hierarchical mesh data structure is used to examine the resection strategies of Figure 7.5. This shows the benefits of the data structure for surgical planning.

(a) If the mesh resolution is too low, leaks can occur in the border which separates the inside and outside entity. In this case, the algorithm is not able to separate the entities. The yellow colored arrows denote the incorrect border.

(b) A correct partitioning is achieved by increasing the mesh resolution.

Figure 7.7: Limitations of the shape partitioning algorithm: although the iterative subdivision is performed correctly, the assignment to entities can fail.

92

7.2. Discussion

Results

(a)

(b)

Figure 7.8: The subdivision algorithm can also be used to partition a liver into its eight liver segments: based on labeled liver vessel information (see Figure (a)) each tetrahedron is split until it can be assigned uniquely to the corresponding liver segment (see Figure (b)).

(a) Quality after partitioning: 101 degeneracies.

(b) Quality after full optimization without error: 56 degeneracies.

Figure 7.9: Degenerated tetrahedra can be created by the subdivision. The mesh quality of experiment P C1 in Table 7.1 is visualized: badly shaped tetrahedra are marked orange.

93

A

B

C

D

533

96,266

10,048

65,114

P C2 + N S

101

123

882

11,275

1,010

10,549

56

18

26

70

86

101

22

10

10

23

22

21

1087

333

454

1651

1256

1844

890

333

454

1417

913

1419

176

49

55

253

192

260

257

254

58

90

379

312

417

387

G

783

211

261

1198

783

1199

816

29

73

489

225

1922

14,802

5,640

10,549

SC12

H

110

20

21

123

110

123

419

22

44

133

220

2000

12,010

1,269

10,549

SC13

I

270

120

139

390

309

393

541

24

55

241

221

2005

12,860

1,972

10,549

SC14

J

243

99

141

628

246

627

1,198

270

177

628

123

882

68,634

3,396

65,114

SC21

K

776

132

197

813

798

842

1,245

243

194

685

123

882

70,816

4,152

65,114

SC21

L

1999

511

754

3460

2001

3459

3,286

235

976

1,671

404

1922

98,987

25,921

65,114

SC22

M

1920

538

674

3105

1863

3244

2,222

346

479

976

421

2000

80,308

10,435

65,114

SC23

N

1510

427

467

2789

1628

3324

2,586

287

646

1,102

551

2005

84,431

15,438

65,114

SC24

Performance and quality measurements of the algorithms (applied to the cube model): Mesh size before and after the partitioning, intersected tetrahedra, runtime, and mesh quality (before and after optimization) are given. Table sorted by experiment type, volumetric mesh size, and partitioning shape size.

Table 7.1:

[tetras]

(no error)

optimization

after full

Degeneracies

[tetras]

(with error)

optimization

after full

Degeneracies

[degeneracies]

(with error)

Edge collapse

Optimization:

[degeneracies]

(no error)

Edge collapse

Optimization:

[degeneracies]

Smoothing

Optimization:

created [tetras]

Degeneracies

time [ms]

Overall

detection [ms]

3

41

220

123

882

12,075

2,515

10,549

F SC11

E SC11

2 479

100,602

10,048

65,114

P C2

30

23

11,689

463

10,549

P C1 + N S

Region

10

11,799

463

10,549

P C1

Subdivision [ms]

intersections [ms]

Calculation of

creation [ms]

Octree

size [tris]

Part. shape

[tetras]

after part.

Mesh size

[tetras]

tetrahedra

Intersected

[tetras]

Mesh size

Type

7.2. Discussion Results

94

A Mesh size

67

490

[tetras]

[tetras]

Performance and quality measurements of the algorithms (applied to the sphere model). Mesh size before and after the partitioning, intersected tetrahedra, runtime, and mesh quality (before and after optimization) are given. Table sorted by experiment type, volumetric mesh size, and partitioning shape size.

A

284

67

142

294

620

653

213

159,082

4,066

144,404

PC

B

132

35

67

192

134

192

381

149,978

4,066

144,404

PC+NS

C

35

10

55

120

64

124

801

23

338

317

123

882

147,000

2,670

144,404

SC 1

D

43

8

39

109

75

109

814

21

357

313

123

882

146,731

3,533

144,404

SC 1

E

234

104

197

387

242

387

1,976

194

462

1,095

225

1922

152,948

6,931

144,404

SC 2

F

309

206

308

547

309

546

3,122

357

654

1,891

220

2000

158,469

6,515

144,404

SC 3

Performance and quality measurements of the algorithms (applied to the head model). Mesh size before and after the partitioning, intersected tetrahedra, runtime, and mesh quality (before and after optimization) are given. Table sorted by experiment type, volumetric mesh size, and partitioning shape size.

(no error)

(no error)

Table 7.3:

optimization

optimization

Table 7.2:

after full

Degeneracies

after full

95

[tetras] 75

Degeneracies

19

[tetras] 55

(with error)

(with error)

25

optimization

optimization

109

after full

Degeneracies

59

after full

54

[degeneracies] 24

Degeneracies

18

[degeneracies]

11

(with error)

(with error)

30

Edge collapse

89

Optimization:

76

Edge collapse

23

[degeneracies] 29

Optimization:

17

(no error)

[degeneracies]

Optimization:

(no error)

50

98 126 Edge collapse

97

77

Edge collapse

33

19

[degeneracies]

84

159

Optimization:

57

105

[degeneracies]

44

Smoothing

25

Optimization:

Smoothing

134

Optimization:

101 created [tetras]

33

Degeneracies

86

created [tetras]

46

time [ms]

160

Degeneracies

746

time [ms]

875

Overall

463

detection [ms] 583

Region

Overall

73

112

detection [ms]

38

102

Subdivision [ms]

26

44

Region

55

88

Subdivision [ms]

341 intersections [ms]

510

Calculation of

259

intersections [ms]

328

220

Calculation of

225 creation [ms]

123

Octree

123

Octree

creation [ms]

size [tris]

2000

Part. shape

1922

size [tris]

882

[tetras] 882

Part. shape

25,044

[tetras]

25,160 after part.

22,849

Mesh size

25,838

after part.

24,164

[tetras]

31,653

Mesh size

2,920

21,895

[tetras]

4,100

21,895

Type

tetrahedra

1,982

21,895

F SC 3

Intersected

4,466

21,895

E SC 2

tetrahedra

2,744

21,895

D SC 1

C SC 1

Intersected

2,744

B

PC+NS [tetras]

21,895

PC

[tetras]

Mesh size

Type

7.2. Discussion Results

95

587

303,928

5,697

289,607

385

123

882

12,434

3,557

9,824

109

50

86

235

119

241

29

13

24

54

31

56

129

46

106

321

131

354

35

19

29

68

35

68

64

34

65

159

64

159

584

63

29

37

96

63

96

491

G

170

55

100

295

174

297

1,012

14

149

624

225

1922

15,920

6,012

9,824

SC12

H

120

61

103

281

120

282

988

33

82

653

220

2000

14,706

5,313

9,824

SC13

I

188

94

149

383

188

383

1,019

29

73

696

221

2005

13,774

4,881

9,824

SC14

J

30

21

32

75

35

81

2,565

253

964

1,225

123

882

300,094

8,087

289,607

SC21

K

27

10

39

47

27

47

1,919

230

810

756

123

882

295,829

5,384

289,607

SC21

L

151

93

179

312

149

312

5,441

1,947

1,329

1,761

404

1922

311,238

14,548

289,607

SC22

M

129

103

187

311

134

293

6,407

2,134

1,836

2,016

421

2000

314,668

16,672

289,607

SC23

N

137

69

198

305

137

305

6,779

1,674

1,992

2,598

515

2005

311,162

14,997

289,607

SC24

Performance and quality measurements of the algorithms (applied to the troll model): Mesh size before and after the partitioning, intersected tetrahedra, runtime, and mesh quality (before and after optimization) are given. Table sorted by experiment type, volumetric mesh size, and partitioning shape size.

Table 7.4:

[tetras]

(no error)

optimization

after full

Degeneracies

[tetras]

(with error)

optimization

after full

Degeneracies

[degeneracies]

(with error)

Edge collapse

Optimization:

[degeneracies]

(no error)

Edge collapse

Optimization:

[degeneracies]

Smoothing

Optimization:

created [tetras]

Degeneracies

time [ms]

Overall

detection [ms]

3

37

328

123

882

11,654

2,760

9,824

F SC11

E SC11

22 401

310,154

5,697

289,607

D P C3 + N S

54

45

12,211

1,023

9,824

C P C3

Region

28

13,581

B

P C1 + N S

Subdivision [ms]

intersections [ms]

Calculation of

creation [ms]

Octree

size [tris]

Part. shape

[tetras]

after part.

Mesh size

[tetras]

tetrahedra

Intersected

1,023

9,824

[tetras]

Mesh size

A

P C1

Type

7.2. Discussion Results

96

A

B

C

D

353

70,702

2,585

67,806

P C2 + N S

E

149

92,741

3,376

80,544

P C3

F

794

83,629

3,376

80,544

P C3 + N S

1,180

123

882

18,251

7,196

11,938

142

39

49

217

142

217

113

72

98

146

125

159

137

50

90

246

152

258

57

18

32

84

58

84

62

15

21

132

55

142

22

9

10

40

22

40

39

21

37

117

39

118

1,545

169

39

57

227

169

229

723

I

207

151

189

268

211

271

1,574

38

193

1,123

220

2000

18,099

6,320

11,938

SC13

J

43

7

22

86

44

86

831

31

223

454

123

882

73,209

5,349

67,806

SC21

K

70

29

86

132

67

132

1,652

270

318

839

225

1922

74,788

5,234

67,806

SC22

L

214

34

89

303

215

310

1,734

310

385

828

220

2000

74,041

5,324

67,806

SC23

M

59

26

45

83

46

83

924

91

267

443

123

882

86,775

5,183

80,544

SC31

N

71

55

94

177

82

178

1,374

297

243

609

225

1922

85,630

3,648

80,544

SC32

O

59

41

71

158

94

159

1,499

291

296

982

220

2000

88,059

5,587

80,544

SC33

Performance and quality measurements of the algorithms (applied to the liver model): Mesh size before and after the partitioning, intersected tetrahedra, runtime, and mesh quality (before and after optimization) are given. Table sorted by experiment type, volumetric mesh size, and partitioning shape size.

Table 7.5:

[tetras]

(no error)

optimization

after full

Degeneracies

[tetras]

(with error)

optimization

after full

Degeneracies

[degeneracies]

(with error)

Edge collapse

Optimization:

[degeneracies]

(no error)

Edge collapse

Optimization:

[degeneracies]

Smoothing

Optimization:

created [tetras]

Degeneracies

time [ms]

Overall

detection [ms]

23

49

426

225

1922

14,276

2,592

11,938

H SC12

G SC11

31 103

77,171

2,585

67,806

P C2

211

31

14,122

1,146

11,938

P C1 + N S

Region

24

16,122

1,146

11,938

P C1

Subdivision [ms]

intersections [ms]

Calculation of

creation [ms]

Octree

size [tris]

Part. shape

[tetras]

after part.

Mesh size

[tetras]

tetrahedra

Intersected

[tetras]

Mesh size

Type

7.2. Discussion Results

97

Chapter 8 Conclusion and Future Work The presented plane and shape partitioning algorithms are promising techniques for classifying volumetric meshes into different regions. The plane partitioning algorithm performs an exact partitioning of a given tetrahedral mesh. A hash table is used for efficient intersection point propagation in order to keep the mesh consistent. The propagation does not rely on any adjacency information. The hash table approach has been proven to be simple and efficient and may be useful in other fields of application. The subdivision of tetrahedra has been the most difficult part of the plane partitioning method. Subdivision and consistent splitting is well researched but not explicitly described in relevant publications. Therefore, the used subdivision techniques were specified in detail in this thesis. The presented node snapping method effectively reduces the number of subdivisions and degenerated tetrahedra. The runtime of the plane partitioning algorithm is satisfying, since the requirement for interactivity is fulfilled (runtime should not exceed one second). In order to partition a volumetric mesh with deformable grids or analytical shapes, a novel shape partitioning approach was presented where volumetric meshes can be partitioned with almost any surface mesh. The algorithm is approximative and does not consider partially split tetrahedra. Therefore, no additional points are added to the mesh in order to keep the mesh size small. Based on this characteristic of the algorithm, coarse partitions can occur in low-resolution meshes. An octree is generated from the partitioning shape to reduce exact intersection tests. This method is efficient for volumetric meshes with a resolution less than 100k tetrahedra. However, the collision detection must be improved if high-quality meshes are to be partitioned (> 200k tetrahedra). Similarly to the plane partitioning algorithm, a hash table is used for intersection point propagation. The propagation algorithm relies on orientation tests where relative error bounds were used to avoid roundoff errors. In addition, implementation details were given to ensure consistency by using an adaptive precision floating point arithmetic. Since multiple intersection points per edge can occur, a new subdivision technique was introduced which handles tetrahedra splitting in an iterative way. The iterative subdivision may be useful in other areas related to volumetric meshes. The robust assignment of partitioning results to entities, especially 98

Conclusion and Future Work of subdivided tetrahedra, turned out to be a difficult task. Nevertheless, an algorithm was presented which permits to assign the tetrahedra of the volumetric mesh to the corresponding entity in linear runtime. Since this algorithm requires a connected border of correctly split tetrahedra dividing the mesh, it may fail if the mesh resolution is too low. The average runtime of all shape partitioning experiments is less than 1 second for mesh sizes smaller than 100k tetrahedra. However, the runtime can exceed 6 seconds for highresolution meshes (up to 300k tetrahedra). The problem specification of a runtime less than one second could not be reached in all experiments. This can potentially be achieved in future work. Both algorithms, plane partitioning and shape partitioning, create degenerated tetrahedra after a partitioning operation. Therefore, two optimization techniques were provided and analyzed which are capable of improving the mesh quality. A combination of a smoothing and a simplification technique achieved best results. Finally, the described hierarchical mesh model was used for identification and modification of individual entities, and efficient boundary extraction. Concluding, it can be said that this thesis provides two partitioning techniques and a set of additionally required algorithms. The entity concept (using the hierarchical mesh model) in combination with partitioning or iterative subdivision may lead to new possibilities in various fields. Known problems concerning partitioning and cutting were solved and new problems were identified. However, the partitioning algorithms and optimization techniques can be improved, which is subject of future work.

Future Work As experiments indicate, plane partitioning with node snapping is an effective technique in order to reduce the number of degeneracies and subdivided tetrahedra. Therefore, the node snapping algorithm should be target for extensions: the projection of snapped vertices can be improved by using a technique by Nienhuys et al. [52] (see Section 4.4). In addition, Mor [49] proposed a method where snapping is only applied if it results in improved element quality (see Section 2.1). The verification whether node snapping is possible (e.g. coplanarity test) is runtime-expensive, since each tetrahedron which contains the snap candidate has to be examined. More complex test algorithms may improve the runtime. Specialized versions of the shape partitioning algorithm for frequently used, analytical shapes will be useful. For instance, the use of an analytically defined sphere will improve the runtime of the collision detection (sphere/mesh collision detection instead of mesh/mesh collision detection) and the region detection algorithm (tetrahedron in sphere test). A single tetrahedron of the volumetric mesh has to be intersected by the partitioning shape in a convex way if multiple intersections occur. This is required as a precondition for 99

Conclusion and Future Work the assignment of subdivided tetrahedra to entities. However, situations can arise where no unique assignment is possible. Therefore, additional data structures which determine the position of a point relative to the partitioning shapes can be used in order to improve the accuracy of the partitioning results. For instance, precalculated binary space partition trees or distance functions may be used. The octree, which is used for the collision detection of the shape partitioning algorithm, should be extended to a bucket tree (see Section 2.3 and Section 5.2) or a similar collision detection technique for deformable objects. A bucket tree is able to handle modifications of the initial model by efficient updates. Therefore, two trees can be generated in a preprocessing step (for the volumetric mesh and the partitioning shape) which are updated on demand. The iterative subdivision can be extended to support partially split tetrahedra (see Bielser and Gross [6]). Thus, additional Steiner points will be added if the region detection algorithm fails or the partitioning result is inaccurate (an adaptive approach would be useful). Both partitioning algorithms have the tendency to create degenerated tetrahedra after a partitioning operation. Node snapping is used by the plane partitioning algorithm to reduce the number of degeneracies. A similar approach for shape partitioning would be useful but it is a non-trivial task to integrate correctly with all components of the current shape partitioning algorithm. In addition, the presented optimization algorithms can be further improved: It was shown that constrained Laplacian smoothing is an efficient technique for removing degeneracies. The projection of boundary vertices can be extended by adapting a method which is part of the node snapping algorithm presented in [52] (see also Section 4.4). The Laplacian smoother may be combined with an optimization-based smoother for better results (see Section 2.4). Results indicate that almost any badly shaped tetrahedron lies on the cut surface. Therefore, the efficiency of the edge collapsing technique is limited if no boundary error is permitted. A more sensitive error metric may improve the algorithm.

100

Chapter 9 Appendix Naming conventions E recognizable by a uppercase bold letter, represents a data structure. T recognizable by a uppercase calligraphic letter, represents a geometric object like a triangle, tetrahedron or mesh. Point pi recognizable by a lowercase letter, represents a vector of real numbers in ndimensional space. Point Pi recognizable by an uppercase letter, represents an index pointing to a point pi in vertex buffer V. Edge (pi , pj ) represents a line segment, where pi , pj are points. Edge (Pi , Pj ) represents an indexed line segment, where Pi , Pj are points. Tetrahedron 44 (p0 , p1 , p2 , p3 ) represents a tetrahedron consisting of points p0 , p1 , p2 and p3 , where pi corresponds with Vi in Figure 9.1(a). Tetrahedron 44 (P0 , P1 , P2 , P3 ) represents an indexed tetrahedron consisting of points P0 , P1 , P2 and P3 , where Pi corresponds with Vi in Figure 9.1(a). Pyramid 45 (p0 , p1 , p2 , p3 , p4 ) represents a pyramid consisting of points p0 , p1 , p2 , p3 and p4 , where pi corresponds with Vi in Figure 9.1(b). Pyramid 45 (P0 , P1 , P2 , P3 , P4 ) represents an indexed pyramid consisting of points P0 , P1 , P2 , P3 and P4 , where Pi corresponds with Vi in Figure 9.1(b). Prism 46 (p0 , p1 , p2 , p3 , p4 , p5 ) represents a prism consisting of points p0 , p1 , p2 , p3 , p4 and p5 , where pi corresponds with Vi in Figure 9.1(c). Prism 46 (P0 , P1 , P2 , P3 , P4 , P5 ) represents an indexed prism consisting of points P0 , P1 , P2 , P3 , P4 and P5 , where Pi corresponds with Vi in Figure 9.1(c). 101

Appendix

Vector algebra − → d denotes a directional vector. − → → − → − h− a , b i denotes the dot product of two directional vectors → a and b . − → − → − → − a × b denotes the cross product of two directional vectors → a and b . As not defined otherwise in context, distance calculation and normalization are done using the squared Euclidean metric. Thus the distance of the point a and b is calculated as follows: ||a − b||2 = ha − b, a − bi

Local numbering V4

V4

V6

V5 V5

V4

V3 V1

V2 (a) Tetrahedron

V1

V3 V2

(b) Pyramid

V3

V1 V2

(c) Prism

Figure 9.1: Local numbering of vertices of (a) a tetrahedron, (b) a pyramid and (c) a prism.

102

Bibliography [1] T. Akenine-M¨oller. Fast 3d triangle-box overlap testing. J. Graph. Tools, 6(1):29–33, 2001. [2] D. H. Bailey. High-precision arithmetic in scientific computation. Computing in Science and Engineering, pages 54–61, May/June 2005. [3] M. W. Bern and D. Eppstein. Mesh generation and optimal triangulation. In D.-Z. Du and F. K.-M. Hwang, editors, Computing in Euclidean Geometry, number 4 in Lecture Notes Series on Computing, pages 47–123. World Scientific, second edition, 1995. [4] D. Bielser, P. Glardon, M. Teschner, and M. Gross. A state machine for real-time cutting of tetrahedral meshes. In Pacific Conference on Computer Graphics and Applications, 2003. [5] D. Bielser, P. Glardon, M. Teschner, and M. Gross. A state machine for real-time cutting of tetrahedral meshes. In W. W. J. Rokne, editor, Journal of Graphical Models, volume 66, pages 398–417. Elsevier, October 2004. [6] D. Bielser and M. Gross. Interactive simulation of surgical cuts. In Pacific Conference on Computer Graphics and Applications, pages 116–125, 2000. [7] D. Bielser, V. Maiwald, and M. Gross. Interactive cuts through 3-dimensional soft tissue. Computer Graphics Forum, 18(3):31–38, 1999. [8] A. Bornik, R. Beichel, B. Reitinger, G. Gotschuli, E. Sorantin, F. Leberl, and M. Sonka. Computer aided liver surgery planning: An augmented reality approach. In SPIE Medical Imaging ’03, pages 395–405, February 2003. [9] D. Brodsky and B. Watson. Model simplification through refinement. In Graphics Interface, pages 221–228, 2000. [10] C. Bruyns, S. Senger, A. Menon, K. Montgomery, S. Wildermuth, and R. Boyle. A survey of interactive mesh-cutting techniques and a new method for implementing generalized interactive mesh cutting using virtual tools. Journal of Visualization and Computer Animation, 13(1):21–42, 2002. 103

BIBLIOGRAPHY

BIBLIOGRAPHY

[11] S. Canann, J. Tristano, and M. Staten. An approach to combined laplacian and optimization-based smoothing for triangular, quadrilateral, and quad-dominant meshes. In Proceedings, 7 th International Meshing Roundtable, pages 479–494, 1998. [12] L. Chen. Mesh smoothing schemes based on optimal delaunay triangulations. In IMR, pages 109–120, 2004. [13] P. Chopra and J. Meyer. Tetfusion: an algorithm for rapid tetrahedral mesh simplification. In VIS ’02: Proceedings of the conference on Visualization ’02, pages 133–140, Washington, DC, USA, 2002. IEEE Computer Society. [14] P. Cignoni, D. Constanza, C. Montani, C. Rocchini, and R. Scopigno. Simplification of tetrahedral meshes with accurate error evaluation. In VIS ’00: Proceedings of the conference on Visualization ’00, pages 85–92, Los Alamitos, CA, USA, 2000. IEEE Computer Society Press. [15] P. Cignoni and et al., editors. Tutorial on Multi-resolution Modeling, Visualization and Streaming of Volume Meshes. Eurographics ’04, 2004. ISSN 1017-4656. [16] P. Cignoni, C. Montani, E. Puppo, and R. Scopigno. Multiresolution representation and visualization of volume data. Visualization and Computer Graphics, IEEE Transactions, 3(4):352–369, 1997. [17] P. Cignoni, C. Montani, and R. Scopigno. A comparison of mesh simplification algorithms. Computers & Graphics, 22(1):37–54, 1998. [18] C. S. Co, B. Heckel, H. Hagen, B. Hamann, and K. I. Joy. Hierarchical clustering for unstructured volumetric scalar fields. In G. Turk, J. J. van Wijk, and R. Moorhead, editors, Proceedings of IEEE Visualization 2003, pages 325–332. IEEE, October 2003. [19] T. K. Dey, S. Guha, D. V. Nekhayev, and H. Edelsbrunner. Topology preserving edge contraction. Publ. Inst. Math. (Beograd) (N. S.), 66:23–45, 1999. [20] J. Dompierre, P. Labbe, M.-G. Vallet, and R. Camarero. How to subdivide pyramids, prisms, and hexahedra into tetrahedra. In 8th International Meshing Roundtable, South Lake Tahoe, California, 1999. [21] Q. Du and D. Wang. Tetrahedral mesh generation and optimization based on centroidal voronoi tessellations. International Journal for Numerical Methods in Engineering, 56(9):1355–1373, March 2003. [22] D. H. Eberly. 3D Game Engine Architecture. The Morgan Kaufmann Series in Interactive 3D Technology. Morgan Kaufmann Publishers, 2005. [23] D. H. Eberly and P. J. Schneider. Geometric Tools for Computer Graphics. The Morgan Kaufmann Series in Computer Graphics and Geometric Modeling. Morgan Kaufmann Publishers, 2003. 104

BIBLIOGRAPHY

BIBLIOGRAPHY

[24] H. Edelsbrunner. Geometry and Topology for Mesh Generation. Cambridge Univ. Press, 2001. [25] C. Forest, H. Delingette, and N. Ayache. Cutting simulation of manifold volumetric meshes. In MICCAI (2), pages 235–244, 2002. [26] F. Ganovelli. Multiresolution and Cuts in Deformable Objects Modelling. PhD thesis, University of Pisa, 2000. [27] F. Ganovelli, P. Cignoni, C. Montani, and R. Scopigno. Enabling cuts on multiresolution representation. In Computer Graphics International, 2000. [28] F. Ganovelli, J. Dingliana, and C. O’Sullivan. Buckettree: Improving collision detection between deformable objects. In SCCG2000, pages 156–163, 2000. [29] F. Ganovelli and C. O’Sullivan. Animating cuts with on-the-fly re-meshing. In Eurographics 2001 short paper proceedings. Eurographics Association, 2001. [30] M. Garland. Multiresolution modeling: Survey & future opportunities. In Proc. Eurographics, State-of-the-Art Report, pages 111–131, Aire-la-Ville, Switzerland, 1999. Eurographics Association. [31] D. Goldberg. What every computer scientist should know about floating-point arithmetic. ACM Comput. Surv., 23(1):5–48, 1991. [32] S. Gottschalk, M. C. Lin, and D. Manocha. Obbtree: a hierarchical structure for rapid interference detection. In SIGGRAPH ’96: Proceedings of the 23rd annual conference on Computer graphics and interactive techniques, pages 171–180, New York, NY, USA, 1996. ACM Press. [33] R. Grosso and G. Greiner. Hierarchical meshes for volume data. In Computer Graphics International, pages 761–ff., 1998. [34] R. Grosso, C. L¨ urig, and T. Ertl. The multilevel finite element method for adaptive mesh optimization and visualization of volume data. In VIS ’97: Proceedings of the 8th conference on Visualization ’97, pages 387–ff., Los Alamitos, CA, USA, 1997. IEEE Computer Society Press. [35] P. Guigue and O. Devillers. Fast and robust triangle-triangle overlap test using orientation predicates. Journal of Graphics Tools, 8(1):25–32, 2003. [36] B. Heidelberger, M. Teschner, and M. Gross. Detection of collisions and self-collisions using image-space techniques. In V. S. Roberto Scopigno, editor, Proceedings of WSCG ’04, volume 12, pages 145–152. University of West Bohemia, February 2004. [37] M. Held. Erit: A collection of efficient and reliable intersection tests. Journal of Graphics Tools, 2(4):25–44, 1997. 105

BIBLIOGRAPHY

BIBLIOGRAPHY

[38] H. Hoppe. Efficient implementation of progressive meshes. Journal of Computers & Graphics, 22(1):27–36, 1998. [39] P. M. Hubbard. Approximating polyhedra with spheres for time-critical collision detection. ACM Trans. Graph., 15(3):179–210, 1996. [40] P. Jim´enez, F. Thomas, and C. Torras. 3D Collision Detection: A Survey. Computers and Graphics, 25(2):269–285, Apr. 2001. [41] D. E. Knuth. The Art of Computer Programming, Volume II: Seminumerical Algorithms. Addison-Wesley, 2nd edition edition, 1981. [42] O. Konrad-Verse, B. Preim, and A. Littmann. Virtual Resection with a Deformable Cutting plane. In Simulation und Visualisierung 2004, pages 203–214. SCS, 2004. [43] T. Larsson and T. Akenine-M¨oller. Collision detection for continuously deforming bodies. In Eurographics 2001, Short Presentations. Eurographics Association, September 2001. [44] J.-C. Lombardo, M.-P. Cani, and F. Neyret. Real-time collision detection for virtual surgery. In Computer Animation’99, May 1999. [45] D. Luebke, B. Watson, J. D. Cohen, M. Reddy, and A. Varshney. Level of Detail for 3D Graphics. Elsevier Science Inc., New York, NY, USA, 2002. [46] M., B. Macq, and S. Warfield. Deformable modeling for characterizing biomedical shape changes. In Proc. of Discrete Geometry for Computer Imagery (DGCI), pages 13–15, 2000. [47] S. Melax. Dynamic plane shifting bsp traversal. In Graphics Interface, pages 213–220, 2000. [48] T. M¨oller. A fast triangle-triangle intersection test. J. Graph. Tools, 2(2):25–30, 1997. [49] A. Mor. Progressive Cutting with Minimal New Element Creation of Soft Tissue Models for Interactive Surgical Simulation. PhD thesis, Robotics Institute, Carnegie Mellon University, Pittsburgh, PA, 2001. [50] A. Mor and T. Kanade. Modifying soft tissue models: Progressive cutting with minimal new element creation. In Medical Image Computing and Computer-Assisted Intervention - MICCAI 2000, volume 1935, pages 598–607. Springer-Verlag, 2000. [51] H.-W. Nienhuys. Cutting in deformable objects. PhD thesis, Utrecht University, 2003. [52] H.-W. Nienhuys and A. van der Stappen. Supporting cuts and finite element deformation in interactive surgery. In Proc. of the 4th Int. Conf. on Medical Image Computing and Computer-Assisted Intervention (MICCAI), pages 145–152. Springer, 2001. 106

BIBLIOGRAPHY

BIBLIOGRAPHY

[53] H.-W. Nienhuys and A. F. van der Stappen. A delaunay approach to interactive cutting in triangulated surfaces, 2002. [54] S. J. Owen. A survey of unstructured mesh generation technology. In International Meshing Roundtable, pages 239–267, 1998. [55] D. M. Priest. Algorithms for arbitrary precision floating point arithmetic. In P. Kornerup and D. W. Matula, editors, Proceedings of the 10th IEEE Symposium on Computer Arithmetic (Arith-10), pages 132–144, Grenoble, France, 1991. IEEE Computer Society Press, Los Alamitos, CA. [56] J. R. Shewchuk. Robust Adaptive Floating-Point Geometric Predicates. In Proceedings of the Twelfth Annual Symposium on Computational Geometry, pages 141–150. Association for Computing Machinery, May 1996. [57] J. R. Shewchuk. Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates. Discrete & Computational Geometry, 18(3):305–363, october 1997. [58] K. Shimada, A. Yamada, and T. Itoh. Anisotropic triangulation of parametric surfaces via close packing of ellipsoids. International Journal of Computational Geometry and Applications, 10(4), 2000. [59] H. Si. TetGen: A quality tetrahedral mesh generator and three-dimensional delaunay triangulator. Technical Report 9, Weierstrass Institute for Applied Analysis and Stochastics, 2004. v1.3. [60] O. G. Staadt and M. H. Gross. Progressive tetrahedralizations. In IEEE Visualization, pages 397–402, 1998. [61] M. Teschner, B. Heidelberger, M. M¨ uller, D. Pomerantes, and M. H. Gross. Optimized spatial hashing for collision detection of deformable objects. In VMV, pages 47–54, 2003. [62] M. Teschner, S. Kimmerle, G. Zachmann, B. Heidelberger, L. Raghupathi, A. Fuhrmann, M.-P. Cani, F. Faure, N. Magnetat-Thalmann, and W. Strasser. Collision detection for deformable objects. In Proc. Eurographics, State-of-the-Art Report, pages 119–135, Grenoble, France, 2004. Eurographics Association. [63] G. van den Bergen. Efficient collision detection of complex deformable models using aabb trees. J. Graph. Tools, 2(4):1–13, 1997. [64] W. Wu and P. Heng. A hybrid condensed finite element model with GPU acceleration for interactive 3D soft tissue cutting. Computer Animation and Virtual Worlds, 15(34):219–227, 2004. [65] G. Zachmann. Rapid collision detection by dynamically aligned dop-trees. In IEEE Virtual Reality Annual International Symposium (VRAIS ’98), March 1998. 107

BIBLIOGRAPHY

BIBLIOGRAPHY

[66] G. Zachmann. Minimal hierarchical collision detection. In ACM Symposium on Virtual Reality Software and Technology (VRST), pages 121–128, November 2002. [67] G. Zachmann and E. Langetepe. Geometric data structures for computer graphics, September 2002. Tutorial. [68] D. Zhang and M. M. F. Yuen. Collision detection for clothed human animation. In PG ’00: Proceedings of the 8th Pacific Conference on Computer Graphics and Applications, page 328, Washington, DC, USA, 2000. IEEE Computer Society. [69] T. Zhou and K. Shimada. An angle-based approach to two-dimensional mesh smoothing. In IMR, pages 373–384, 2000.

108

Suggest Documents