5.8 The input surface meshes for modeling the rock mass labeled as 0 . . . . . . . . 98. 5.9 The ...... bust code by simple accepting this CORE library. However, when ...
RealModel: A System for Modeling and Visualizing Sedimentary Rocks Gang Mei geboren am 15.Dec.1983 in Hubei, China 2014
DISSERTATION zur Erlangung des Doktorgrades der Fakult¨at f¨ur Chemie, Pharmazie und Geowissenschaften der Albert-Ludwigs-Universit¨at Freiburg im Breisgau
Keywords: 3D Geological Modeling, Erosion, Deposition, Visualization, Sedimentary Rocks, Mesh Generation, Interpolation, Boolean Operations, Surface Mesh, Robustness
Promotionsausschusses Vorsitzender: Prof. Dr. Thorsten Koslowski Referent: Prof. Dr. Thorsten Koslowski Koreferent: Prof. Dr. John C.Tipper Tag: Juni 3, 2014
Declaration • I declare that I wrote this thesis without the unauthorized help of third persons and without
using any aids other than those here stated. All data and ideas which were taken directly or indirectly from other sources are marked as such. In particular, I did not take advantage of paid help from consulting services or agencies. No one received payment from me, either directly or indirectly, for work performed in connection with this dissertation. • The dissertation has never been submitted in the same or similar form to any other exami-
nation committee in Germany or abroad. • I am aware of the provisions described in the doctoral regulations of the Faculty of Chem-
istry, Pharmacy, and Earth Sciences. In particular, I know that I am not authorized to use the academic title of Doctor until I have received my doctoral diploma.
Date: April 1, 2014
Signature: Gang Mei
v
vi
Abstract Geologists are always interested in three-dimensional rock bodies. When dealing with mainly outcrop data, geologists can only reconstruct the rock body if they have some preconceived idea of what it should probably look like. In other words, they have to have some Geologically Reasonable Model of its geometry and compositional make-up. In sedimentary environments, those geologically reasonalble models can be built according to the characterizations and mechanisms of various sedimentary processes such as sediment transport, erosion, and deposition. The geometries of outcrops can be adopted to interpret the stratigraphic models in sedimentary settings. Thus, those geologically reasonalble models in sedimentology can be created by considering several kinds of sedimentary processes and according to the interpreted geological and geometrical information from outcrops. In this work, a 3D forward modeling system, RealModel, is designed and developed to construct and predicate geologically reasonalble objects (sedimentary rocks) according to the geological and geometrical information acquired from the outcrops while considering only two basic sedimentary processes (deposition and erosion). The heart of this kind of modeling is the simulating of two basic sedimentary processes, i.e., the deposition and the erosion. When simulating the above two sedimentary processes within a geometric modeling system, the process of deposition is modeled via the intersecting of a pairs of input surface meshes that represent an old and a new geological interfaces; and the process of erosion is modeled via cutting previously formed sets of polyhedrons that represent previously deposited sediments with a input surface that represents a newer geological interfaces. The motivation of designing and developing the system RealModel is to model a kind of geologically reasonalble and specifically assumed sedimentary rocks via simulating the sedimentary processes of deposition and erosion within a geometric modeling system. The developed forward modeling system, the RealModel, is in fact a geometric modeling system integrating the functions of modeling and visualizing for sedimentary rocks. The procedure of modeling is in fact a set of geometric computations, including two very important modeling operations, i.e., the intersecting of triangulated surfaces and the cutting of sets of polyhedrons with triangulated surfaces. The visualization pipelines are realized based on MFC and OpenGL. Geological objects can be very interactively displayed in several different viewing modes. Besides, various toolbars for manipulating the user-friendly interactions are also conducted. In summary, the RealModel is a system for modeling geologically reasonalble objects (sedimentary rocks) that result from the two basic sedimentary processes (deposition and erosion), and then for viewing and manipulating those geological objects.
viii
Acknowledgments This thesis ends a wonderful journey of my PhD study with the people who have supported and helped me during the last few years. Nevertheless, my gratitude to these colleagues, friends and family members will never fade. The impressive experience will be a priceless treasure throughout all my life. First, I would especially like to thank my supervisor, Prof. Dr. John C. Tipper. Prof. Tipper has a deep and wide understanding of the entire field of Geosciences, and has dedicated plenty of time to discussing and defining a promising and interesting Ph.D subject for me. During the study period of my PhD, Prof. Tipper gave the prevalent and benevolent supports on both my study and my living in Germany. During this thesis writing, his rigorous scientific approach, enlightened guidance, creativity, and encouragement are much appreciated. I greatly benefited from regular discussion with him on scientific topics that not only stick to the interests in 3D geological modeling but also quite broaden to entire Geosciences by his wisdom and extensive experience and knowledge on the subjects. Besides, I indeed owe thanks to my supervisor and his wife, Mrs. Felicity Tipper, for inviting me and my wife to visit them on Christmas days and having very delicious food and pleasant moments! My thanks go to Prof. Dr. Thorsten Koslowski, Prof. Dr. Andreas Henk, Prof. Dr. Thomas Kenkmann, and Prof. Dr. Stefan Hergarten, for their help during my research work. Also, I would like to thank Dr. Xiaoyan Li, Dr. Raphael Bissen, M.Sc Karsten Fischer for their help to carry out my research work. I also would like to thank Ms. Manuela Tombrink for her concerning about my living in Freiburg and Ms. Joanna Norek for her help in the preparation of my PhD defence. Thanks to all my colleagues at the Institute of Earth and Environmental Science for their help and all the pleasant moments. I really appreciate what they have done for me. This thesis was conducted at the Institute of Earth and Environmental Science, University of Freiburg, Germany from September 2009 to August 2014. Many thanks also go to the China Scholarship Council (CSC), for the scholarship from CSC that supports me for pursuing my PhD degree. Finally, I am really grateful for my parents and my wife, who unconditionally supported me to pursue my study. I am sorry I did not spend too much time with them in the last four years. I hope this thesis can be a gift to express my thankfulness to them
x
Contents Declaration
v
List of Figures
xv
List of Tables
xix
List of Code
xxi
1
2
Introduction 1.1 The Modeling of Sedimentary Processes . . . . . 1.1.1 Previous Reviews and Recent Advances . 1.1.2 Brief Survey of Existing Models . . . . . 1.2 The Object in Developing the System RealModel 1.3 Main Content of This Thesis . . . . . . . . . . . Theoretical Basis 2.1 Representation Types of 3D Geological Models 2.1.1 Boundary Representation Model . . . 2.1.2 Wire-frame Model . . . . . . . . . . . 2.1.3 Section Model . . . . . . . . . . . . . 2.1.4 3D Mesh Models . . . . . . . . . . . . 2.1.5 The Hybrid Model . . . . . . . . . . . 2.2 Mesh Generation Techniques . . . . . . . . . . 2.2.1 Delaunay Triangulation . . . . . . . . . 2.2.2 Polygon Partitioning . . . . . . . . . . 2.3 Interpolation Algorithms . . . . . . . . . . . . 2.3.1 Kriging Method . . . . . . . . . . . . . 2.3.2 Discrete Smooth Interpolation (DSI) . . 2.3.3 Inverse Distance Weighted (IDW) . . . 2.4 Intersection of Triangulated Surfaces . . . . . . 2.4.1 Triangle-triangle Intersection Algorithm 2.4.2 Speedup for the Intersecting . . . . . . xi
. . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . .
. . . . .
. . . . . . . . . . . . . . . .
. . . . .
1 1 2 3 6 7
. . . . . . . . . . . . . . . .
9 9 9 10 11 12 12 13 13 15 17 17 18 19 20 20 25
3
4
The System RealModel 3.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1.1 Framework of RealModel . . . . . . . . . . . . . . . . . . . 3.1.2 Preliminaries (Data Structures and Definitions) . . . . . . . . 3.2 Graphic User Interface (GUI) of RealModel . . . . . . . . . . . . . . 3.2.1 The Windows Developed with MFC . . . . . . . . . . . . . . 3.2.2 The Displaying with OpenGL . . . . . . . . . . . . . . . . . 3.3 Procedure of Modeling . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.1 Creating Surfaces for Representing Geological Interfaces . . . 3.3.2 Cutting and Intersection of Geological Interfaces . . . . . . . 3.3.3 Forming Geological Blocks . . . . . . . . . . . . . . . . . . 3.3.4 Obtaining Updated Top Surfaces . . . . . . . . . . . . . . . . 3.3.5 Cutting and Intersection of New Surface with Previous Blocks 3.3.6 Determine Property of Geological Blocks . . . . . . . . . . . 3.4 Implementation of Several Key Techniques . . . . . . . . . . . . . . 3.4.1 Supporting Exact Geometric Computation (EGC) . . . . . . . 3.4.2 Parallelization Based on the Library OpenMP . . . . . . . . . 3.4.3 Parallelization Based on CUDA-enabled GPUs . . . . . . . . Boolean Operations for Triangulated Surfaces 4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . 4.1.1 Related Work . . . . . . . . . . . . . . . . . 4.1.2 Highlights . . . . . . . . . . . . . . . . . . . 4.2 Overview . . . . . . . . . . . . . . . . . . . . . . . 4.3 Data Structure and Notation . . . . . . . . . . . . . 4.4 The Method . . . . . . . . . . . . . . . . . . . . . . 4.4.1 Searching Intersected Triangle-Pairs . . . . . 4.4.2 Intersecting of Triangles and Re-triangulating 4.4.3 Merging and Updating . . . . . . . . . . . . 4.4.4 Forming Intersection Loops . . . . . . . . . 4.4.5 Creating Sub-surfaces . . . . . . . . . . . . 4.4.6 Assembling and Distinguishing Sub-blocks . 4.5 Examples . . . . . . . . . . . . . . . . . . . . . . . 4.6 Remarks . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
27 27 27 29 32 32 34 41 41 43 46 47 51 60 65 65 66 68
. . . . . . . . . . . . . .
71 71 71 73 73 76 77 77 78 80 80 83 84 87 90
5
Application 91 5.1 The Haut-Barr Castle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 5.2 The Outcrops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 5.3 Implementation of Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
6
Discussion and Conclusion 105 6.1 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 6.1.1 The Efficiency / Speed in RealModel . . . . . . . . . . . . . . . . . . . 105 6.1.2 Non-robustness Issues in RealModel . . . . . . . . . . . . . . . . . . . . 108 xii
6.2
6.1.3 The User Interface in RealModel . . . . . . . . . . . . . . . . . . . . . . 109 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
A Robustness in Geometric Computation A.1 Why Non-robustness arise? . . . . . . . . . . . . A.1.1 Types of Non-robustness . . . . . . . . . A.1.2 Error Source in Floating-point Arithmetic A.2 Solutions of Non-robustness . . . . . . . . . . . A.2.1 Comparing Floating-point Numbers . . . A.2.2 Several Geometric Predicates . . . . . . A.2.3 Exact Geometric Computation (EGC) . . A.3 The Installation of CORE library . . . . . . . . . B Some Implementation Details B.1 Main Data Types and Notations . . . . . . B.2 Mesh Generation and Spatial Interpolation B.2.1 Bowyer-Watson algorithm . . . . B.2.2 Kriging . . . . . . . . . . . . . . B.2.3 IDW . . . . . . . . . . . . . . . . B.3 Visualization Based on OpenGL . . . . . B.3.1 Displaying Surface Meshes . . . . B.3.2 Displaying Blocks / Layers . . . . Bibliography
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
113 113 113 114 116 116 121 126 130
. . . . . . . .
131 131 135 135 138 141 142 142 144 149
xiii
xiv
List of Figures 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 2.10 2.11 2.12 2.13
Boundary representation models of a hydropower dam . . . . . . . . . . . . . . A wire-frame model of the hydropower dam shown in Figure 2.1 . . . . . . . . . Section models of a coalmine . . . . . . . . . . . . . . . . . . . . . . . . . . . . Voronoi diagram (dashed) and Delaunay triangulation (solid) . . . . . . . . . . . Creating bridges for the polygon with holes . . . . . . . . . . . . . . . . . . . . Modeling a surface with polygonal mesh . . . . . . . . . . . . . . . . . . . . . . Surfaces interpolated by IDW (the power p = 4 or 8) . . . . . . . . . . . . . . . . Intersection of triangle with triangle (M¨oller, 1997) . . . . . . . . . . . . . . . . Intersection line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Computing the intersection of triangle-triangle with Held’s algorithm (Held, 1997) Computing the intersection of triangle-triangle with Devillerss algorithm . . . . . Computing the intersection of triangle-triangle with Tropps algorithm . . . . . . Bounding volumes: sphere, axis-aligned bounding box (AABB), oriented bounding box (OBB), eight-direction discrete orientation polytope (8-DOP), convex hull 2.14 Intersection test for triangles based on AABBs . . . . . . . . . . . . . . . . . . .
10 11 11 14 16 18 19 20 21 22 23 24
3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11 3.12 3.13 3.14 3.15 3.16 3.17 3.18 3.19
28 31 33 34 36 36 37 37 38 39 39 40 40 41 43 44 45 47 48
Framework of RealModel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The array of block groups - m aBlks . . . . . . . . . . . . . . . . . . . . . . . Graphic User Interface (GUI) of RealModel . . . . . . . . . . . . . . . . . . . The icon toolbars of RealModel . . . . . . . . . . . . . . . . . . . . . . . . . The Surface View mode for a surface mesh in RealModel . . . . . . . . . . . . The Point View mode for a surface mesh in RealModel . . . . . . . . . . . . . The Line View mode for a surface mesh in RealModel . . . . . . . . . . . . . The Area View mode for a surface mesh in RealModel . . . . . . . . . . . . . The Block View mode for Blocks in RealModel . . . . . . . . . . . . . . . . . The Point View mode for Blocks in RealModel . . . . . . . . . . . . . . . . . The Line View mode for Blocks in RealModel . . . . . . . . . . . . . . . . . . The Area View mode for Blocks in RealModel . . . . . . . . . . . . . . . . . The Polyhedron View mode for Blocks in RealModel . . . . . . . . . . . . . . Flow chart of the modeling procedure in RealModel . . . . . . . . . . . . . . . The planar triangular mesh before interpolating . . . . . . . . . . . . . . . . . The original surface meshes before intersecting and cutting . . . . . . . . . . . Inside vertices (black circle) and intersection points (white circle) . . . . . . . Forming a polyhedron based on two triangles intersected only in 2D . . . . . . Forming two polyhedrons based on two triangles intersected in both 2D and 3D xv
. . . . . . . . . . . . . . . . . . .
25 26
3.20 3.21 3.22 3.23 3.24 3.25 3.26 3.27 3.28 3.29 3.30 3.31 3.32 3.33
Forming a block by intersecting in both 2D and 3D . . . . . . . . . . . . . . . . Polygonal top surface without polygon triangulation . . . . . . . . . . . . . . . . Triangular top surface after polygon triangulation . . . . . . . . . . . . . . . . . The intersection of a polygon with a plane . . . . . . . . . . . . . . . . . . . . . Intersection of a plane with a polyhedron . . . . . . . . . . . . . . . . . . . . . . The intersection of a triangle with a polyhedron . . . . . . . . . . . . . . . . . . The intersection of a surface mesh with a polyhedron . . . . . . . . . . . . . . . Intersection of Surface with Block Groups . . . . . . . . . . . . . . . . . . . . . Procedure of adding surfaces and modeling . . . . . . . . . . . . . . . . . . . . Forming new blocks by only cutting a block with a newly added surface . . . . . Forming blocks by the intersecting of the top surface with a newly added surface The blocks created by both cutting and intersecting . . . . . . . . . . . . . . . . The previous blocks and another new surface in next step . . . . . . . . . . . . . The final step of building a simple sedimentation model . . . . . . . . . . . . . .
4.1 4.2
49 51 52 53 55 56 57 58 59 61 62 63 63 64
Flow of the approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A simple example of Boolean operations for closed surface meshes(blocks). In (c), the notations A∪B, A∩B, A−B and B−A represent the union, intersection, and subtractions of models A and B, respectively. . . . . . . . . . . . . . . . . 4.3 Intersected triangle and corresponding re-triangulation. (a) A triangle and its edge-loops; (b) Original triangle divided into 2 polygons; (c) Original triangle divided completely; (d) Triangular partition of the sub polygons. . . . . . . . . 4.4 Clear the topology of triangular meshes. (a) Original meshes with invalid triangles T0 , T1 and T2 ; (b) Cleared meshes without same edges . . . . . . . . . . . 4.5 Boolean operations of a pair of blocks . . . . . . . . . . . . . . . . . . . . . . 4.6 Opposite loops and their owned or shared sub-surfaces . . . . . . . . . . . . . 4.7 Intersection of a pair of open surfaces . . . . . . . . . . . . . . . . . . . . . . 4.8 A planar mesh and Chinese lion before dividing . . . . . . . . . . . . . . . . . 4.9 A planar mesh and Chinese lion after dividing . . . . . . . . . . . . . . . . . . 4.10 Boolean operations of a pair of cylinders . . . . . . . . . . . . . . . . . . . . . 4.11 Boolean operations of a pair of torus . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
80 85 86 88 88 88 89 90
5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 5.10 5.11 5.12
. . . . . . . . . . . .
91 92 93 93 94 95 97 98 99 100 101 102
The Haut-Barr Castle (HautBarr, 2013) . . . . . . . . . . . . . . . The Haut-Barr Castle displayed in Google Earth . . . . . . . . . . . The planar boundary of Haut-Barr Castle . . . . . . . . . . . . . . Contour map of the study area . . . . . . . . . . . . . . . . . . . . The viewing of the outcrops at the Haut-Barr Castle in Google Earth The simulating of erosion and deposition by cutting and intersecting The input meshes for the modeling of the Haut-Barr Castle . . . . . The input surface meshes for modeling the rock mass labeled as 0 . The sedimentation model of the rock mass labeled as 0 . . . . . . . The modeling of the rock mass labeled as 1 . . . . . . . . . . . . . The modeling of the rock mass labeled as 2 . . . . . . . . . . . . . The modeling of the rock mass labeled as 3 . . . . . . . . . . . . . xvi
. . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . .
. 74
. 75
. 79
5.13 The final sedimentation model of the Haut-Barr Castle . . . . . . . . . . . . . . 103 6.1
The creation of Octree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
A.1 A.2 A.3 A.4 A.5 A.6
Numbers spaced on the number line . . . . . . . Coincidence predicate. Left: by difference. Right: Space regions divided by a cube and a sphere . . The orientation predicate in 2D and 3D . . . . . The inCircle and inSphere predicates . . . . . . . Center of gravity of a triangle . . . . . . . . . . .
. . . . . . . by distance . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
114 121 122 124 125 128
B.1 Front and Back views for the scenes in Realodel . . . . . . . . . . . . . . . . . . 146 B.2 Left and Right views for the scenes in Realodel . . . . . . . . . . . . . . . . . . 147 B.3 Top and Bottom view for the scenes in Realodel . . . . . . . . . . . . . . . . . . 148
xvii
xviii
List of Tables 1.1
Models for simulating sedimentary processes . . . . . . . . . . . . . . . . . . .
3.1 3.2
Data types designed in RealModel . . . . . . . . . . . . . . . . . . . . . . . . . 30 View modes in RealModel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.1 4.2
Boolean operations on triangulated surfaces . . . . . . . . . . . . . . . . . . . . 75 Data structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
5.1
Sedimentation models of the Haut-Barr . . . . . . . . . . . . . . . . . . . . . . 96
xix
5
xx
List of Code A.1 A.2 A.3 B.1 B.2 B.3 B.4 B.5 B.6
Comparing floating-point numbers . . . . . . . Coincidence predicate for points . . . . . . . . An example of supporting EGC . . . . . . . . Main Data Types and Notations . . . . . . . . . Implementation of Bowyer-Watson Algorithm . Implementation of Universal Kriging . . . . . . Implementation of IDW . . . . . . . . . . . . . The displaying of surface meshes in RealModel The displaying of blocks / layers in RealModel
xxi
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
120 123 129 131 135 138 141 142 144
xxii
Chapter 1 Introduction 1.1
The Modeling of Sedimentary Processes
With the increased computing power of the past several decades, there has been a rapid increase in the development of computer modeling and simulation of a variety of geological phenomenon and objects through the use of computer models (Harbaugh and Bonham-Carter, 1970; Tipper, 1976a,b, 1977a,b, 1978, 1979a,b; Franseen, 1991; Houlding, 1994; Harbaugh et al., 2001; Mallet, 2002; Zakrevsky, 2011). Numerical models can simulate the physical processes in sedimentary environments. For over 40 years, geoscientists have been developing numerical models to help understand how sedimentary systems are formed (Briggs and Pollack, 1967). The modeling of sedimentary processes is the procedure of developing theoretical concepts and computational algorithms or approaches that interpret, reproduce and simulate the characteristics and mechanisms of various sedimentary processes such as sediment transport, erosion, and deposition. Lots of systems (software packages) have been developed to model various sedimentary processes. And recently, the activities of the Community Surface Dynamics Modeling System (CSDMS, 2013; Peckham et al., 2013) focus on developing and applying a variety of modeling tools in sedimentary geology. Generally, the input data for the modeling of sedimentary processes includes outcrops, well logs, and seismic sections. Currently there is a wide range of practical models that have been designed to model the sedimentary processes; these models differ in terms of complexity, processes considered, and the data required for model calibration and model use (Merritt et al., 2003). In the aspect of the process representation of the model, various models can be divided into three main categories: Empirical, Conceptual, and Physics-based (Wheater et al., 1993). In the aspect of the processes considered, these developed software packages are aimed at modeling the sedimentary processes for both siliciclastic and carbonate environments. The processes that are modeled and simulated usually include: (1) siliciclastic processes such as avulsion, multi-scale channel evolution, and turbulent flow in gravity currents; and (2) carbonate processes such as sediment transport, erosion, deposition, etc. 1
1.1.1
Previous Reviews and Recent Advances
Various aspects of the modeling of sedimentary processes have been reviewed previously in the literature (Paola, 2000; Merritt et al., 2003; Fu et al., 2010; Hajek and Wolinsky, 2012; Burgess, 2012; Weltje, 2012). These reviews are drawn on to provide the reader with an overview of the broad scope of issues on the modeling the sedimentary processes such as erosion and sediment movement in various aspects. Noticeably, the classification system used by (Wheater et al., 1993) for describing the process representation of the model (empirical, conceptual and physics-based) is widely accepted in later reviews. The processes of sediment generation, transport and deposition have been well described in Rose (1993). Bull and Kirkby (1997) summarized the development of gully erosion models, from the first stochastic models to the more recent process-based representations of the system. Prosser and Rustomji (2000) reviewed the representations and use of sediment transport capacity relationships in modeling sediment transport in overland flow. In Merritt et al. (2003), various models that simulate the processes of erosion and sediment transport were summarized in terms of complexity, scale, data inputs and outputs, requirements, and limitations. In Fu et al. (2010), the representations, assumptions, application and limitations of several models for estimating the surface erosion and sediment delivery processes were reviewed. Another comprehensive review concerned the simplified process modeling of river avulsion and alluvial architecture (Hajek and Wolinsky, 2012). Weltje (2012) gave an overview of various quantitative approaches including (1) analytical, statistical and numerical methods and (2) forward modeling to the analysis and modeling of sediment generation and provenance. Burgess (2012) declared the definition of Stratigraphic Forward Modeling (SFM) as “Forward modeling methods applied to stratigraphy use various numerical and algorithmic methods to create synthetic strata based on simulated tectonic and stratigraphic processes such as subsidence and uplift, sediment supply variations, and the various processes of sediment transport and deposition.”, Then he provided a review of various SFM models and results between the year 2000 and 2009 since the publication of Paola (2000). A model called DELTASIM was developed by Hoogendoorn et al. (2008), which simulated the stratigraphy of fluvial-dominated deltaic systems in 2D on the basis of simplified diffusion rules of cross-shore sedimentation. Sanford (2008) presented a new 1D, multi-layer sediment bed model for simulating erosion and deposition of fine and mixed sediments subject to consolidation, armoring, and bioturbation. Within the coastal-circulation model Regional Ocean Modeling System (ROMS v3.0), Warner et al. (2008) implemented a 3D numerical model for simulating sediment transport and evolution of bottom morphology. Gratac´os et al. (2009a) first introduced a new 3D mathematical forward simulation model SIMSAFADIM-CLASTIC that simulated the terrigenous and carbonate marine sedimentation; and then Gratac´os et al. (2009b) adopted the process-based SIMSAFADIM-CLASTIC to model transport and deposition of clastic sediments in Camarasa artificial lake. Carmona et al. (2010) analyzed the evolution of syntectonic geometries in an extensional environment and also associated with thrust fault propagation by merging Simsafadim-Clastic and a discrete element model. 2
A mathematical modeling scheme was proposed to simulate the fate of mechanically eroded masses in the Thermaikos Gulf, which consisted of the determination of the mechanical erosion rate, the production of turbulence and the physical processes that control the propagation of the generated sedimentary plume (Kombiadou and Krestenitis, 2011). A numerical glacial erosion and sediment flux process model that was capable of quantifying sediment generation and sub glacial transport has been developed to explain the evolution of sedimentary fjord fills (de Winter et al., 2012). The statistical end-member mixing analysis (EMMA) was performed to characterize the transport processes and sedimentary deposits of terrestrial sediments in the Donggi Cona lake catchment, NE Tibetan Plateau (Ijmker et al., 2012). Rouby et al. (2013) developed a new numerical model to characterize deposits generated by storms along clastic coasts away from major rivers. In recent years, various models such as Sedflux 2.0 (Hutton and Syvitski, 2008), Sedtrans05 (Neumeier et al., 2008), CARBONATE-3D (Warrlich et al., 2008), SIMSAFADIM-CLASTIC (Gratac´os et al., 2009a), SimClast (Dalman and Weltje, 2012), and CarboCAT (Burgess, 2013) have been developed to simulate sedimentary processes. A brief survey of those developed models is presented in the closely followed subsection.
1.1.2
Brief Survey of Existing Models
As noted above, many software packages have been developed to model and simulate various sedimentary processes. The following is the brief introduction to several famous or recently developed models (software packages). Also, a brief survey of the existing models is presented in Table 1.1. Of these developed models, some were developed individually and thus are selfcontained, while others were developed by coupling two or more already existing models to have more functionalities. SEDSIM (sedimentary process simulation program) is a 3D stratigraphic forward modeling system developed originally at Stanford University and then extended in Australia since 1994, which is composed of several sub-components that can be linked together or run separately. The model SEDSIM is capable of simulating sediment erosion, transport, and deposition, and predicting both the clastic and carbonate sediment distribution on a given bathymetric surface (Tetzlaff and Harbaugh, 1989). Sedflux 2.0 (Hutton and Syvitski, 2008) is the extended version of Sedflux 1.0C (Syvitski and Hutton, 2001). The additions in Sedflux 2.0 include: (1) features that simulate sediment erosion and deposition along a riverbed, cross-shore transport, turbidity currents, and hyperpycnal flows; (2) new processes such as river channel avulsion, two-dimensional diffusion, and two-dimensional flexure (Hutton and Syvitski, 2008). CARBONATE-3D is a forward numerical model focused on modeling the stratigraphic and sedimentological development of carbonate platforms and mixed carbonate-siliciclastic shelves by simulating the following sedimentary processes: carbonate shallow, pelagic sediment pro3
duction and deposition, coarse and fine siliciclastic input, erosion, transport and redeposition of sediment, dissolution of subaerially exposed carbonate (Warrlich et al., 2002, 2008). SIMSAFADIM-CLASTIC (Gratac´os et al., 2009a) is a 3D process-based, mathematical forward simulation model for clastic sediments, which was developed from SIMSAFADIM (Bitzer and Salas, 2002). SIMSAFADIM-CLASTIC simulates processes of autochthonous marine carbonate production and accumulation, together with clastic transport and sedimentation in three dimensions of both carbonate and terrigenous sediments. SIMSAFADIM-CLASTIC + DEM (Carmona et al., 2010) is a mixed model that combines a discrete element model of the tectonic deformation of a sedimentary cover, i.e., DEM (Hardy and Finch, 2006), and a process-based model of sedimentation, i.e, the model Simsafadim-Clastic (Gratac´os et al., 2009a), in a single framework. The simulation of both sedimentation and deformation processes is therefore made more effective. SimClast is a basin-scale, 2DH model of continental shelves with a focus on generating clastic stratigraphy, which is capable of simulating fluvial channel network dynamics, plume deposition, wave-induced cross-shore and longshore transport, and large-scale marine circulation (Dalman and Weltje, 2012). CarboCAT (Burgess, 2013) is a new numerical model of carbonate deposystems, including various geological processes such as tectonic subsidence, eustatic sea-level oscillations, water depth-dependent carbonate production rates in multiple carbonate factories, lateral migration of carbonate lithofacies bodies, and a simple representation of sediment transport (Burgess, 2013; Laigle et al., 2013). As mentioned above, some models and their applications were generated by coupling existing models or other relevant software packages. For instance, a new code generated by combining two previous models, Simsafadim-Clastic and a discrete element model DEM is presented in Carmona et al. (2010) to model syntectonic sedimentation. Several realistic applications carried out by adopting the models Hydro-trend v3.0 and 2D-Sedflux 1.0C are presented in Maselli et al. (2011). Ashton et al. (2013) combined Coastline Evolution Model (CEM), and the CSDMS Component Modeling Tool (CMT) to provide new insights into plan-view evolution of waveinfluenced deltas. The models described above are those that are most widely used or recently developed, and are of only a small part of all existing models. Much more individually designed or coupled models have been developed and published. Some of these models can be publicly referred and available at the official website of the Community Surface Dynamics Modeling System (CSDMS, http://csdms.colorado.edu/). In this section, several models are chosen and briefly introduced in the Table 1.1, with a focus on the objective and the features of those models.
4
Table 1.1: Models for simulating sedimentary processes Models (References)
Objective / Features
Dim Language
DEPOSIM (Bitzer and Harbaugh, 1987)
To model interaction between transport, deposition, erosion, and compaction of clastic sediments
2D
Basic
SEDSIM (Tetzlaff and Harbaugh, 1989)
To model sediment erosion, transport, and deposition, and predicates clastic and carbonate sediment distribution on a given bathymetric surface
3D
Fortran90
SEDPAK (Strobel et al., 1989)
To model sedimentary bypass, deposition, erosion, keep up, catch up, back step, progradation, aprons
2D
C
CYCOPATH 2D (Demicco, 1998)
To model the cyclostratigraphic pathways within carbonate platform deposits
2D
Fortran90
BASIN (Bitzer, 1999)
To simulate the clastic and carbonate fluid flow, heat flow, sedimentation, consolidation, subsidence
2D
Fortran77
DELTA2 (Syvitski and Hutton, 2001)
To simulate the progradation of a fjord or graben delta and the resultant fill of matrine basins
2D
Fortran77
SEDFLUX 1.0C (Syvitski and Hutton, 2001)
To model effects of river floods, ocean storms, sealevel fluctuations, and other environmental factors
2D
C
SIMSAFADIM (Bitzer and Salas, 2002)
To simulate the production, transport and deposition of carbonate sediment
3D
Fortran77
SEDFLUX 2.0 (Hutton and Syvitski, 2008)
A framework within which individual processresponse models communicate to deliver multigrain -sized sediment load across a continental margin
3D
C
Sedtrans05 (Neumeier et al., 2008)
A model that predicts the sediment transport at one location as function water depth, sediment type, current and waves (single point model)
1D
Fortran77
CARBONATE-3D (Warrlich et al., 2002, 2008)
A stratigraphic forward model that simulates the evolution of carbonate platforms and mixed carbonate siliciclastic systems over millions of years
3D
IDL
SIMSAFADIM-CLASTIC (Gratac´os et al., 2009a,b)
To simulate marine carbonate production and accumulation, clastic transport and sedimentation in 3D of both carbonate and terrigenous sediments
3D
Fortran77
SIMSAFADIM-CLASTIC + DEM (Carmona et al., 2010)
To carry out the simulation of both sedimentation and deformation processes within a single and more effective model
3D
Fortran77
SimClast (Dalman and Weltje, 2012)
To model fluvial channel network dynamics, plume deposition, wave-induced cross-shore and longshore transport, and marine circulation
2DH
Fortran77 Fortran90
CarboCAT (Burgess, 2013)
A model that uses a cellular automata to calculate lithofacies spatial distributions and the accumulation of heterogeneous carbonate strata in 3D
2D
Matlab
5
1.2
The Object in Developing the System RealModel
Geologists are always interested in three-dimensional rock bodies, for whatever reason. For instance, one geologist is interested in a particular sandstone that acts as a petroleum reservoir; another geologist is interested in a granite pluton that acts as a source for geothermal energy; another geologist is interested in a shale unit in which there are important fossils. None of these rock bodies are completely exposed - indeed some of them are probably not exposed at all. Therefore the geologists concerned who want to work with these rock bodies have to do so on the basis of incomplete information. This information will come from outcrops (if there are any), from drill holes (if there are any), and from various geophysical investigations (if there are any). All this information will inevitably be very incomplete indeed, but it is all the geologists have. So what they have to do is to try to reconstruct the rock bodies from that incomplete information. The reconstruction problem is simple to describe: it involves using various types of 1D, 2D and 3D data to reconstruct the geometry and compositional make-up of a fully 3D object. This sounds like a problem that should have a very straightforward computational solution. However, this isn’t so. Only in the simplest of cases is it possible to use straightforward deterministic reconstruction algorithms - an example is when a geologist have sets of closely spaced serial sections and want to reconstruct the 3D geometry from them (see Tipper, 1976b, 1977a) . When things are more complex, i.e., that there are always several possible reconstructions; in that case it is sensible to try and use simulations to work out which of these are more likely to be right (see Tipper, 2011). These reconstruction approaches are usable for subsurface data. When a geologist has got mainly surface data, however, the problems get worse. This is because the data are biased by being outcrop-based. And in that case the data sometimes tell more about the outcrop from which they were obtained than they do about the rock body that the outcrop exposes. When dealing with mainly outcrop data, geologists can only reconstruct the rock body if they have some preconceived idea of what it should probably look like. In other words, they have to have some geologically reasonable model of its geometry and compositional make-up. In sedimentary environments, those geologically reasonable models can be built according to the characterizations and mechanisms of various sedimentary processes such as sediment transport, erosion, and deposition. In previous section, the methods and systems that are developed for the modeling of sedimentary processes have been introduced. As noted above, the input data for sedimentary process modeling includes the outcrops, the well logs, and the seismic data. An outcrop is simply an exposure of a hidden rock body, which is a place where that body comes to the surface and can be touched. The geometries of outcrops can be used to interpret the stratigraphic models in sedimentary settings. Thus, those geologically reasonable models in sedimentology can be created by considering several kinds of sedimentary processes and according to the interpreted geological and geometrical information from outcrops. The motivation of developing the 3D geological modeling system, RealModel, is to construct and predict geologically reasonable objects (sedimentary rocks) according to the geological and geometrical information acquired from the outcrops while considering only two basic sedimen6
tary processes (deposition and erosion). This method of modeling has several features: 1. The target is only the sedimentary rock, and other types of rocks are not considered. 2. The geological interfaces in a sedimentary rock are well layered, which are assumed to be and only can be represented with single-valued surfaces. 3. The input geometric surfaces created for representing the geological interfaces have single values in the height direction (i.e., in z-axis); surfaces with multi-values in z-direction are not considered. 4. Only the sedimentary processes of deposition and erosion are considered and simulated when modeling the sedimentary rocks; other types of sedimentary processes or geological structures such as folds are not considered. The heart of this kind of modeling is the simulating of two basic sedimentary processes, i.e., deposition and erosion. In nature, deposition and erosion are generally carried out by fluids such as water and wind. The sediments are interpreted and classified with various geological interfaces; thus the formation of sedimentary rocks can be modeled and simulated according to the information of those geological interfaces. When simulating the above two sedimentary processes within a geometric modeling system, the process of deposition is modeled via the intersecting of a pairs of input surface meshes that represent old and new geological interfaces; the process of erosion is modeled via cutting previously formed sets of polyhedrons that represent previously deposited sediments with input surfaces that represent newer geological interfaces. In summary, the purpose of designing and developing the system RealModel is to model geologically reasonable and specifically assumed sedimentary rocks by simulating the sedimentary processes of deposition and erosion within a geometric modeling system. The developed geological modeling system, RealModel, is in fact a geometric modeling system integrating the functions of modeling and visualizing for sedimentary rocks. In short, RealModel is a system for modeling geologically reasonable objects (sedimentary rocks) that result from the two basic sedimentary processes (deposition and erosion), and then for viewing and manipulating those geological objects.
1.3
Main Content of This Thesis
An integrated system (software package) named RealModel is designed and developed in order to model and visualize sedimentary rocks. This system, which is developed by using Visual C++ and OpenGL, mainly consists of two key parts—modeling and visualizing. The implementation details of both these parts are described in details in this thesis. The procedure of modeling is in fact a set of geometric computations, including two very important modeling operations, i.e., the intersecting of triangulated surfaces and the cutting of sets of polyhedrons with triangulated surfaces. Noticeably, the input data are the triangulated 7
surfaces that are created via generating planar meshes first and then height interpolation; thus each of these input surfaces is single-valued in Z-axis. Additionally, some important issues in the geometric modeling such as speedup and robustness are also considered. The visualization pipelines are realized based on the MFC (Microsoft Foundation Class) and shading language OpenGL. Geological objects, e.g., the geological interfaces and the sedimentary rocks, can be very interactively displayed in different viewing modes including point view, line view, area view, polyhedron view, and block view (a block is a set of neighboured polyhedrons). Besides, various toolbars for manipulating the user-friendly interactions are also conducted. This thesis is divided into 6 chapters. The first chapter briefly introduces the main research work in this thesis. The second chapter presents the theoretical basis for developing this geological modeling system, RealModel; several common but key techniques in geological modeling such as mesh generation and point cloud interpolation are described. In the third chapter, the implementation details of the system RealModel are presented; both the modeling and the visualizing components of the system are described in details to explain how to implement them. The Boolean operations for triangulated surfaces are putted in the fourth chapter; noticeably, these Boolean operations are aimed at generic triangulated surfaces, rather than those which are created by height interpolation and thus are single-valued in the direction of the Z-axis. The input data in the system RealModel are the surfaces with single values in Z-axis which are created via generating planar meshes and then height interpolation. The algorithms of the Boolean operations for triangulated surfaces described in the fourth chapter are not only able to use to carry out the intersecting and the cutting for those surfaces with single values, but also able to accept to conduct the intersecting and the cutting for the generic surfaces that are not single-valued. In the fifth chapter, a realistic and complex application example is conducted in order to demonstrate the effectiveness of the system RealModel. The selected research area is at the Haut-Barr Castle, France. The sedimentary rocks at the Haut-Barr is divided into 4 sub parts; and the sedimentary rock model for each part is separately built within the system RockModel, and then all sub rock models are combined into the final model for the sedimentary rocks at the Haut-Barr Castle. The discussion of the main research work in this thesis is presented in the sixth chapter. Several problems or challenges, and their corresponding solutions when developing the system RealModel are described; and the research work in this thesis is concluded in the final chapter, Additionally, many implementation details of the system RealModel including the main data structures, and the source codes for several key modeling procedures or techniques (e.g. the mesh generation, the point cloud interpolation, and the solutions to non-robustness) are listed as appendixes.
8
Chapter 2 Theoretical Basis ∗ In this chapter, several commonly-used techniques and background knowledge in geological modeling are introduced. The representation forms for geological models are briefly described in the first section; and in the following three sections, the approaches or algorithms for mesh generation, spatial interpolation, and the intersection of triangulated surfaces are described.
2.1
Representation Types of 3D Geological Models
The research on 3D spatial data model is essential in 3D geological modeling. Currently, many three-dimensional spatial data models are proposed; and there are about twenty representative and commonly used models. According to the geometric features, these models can be roughly divided into three types: the surface-based, the volume-based, and the hybrid; and in another aspect, i.e. according to the representation form of the data in various models, these models can be divided into the raster data model, the vector data model, and the hybrid model. When building geological models in various and different cases of applications, a kind of suitable data model can be selected and used according to the motivation and purpose why creates the geological models. In this section, several commonly used data models in 3D geological modeling is briefly described, including boundary representation model (B-Rep), wire-frame model, section model, tetrahedral networks model, triangular prism model, and hybrid model.
2.1.1
Boundary Representation Model
The Boundary representation (B-Rep) is a hierarchical data model for representing objects [67], in which three-dimensional objects are abstracted as sets of four basic geometric primitives, i.e., the point, line, face, and volume. A variety of complex objects can be constructed by using of the above four geometric primitives. ∗
The second, third and fourth sections of this chapter have been summarized in the paper (Mei, 2014)
9
In the boundary representation model, each class of primitive is interpreted with the geometric data, the classification marks, and the relationship with other type of primitive (i.e., the topological relations). A point is defined by its coordinates; a line consists of a set of points in which the starting and end points are used to define the boundary of the line; a face is composed of a series of lines including the outer boundary lines, the inner boundary lines, and the constrained lines on the face; a volume is enclosed with a group of faces. The boundary representation model is accurate, and able to explicitly express the spatial topological relations between geometric primitives; also, it is the most mature and unambiguous representation form in geometric modeling and thus not only widely used in three-dimensional geological modeling software but also in most CAD, CAE and CAM software involving geometric modeling. An application example based B-Rep is presented in Figure 2.1.
(a)
(b)
Figure 2.1: Boundary representation models of a hydropower dam (Mei, 2009)
2.1.2
Wire-frame Model
”A wire-frame model is a visual presentation of a three dimensional or physical object used in 3D computer graphics. It is created by specifying each edge of the physical object where two mathematically continuous smooth surfaces meet, or by connecting an object’s constituent vertices using straight lines or curves (Wire-frame, 2013).” The geological models built based on wire-frames consists only lines, points and curves defining the edges of an object. The advantage of a wire-frame model is that it is fast to render or manipulate since wireframe models represent the basic characteristics of spatial objects by using only three geometric primitives (i.e., points, lines, and curves). And the data structures for storing wire-frame models are relatively simpler than those of other representation models such as B-Rep. However, wireframe models are difficult to reflect the accurate information for the interior parts of the target objects. 10
Figure 2.2: A wire-frame model of the hydropower dam shown in Figure 2.1 (Tian, 2008)
2.1.3
Section Model
The cross-section model represents the spatial three-dimensional objects by using of a series of two-dimensional models (i.e., the cross sections) (Tipper, 1976b, 1977a). In fact, this method is an improvement of traditional geological mapping. The basic idea behind this method is simple, i.e, using a series of planes to cut specific geological objects and then obtaining a series of vertical and/or horizontal cross-sections. The characteristics information of the spatial geological objects can be recorded on the various cross-sections and then delivered to the geologists, as shown in Figure 2.3. Since that the geological information of geological bodies is only displayed on a vary of two dimensional sections, the section model is difficult to represent the overall or the internal threedimensional structure for geological objects; and it needs to be used with other kinds of data models to form hybrid models such as the section–TIN model.
(a)
(b)
Figure 2.3: Section models of a coalmine (Xu et al., 2010)
11
2.1.4
3D Mesh Models
Tetrahedral Network Model The tetrahedral network (TEN) can be considered as the extension of the TIN, in which the irregular tetrahedrons are accepted as the basic voxel for representing spatial objects (Cheng, 2005). When applying this type of data model, any spatial object or set of discrete points are tessellated into a tetrahedral mesh. There are four geometric primitives in a TEN model including vertex, edge, triangle, and tetrahedron. In TEN,the data structures are relatively simple: the most basic primitive is the vertex with its coordinates; and then two vertices can define an edge; a triangle is composed of three edges and a tetrahedron consists of the four triangles. The TEN can be deemed as a special case of the B-Rep. Triangular Prism Model In the triangular prism (tri-prism) data model, there are five geometric primitives, i.e., the vertex, edge, triangle, quadrilateral, and prism. According to the topology for defining prisms, this kind of voxel can be divided into the exact and the quasi. The exact tri-prism is determined by a pair of parallel triangles with the same shape, while the quasi tri-prism is not needed to meet the above constraint. Obviously, the quasi tri-prism is more flexible than the exact tri-prism for modeling the layered geological bodies such as sedimentations. However, both the exact and the quasi prisms are difficult to represent complex geological objects such as a large-scale rock mass with many complex faults.
2.1.5
The Hybrid Model
The modeling based on surface / area data model focuses on representing the boundaries of spatial objects such as the ground surface and geological interface. The advantage of surface-based modeling is that it is very easily to display and modify the boundary surfaces, while the drawback is that surface-based geological models cannot be used for querying the interior information of geological objects. The modeling based volume / voxel can represent both the boundary and interior parts of the target spatial objects. Detailed geological and geometric information of the hidden parts of geological objects can be easily recorded and viewed; however, since that lots of information and details need to be stored in this kind of model, the time and space costs for building such models could be very expensive. The hybrid models are those merge the models based on surface / face and the models based on volume / voxel. In general, the hybrid models are built for very complex geological objects or environments; and the kind of models (surface-based or volume-based) could be chose in different steps of modeling or for different part of geological objects according to the specific situations or requirements. 12
2.2
Mesh Generation Techniques
The simulation of geological interfaces is one of the core steps in the three-dimensional geological modeling, which commonly involves two major processes: firstly, the expected interface is projected on a plane and then the corresponding projected region will be divided into a planar triangular or quadrilateral mesh; secondly, the coordinates of all vertices of the planar mesh will be obtained by interpolation according to the sample data point, and the required surface for simulating the target geological interface can be formed. Many algorithms for generating planar meshes have been proposed such as the Delaunay triangulation method (Delaunay, 1934), advancing front technique (AFT) (Lo, 1985) and the greedy algorithm, see (Ho-Le, 1988; Owen, 1998) for surveys; among them, the first one of the most popularly used is the Delaunay triangulation algorithm which intends to create high quality elements with biggest smallest angles by nature, and the second one perhaps is the advancing front technique although it does not have so solid mathematical foundations as that of the Delaunay triangulation method. Normally, the Delaunay triangulation method aims at creating triangulations for point sets and does not consider other constraints such as the fixed segments or faces; and this type of Delaunay algorithm is termed as the classical, or standard, or unconstrained Delaunay method. The triangular mesh generated by the Delaunay method is the so-called Delaunay triangulation. In this section, the Delaunay triangulation method including the standard form and the constrained form, the advancing front technique will be described. In addition, several algorithms for dividing / partitioning polygons (o’Rourke, 1998; Berg et al., 2008) and for improving the quality of meshes will also introduced.
2.2.1
Delaunay Triangulation
The Delaunay triangulation (DT) is the straight-line dual structure of the Voronoi diagram (see Figure.2.4). The Voronoi diagram is a type of geometric structure that can be used to represent the proximity relationships for a set of sites / points. The Voronoi diagram was first presented by Dirichlet in 1850 (Dirichlet, 1850), and developed in further by Voronoi (Voronoi, 1908). Voronoi diagrams have been successfully used in various applications such as nearest neighbor search (e.g., the well-known post office problem), facility location (e.g., finding a good location to build a market), largest empty circle, robot navigation / path planning, and high quality triangulation. A full description of Voronoi diagram and its applications can be found in (Okabe et al., 2000). Many algorithms have been designed to construct Voronoi diagrams (Tipper, 1990, 1991); see surveys in Aurenhammer (1991) and Fortune (2004) . A commonly used one is the incremental algorithm which inserts a new point / site into a previous existing diagram sequentially until no sites left. The so-called sweepline algorithm proposed by Fortune (1987) is more efficient in time than any incremental algorithm. 13
Figure 2.4: Voronoi diagram (dashed) and Delaunay triangulation (solid) (Berg et al., 2008)
As mentioned above, the Delaunay triangulation (DT) is the straight-line dual structure of the Voronoi diagram . Chew gave clear definitions of the Delaunay triangulation and constrained Delaunay triangulation (Paul Chew, 1989). In this part, the easily-understandable definition of DT borrowed from Chew is introduced as follows: Definition Let S be a set of points in the plane. A triangulation T is a Delaunay triangulation of S if for each edge e of T there exists a circle e with the following properties: (1) The endpoints of edge e are on the boundary of c. (2) No other vertex of S is in the interior of c. Note that if there are no four cocircular points of S, i.e., there are no degenerate cases, then the Delaunay triangulation T is unique. Properties Delaunay triangulation has several interesting properties; and among them, there are two important properties that are very useful in applications: (1) Maximize minimum angle: the DT by nature intends to avoid creating “badly” shaped triangles with too small interior angles. Those triangles that have very small interior angles are called sliver triangles, which should be avoided being used in the numerical analysis such as finite element method or finite volume method. (2) Empty circumcircle: the circumcircle of a triangle does not contain any other points (i.e., the vertices of other triangles) in the case there are no more than three cocircular points. This feature ensures that the length of all triangles is also minimized. The Delaunay triangulation method is currently the most popular generic mesh generation method. There are various algorithms proposed for constructing DTs, such as divide-and conquer method (Lee and Schachter, 1980), sweepline (Fortune, 1987), and incremental (Lawson, 1977). The basic idea behind the incremental algorithms is to insert points into an existing triangulation one by one and then modify some local triangles. The incremental algorithm was thought initially proposed in 1977 by Lawson (Lawson, 1977), and later, Bowyer (Bowyer, 1981) and Watson (Watson, 1981) developed it in further in 1981. 14
2.2.2
Polygon Partitioning †
Polygon partitioning is the procedure of decomposing a polygonal area into simpler components such as triangles (Chazelle, 1982, 1991), trapezoids (Seidel, 1991) or even sub-polygons (Feng and Pavlidis, 1975). Usually, polygons are divided into sets of triangles; and this partitioning is also referred as Polygon Triangulation. Two Ears Theorem “One way to triangulate a simple polygon is based on a fact that any simple polygon with at least 4 vertices without holes has at least two so called ‘ears’, which are triangles with two sides being the edges of the polygon and the third one completely inside it.” The above fact has been proved by Meisters (1975). Meisters proposed a recursively triangulating algorithm that consists of searching such an ear and then cutting it off from current polygon. Removing an ear results in forming a new polygon that still meets the ‘two ears’ condition and repetitions can be done until there is only one triangle left. This is known as the ear clipping or ear cutting algorithm. An efficient technique named ‘prune-and-search’ for finding an ear in the linear time was discovered by ElGindy In 1993 (ElGindy et al., 1993). Also, a simple reorganization of Meisters’s algorithm made by Rourke (o’Rourke, 1998) leads to run ear clipping algorithm in time complexity of O(n2 ). Held (Held, 2001) designed a completely reliable triangulation algorithm and engineered its code FIST based on ear clipping.
Triangulating Simple Polygons The ear clipping triangulation algorithm consists of searching an ear and then cutting it off from current polygon. Meisters’s algorithm runs in O(n3 ) time, Rourke (o’Rourke, 1998) simply modified Meisters’s algorithm and made the new version of ear clipping algorithm run in O(n2 ) time. Given a simple polygon P with n vertices V (v0 , v1 , · · · ,vn−1 ) orientated in count-clockwise, the basic algorithm for triangulating simple polygon P is divided into four steps. Step 1: Compute the interior angles at each vertex of P , and then determine the vertices whether they are convex or reflex. If the interior angle on a vertex is less than 180 ˚ , then the vertex is convex; Otherwise, reflex. Step 2: Find out all ear tips of P and initiate the ear tip status for each vertex according to the condition described in (Toussaint, 1991; Held, 2001). Step 3: Select the ear tip vi which has smallest angle to create a triangle (vi1 , vi , vi+1 ), and then delete the ear tip vi , update the connection, angle and ear tip status for both vi1 and vi+1 . Step 4: Repeat Step 3 until (n-2) triangles are constructed. Both Step 1 and Step 2 are to initiate status for the original polygon, while Step 3 and Step 4 are the repetition of cutting and updating. †
This section is taken directly from the author’s published paper (Mei et al., 2013)
15
Triangulating Polygons with Holes The general ear cutting algorithm for simple polygons has described in above section. Noticeably, the general ear clipping algorithm is only valid for simple polygons and cannot be directly applied on polygons with holes. Thus, a pre-processing of creating ‘bridge’ edges must be done in order to transform the polygon with holes into a single polygon. Creating ‘bridge’ edges is widely used to divide a general closed domain into several simply connected sub domains; and then DTs for sub domains are obtained in turn, and patched together to generate the whole triangulation, see Tipper (1991). Different from dividing a closed domain, Held (2001) adopts ‘bridge’ edges to transform a multiply-connected polygonal area into a single polygon which can be triangulated by ear clipping based algorithms. After transforming a polygon with holes to a degenerate polygon, the ear-cutting algorithms can be accepted to generate the final triangulation. Noticeably, some vertices can be accepted to form triangle twice due to introducing those ‘bridge’ edges. In following Figure.2.5, (a) is a polygon with two holes from (Berg et al., 2008), (b) is the resulting degenerate polygon after creating two ‘bridge’ edges, (c) and (d) show the triangulations generated by the basic algorithm described in in above section and a hybrid algorithm consisting the above described ear-cutting algorithm and the edge-swapping optimization, respectively.
(a) Original polygon with two holes
(b) Resulting degenerate polygon
(c) Triangulation by ear-cutting
(d) After further edge-swapping
Figure 2.5: Creating bridges for the polygon with holes (Mei et al., 2013) 16
2.3
Interpolation Algorithms
In plain words, interpolation is the method of obtaining the evaluation value at an unknown point according to a set of known data points based on some types of relationships. In mathematics, there are various kinds of interpolation approaches such as linear interpolation, polynomial interpolation, spline interpolation, trilinear interpolation, and Gaussian interpolation (Bronshtein et al., 2007). In geosciences, the most popular interpolation methods perhaps are the following three: Kriging interpolation (Oliver and Webster, 1990), Discrete Smooth Interpolation (DSI) (Mallet, 1989, 1992), and Inverse Distance Weighted (IDW) (Shepard, 1968). In this section, these three methods will be briefly described.
2.3.1
Kriging Method
In three-dimensional geological modeling, Kriging is usually adopted to generate guaranteed geological interfaces with effectively conforming to the original data, and does not depend on existing meshes. Kriging interpolation method (Oliver and Webster, 1990) is an optimal geostatistical estimator for the regionalized variables within a limited area based on the variogram or covariance. The Kriging method was originally developed by the South African mining engineer D.G.Krige (Krige, 1951b,a). The mathematics was further developed by Matheron (Matheron, 1963) in 1963. More details about the origin of Kriging method was presented in (Cressie, 1990). For a set of regionalized variables Z(x), Kriging estimates the expected value Z(x0 ) at the location x0 where the observation is not available by using a linear weighted sum of the known values Z(x1 ), Z(x2 ), ..., Z(xn ) at locations x1 , x2 , ..., xn , such that: n P λi · Z(xi ) Z(x0 ) = i=1 n P λi = 1
(2.1)
i=1
, where: λi is the weights at the location xi which can be calculated according to the system of equations of the Kriging. There are two widely used estimators of the Kriging method: the Ordinary Kriging (OK) and Universal Kriging (UK). Both of them estimate the interpolation values with a linear weighted sum (Equation.2.1). The differences of them are the calculating the weights λi in different ways due to different assumptions. The most important analysis tool in Kriging is semivariogram which is used to quantify the spatial correlations between scatter points. In this subsection, the semivariogram is first described briefly, and then the Ordinary Kriging and Universal Kriging. 17
2.3.2
Discrete Smooth Interpolation (DSI)
The Discrete Smooth Interpolation (DSI) is an interpolation algorithm proposed by Mallet (1992), which has become one of the key techniques in the geological modeling software GOCAD (2013). The basic ideas behind DSI are as follows: for those known and unknown nodes on a “grid” of a discrete natural object, the values attached to the unknown nodes can be obtained by making the unknown nodes satisfy the constraints defined by the known nodes. This interpolation method can be applied in any dimension since it relies on the topology of nodes on a “grid”.
S
k
Known points
ϕ (k )
Unknown points
Figure 2.6: Modeling a surface with polygonal mesh As shown in Figure 2.6, S is a curved surface composed of continuous polygonal faces; G(S) is the set of all polygonal faces in S; and Ω (S) is the set of all nodes in S. N (k) is the neighbourhood of the node k, which is a subset of Ω (S) including all the nodes within sk steps to the node k. ϕ (k) is the function defined on the node k ∈ Ω (S), which can be nodal coordinates or other physic properties attached on the node k. Denote I and J as the subsets of Ω while satisfying I = Ω − J, for all nodes in the subset J, the ϕ (j) is known while the ϕ (i) is unknown for those nodes in the subset I; the procedure of acquiring the {ϕ (i) |i ∈ I} according to the {ϕ (j) |j ∈ J} is actually the Discrete Smooth Interpolation (DSI). A little more detailed, the function ϕ (·) defined on all the nodes (known and unknown) in Ω (S), i.e. {ϕ (k) |k ∈ Ω}, can be decided via minimizing a type of objective function R∗ (ϕ). The objective function is as follows: R∗ (ϕ) = R (ϕ) + ρ (ϕ) , where the R (ϕ) is the global robustness function and ρ (ϕ) denotes various constraints. The calculation of the R (ϕ) and the determination of the ρ (ϕ) can be referred in Mallet (1992). Also, the solution of minimizing the function R∗ (ϕ) is described in details in the above references. A famous application example by using of the DSI, the salt dome model , is presented in GOCAD (2013). 18
2.3.3
Inverse Distance Weighted (IDW)
IDW (Inverse Distance Weighted / Weighting) (Shepard, 1968) is a very simple and widely used geospatial interpolation method. The expected value of an interpolated point (unknown point) is the weighted average of all (or sometimes part of) the sample points. The weights only depend on the distances between the interpolation points and the sample points. A general form of finding an interpolated value Z at a given point x based on samples Zi = Z(xi ) for i = 1, 2, . . . , n via the IDW can be represented with the following formula: n X ωi (x)zi , Z(x) = n P i=1 ωj (x)
ωi (x) =
1 d(x, xi )p
(2.2)
j=1
Above equations are the simple IDW weighting functions defined by Shepard (1968). In the equations, x denotes an interpolation point, xi is an sample point, d is the distance from the known point xi to the unknown point x, n is the total number of known points used in interpolation, and p is a positive real number called the power parameter. Two application examples by implementing the IDW by setting different the power values (power = 4 or 8) is generated and shown in Figure.2.7.
(a) p = 4
(b) p = 8
Figure 2.7: Surfaces interpolated by IDW (the power p = 4 or 8) In contrast to Kriging, IDW also obtain the expected values of unknown points (interpolated points) by weighting average of the values of known points (data points). The name, i.e., Inverse Distance, of this method was motivated by the weighted average applied since it resorts to the inverse of the distance to each known point when calculate the weights. The difference between IDW and Kriging is that they calculate the weights differently. In Kriging, it is needed to calculate the spatial correlations between (1) all sample points, and (2) the interpolated points with the sample points. In the IDW, however, the weights and correlations are only involved with the distances between points. This approach of determining the weights only depending on distance is reasonable in some cases such as analyzing the propagation of sound or the spread of pollutants. But in other cases, e.g., reconstructing the ground surface or creating DEM, the IDW is not as effective as Kriging. 19
2.4 2.4.1
Intersection of Triangulated Surfaces Triangle-triangle Intersection Algorithm
M¨oller’s Algorithm Define two triangles T1 and T2 as sets of three vertices: T1 : V01 , V11 , V21 T2 : V02 , V12 , V22 And let π1 and π2 denote the underlying planes of the triangles T1 and T2 , respectively. The most direct method is to simply check whether each edge of a triangle such as T1 intersects the other triangle T2 ; if does, i.e., the intersection of edge with triangle is found, then T1 intersects T2 and return true; otherwise, return false. M¨oller proposed a method named “interval overlap” for checking whether a pair of triangles intersects (M¨oller, 1997; M¨oller et al., 2008). The basic idea behind M¨oller’s algorithm is this: if the degenerate case that there is a triangle such as T1 whose three vertices completely locate on one side of the underlying plane of the other triangle T2 is rejected, then the intersection of the two underlying planes of T1 and T2 denoted as a line L will intersect T1 and T2 ; The intersections of the line L with the triangles T1 and T2 are two line segments (also called intervals). If those intervals overlap, then the triangles T1 and T2 intersect; otherwise, not intersect.
π1
π1
L
L
T2
π2
T2
T1
π2
T1 (a) Intersect
(b) Not intersect
Figure 2.8: Intersection of triangle with triangle (M¨oller, 1997) The outline of M¨oller’s algorithm can be summarized as follows: 1. Compute the plane equation of the triangle T2 (actually it is equation of the underlying plane π2 ) . 2. Reject if all of the three points of the triangle T1 are on same side of T2 . (a) Compute the signed distances dVi2 of the vertices of T2 . 20
(b) Compare the signs of dVi2 : if they are all the same, return false; otherwise, proceed to the next step. 3. Compute the plane equation of the triangle T1 (actually it is equation of the underlying plane π1 ) . If the plane equations of π1 andπ2 are the same, then compare the d values to see if the planes are coincident: – If coincident, then project the triangles onto the axis-aligned lane that is most nearly oriented with the triangles’ plane, and perform a 2D triangle intersection test. – Otherwise, the parallel planes are not coincident, so no possible intersection; exit the algorithm. 4. Reject if all of the three points of triangle T2 are on same side of T1 . (a) Compute the signed distances dVi1 of the vertices of T1 . (b) Compare the signs of dVi1 : if they are all the same, return false; otherwise, proceed to the next step. 5. Compute the intersection line L and project onto largest axis. 6. Compute the line segments / intervals for each triangle. 7. Calculate the intersection the intervals. – If intervals overlap, triangles intersect, return true. – Otherwise, triangles do not intersect, return false.
V21
V01
L
pV =D.(V11−O)
dV
1 0
1 1
K01 pV =D.(V01−O) 1 0
t2 K11 t1 (B)
2
dV
1 1
V11 1
Figure 2.9: Intersection line (M¨oller, 1997)
Held’s Algorithm Very similar to M¨oller’s algorithm, Held’s algorithm is also carried out via dimension deduction (Held, 1997). However, in M¨oller’s algorithm, the determining of intersection of two triangles 21
in 3D is deduced to compute the overlap of two line segments in 1D; while in Held’s algorithm, the calculation of the intersection of two triangles is transformed to determine the intersection of a line segment with a triangle in 2D.
T1
π2
L
T2 Figure 2.10: Computing the intersection of triangle-triangle with Held’s algorithm (Held, 1997) Also give two triangles T1 and T2 that each of them is defined by three points , and let π1 and π2 denote the underlying planes of the triangles T1 and T2 , respectively, the main procedure of Held’s algorithm can be divided into the following steps (Figure 2.4.1): 1. Check whether there exists a triangle whose three points lie on a same side of the other triangle; if there is, the two triangles do not intersect, and return false. 2. Compute the intersection of T1 with π2 , and form a line segment L as the intersection. 3. Calculate the intersection of the line segment L with triangle T2 on the plane π2 . Obviously, the obtained intersection of L with T2 is the expected intersection of T1 with T2 . Devillers and Guigue’s Algorithm In Devillers and Guigue’s algorithm, each vertex of each triangle is classified with respect to the other triangle using six orientation predicates: Triangle T1 is first tested for intersection with the plane π2 . To do so, the algorithm classifies the vertices of T1 with respect to the plane π2 by simply comparing the signs of the three determinants [p2 , q2 , r2 , p1 ], [p2 , q2 , r2 , q1 ] and [p2 , q2 , r2 , r1 ]. Three distinct situations are possible: 1. all three determinants evaluate to the same sign and no determinant equals zero, 2. all three determinants equal zero, 3. the determinants have different signs. Case (1) occurs when all three vertices of T1 lie on the same open half-space induced by π2 . In this case no further computation is needed since there can be no intersection. Case (2) occurs when both triangles are coplanar and define the same plane. This special case is solved by a two-dimensional triangle-triangle intersection test after projecting the threedimensional input vertices to a convenient plane. 22
Case (3) happens when the vertices of T1 lie on different sides of the plane π2 and T1 surely interests π2 . In this case, the algorithm then checks in the next step whether T2 intersects π1 in a similar manner.
π2
π1 L
p2 q1 r1
i
T1
k T2
j
l p1
r2
q2
Figure 2.11: Computing the intersection of triangle-triangle with Devillerss algorithm (Devillers and Guigue, 2002; Guigue and Devillers, 2003) Indeed, if the triangle pair passes these tests and if it is assumed to be in general position, each triangle has exactly one of its vertices lying on one side of the other triangles’ supporting plane with the two other vertices on the other side. The algorithm then applies a circular permutation to the vertices of each triangle such that p1 is the only vertex of its triangle that lies on its side. An additional transposition operation is performed at the same time on vertices q2 and r2 to map vertex p1 on the positive open halfspace induces by π 2 . Notice that such a reordering exists for all possible configurations except when two of the triangle’s vertices lie on one side and the other is on the plane. Such cases are handled by permuting the vertices of the triangle such that p1 is the only vertex of its triangle that does not lie on the negative open halfspace induced by π2 . Due to the previous rejections, each incident edge of vertices p1 and p2 can be guaranteed to intersect L at a unique point. Let i, j, k, and l, be the intersection points of L with edges p1 r1 , p1 q1 , p2 q2 , and p2 r2 , respectively. These intersection points form closed intervals I1 and I2 on L that corresponds to the intersection between the two input triangles. Tropp’ Algorithm Unlike M¨oller’s or Held’s algorithms, Tropp’s algorithm intends to carry out the triangle-triangle intersection test in the algebraic viewpoint, rather than the geometric viewpoint. In Tropp’s algorithm, the process of determining the intersection of a pair of triangles is well speeded up by taking advantage of the linearity of arithmetic operations on relevant metrics and the strong linear relations between the columns of relevant metrics. Let A and B denote a pair of triangles in 3D, if there exists at least one edge of a triangle such as A intersect the other triangle B, then A and B intersect. 23
q3 Tri A q1 q2
L
t T
p2 Tri B p1
P
Figure 2.12: Computing the intersection of triangle-triangle with Tropps algorithm (Tropp et al., 2006) According to the above fact, the most direct method of determining triangle-triangle intersection is to check all possible intersection tests between an edge and a triangle. Obviously, this approach is naive and not efficient. Let p1 and p2 denote two edges of the triangle B that share a same point P , and qi , 1 6 i 6 3 denote edges of the triangle A starting from the vertices Qi (see Figure 2.4.1 ). In order to obtain the intersection point between the edge qi and the underlying plane defined by the edges p1 and p2 , the following equation should be solved: P + α1 × p1 + α2 × p2 = Qi + βi × qi
(2.3)
Some constraints should be satisfied to make the intersection point lie inside the triangle; those constraints are: 0 6 βi 6 1, α1 , α2 > 0, α1 + α2 6 1. Obviously, there are six cases of edge-triangle intersection: three edges of the triangle A with the triangle B separately, and similarly three edges of the triangle B with the triangle A. Thus, six tests formulated in Equation 2.3 need to be carried out for obtaining all possible intersection points. The above six formulations for edge-triangle intersection can be assembled as a matrix form. The core idea behind Tropp’ algorithm is to intend to reduce arithmetic operations by reusing the common elements in the matrix for edge-triangle intersection test, and fully taking advantage of the strong linearity of matrix operations. In Tropp’s algorithm, the parameters βi , 1 6 i 6 3 is firstly obtained by solving three equations that correspond to determine the intersections of three edges of the triangle A with the underlying plane of the triangle B. Noticeably, only βi needs to be calculated to perform a pre-rejection procedure. However, in later calculations, those βi are adopted to determine the → − intersection segment of the triangle A with the underlying plane of B (see t in Figure 2.4.1). 24
Obviously, any intersection segments between a pair of triangles must lie on the line L. Thus, as same as Held’s algorithm, the problem of acquiring the intersection of two triangles in 3D will reduce to determine the intersection of a segment with the triangle B in 2D. In summary, Tropp’s algorithm can be divided into the following steps: 1. Calculate the parameters βi , 1 6 i 6 3 using determinants. 2. If the constraints 0 6 βi 6 1 cannot be satisfied, then two triangles A and B do not intersect, and return false; otherwise, proceed in next steps. 3. Compute the line segment of intersection between triangle A and the underlying plane of triangle B. 4. Check whether the segment obtained in Step 3 intersects triangle B, if intersects, then the two triangles intersect, and return true, otherwise, not intersect and return false.
2.4.2
Speedup for the Intersecting
When computing the intersection of a pair of triangulate surface, a key procedure which strongly affect the effectiveness and efficiency of the whole algorithm is how to robustly obtain the intersection lines and loops of all intersected entities as fast as possible. The core of such procedure is to accurately find out all potentially intersected entities in a short time to reduce computation cost. Many techniques based on BSP(binary space partitions) (Campen and Kobbelt, 2010), Octree (Pavic et al., 2010), OBB trees (Gottschalk et al., 1996), AABB trees (Van Den Bergen, 1997) and tracking neighbors (Guo et al., 2007; Lo and Wang, 2005) have been developed to realize this goal. Most of above cited methods and other similar approaches are performed by using various Bounding Volumes, see Figure 2.13. BETTER BOUND, BETTER CULLING FASTER TEST, LESS MEMORY
SPHERE
AABB
OBB
8-DOP
CONVEX HULL
Figure 2.13: Bounding volumes: sphere, axis-aligned bounding box (AABB), oriented bounding box (OBB), eight-direction discrete orientation polytope (8-DOP), convex hull (Ericson, 2004) As summarized above, before calculating the intersection of any pair of triangles, we should know which pair of triangles does intersect. The direct and inefficient method to do this is to make a bounding box intersection test for each triangle in a surface with that of another one. It 25
needs to test m × n times when there are m and n faces in the pair of surface meshes. Obviously, this will be very slow or even cannot be realized in some cases. In order to improve the efficiency, we adopt the spatial decomposition data structure Octree to locate and then find out the candidate intersected triangle-pairs. Given two surface meshes, SA and SB , compute the smallest AABBs denoted as BoxA and BoxB for them, respectively. And then calculate the intersection BoxAB of BoxA and BoxB , i.e., BoxAB = BoxA ∩BoxB ; check each triangle of SA and SB whether it is outside of the volume BoxAB , and divide SA and SB into two sub-arrays where SAout + SAin = SA , SBout + SBin = SB ; and then extend the volume BoxAB into a cube to be an AABB for the triangles from both SAin and SBin (SAin ∪SBin ); Let the bounding cube as the root node of an Octree, and create eight octants for each node recursively. Let the Na and Nb denote the number of triangles that intersect each interior node from SAin and SBin respectively, the recursion of creating 8 octants for each node terminates and then the node becomes a leaf when (1) The depth of the node reaches a user-specified maximum level; (2) Both Na and Nb are less than a given allowable number; (3) Na or Nb is zero. When to check whether a triangle from either SAin or SBin is inside a node of the Octree, a simple method is to make an intersection test between the bounding box of the triangle and the node of Octree. If they intersect, the triangle can be considered to be inside the node. Noticeably, a same triangle can intersect with several nodes. Additionally, in order to reduce the cost of computing, the preliminary intersection test based on triangle’s AABB for each pair of triangles is carried out, as shown in Figure 2.14; and this preliminary test can be performed efficiently by calculating the AABBs for all triangles from both SAin and SBin once, and then adopting the boxes when needed.
AABBs intersect Need further test
AABBs not intersect Not need further test
Figure 2.14: Intersection test for triangles based on AABBs
26
Chapter 3 The System RealModel 3.1
Overview
The system RealModel is a package for modeling and visualizing sedimentary rocks, which is developed by using MFC (Microsoft Foundation Class), STL (Standard Template Library), and OpenGL shading language. All routines in RealModel are written in C/C++. And several packages including OpenMP (2013), CORE (Karamcheti et al., 1999), and RAPID (Gottschalk et al., 1996) have been adopted. Also, parallelization is implemented on CUDA-capable GPUs. The input data of RealModel is a set of triangular surface meshes that are adopted to represent various geological interfaces. By intersecting and cutting those surfaces with others, several groups of polyhedrons will be created. A group of polyhedrons generated based on the same two geological interfaces is defined as a geological layer, which is also called a block. The components, i.e., polyhedrons, of a geological layer have the same properties such as material and age. The output data is a sedimentation model which consists of a set of geological layers. This section will give an overview of RealModel. In the following section the visualization part in RealModel will be described. The most important part of RealModel – the procedure for building sedimentation models – will be illustrated in the third section by presenting a simple example. Finally in the fourth section, several important implementations in RealModel will be explained.
3.1.1
Framework of RealModel
The system RealModel is composed of two parts: the data visualization and the geometric modeling, as shown in Figure 3.1. The visualization component is designed for user–friendly interactions, including various windows, menus and toolbars developed under the MFC paradigm, and displaying for geometries on the basis of OpenGL. The modeling part, which is the key component of this system, consists of some basic and kernel functions of geometric computing. 27
Window Dialog Menu MFC
Toolbar Display geometry
For visualizing OpenGL
Operate geometry Data structures
RealModel
Mathematics Basic
Mesh generation Height interpolation
For modeling
Geometric algorithm Kernel Surfaces intersecting Cutting polyhedrons Supporting EGC Parallelizing Figure 3.1: Framework of RealModel Visualizing The visualization part of RealModel is performed by using MFC and OpenGL. All sub components of the user interfaces such as the main display window, input / output windows, interactive message dialogs, menus, and icon toolbars are created on the basis of the MFC. The geometric objects are rendered with OpenGL. Manipulations or operations to those geometries include zooming in or out, rotating, moving, and displaying in top, bottom, left, right, front, and back views. Several useful techniques such as Display Lists, Vertex Arrays, Polygon Offset, and Multisampling for anti-aliasing are used to improve the performance of rendering. 28
Modeling The modeling part of RealModel is composed of (1) a set of basic classes or functions and (2) a set of kernel classes or functions. The most important but basic geometric algorithms are the intersections of basic geometric primitives such as the intersection of segment-segment, polygonpolygon in 2D, triangle-triangle in 3D, and plane-polyhedron. These basic geometric algorithms are the important basis for carrying out the kernel and complex geometric computations such as surface meshes intersecting and cutting polyhedrons with a surface mesh. An unavoidable issue in geometric computation is the robustness problem which derives from floating-point arithmetic. In RealModel, in order to deal with the robustness issue in geometric computation, the Exact Geometric Computation (EGC) principle is supported to avoid unexpected crashes or infinite loops. More descriptions about the robustness issues can be seen in Appendix A.
3.1.2
Preliminaries (Data Structures and Definitions)
In the field of computer science and its relevant disciplines, perhaps every researcher realizes the fact that: Program = data structure + algorithm. This means the designing of data structure is the basis of developing a program, especially when the developers plan to create a complicated system effectively and efficiently. Therefore, before introducing the mechanism of building sedimentation models in RealModel, the designed data structure and some other preliminaries are described. As a system for building geological models, the most important part is the related geometric computations. And when implementing those various functional geometric algorithms, the first thing is to design series of data types for representing various geometric primitives. In the system RealModel, only several commonly used and basic geometric primitives such as points / vertex, segment / edge, triangle, mesh, and polyhedron are designed. The most important data types for representing geometric primitives are listed in the Table 3.1. Note that, only several key members of those Classes are presented in the following table; and more detailed description of these data types is given in Code B.1. Besides those basic data types listed in the Table 3.1, some other preliminaries such as useful notations, definitions, and variables are also designed. Most of them are created for the various geometric computations, and the rest are the switches or indicators used in the implementation of displaying geometric data / geological models. Some global arrays and variables are used in RealModel that are adopted in the entire process of building sedimentation rocks. These arrays or variables are the objects of those Classes listed in Table 3.1 and in Appendix B. Note that for designing the following arrays under the MFC paradigm, a header file afxtemp.h is required and must be included in the implementations. 29
Table 3.1: Data types designed in RealModel Class
Primitive
Main members
CNode
Point, vertex, node
ID and coordinates Neighboring nodes
CEdge
Segment, edge
IDs and coordinates of Head and Tail node Triangles share each edge
CTrgl
Triangle
IDs and coordinates of 3 nodes Neighboring triangles
CQuad
Quadrilateral
ID and coordinates Neighboring quadrilaterals
CLoop
Polyline, polygon
IDs and coordinates of all nodes in a loop IDs of all edges in a loop
CHehd
Hexahedron
IDs and coordinates of 8 nodes Neighboring hexahedrons
CPohd
Polyhedron
IDs and coordinates of all nodes in a polyhedron IDs of all polygonal faces in a polyhedron Neighboring polyhedrons
CSurf
Surface mesh
IDs and coordinates of all nodes in a mesh All elements / polygonal faces in a mesh Outer and inner boundary loops in a mesh
CBlock
IDs and coordinates of all nodes in a block A group of polyhedrons IDs of all loops / polygonal faces IDs of all polyhedrons
CArray m aSurfs. The input data for building a sedimentation model in RealModel is a set of triangular surface meshes. These input surfaces are formed by creating a planar triangular mesh and then height interpolation. This array, m aSurfs, is designed to store all original input surface meshes. The input surfaces will be added into this array in sequence during the procedure of building a sedimentary model. CArray m aNodes. This array is used to store all points of a sedimentation model. The points in this array come from (1) the original nodes of the input surface meshes, and (2) new points produced in the procedure of geometric computations such as intersection of surface meshes and cutting polyhedrons with surface meshes. Noticeably, after a step of building a geological layer, i.e., adding a new surface and then intersecting with a previous surface or cutting the polyhedrons generated in the previous step, all points have to be merged and reordered. CArray m aTrgls. This array is a temporary container for storing the triangles in a step of building a geological layer. When creating the first layer, this array 30
is used to store the triangles of a pair of input triangular surface meshes; and in later steps when at least a layer has been created, this array is adopted to store the “skin” and top triangles. After intersecting and / or cutting, this array will be cleared first and then updated. CArray m aLoops. This array is adopted to save all polygonal faces of a sedimentary model. The polygonal faces can be triangles, quadrilaterals, or the general polygons. These polygonal faces are the components of all polyhedrons in a sedimentary model. The vertices of each polygonal face are from the refreshed array m aNodes. In order to maintain the valid topology of all faces, the objects of class CLoop – polygons / loops, should also be cleared and updated according to the new set of points in the array m aNodes. CArray m aPohds. This array is accepted to store all polyhedrons of a sedimentary model. Each polyhedron is composed of several polygonal faces derived from the array m aLoops. Like the array m aLoops, all elements in this array have to be also refreshed after updating all points in the array m aNodes and all polygons in the array m aLoops. CArray m aBlks. A sedimentation model consists of at least one geological layer. Each layer, which is composed of a group of polyhedrons that have the same property, is called a block. This array m aBlks is allocated to store all layers of a sedimentation model. And similar to the above arrays, all blocks must be updated after a step of building the sedimentation model. m_aBlks pBlk0 pPhd0
…
…
pBlk1 pPhd (i-1)
pPhd0
…
pPhd (j-1)
pBlk(n-1) pPhd0
…
pPhd (m-1)
Figure 3.2: The array of block groups - m aBlks int m nOperateType. This variable is an indicator for the image operations including zooming, rotating, and moving in 3D. The options of this indicator can be one of the following settings. #define #define #define #define
OPERATOR_VIEW_NULL OPERATOR_VIEW_ZOOM OPERATOR_VIEW_ROTATE OPERATOR_VIEW_MOVE
0 1 2 3
// // // //
Do nothing Zoom in / out Rotate Move
int m nDisplayMode. This variable is used to indicate the mode of displaying a sedimentation model or input surface meshes. As described above, a sedimentary model is composed of sets of points, line segments, polygons / areas, polyhedrons, and blocks; thus, the sedimentary model can be viewed in the above five modes. For the input surface meshes, they can be dis31
played in the modes of points, line segments, polygons / areas, and surfaces. The mode of view can be one of the following options. #define #define #define #define #define #define #define
DISPLAY_MODE_NULL DISPLAY_MODE_POINT DISPLAY_MODE_LINE DISPLAY_MODE_AREA DISPLAY_MODE_SURFACE DISPLAY_MODE_POLYHEDRA DISPLAY_MODE_BLOCK
0 1 2 3 4 5 6
// // // // // // //
NULL Point Line Area Surface Polyhedra Block
int m nAntialiasing. This variable is a simple switch for whether adopting the antialiasing function in OpenGL. When to display images on screen, the phenomenon of aliasing will normally arise; and in order to improve the performance of data visualization in RealModel, a good solution is to adopt the anti-aliasing function. The following two options are used to indicate whether to turn on this function. #define DISPLAY_ANTIALISING_OFF #define DISPLAY_ANTIALISING_ON
3.2
0 1
// Turn OFF // Turn ON
Graphic User Interface (GUI) of RealModel
The GUI of the system RealModel consists of two components: the windows developed with MFC and the displaying for geometric objects with OpenGL. In this section, the above two components are illustrated with several screenshots of the real interface windows and scenes of geometric models rendered by RealModel.
3.2.1
The Windows Developed with MFC
The whole interface window of RealModel is shown in Figure 3.3, which consists of the main displaying window, the menu, the icon toolbar, the file or class tree window, the property window, and the message output window. The most important part of the interface window is certainly the main displaying window which is designed for visualizing geometric objects in the system RealModel. As shown in the Figure 3.3, a very simple model of sedimentary rocks is rendered in the main displaying window. All geometric entities displayed in the main displaying window is rendered with OpenGL; and the function of displaying geometries with OpenGL will be introduced in the next subsection. In order to make the interactive operations easy, the icon toolbars that correspond to several modeling process or displaying operations are created. There are three icon toolbars: the main toolbar corresponds to the modeling procedure, while both the image toolbar and the image more tool bar are for manipulating the rendered geometries or displaying operations. The details of these icons are described in the Figure 3.4. 32
Figure 3.3: Graphic User Interface (GUI) of RealModel 33
Get Coordinate System
Add New Surface
Open Blocks
Set Coordinate System
Intersect and Cut
Save Blocks
Zoom In
Zoom Dynamic
Zoom Out
Zoom Original
Move Left
Move Up
Previous View
Pan
Initialize
Move Right
Move Down
Next View
Rotate
Capture
Front View
Left View
Top View
Point View
Area View
Polyhedron View
Back View
Right View
Bottom View
Line View
Surface View
Block View
Rotate Left along X-axis
Rotate Left along Y-axis
Rotate Left along Z-axis
Rotate Right along X-axis
Rotate Right along Y-axis
Rotate Right along Z-axis
Figure 3.4: The icon toolbars of RealModel
3.2.2
The Displaying with OpenGL
The visualization of geometric entities in RealModel is implemented with OpenGL. All the displaying issues involving the OpenGL are carried out by using the glut / freeglut packages. The component for displaying with OpenGL in RealModel include the basic part which is for directly rendering geometric models and the advanced part which is for various displaying operations such as moving (panning), rotating, scale, and the settings of different viewpoints.
The Basic Displaying As mentioned above, the basic part of displaying is to render various geometries directly, for instance, draw points, lines, polygons, or polyhedrons. These implementations of rendering the simple geometric entities are easy to realize with OpenGL. However, several useful techniques including Vertex Array, Display List, Multisampling, and Polygon Offset need to be adopted to improve the performance of rendering such as anti-aliasing, especially when rendering a large number of geometric entities. The excellent introductions of the above techniques can be found in the OpenGL red book (Shreiner, 2009). 34
The Advanced Displaying The most commonly used displaying operations for geometries include moving (panning), rotating, and scaling, and different views of a same scene. These operations have been implemented and integrated in RealModel. Obviously, a scene can be viewed from various viewpoints. The most common ones are the front, the back, the left, the right, the top, and the bottom views. Figure B.2 demonstrates the above six views of a same simple model. Note that the model displayed in Figure B.2 is the one rendered in the Figure 3.3. There are two important types of geometric objects in RealModel: the surface meshes that represent various geological interfaces and the blocks (i.e. the groups of polyhedrons) that represent geological layers. Several kinds of view modes in the aspect of geometry have been developed for the above two objects, see Table 3.2.
View mode
Table 3.2: View modes in RealModel Object Description
Point view Line view Area view Surface view Polyhedron view Block view
Surface meshes, blocks Display only points of the objects Surface meshes, blocks Display only line segments of the objects Surface meshes, blocks Display only polygonal faces of the objects Surface meshes Display lines and faces of each surface mesh Blocks Display lines and faces of each polyhedron Blocks Display polyhedrons of each block
The implementation of the different view modes (Point, Line, Area, and Surface View) for the surface meshes is demonstrated in the Figure 3.5. The implementation of five different view modes (Point, Line, Area, Polyhedron, and Block) of the blocks (groups of polyhedrons) is demonstrated in the Figure 3.9.
35
Figure 3.5: The Surface View mode for a surface mesh in RealModel
Figure 3.6: The Point View mode for a surface mesh in RealModel 36
Figure 3.7: The Line View mode for a surface mesh in RealModel
Figure 3.8: The Area View mode for a surface mesh in RealModel 37
Figure 3.9: The Block View mode for Blocks in RealModel
38
Figure 3.10: The Point View mode for Blocks in RealModel
Figure 3.11: The Line View mode for Blocks in RealModel 39
Figure 3.12: The Area View mode for Blocks in RealModel
Figure 3.13: The Polyhedron View mode for Blocks in RealModel 40
3.3
Procedure of Modeling
The procedure of building models for sedimentary rocks in RealModel is presented in the Figure 3.14. The most important two algorithms in the procedure of modeling are: (1) the intersecting of triangular surface meshes, and (2) the cutting of polyhedrons with triangulated surfaces. The above two algorithms are performed repeatedly when building the sedimentary models. In this section, a simple example is created to illustrate how to build a sedimentation model from the starting to the ending.
Add Bottom surface
Add 1st surface only intersecting
1st layer / blocks
Add 2nd surface intersecting and/or cutting
2nd layer / blocks
Add 3rd surface Add surfaces and form layers
(n-1)th layer / blocks
Add nth surface intersecting and/or cutting
nth layer / blocks
Figure 3.14: Flow chart of the modeling procedure in RealModel
3.3.1
Creating Surfaces for Representing Geological Interfaces
As mentioned above, the input data in RealModel is a set of surface meshes. Thus, before starting to build the models, the first thing is to create the surface meshes that are adopted to represent various geological interfaces. In more details, these surfaces are single valued in the axis Z which means there are no self-intersections when each of those surfaces is projected onto the XY plane. Single valued surfaces are normally generated by creating planar meshes first and then interpolating with height or elevation values. 41
Creating Planar Meshes The generation of planar triangular meshes is quite mature now. The most popular algorithms for forming triangulations in the plane can be divided into two families: the Delaunay based and the Advancing Front Technique (AFT) based. Details of these algorithms have been introduced in Section 2.2. Generally, two issues, i.e., the region for meshing and the approximate number of triangular elements, need to be considered to create appropriate expected meshes. The Region for Meshing The first requirement in generating meshes is to know which target region should be meshed. For planar meshes, the regions for meshing are normally sets of polygons. These polygons are deemed as the boundaries of meshes which can be outer and / or inner, and will be transferred as the mesh constraints in the procedure of meshing. In RealModel, the region for meshing must be determined according to the shape of a target research sedimentary rock or the scale of a target sedimentation region. In this simple example, the region for meshing is simply determined as a rectangle. In the application example presented in Chapter 5, the region for meshing is much more complex, see Figure 5.7(b). The Number of Elements Normally, the exact number of the triangular elements cannot be determined when triangulating the regions. This is unlike the situation when creating a Delaunay triangulation of a set of points. In RealModel, the number of elements is approximately determined by specifying the length of the edge of a triangle. The specification of the length of edge may have to be changed several times until the resulting triangular mesh meets the expected requirement. After determining the target region and specifying the edge length of triangular elements, the corresponding planar triangular mesh can be generated by using the Constrained Delaunay algorithm or the AFT approach. Figure 3.15 shows a very simple resulting triangular mesh before interpolating.
Height Interpolation The height interpolation is to obtain the Z coordinate (considered as the height or elevation in some applications) while without changing the X and Y coordinates of a point according to a set of observations. The height interpolation is commonly used to create TINs (triangulated irregular networks) when building the Digital Elevation Models (DEMs) in GIS. There are several popular algorithms for height interpolation such as the Kriging, the IDW, and the polygonal interpolation. In the Section 2.3, three interpolation algorithms, the Kriging, the IDW, and the DSI, have been introduced in details. Among them, the Kriging interpolation algorithm and the IDW approach in 3D are the algorithms for strict height interpolation, while the DSI is not. This is because in the interpolating by using the Kriging and the IDW, only the Z values are updated; but in the DSI interpolation, the X, Y, and Z coordinates of a point will be 42
changed. Figure 3.16 illustrates 9 surfaces interpolated by using the Kriging method. Although the DSI is not strictly-speaking an algorithm for height interpolation, it is also implemented and integrated in the system RealModel. Additionally, when creating the surfaces for representing various geological interfaces via interpolation, all of the nodal coordinates including X, Y, and Z can be allowed to be updated, rather than only the Z values. In RealModel, when the number of nodes of a planar triangular mesh is small, for instance less than 2000, then the first choice of selecting the interpolation algorithms is the Kriging method; when the number is large, the interpolating procedure by using the Kriging will be very slow and even in some cases the interpolating cannot be carried out. In this case the DSI is first selected, and the IDW is the last choice.
Figure 3.15: The planar triangular mesh before interpolating
3.3.2
Cutting and Intersection of Geological Interfaces
Computing the Intersection of Triangular Meshes in 2D In this section, the computation of the intersection of triangular meshes in the plane is described. The computing procedure can be mainly divided into 2 stages: the first is to determine all pairs of the potentially intersected triangles to reduce the number of intersection test; and secondly, the intersections of all intersected-triangle pairs are computed, and then all intersections will be merged and rearranged to form the intersection of meshes. 43
Figure 3.16: The original surface meshes before intersecting and cutting Stage 1: Determining all potential intersected-triangle pairs. An iterative algorithm has been developed to find out all intersected-triangle pairs: • Step 1: Find out the first intersected-triangle pair TP1 (T1, T2) which includes a triangle
T1 of one triangle mesh M1 and another triangle T2 of the other triangle mesh M2. • Step 2: Aiming at the first pair of triangle TP1 (T1, T2), find out all adjacent triangles of
T1 and T2, and denote them as T1adj and T2adj , respectively. This can be carried out easily according to the topology of the mesh. Noticeably, the triangleS T1 and T2 have to be considered as one of their adjacent triangles. • Step 3: Test every triangle of T1adj with that of T2adj to check whether they intersect each
other or not. If any two triangles do intersect and also this pair of triangle has not existed already, then the pair should be recorded and saved into an array. • Step 4: For every new pair of triangle which was added at the last time in step 3, the
operations described in step 2 and step 3 should be repeated until there are no more new pairs that can be found. Stage 2: Computing triangle-triangle intersection in 2D. Given two triangles A and B, the approach to compute their intersection is as follows: • Step 1: Compute the intersection between 3 segments of A and those of B. The implemen-
tation of computing segments intersection is directly accepted from pages 241-245 in the literature (Schneider and Eberly, 2002). 44
• Step 2: Compute whether the 3 vertices of A are inside B, and similarly, compute whether
the 3 vertices of B are inside A. If a vertex of one triangle locates inside the other triangle, then mark it as inside vertex, as shown in Figure 3.17. • Step 3: Define the intersection point and the inside vertex as the valid point (Figure 3.17),
and compute the convex hull of these valid points to form the intersection (overlapping) part. According to the number of valid points, the intersection can be follows cases: If there is only 1 valid point, then the intersection is a point. If there are 2 valid points, then the intersection is a segment. If there are more than 2 valid points, then the intersection is a polygon.
Figure 3.17: Inside vertices (black circle) and intersection points (white circle)
Computing the intersection of triangular meshes in 3D Technique of Searching Intersected-Triangle Pairs Before computing triangle-triangle intersection, it is necessary to identify which triangles on one mesh may intersect each triangle of another mesh in 3D. Given two triangle meshes S1 and S2 , and triangle Ti (0≤ i ≤ m) is a triangle of S1 while Tj (0≤ j ≤ n) is a triangle of S2 . The simplest method to find out intersected-triangle pairs is to test each triangle of S1 (Ti )with each triangle of S2 (Tj ). Obviously, it will cost so much time to compute whether the triangles intersect or not when there are plenty of triangles on each mesh. For instance, it is necessary to test m×n times between S1 and S2. An optimization method has been developed to reduce the computation cost: • Step 1: Find out the maximum and minimum value of coordinates X, Y, Z of all the points,
and note them as Xmax , Xmin , Ymax , Ymin , Zmax and Zmin ; • Step 2: Create a boundary box according to Xmax , Xmin , Ymax , Ymin , Zmax and Zmin ; • Step 3: Compute the length of each edge/side of every triangle, and then get the average
length of all edges, note it as lenavg ; • Step 4: Divide the boundary box into sub-boxes using the average length lenavg ;
45
• Step 5: Check each triangle of S1 and S2 to test which triangle on meshes S1 and S2
intersect every sub-box. For a sub-box, all triangles of S1 that intersect it may intersect those triangles of S2 that also intersect the same sub-box, so all intersected triangle pairs in 3D can be found out by testing those triangles of S1 that intersect a sub-box with those triangles of S2 that also intersect the same sub-box. Triangle-Triangle Intersection Method in 3D The methodology and its code developed by M¨oller (1997) are directly used to compute triangle-triangle intersection in 3D. To compute the intersection of a pair of triangles, triangle T1 and triangle T2 ., the summarized steps of the algorithm are as follows: • Step 1: Compute plane equation of the triangle T2 . • Step 2: Reject as trivial if all points of the triangle T1 are on the same side of the underlying
plane of the triangle T2 . • Step 3: Compute plane equation of the triangle T1 . • Step 4: Reject as trivial if all points of the triangle T2 are on the same side of the underlying
plane of the triangle T1 . • Step 5: Compute intersection line and project it onto the largest axis. • Step 6: Compute the intervals for each triangle. • Step 7: Intersect the intervals to obtain the expected intersection.
3.3.3
Forming Geological Blocks
In this section, two situations when a pair of triangles intersect are introduced. If a pair of triangles intersects each other after they are projected into XY coordinate plane, then these two triangles are considered to be intersected in 2D. And obviously, even if a pair of triangles intersects in 2D, they may not intersect in 3D. If a pair of triangles intersects not only in 2D after being projected but also intersects each other in 3D, then this pair of triangles is deemed that they intersect in both 2D and 3D. According to the different intersection situations, different methods are used to form polyhedrons. For the first situation, in which a pair of triangles intersects only in 2D (as shown in Figure 3.18(a)), only a polyhedron can be formed: after computing the intersection in 2D, which is a polygonal area bounded with a loop, the X and Y values of all the points of the intersection loop are maintained, as shown in Figure 3.18(b) ; then, two Z values for a same point will be updated according to the equations of the two original triangles in 3D; and finally, a polyhedron, which is composed of several pairs of corresponding points (same X and Y, different Z) is formed, as shown in Figure 3.18(c). For the second situation, in which a pair of triangles intersects in both 2D and 3D, as shown in Figure 3.19(a), one or two polyhedrons can be formed: after computing the intersection in 2D, the X and Y value of all the points of the intersection loop are also kept, as shown in Figure 3.19(b); 46
(a) Two triangles in 2D
(b) The intersection in 2D
(c) Intersections after updating Z values
Figure 3.18: Forming a polyhedron based on two triangles intersected only in 2D then, the intersection line in 3D is computed by using the triangle intersection test developed by M¨oller (1997). Considering the intersection in both 2D and 3D, there are two sub-situations: 1. The intersection line in 3D (a segment), which divides the intersection of projected triangles in 2D, i.e., a loop, into two smaller loops after the intersection line is also projected into XY coordinate plane, as shown in Figure 3.19(c). These two new loops are defined as sub-loops. In this situation, two polyhedrons can be generated based on the two sub-loops, as shown in Figure 3.19(d) and Figure 3.19(e). In practice, most of the cases fall into this situation. 2. The intersection line in 3D exactly is an edge of the intersection of triangles in 2D; in other words, the line segment coincides with an edge of the intersection loop. Thus, there is only one sub-loop and thus in further only one polyhedron can be generated in this situation.
3.3.4
Obtaining Updated Top Surfaces
After forming at least one block and before adding another surface, the top polygonal surface needs to be found. This is because the newly added surface in the next step will intersect this generated top polygonal surface and then form a new block. Noticeably, the newly formed block can derive from only the intersecting of the top polygonal surface with the newly added surface, or both the above intersecting and the cutting of the previous blocks by the newly added surface. This process of cutting and intersection of new surface with previous geological blocks will be introduced in the next subsection. In this subsection, the procedure of how to obtain the top polygonal surface of a generated sedimentation model which is composed of at least one block. Obviously, the top polygonal surface is certainly the boundary of the already formed blocks. Thus, the boundary faces of the polyhedral model are first found. This can be very easily carried out by checking the number of being shared by polyhedrons for each polygonal face; this checking is easily understood by considering the topology of the polygonal mesh model since that a 47
Intersection loop
(a) Two triangles in 3D
Sub-loops
(b) The intersection after projecting
2
1
(c) Intersection in 3D and sub-loops in 2D
(d) Sub-loops in 3D after updating Z values
(e) The two polyhedrons
Figure 3.19: Forming two polyhedrons based on two triangles intersected in both 2D and 3D 48
(a) Two triangular surfaces (The bottom surface and the first surface)
(b) The generated block
Figure 3.20: Forming a block by intersecting in both 2D and 3D 49
polyhedron is composed of several polygonal faces and each polygonal face can be shared (used) by one or two polyhedrons. The simple fact is that if a polygonal face is shared by two adjacent polyhedrons in a polyhedral mesh model, then the polygonal face is inner (i.e., not a boundary face); and it is obvious that a polygonal face is the boundary face if it is shared by only one polyhedron. Therefore, all boundary polygonal faces can be determined by checking the numbers being shared by polyhedrons. After finding all boundary faces, there still exist unexpected faces such as those of the bottom surface and all the vertical faces. And these unexpected faces should be eliminated via some effective methods. For the vertical polygonal faces, their normals are perpendicular to the Z-axis. Thus, the normal of each polygonal face is first obtained by calculating the equation of its underlying plane; and then the normal is checked whether it is perpendicular to the Z-axis. For the polygonal faces of the bottom surface, if being viewed in the top viewpoint, they will be covered by corresponding polygonal faces of the top surface. Given a vertical line which goes through a polygonal face of the bottom surface, the line will certainly intersect the polygonal face of the bottom surface and a corresponding polygonal face of the top surface at two points denoted as Pbottom and Ptop , respectively. Obviously, the Z coordinate of the intersection point Pbottom is less than that of the point Ptop . Thus, a polygonal face can be determined whether it is in the top or bottom surface by creating a vertical line first and then checking the Z coordinates of the intersection points Pbottom and Ptop . After obtaining the polygonal top surface (see Figure 3.21), it needs to be converted into a triangular surface mesh by dividing any polygonal face into several triangles by polygon triangulation algorithms such as ear-cut or Delaunay. This conversion is needed since that in RealModel only the intersecting of a pair of triangular surface mesh is implemented; and if the top surface is transferred from a polygonal mesh to a triangular mesh, then in the next step when adding a new triangular surface, only the implementation of the intersecting of two triangular surfaces is needed to carried out, while without implementing the intersecting of a polygonal surface mesh (such as the original top surface) with a pure triangular surface mesh. In summary, the procedure of obtaining the top surface of a previously generated sedimentation model (i.e., a polyhedral mesh model) can be mainly divided into the following steps: Step 1: Obtain all boundary polygonal faces of the polygonal mesh model. Step 2: Eliminate the unexpected boundary faces (vertical faces and faces of bottom surface). Step 3: Convert the polygonal top surface into a triangular surface mesh by triangulating any polygonal face, as shown in Figure 3.22.
50
Figure 3.21: Polygonal top surface without polygon triangulation
3.3.5
Cutting and Intersection of New Surface with Previous Blocks
In this subsection, the problem is of how to cut previous polyhedrons down and form new polyhedrons when adding a triangular surface into a 3D sedimentary model created in the last step. In order to introduce this problem in detail, several sub problems are described, including how to compute intersection of a plane with polyhedron, how to compute intersection of triangle with polyhedron, and if adding a triangular surface then how to cut down needless polyhedrons and form desired polyhedrons.
Intersection of Plane with Polyhedron Step 1: Compute the signed distance of each vertex to the plane. The efficient method to compute the signed distance from a point to a plane is described on the pages 374∼375, Geometric Tool for Computer Graphics (Schneider and Eberly, 2002). When the distance is positive, zero or negative, note it as +, 0, − respectively. Mathematically, there are 7 combinations: {0}, {+}, {−}, {0, +}, {0, −}, {+, −} and {+, 0, −}. In geometry, each case (combination) has its own meaning. Only case 6 {+, −} and case 7 {+, 0, −} are what we are interested in. And these 2 cases can be considered as only one case {+, . . . , −}, which means the distance of one vertex or several 51
(a) The top surface (a triangular surface mesh)
(b) The triangulations of all polygonal faces
Figure 3.22: Triangular top surface after polygon triangulation 52
vertices to the plane is positive, while one or several distances are negative. In this case, the cross section is a polygon and 2 new polyhedrons will be formed.
Plane
Plane
Intersection line
Intersection line
Polygon
Polygon
(a) Intersection line is on an edge
(b) Intersection line is not on an edge
Figure 3.23: The intersection of a polygon with a plane Step 2: Compute the intersection of each face of polyhedron with the plane. Each face of a polyhedron is a polygon; the computing of the intersection of a polyhedron with a plane is exactly to compute the intersections of these polygonal faces with the plane. The main steps are as follows: 1. Compute the signed distance of each vertex of a polygon with the plane. 2. Compute each edge of the polygon with the plane, and record all intersection points. 3. Use every intersection point to divide its corresponding edge and record them. If the intersection point is exactly at the vertex of the edge, only one edge can be formed, which is just equal to the original edge. Add it into the set of edge. If the intersection point is not at the vertex of the edge, two new edges can be formed by three vertices (two original ones and a new one). Also, add the edges into the set of edge. 4. Form the intersection line (a segment) by 2 intersection points. If the intersection line coincides with an edge of the face, as shown in Figure 3, store the intersection line and this original face as a new one; there is no need to compute the subdivisions of the polygon. If the intersection line is not an edge of the face, as shown in Figure 4, two new faces will be formed, store the intersection line and then go to the next step. 5. Compute each edge with the plane to test on which side it lays. An edge (a segment) can be on the positive or negative side of a plane, or even just on the plane. The following method describe how to test the edges except the intersection line. Firstly, compute the center of gravity of each edge; the coordinates of the center of gravity are the 53
averages of the coordinates of all vertices. Secondly, compute the signed distance of the center of gravity to the plane. If the signed distance is positive or negative, then the edge is on the positive or negative side. 6. Form 2 new polygons. All the positive edges and the intersection line (a segment) can form a ‘positive’ polygon, while all the negative edges and the intersection line (a segment) can form a ‘negative’ polygon. Step 3: Form the cross section (a polygon). After computing the intersection of each face of polyhedron with the plane, an intersection line can be generated if the face intersects the plane. As described in step 2, there are only two cases that need to be considered. One case is that the intersection line, which is a segment, is just an edge of the face. In this case, when use the intersection line to divide the original face (polygon), only one polygon can be formed and this new one is exactly the same as the original face. The other case is that the intersection line, which is also a segment, is not an edge of the face. In this case, when using the intersection line to divide the original face (polygon), two new polygons can be formed. No matter in which case, all the intersection lines are needed and adopted to form the cross section. The following paragraph will explain how to form a polygon / face if there are some segments / edges. The method is, firstly find an intersection line and add its two vertices into a set of vertex. Then during the rest intersection lines, search to find out an intersection line which one of its vertices is the same as the last member (vertex) of the set of vertex, if does, add the other vertex of the intersection line into the set of vertex as the new last member of the set. And repeat the search operation iteratively until the first member of the set is the same as the last member. Step 4: Form two new polyhedrons. After computing the intersection of each face of polyhedron with the plane, some new faces (polygons) are formed. Before computing the intersection, a set of face is created to store all faces. For each face of the original polyhedron, it may intersect the plane or not. If it does intersect and the intersection is one of the two cases described in step 2, then save and add one or two new faces into the set of face; if it does not, add the original face into the set of face directly. Noticeably, add the cross section into the set of face. As it is known, the plane cuts the original polyhedron into two new polyhedrons. Obviously, one polyhedron is on one side of the plane, while the other polyhedron is on the other side. And it has been described that the side of a plane is denoted as positive or negative side. If the polyhedron is on the positive side of the plane, all its faces except the cross section are one the positive side; so does the polyhedron on the negative side. Hence, the next thing we would like to do is test which side the faces are on. 54
Cross section
Polyhedron
Plane
Figure 3.24: Intersection of a plane with a polyhedron Similarly, compute the coordinates of the center of gravity of each face. It’s easy because the average of the coordinates of each vertex of the face is just the coordinates of center of gravity; then, compute the signed distance of the center of gravity to the plane, if the distance is positive, the corresponding face is on the positive side, so does the negative one. And then, use all the ‘positive’ faces and the cross section to form the ‘positive’ polyhedron; use all the ‘negative’ faces and the cross section to form the ‘negative’ polyhedron.
Intersection of Triangle with Polyhedron The algorithm for computing the intersection of triangle with polyhedron is as follows. Step 1: Create bounding boxes such as AABB or OBB for a triangle and polyhedron, and then use the bounding box intersection test to eliminate the case that does not intersect. Step 2: Compute the plane equation of the triangle, create a plane on which the triangle lays according to the plane equation, and then compute the intersection of a plane with polyhedron. Noticeably, when computing the intersection of a plane with polyhedron, the purpose is to find out the cross section (a polygon); and in order to avoid redundant computation, there is no need to form new polyhedrons. Step 3: Compute the local coordinate system of the triangle, and then transfer the local system to make sure the triangle and the cross section are on XY coordinate plane. And then compute the intersection of polygon with polygon to generate the final intersection. When the triangle and cross intersection are on XY coordinate plane, the z coordinate is equal to 0. Thus, the triangle and cross section can be considered as two polygons in 2D. Computing of intersection of triangle with a triangle in 2D is actually to compute intersection of polygon with polygons in 2D. After computing the intersection of triangle with cross section, the last thing is 55
to transfer the intersection from 2D to 3D, i.e., change it back, as shown in Figure 3.25. Polyhedron
Cross section Plane
(a) Intersection of a plane with a polyhedron
Cross section
Triangle
Intersection
Plane
(b) Intersection of a polygon with a polygons
Polyhedron
Cross section
Plane
Triangle Intersection
(c) Intersection of a triangle with a polyhedron
Figure 3.25: The intersection of a triangle with a polyhedron
Intersection of Surface with Polyhedron When a triangular surface has been added into a 3D model, it needs to test that which polyhedrons intersect with the surface. If there are intersected polyhedrons, then use the surface to divide each intersected polyhedron and then remove needless polyhedron. The method to compute the intersection of a surface with polyhedron is as follows: Step 1: Use the method of computing the intersection of triangle with triangle to obtain the cross section of a polygon with triangle surface. The cross section consists of one or several triangles or polygons, as shown in Figure 3.26(a). 56
Polyhedron An original face Cross section
New face 1 Boundary edges
Boundary edge
New face 2
(a) Cross section and boundary edges
(b) Dividing by boundary edges
Figure 3.26: The intersection of a surface mesh with a polyhedron
Step 2: Rearrange and merge all points and segments (edges), compute the number of sharing each edge. If the number of shares is equal to 1, then it means this edge is a boundary edge, as shown in Figure 3.26(a). Step 3: For each face of the original polyhedron, find out that which boundary edge(s) is (are) on the face. Step 4: For each face, if there are boundary edges on it, then use the boundary edge(s) to divide it. 1. Compute which vertices of the boundary edges are on the edges of the face, then use the vertex to divide the edge and add the new edge into a set of edge. 2. Test all edges of the set of edge to decide which edge is on the positive or negative side of the boundary edges (a polyline). The method is to compute the center of gravity of each edge, and then compute the distance of the center of gravity to the boundary edges. This method has described before. Using all edges of the set of edge to form new polygons (faces), as shown in Figure 3.26(b): All ‘positive’ edges + polyline = ‘positive’ polygon; All ‘negative’ edges + polyline = ‘negative’ polygon. Step 5: Add all newly forming face into a set of face, and add the original edges which has not been divided into the set. Compute the center of gravity of each face, and then compute the signed distance of the center to each polygon of cross section. If the signed distance > 0, the face is ‘positive’; if distance < 0, the face is ‘negative’. Step 6: Form new polyhedrons 57
All ‘positive ’faces + cross section = ‘positive’ polyhedron; All ‘negative’ faces + cross section = ‘negative’ polyhedron. To test which side each face is on, firstly form a tetrahedron using the center of gravity of each face with 3 vertices on a polygon of cross section. And then compute the volume of a tetrahedron, if the volume > 0, the face is positive; if the volume < 0, then the face is negative. Noticeably, there is a special case: when the cross section is a plane, and it lies on a face of the polyhedron, at this time, the newly formed polyhedron is similar as the original polyhedron, the difference between the new polyhedron and the original one is that a face of the original polyhedron is an entire polygon, but in the new polyhedron the corresponding face is divided into one or several polygons, in other words, the face of new polyhedron is the cross section. So, in this case, there is no need to compute which side each face is on, just form a new polyhedron according to the cross section and the original polyhedron. Intersection of Surface with Block Groups When a triangular surface is added into a previous 3D sedimentary model, it may result in (1) only forming new polyhedrons, (2) only dividing and removing old polyhedrons, or (3) forming new polyhedrons and removing old polyhedrons.
S2 3 2
1
S2 S1
3 2
S0
S1
1 S0
(a) S0 and S1 intersect in 2D and 3D
(b) S0 and S1 intersect only in 2D
Figure 3.27: Intersection of Surface with Block Groups In Figure 3.27, layer 1 and 2 are created by surface S0 and S1. Layer 3 is created by surface S1 and S2, but cut layer 2 down. For surface S0, its original triangle mesh can be divided into a polygon mesh by intersection lines in 2D and/or 3D. However this not important because there are no more surfaces intersect S0 to create polyhedrons/layer anymore. Thus, there is no need to divide and combine polyhedrons to make sure all ‘bottom’ faces of newest polyhedrons are triangles, in other words, to make sure the surface S0 is converted to be a new triangle mesh. For surface S1, it must be recreated into a new triangle mesh. And there are 2 cases: 58
Add in surface S0 and S1
S0 and S1 are triangle mesh
S0 intersect S1
S0 and S1 are polygon mesh
Combine and/or divide polyhedrons
S0 is polygon mesh S1 is triangle mesh
Add in surface S2
S2 is triangle mesh
S1 and S2 are polygon mesh
S1 intersect S2
S1 is polygon mesh S2 is triangle mesh
Combine and/or divide polyhedrons
Figure 3.28: Procedure of adding surfaces and modeling
59
Case 1: S1 and S0 intersect only in 2D, as shown in Figure 3.27(a). After computing the intersection of surface S0 and S1, polyhedrons are formed. According to the original triangle mesh of surface S1, combine relative polyhedrons to form new polyhedrons to make sure all ‘top’ faces of the polyhedrons are the same as the original triangle mesh of S1. Case 2: S1 and S0 intersection in both 2D and 3D, as shown in Figure 3.27(b). For those triangles which intersect in both 2D and 3D, the intersection line in 3D divides original triangles into several triangles and/or polygons. After forming the polyhedrons, if the ‘top’ face of the polyhedron is a polygon (except a triangle), divide this polygon into several triangles and update the original polyhedron to make sure its ‘top face’ consist of triangles. For those triangles which just intersect in 2D, according to the original triangle mesh of surface S1, combine relative polyhedrons to form new polyhedrons to make sure all ‘top’ faces of the polyhedrons are the same as the original triangle mesh of S1. The purpose of combining and dividing polyhedrons is to make sure each newly added triangle surface will keep as a triangle mesh, if possible, keep the newly added triangle surface as its original triangle mesh. The procedure of adding new surface and creating polyhedrons is as shown in Figure 3.28. Before computing the intersection of a pair of surfaces, all original surfaces like surface S0, S1 and S2 are triangle surfaces. After computing the intersection of S0 and S1, they change to a polygon mesh. Firstly S0 and S1 are same as each other if they are mapped into XY coordinate plane. In other words, if do not consider the zvalue, S0 and S1 are the same one. However, after the polyhedrons created by S0 and S1 are combined or divided, surface S0 still keeps as polygon mesh, surface S1 change back to triangle mesh, if possible, change back to its original triangle mesh. Hence, in the next step, when adding surface S2, and both S1 and S2 are triangular meshes, it only needs to compute the intersection of another pair of triangle surfaces, not a polygon mesh with a triangle mesh. Again, when adding in a triangle surface and then computing the intersection of the newly added surface with the last surface, it is much easier and faster to get the intersection if the new added one and the last one are both triangle meshes. Additionally, keep the last one as its original triangle mesh if possible.
3.3.6
Determine Property of Geological Blocks
After creating all layers of the sedimentary rocks, the final step of the modeling is to identify and then set the properties for each geological layer. The properties include the type of the rocks, the age, structures, and other description about the layers. In RealModel, a library of properties is specifically created for each geological model, which consists of lists of properties; a list of properties is specifically created for an individual geological layer. And the library is in fact a 60
(a) The previouse blocks and a newly added surface
(b) The blocks after only cutting
Figure 3.29: Forming new blocks by only cutting a block with a newly added surface 61
(a) The triangular top surface and a newly added surface
(b) The new block generated by only intersecting
Figure 3.30: Forming blocks by the intersecting of the top surface with a newly added surface 62
Figure 3.31: The blocks created by both cutting and intersecting
Figure 3.32: The previous blocks and another new surface in next step 63
(a) All previous blocks and the last surface
(b) All the blocks
Figure 3.33: The final step of building a simple sedimentation model 64
list of descriptions about each geological layer, which can be defined in a separate file. Before defining the properties of the geological layers, it is needed to create a library of properties. In RealModel, this function of creating libraries of properties has not yet been implemented. Alternatively, this procedure of establishing the libraries of properties can be quite conveniently realized manually. And in the above procedure, a key step is to give a unique index (ID) to each list of properties for being referred simply. A geological layer may be composed of one or several unconnected blocks that have the same list of properties. A block is a group of polyhedrons that are created by intersecting and/or cutting. When defining the properties of the geological layers, the list of properties is individually set and attached to a block rather each polyhedron. In fact, the definition of the properties can be very simply realized by setting and attaching the index of a list of properties rather the properties themselves to each block; in other words, the specific list of properties of each block can be referred to a library of properties according to the index (ID) of the list.
3.4
Implementation of Several Key Techniques
3.4.1
Supporting Exact Geometric Computation (EGC)
Non-robustness issues usually arise in geometric computations. There are various practical approaches to dealing with the non-robustness problem in geometric computation (see surveys in (K.Yap, 2004; Schirra, 2000, 2004)). Since about the year 1990, a method named Exact Geometric Computation (EGC) has emerged (K.Yap, 1997), and soon become one of the most successful options. Major geometric computation libraries such as CGAL (Fabri et al., 1998; CGAL, 2013) and LEDA (Mehlhorn and N¨aher, 1999; LEDA, 2013) are designed on the basis of supporting the EGC principles. As one type of geometric modeling systems, the 3D geological modeling system RealModel is also definitely sensitive to nonrobustness problems due to the numerical and the geometrical nature of adopted algorithms. The 3D geological modeling system could not be reliable without considering the robustness issues in geometric computation. As mentioned several times, there are two main components in the system RealModel, i.e. visualizing and modeling. When visualizing of geological objects, the supporting of the EGC principle is not needed. The displaying / rendering of geometric entities can be fast performed using inaccurate numbers represented in single-precision or even integers without needing to support the EGC principle. In the various geometric computations that are used in building the geological models, only some very important procedures or algorithms such as the intersecting of two triangles or a triangle with a polygon need to support the EGC principle. Not all procedures in the entire geometric modeling for building geological models need to support the EGC; this is because (1) it is not needed and (2) it would be very slow if all geometric computations are realized under 65
the EGC framework. In RealModel, several pre- and/or post- steps during creating the geological models are not implemented to support the EGC. These steps include the procedures for generating triangle meshes (mesh generation), creating single-valued surfaces via spatial interpolation, and the updating and renumbering for geological models composed of sets of polyhedrons. The key activities in RealModel are the intersecting of triangulated surfaces and the cutting of polyhedrons with triangulated surfaces. More specifically, the key procedures are the intersecting of two triangles and the intersecting of a triangle with a polyhedron. Both of the above two procedures have been implemented to support the EGC principle by using the CORE library. This can be very easily realized by adding the following runtimes to the original C/C++ code: #ifndef CORE_LEVEL # define CORE_LEVEL 3 #endif #include "CORE/CORE.h"
Besides adding the above runtimes, several other modifications are also made: 1. Change the accuracy of numbers from single-precision to double-precision, i.e., from float to double The CORE library can automatically recognize and transfer the numbers represented with double-precision into corresponding numbers represented with multi-precision, and then perform the computations in multi-precision. Single-precision numbers cannot be recognized and thus are ignored. 2. Avoid any DLLs (dynamic link library) involving the geometric computations in which the EGC is expected to support When developing complex software packages, the files DLLs are popularly created to encapsulate individual functions. A DLL version is also created for the intersecting of triangle pairs; however, such DLL cannot be called within the runtimes in which the EGC is supported. The solution is to directly call the functions or classes for performing the intersecting while supporting the EGC. In addition, the much more detailed descriptions and discussions of the non-robustness issues in geometric computations are presented in Appendix A.
3.4.2
Parallelization Based on the Library OpenMP
The OpenMP (2013) is one of the most popular frameworks for implementing parallel algorithms. Parallelization based on OpenMP is much easier to realize than that based on MPI . Only several very simple runtimes need to be added for transforming the serial code into the corresponding parallel version. In addition, the complier IDE Visual Studio, which is adopted to develop RealModel, can directly support the OpenMP without needing extra installation. 66
In RealModel, several relatively simple but important algorithms or procedures are carried out to be parallel based on the OpenMP, including the intersection of triangle pairs, the intersection of triangle with polyhedrons, and the partitioning for polygons (polygon triangulation). The above three implementations are the key procedures for building sedimentary models via the intersecting of triangulated surfaces and the cutting for polyhedrons with triangulated surfaces. When calculating the intersections of triangulated surfaces, the heart of this procedure is to compute the intersection of two triangles. Since that the calculating of the intersection of a pair of triangles does not affect or depend on the calculating of another pair, it is able to compute the intersections for several pairs of triangles synchronously. This is the basic idea for implementing the intersecting in parallel. The following piece of code demonstrates the parallel implementation of the intersecting of triangles. Noticeably, no matter the intersection line of a pair triangles exists, it should be stored into a pre-allocated array rather into a dynamically allocated array. // Parallel Computing #pragma omp parallel for for(int i = 0; i < numOfPairs; i++) { CPair* pr = a triangle pair; CTrgl* ta = 1st triangle of the pair *pr; CTrgl* tb = 2nd triangle of the pair *pr; // Calculate using Moller’s algorithm CEdge* eg = line segment; moller.tri_tri_intersect_with_isectline(ta, tb, eg); // Save intersection line m_aInsectEdge[i] = eg; } // End Parallel Computing
The procedure of calculating the intersection of a triangle with a polyhedron is similar to that of triangle pairs, which can be reduced into the intersections of the triangle with each polygonal face of the polyhedron. The intersecting of a triangle with a polygon is quite similar to that of two triangles, and is able to be easily implemented in parallel. Another parallel implementation based on the OpenMP is polygon triangulation (i.e., to divide a polygon into a set of triangles). After performing the intersecting of triangulated surfaces, most intersected triangles are divided into two or more sub-polygons with the intersection lines. In order to reduce the computational complexity in the subsequent modeling procedures, those sub-polygons need to be transformed into triangles, and any surfaces composed of generic polygonal faces should be transformed into surfaces consisted of only triangles. Obviously, the subdivision of a polygon does not affect or depend on that for another polygon; thus, several polygons can be triangulated synchronously in parallel threads. A problem 67
in the parallel implementation is the storage for the generated triangles: the resulting triangles are obtained dynamically and can be stored into a dynamic array in serial implementation, but in parallel implementation, the computational results from different threads may conflict when being stored into a dynamic array. The solution to the above problem is as follows: in parallel implementation, the generated triangles of ONLY a polygon are stored into its privately owned dynamic array, and after dividing all polygons in parallel, all obtained triangles will be merged into a global dynamic array in serial. // Parallel Computing #pragma omp parallel for for(int i = 0; i < numOfPolygons; i++) { CLoop* pg = a polygon; // Divide polygon *pg into triangles // Save obtained triangles in *pg dividePolygon(pg); } // End Parallel Computing // Serial Code for Storing for(int i = 0; i < sizeOfPolygons; i++) { CLoop* pg = the ith polygon; for(int j = 0; j < numOfTri; j++) { CTrgl* tr = the jth triangle in *pg; m_aTrgl.Add(tr); } } // End Serial Computing
3.4.3
Parallelization Based on CUDA-enabled GPUs
“CUDATM (Compute Unified Device Architecture) is a parallel computing platform and programming model invented by NVIDIA. It enables dramatic increases in computing performance by harnessing the power of the graphics processing unit (GPU) (CUDA, 2013).” “Using CUDA, the latest NVIDIA GPUs become accessible for computation like CPUs. Unlike CPUs, however, GPUs have a parallel throughput architecture that emphasizes executing many concurrent threads slowly, rather than executing a single thread very quickly. This approach of solving general-purpose problems on GPUs is known as GPGPU (Wikipedia, 2013).” Due to the powerful capability for parallel computation, CUDA has been widely used in Bioinformatics, computational biology, CFD, image processing, computer vision and other fields in which high performance computing (HPC) takes a really important role. Also, CUDA has been used in geometric computation such as mesh generation or calculating convex hulls [] in order to speed up those algorithms. 68
In RealModel, CUDA is also accepted to deal with several procedures that are quite time consuming such as the solving of a large system of equations and the sorting for a large number of geometric entities. However, the implementation based on CUDA in RealModel focus on dealing with those problems involving geometric computation. In the process of modeling in RealModel, after adding a new surface and then performing the intersecting of surfaces and the cutting of previous blocks with the new surface, it is needed to merge the old polyhedrons formed by cutting and the new polygons formed by intersecting into a newer model that is generated in the current step of modeling. Real application examples have shown that this procedure of merging is quite time consuming and thus is one of the bottlenecks during the modeling process. The merging of sets of polyhedrons is in fact the updating or the renumbering, which consists of the following sub-procedures: 1. Merging and then renumbering all the vertices of all polyhedrons 2. Updating the indices of the vertices that are used to compose each polygonal face A polygonal face is composed of several vertices; due to the indices of all vertices are updated in step (a), the indices of the vertices in a polygonal face is no longer valid and thus needed to be updated. 3. Merging and then renumbering all the polygonal faces Identical polygonal faces may exist; thus all faces need to be merged and updated. 4. Updating the indices of the polygonal faces that are used to form each polyhedron A polyhedron consists of several polygonal faces. In the step (c), the indices of all faces are updated, thus the indices of the faces in a polyhedron need to be updated to obtain their new indices. A key procedure in the merging is to check whether any pair of geometric entities is the same, for instance, to check whether two vertices or two polygons are the same. In the brute force method, a vertex in an array of unordered vertices needs to be checked with each of the rest vertices; and the time complexity is O(n2 ). An efficient solution to the above problem is to sort all vertices first and then check each vertex with its one or two neighbors. Thus, the sorting for a set of geometric entities is strongly desired. The sorting for only numbers like integers or floats is a problem in pure mathematics, which has been excellently realized in the CUDA programming samples given by NVIDIA (CUDA Samples, 2013). And the advanced sorting for Structures or Classes such as a vertex with its index and coordinates is more complex. In RealModel, such type of sorting has been implemented to sort sets of vertices, sets of polygons, and sets of polyhedrons in order to speed up the modeling process. For example, the simplest case of sorting, i.e., the sorting of sets of vertices, can be performed quite easily using the library Thrust.
69
70
Chapter 4 Boolean Operations for Triangulated Surfaces† 4.1
Introduction
Boolean operations are an important aspect in computational geometry, which are used to obtain union, subtraction and intersection of geometric models. The most commonly used method to display geometric models probably is the boundary representation (B-Rep) (Hoffmann, 1989) which can be based on parametric surfaces such as NURBS surfaces or discrete surfaces. The discrete surface is the decomposition of a specific surface domain, of which polygonal meshes especially triangular meshes is the most popular kind of representation form. This chapter focuses on the implementation of Boolean operations over triangular meshes. And the simple and robust Boolean operations are aimed at a pair of manifold triangulated surfaces without considering the case of self-intersecting meshes. In this algorithm, surfaces are classified into two types: open or closed. The Open surfaces have outer or inner boundary loops while closed ones without. When a surface is closed, the geometric model bounded by it can be called as a volume or a block. The geometric objects that are manipulated are a pair of manifold triangulated surfaces which can be open-and-open, open-and-closed or closed-and-closed.
4.1.1
Related Work
Various implementations of Boolean operations have been described in the literatures, which can be classified according to the type of input data, the type of computation and the type of output data (Pavic et al., 2010). Tayebi et al. (2011) assort Booleans into four categories, i.e., exact arithmetic methods (Campen and Kobbelt, 2010), approximate arithmetic methods (Smith and Dodgson, 2007), interval computation methods, and volumetric methods (Wang, 2011). †
This chapter is taken directly from the author’s posted preprint paper (Mei and Tipper, 2013)
71
Most of approaches described in the literatures specially aim at one type of the input models such as those by B-Rep based on NURBS surface (Tayebi et al., 2011; Yang and Qian, 2009), curved surface (Lo and Wang, 2005) and polygonal meshes (Campen and Kobbelt, 2010; Pavic et al., 2010; Schifko et al., 2010). Besides these popular surface-based representations, several other methods like Nef (Hachenberger and Kettner, 2005) and surfel-bounded (Adams and Dutr´e, 2003) for representing geometric models are also developed to construct new models or convert existing ones to target models, and then Boolean operations are also implemented. In another aspect, the input models can be manifold or non-manifold (Pereira et al., 2012), and most methods perform Booleans on manifold ones. Among those types of computations, the exact arithmetic methods and interval computation methods compute Booleans directly over the initial surfaces, while the rest do not and hence are deemed to be indirect. When implementing the direct Booleans for mesh models, there are typically two key procedures which strongly affect the effectiveness and efficiency of the whole algorithm. The first one is how to robustly obtain the intersection lines and loops of all intersected entities as faster as possible. The core of such procedure is to accurately find out all potentially intersected entities in a short time to reduce computational cost. Many techniques based on BSP (binary space partitions) (Campen and Kobbelt, 2010), Octree (Pavic et al., 2010), OBB trees (Gottschalk et al., 1996), AABB trees (Van Den Bergen, 1997) and tracking neighbors (Guo et al., 2007; Lo and Wang, 2005) have been developed to realize this goal. The second key procedure is how to correctly assemble and distinguish the union, subtraction and intersection of intersected models. The most direct method is to make a inside/outside classification (Chen et al., 2010), which checks the location of vertices or facets with the resulting volumes. Many algorithms of direct Boolean operations develop their own solutions for the above two problems. Quite recently, several novel methods of Boolean operations on polygonal meshes have been presented. Pavic et al. (2010) develop a hybrid method which combines polygonal and volumetric computations and representations for performing Boolean operations over polygonal meshes; similarly Garc´ıa et al. (2011) use Extended Simplicial Chains(ESCs) to represent both boundary and volume of free-form solids when perform Booleans. Aiming at robustness of Boolean operations for large number of triangles in industrial applications, Schifko et al. (2010) adopt several suitable libraries from CGAL and GNU multi precision arithmetic library to filter exact arithmetic. An approximate method based on Layered Depth Images(LDI) for polygonal models is developed in Wang (2011), in which LDI is accepted to sample and trimmed adaptive contouring is used to rebuild intersected meshes.Campen and Kobbelt (2010) adopt plane-based representations, BSP techniques and a localization scheme to obtain exact and robust (self-) intersections for polygonal meshes. Besides the well-known libraries CGAL (2013), several open source libraries or packages such as MeshLab (Cignoni et al., 2008), OpenFlipper (M¨obius and Kobbelt, 2012), MEPP (Lavou et al., 2012)) also contains robust implementations of Boolean operations.
72
4.1.2
Highlights
When designing algorithms to solve a specific problem, normally a fast algorithm with better efficiency also has higher complexity than a slow one. This is certainly true for performing Boolean operations on triangular meshes. In this paper, an objective is to try to keep a relative balance between the efficiency and complexity of such algorithms. And the objective is to develop a simple and robust approach of Boolean operations which also have satisfied efficiency. Several highlights can be drawn in the method: (1) A simple and relative fast method to calculate the intersection lines of triangles. In order to reduce computation cost, firstly the spatial decomposition data structure Octree is used to locate and search candidate intersected triangle-pairs, and then compute the intersection line of each pair of triangles parallel. (2) A fast approach only based on operations of the indexes of entities and without computation for coordinates to obtain intersection loops, sub-surfaces and sub-blocks. (3) A novel technique to distinguish the union, intersection and subtraction volume of two intersected closed surfaces(solid models). This simple classification method is very fast and robust since it is also only based on operations of the indexes of entities. The rest of this chapter is organized as follows. In Sect.2, a brief view is given to the algorithm; in Sect.3 some data structure and define several notations are designed for the implementation; and then, all details of the approach will be described in Sect.4; Then, several examples are presented to illustrate the effectiveness of the approach in Sect.5, and finally conclude and discuss the work in Sect.6.
4.2
Overview
The approach can be mainly summarized into 6 steps, as shown in Fig.4.1. In the aspect of computation, the approach can be divided into two sub-procedures: the first, which is based on computation for coordinates of entities, includes searching intersected triangle-pairs, calculating intersection line of each pair of triangles, polygon triangulation (re-triangulation) and updating the resulting surface meshes; the second procedure is only based on operations for indexes of entities including forming intersection loops, creating sub-surfaces, assembling and distinguishing sub-blocks. This procedure can be robust and fast for that it only manipulates indexes while without considering coordinates. Step 1: Search the candidate intersected triangle-pairs. In order to reduce the cost on computing, a robust and fast search algorithm is needed to obtain all triangle-pairs in which two triangles may intersect with each other. And the spatial decomposition data structure Octree (Meagher, 1982) is used to locate and find out all candidate intersected triangle-pairs. Step 2: Compute the intersection line for each pair of triangles. M¨oller (1997) has developed a robust and efficient algorithm to do this. Additionally, when there are a huge number of 73
Input 2 surface meshes Search intersected triangle-pairs
Compute intersection and re-triangulate
Merge and update surface meshes
Assemble sub-blocks and distinguish
Create sub-surfaces
Form intersection loops
Output subsurfaces or/and sub-blocks
Figure 4.1: Flow of the approach
triangle-pairs that needed to calculate their intersections, parallel computation based on OpenMP (OpenMP, 2013) is used here. Step 3: Merge and renumber all vertices, update and clear meshes. New vertices will be produced after intersecting of triangle-pairs, and the original intersected triangles are replaced by re-triangulated triangles. In order to maintain the resulting meshes to have a valid topology, firstly all vertices must be merged and renumbered, then all triangles must be updated and checked whether it is valid. Step 4: Connect intersection lines into closed or open loops. After computing the intersection of each pairs of triangles, a set of discrete edges can be obtained, and they need to be connected into closed or open orientated loops. If there not exists at least one closed loop on an intersected surface, then no closed block bounded by triangular facets will be formed. Step 5: Obtain sub-surfaces based on closed loops. A sub-surface includes the closed loop and all of its incident triangles. The edges of a closed loop are set as the advancing front; ”grow” a new surface based on the topology of the target intersected surface until the number of faces in the sub-surface not increases. A sub-surface could be privately owned by a closed loop (Fig.4.2(b)), or shared by several closed loops (Fig.4.5(b)). Step 6: Assemble and distinguish sub-blocks according to Booleans. As mentioned above, surfaces can be open or closed. The Boolean operations for different types of surface are varied (Table.4.1). Sub-blocks can be easily created by assembling related sub-surfaces (Fig.4.2(c)). In further, the boundary closed loops generated in Step 4 of sub-surface can be used to represent the sub-surface. Hence, assembling and distinguishing can be done based on the boundary closed loops. Figure.4.2 shows a simple example of Booleans. 74
A
B
A+B
(a) Original closed triangulated surfaces
(b) Sub-surfaces
A∪B
A∩B
A-B
B-A
(c) Sub-blocks
Figure 4.2: A simple example of Boolean operations for closed surface meshes(blocks). In (c), the notations A∪B, A∩B, A−B and B−A represent the union, intersection, and subtractions of models A and B, respectively.
Surfaces
Table 4.1: Boolean operations on triangulated surfaces Operations Results
open one + open one open one + closed one closed one + closed one
intersect
only sub-surface, no sub-block sub-surface, and sub-block divide sub-surface ,and sub-block only sub-block, no sub-surface intersect, add, subtract only sub-block, no sub-surface
75
Class
Entity
CVert
Vertex/node
CEdge
CTrgl
CPoly
CLoop
CSurf
CBlock
4.3
Table 4.2: Data structures Members Variable Type
ID x, y, z ID Directed edge Head, Tail ID vtID[3] Triangular face egID[3] x[3], y[3], z[3] ID m vtIDs Polygonal face m egIDs x, y, z ID Edge loop m vtIDs m egIDs ID m vtIDs (Sub-)Surface m trIDs m lpIDs ID m vtIDs (Sub-)Block m trIDs m lpIDs m sfIDs
int double int int int int int double int CArray CArray CArray int CArray CArray int CArray CArray CArray int CArray CArray CArray CArray
Meaning ID of node Coordinates ID of edge Two endpoints ID of triangle IDs of vertices IDs of edges Coordinates ID of polygon IDs of vertices IDs of edges Coordinates ID of polygon IDs of vertices IDs of edges ID of polygon IDs of vertices IDs of triangles IDs of loops ID of block IDs of vertices IDs of triangles IDs of loops IDs of surfaces
Data Structure and Notation
In this section, some Classes for necessary geometric entities are defined in C++ (Table.4.2), and additional properties such as direction are added onto some of them. Definition 1 Directed edge is a directed segment, in which the first vertex is named as Head, while the other is Tail. Definition 2 Orientated loop is a set of connected directed edges, which can be closed or open. It can be also represented by a set of ordered vertices. A pair of orientated loops are defined as twins if they have same vertices and opposite order. Definition 3 Normalized face is a coplanar polygon with its normal, which is triangle or polygon in this paper. To describe the algorithm clearly by pseudo codes in following sections, several common 76
geometric objects and allocate arrays are developed to store geometric entities. vi for the ith vertex, ei for the ith edge, Li for the ith loop, Ti for the ith triangular face while Pi for polygonal face, Si for the ith surface, Bi for the ith block. m aVerts: an array of vertex to store all vertices after intersection of all triangle-pairs and merging; all vertices must be checked and renumbered. m aEdges: an array of edge to store all intersection lines after intersecting of all trianglepairs; the Head and Tail of each edge in this array are updated after merging and renumbering all vertices. m aLoops: an array of loop to store all closed/open intersection loops. The set of ordered vertices in each loop must have the newly updated IDs. m aPolys: an array of polygon to store all resulting polygons produced from the intersecting of triangle-pairs. Each polygon in this array will be decomposed into new triangles via polygon triangulation. m aTrgls: an array of triangle to store all updated triangles after intersecting and merging; the triangles come from (1) the original triangles that do not intersect with others, or (2) the new triangles generated by re-triangulating the resulting polygons from the intersecting of trianglepairs. m aSurfs: an array of surface to store all created sub-surfaces. Each sub-surface has its boundary sub-loop(s) preparing for assembling sub-blocks. m aBlocks: an array of block to store all assembled sub-blocks.
4.4
The Method
In this section, the detailed description to all six steps in the approach will be introduced separately. Several procedures such as clearing triangular mesh, forming intersection loops, and creating sub-surfaces and sub-blocks will be explained with pseudo codes.
4.4.1
Searching Intersected Triangle-Pairs
Before calculating the intersection of any pair of triangles, it is necessary to know which pair of triangles does intersect. The direct and inefficient method to do this is to make a bounding box intersection test for each triangle in a surface with that of another one. It needs to test m × n times when there are m and n faces in the pair of surface meshes. Obviously, this will be very slow or even cannot be realized in some cases. In order to improve the efficiency, the spatial decomposition data structure Octree is accepted to locate and then find out candidate intersected triangle-pairs. 77
Given two surface meshes, SA and SB , compute their smallest AABBs denoted as BoxA and BoxB , respectively; and then calculate the intersection BoxAB of BoxA and BoxB (BoxAB = BoxA ∩BoxB ); check each triangle of SA and SB whether it is outside of the volume BoxAB , and divide SA and SB into two sub-arrays where SAout + SAin = SA , SBout + SBin = SB ; and then extend the volume BoxAB into a cube to be an AABB for the triangles from both SAin and SBin (SAin ∪SBin ). Let the bounding cube as the root node of an Octree, and create eight octants for each node recursively. Let the Na and Nb denote the number of triangles that intersect each interior node from SAin and SBin respectively, the recursion of creating 8 octants for each node terminates and then the node becomes a leaf when (1)The depth of the node reaches a user-specified maximum depth; (2)Both Na and Nb less than a given allowable number; (3)Na or Nb is zero. When to check whether a triangle from either SAin or SBin is inside a node of the Octree, a simple method is to make an intersection test between the bounding box of the triangle and the node of Octree. if they intersect, the triangle can be considered being inside the node. Noticeably, a same triangle can intersect with several nodes. Additionally, in order to reduce the cost for computing the minimum bounding box for each triangle when make the intersection test, the boxes for all triangles from both SAin and SBin once are previously calculated, and then adopt the boxes when needed.
4.4.2
Intersecting of Triangles and Re-triangulating
The intersecting of a pair of triangles is not complex, M¨oller (1997) has developed a robust and efficient algorithm. When there are a huge number of pairs of triangles needed to calculate their intersections, parallel algorithm is meaningful and necessary here. Computing the intersection of one pair of triangles does not affect the procedure of that to another pair of triangles. The intersecting for any two pairs of triangles can be carried out at the same time. This parallelization can be realized very easily by calling the OpenMP API (OpenMP, 2013) and adding several very simple routines into the common serial codes. For instance, the following code is a simple example of computing the intersections of triangle-pairs parallel. #pragma omp parallel for for each pair of triangles pi { Calculate the intersection of pi ; Save the intersection edge of pi if it exists; } After calculating the intersection for all triangle-pairs, for an individual intersected triangle, usually there are several intersection edges inside the triangle since it perhaps intersects with several other triangles, and it will be divided into several sub polygons by the intersection edges. 78
C A
L1
L0 L2 (a) P0
P1
P0
B
P1
(b)
P2
P3
(c)
(d)
Figure 4.3: Intersected triangle and corresponding re-triangulation. (a) A triangle and its edgeloops; (b) Original triangle divided into 2 polygons; (c) Original triangle divided completely; (d) Triangular partition of the sub polygons. To generate these sub polygonal faces for a triangle Ti , all of its intersection edges is firstly found out, and then connect the edges into one or more open or closed loops (the similar details can be found in Algorithm 2), and finally divide the newly produced polygons by a unused intersection loop iteratively until all loops of the triangle Ti are adopt. For instance, in Fig.4.3(a) the triangle 4ABC has three intersection loops L0 , L1 and L2 . It can be divided into two sub-polygons P0 and P1 by the loop L0 (Fig.4.3(b)); and after three repetitions the polygonal face is divided into four new polygons (Fig.4.3(c)). Here, all three loops have been used and the iteration of dividing should terminate. As described above, intersected triangles will be divided into polygonal faces. In order to manipulate the surface mesh more easily in next steps, all resulting polygonal face should be decomposed into triangles via ear-clipping algorithm (Meisters, 1975; Held, 2001). Since that the ear-clipping is valid for planar and count-clockwise polygons, pre-process must be carried out before re-triangulating a polygon in 3D. For each polygon P , its partition can be done in 3 steps: Step 1: Calculate the local coordinate system of P , and then transfer P into its local version 0
P; Step 2: Check whether the vertices of P 0 orders in count-clockwise (CCW) or clockwise (CW). If CW, reverse P 0 to make it be CCW; Step 3: Generate the polygon triangulation T 0 of P 0 via ear-clipping, and then directly obtain the polygon triangulation T for P according to P 0 for that the topologies of T and T 0 are exactly the same while the coordinates of vertices differ. Figure.4.3(d) shows the result of re-triangulating the sub-polygons of 4ABC. 79
4.4.3
Merging and Updating
After intersecting of triangle-pairs, new vertices will be produced and the original intersected triangles are replaced by re-triangulated triangles. In order to get ready for next operations that based on valid topology, the surfaces must be merged and updated. It needs to carry out the following clearings: (1) merge all vertices and renumber them; (2) update the indexes of the vertices for each triangle and loop; (3) check each triangle and loop whether there are same indexed vertices; (4) reverse some newly produced triangles (Fig.4.4). And several requirements must be conformed for the meshes: no same vertices; no degenerated triangles; no same vertices in a loop; no edges shared by more than one triangle. T1 T0
T1 T0
T2
(a)
T2
(b)
Figure 4.4: Clear the topology of triangular meshes. (a) Original meshes with invalid triangles T0 , T1 and T2 ; (b) Cleared meshes without same edges For that the next procedures such as connecting loops and creating sub-surfaces are all based on a valid topology of meshes; thus it is very important to clear the topology besides merging and renumbering vertices. As shown in Fig.4.4, (a) is the original triangular meshes with 3 unallowable faces for that they have same edges with their adjacent triangles and (b) is the cleared version. In following pseudo code, Algorithm 1 gives the detailed description of how to clear a triangular mesh.
4.4.4
Forming Intersection Loops
In this subsection, a detailed method will be given to show how to form loops on triangular surfaces(Algorithm 2). As defined above, Orientated loop is a set of connected directed edges, which can be closed as a cycle or open as a polyline. Open loop is the intersection loop in which either the first or the last vertex is only shared by one intersection edge while each of the rest is shared by two edges. Close loop is the intersection loop in which each vertex is shared by at least two intersection edges. In further, the closed intersection loops are classified into two categories: hard closed and soft closed: Hard closed loop is the intersection loop in which each vertex is shared by only two intersection edges; for example, there are six hard closed intersection loops in Fig.4.5. 80
Algorithm 1 Clear Topology for Triangular Mesh Input: A triangular mesh with invalid triangles and same edges Output: A updated triangular mesh without same edges 1: find out all original triangles that not come from re-triangulating; 2: save boundary edges of original triangles into t aEdges; 3: while all newly produced triangles are not checked completely do 4: for each unchecked new triangles Ti do 5: let nID[3] denote the IDs of 3 vertices of Ti ; 6: for each edge ej in t aEdge do 7: let egHead and egT ail be the first and second vertices of ej ; 8: if (nID[1] = egHead and nID[0] = egT ail) or (nID[2] = egHead and nID[1] = egT ail) or (nID[0] = egHead and nID[2] = egT ail) then 9: add 3 edges of Ti into t aEdge; 10: set Ti has been checked; break; 11: end if 12: if (nID[0] = egHead and nID[1] = egT ail) or (nID[1] = egHead and nID[2] = egT ail) or (nID[2] = egHead and nID[0] = egT ail) then 13: reverse Ti and update its indexes of 3 vertices; 14: add 3 edges of Ti into t aEdges; 15: set Ti has been checked; break; 16: end if 17: end for 18: update t aEdges by removing any pair of opposite edges; 19: end for 20: end while
81
Soft closed loop is the intersection loop in which both the first and last vertices are shared by more than two intersection edges while each of the rest is shared by two edges; as shown in in Fig.4.10, there are 4 soft closed loop; and both the first and last vertices of each soft closed loop is shared by four intersection edges. Algorithm 2 Create Loops From Edges Input: A set of edges stored in an array m aEdges Output: A set of closed/open loops stored in an array m aLoops 1: initialize used-number by edges for each vertex in all edges 2: while the array of edges m aEdges is not empty do 3: create a new empty loop newLp; 4: find a unused edge startEg as the starting one; 5: add the Head and T ail vertices of startEg into the array of vertices in newLp; 6: let lpHead and lpT ail be the first and last vertices of newLp; 7: while the number of vertices of newLp not increases do 8: for each edge ei in m aEdges do 9: let egHead and egT ail be the first and second vertices of ei ; 10: if egT ail = lpHead and lpHead is used twice then 11: add egHead as first vertex; 12: set ei as being used; break; 13: end if 14: if egHead = lpHead and lpHead is used twice then 15: add egT ail as first vertex; 16: set ei as being used; break; 17: end if 18: if egHead = lpT ail and lpT ail is used twice then 19: add egT ail as last vertex; 20: set ei as being used; break; 21: end if 22: if egT ail = lpT ail and lpT ail is used twice then 23: add egHead as last vertex; 24: set ei as being used; break; 25: end if 26: end for 27: end while 28: add the new loop newLp into the array of loops m aLoops; 29: remove all used edges from m aEdges; 30: end while Only closed intersection loops(hard closed and soft closed ones) can be used to create subsurfaces (Sect.4.4.5). The closed or open loops can be assembled by strictly connecting the Head of an edge with the Tail of another edge, or the Tail of an edge with the Head with another edge. The iteration of assembling will stop when no more connected edges can be found. Besides being displayed by a set of edges, the resulting closed/open loops can be also represented by a 82
set of ordered vertices. For an original surface, there may be several loops on it; and it needs to know whether a loop is closed or open simply by comparing the Head of the first edge with the Tail of the last edge.
4.4.5
Creating Sub-surfaces
Assuming there is at least one closed loops in an original surface, then sub-surfaces can be created beginning from the closed loop. A sub-surface includes the closed loop and all of its interior triangles. Set the edges of a closed loop as the advancing edge front, ”grow” a new surface until the number of faces in the sub-surface not increases. The growing can be done according the topology of the target intersected surface, find the next face can be according to the incident faces of an advancing front edge. After a growing step, all of the advancing front must be updated to prepare for next growing until a sub-surface is formed; when all closed loops are used and no more sub-surface can be created, the growing can terminate(Algorithm 3). Algorithm 3 Create Sub-surfaces From Closed Loops Input: A set of closed loops stored in m aLoops and a triangular surface S Output: A set of sub-surfaces stored in m aSurfs 1: for loop Li in m aLoops do 2: create a new empty surface newSf ; 3: copy and add Li as a boundary loop into newSf ; 4: while the number of triangles of newSf increases do 5: for edge ej of loop Li do 6: let egHead and egT ail be the first and second vertices of ej ; 7: for triangle Tk in m aTrgls do 8: let nID[3] denote the 3 vertices of Tk ; 9: if (nID[1] = egHead and nID[0] = egT ail) or (nID[2] = egHead and nID[1] = egT ail) or (nID[0] = egHead and nID[2] = egT ail) then 10: add 3 edges of Tk into loop Li as new advancing front; 11: add triangle Tk into newSf ; break; 12: end if 13: end for 14: update loop Li by removing any pair of opposite edges; 15: end for 16: end while 17: add newSf into m aSurfs; 18: end for From the above procedure described in Algorithm 3, it can be learnt that for a surface several sub-surfaces can be formed, and can be classified into public and private. Definition 4 Public sub-surface: a sub-surface is public when there is more than one closed loops in it. ”Public” means several closed loops share this sub-surface together. Noticeably, if 83
this public sub-surface is generated from an original open surface, then it also must have a closed boundary loop besides the intersection closed loop(s). If it is from an original closed surface, then there is no boundary loop in it. Definition 5 Private sub-surface: a sub-surface is private when there is only one closed loops in it. Private means this sub-surface is owned by a loop privately. Definition 6 Sub-surface owner: the only closed loop which owns the private sub-surface or several closed loops which share the public sub-surface. For an original open or closed surface, these following conclusions can be drawn based on the assumption the intersection closed loop(s) exist. Remark 1 There is no more than one public sub-surface. Remark 2 There is at least one private sub-surface.
4.4.6
Assembling and Distinguishing Sub-blocks
Assembling All Possible Sub-blocks Given two original surface SA and SB , a set of sub-surfaces will be obtained after intersecting. For a sub-surface SS from the original surface SA , assuming it has n closed loops, noted as Li (i = 0, . . . , n − 1). It also means that there are n owners share the sub-surface SS. If n private surfaces can be found from the original surface SB , and each private sub-surface is only owned by the closed loop Li , then a sub-block can be easily assembled by the sub-surface SS from the surface SA and n private surfaces from SB . Therefore, several conclusions for assembling sub-blocks can be drawn. Remark 3 A public sub-surface with a boundary loop, which is generated from an open original surface, cannot be adopted to assemble sub-blocks. For that it is unable to find a subsurface owned also by the boundary closed loop in its intersected original surface. Remark 4 A public sub-surface without boundary loop can be used once or twice. Remark 5 A private sub-surface can be used once or twice. Distinguishing According to Algorithm 4, all possibly produced sub-blocks can be obtained. Now, there is a question that given two blocks BA and BB (Fig.4.5(a)), and after creating all sub-blocks, how to distinguish the union, intersection and subtraction. A novel and simple method is developed to solve this problem. Step 1: Obtain the non-subtraction(union and intersection) according to the orientation of closed intersection loops when assemble sub-blocks 84
In this step, it only can determine whether the sub-blocks are subtraction or not, and cannot distinguish they are the union or intersection clearly.
(a) Original triangular blocks
(b) Sub-surfaces
BA∪BB
BA ∩ BB
BA - BB
BA - BB
(c) Sub-blocks
Figure 4.5: Boolean operations of a pair of blocks For a sub-block SB, assuming it totally has n closed loops, noted as Li (i = 0, . . . , n−1). For each closed loop Li , it has two opposite versions in which L+ i represents this loop with its original + orientation and L− is the loop with same vertices as L but opposite orientation (Fig.4.6). These i i two loops are defined as twins in Sect.4.3. The loop Li owns or shares two sub-surfaces denoted B as SSA Li and SSLi which come from two different original surfaces SA and SB , respectively. the sub-block SB can be easily determined according to following conditions: + − B A B Case 1: if SSA Li and SSLi are owned or shared by Li and Li , respectively, or if SSLi and SSLi + are owned or shared by L− i and Li , respectively, then the sub-block SB is union or intersection volume. + B A B Case 2: if both SSA Li and SSLi are owned or shared by Li , or if both SSLi and SSLi are owned or shared by L− i , then the sub-block SB is subtraction volume.
85
Figure 4.6: Opposite loops and their owned or shared sub-surfaces
Step 2: Distinguish the union firstly and then the intersections As mentioned above, let (BA ∪BB ), (BA ∩BB ), (BA −BB ) and (BB −BA ) represent the union, intersection, and subtractions of a pair of blocks BA and BB . Obviously, it is able to receive the following relationship: (BA ∩BB ) ≤ (BA ∪BB ). The equivalent case holds only when BA and BB coincides, which has to be recognized and handled previously and thus is unnecessary to be considered at this time. Hence, it further has (BA ∩BB ) < (BA ∪BB ). This means the intersection is always smaller than its corresponding union. This also means the minimum coordinates of all vertices of the intersection never smaller than those of the union while the maximum ones of the intersection never larger than those of the union. Therefore, the minimum and maximum coordinates of the vertices from both the union and intersection is exactly equal those only from the union. Thus, the union and the intersection via following three sub-procedure can be distinguished. Step 2-1: Obtain the maximum and minimum coordinates of both intersection and union; this can be done very easily by sorting all the vertices. In fact, this has been realized when merge and update the vertices. This can be realized by storing their indexes there and callll them here. Step 2-2: Check each candidate union sub-block by comparing its maximum and minimum coordinates. If all of them are equivalent to their corresponding values obtained in above Step 2.1, then it must be the only union volume (Fig.4.5(c)). Step 2-3: Set the rest sub-block(s) as the intersection volume (Fig.4.5(c)). Noticeably, the above procedures are invalid only in the case that mesh BA is in BB or BB is in BA . Hence, these very special cases must be handled in pre-process. Step 3: Determine all subtractions After classifying the union and intersection, the subtractions (BA −BB ) and (BB −BA ) can be easily determined. Firstly, define all sub-surfaces which compose the only union volume as outer sub-surfaces, while those from the intersection volume(s) as inner ones. For each undistinguished sub-block, 86
(1) If one of the sub-surfaces from the sub-block is outer, and if the sub-surface belongs the original block BA , then the sub-block is part of (BA −BB ); else the sub-block is part of (BB −BA ). (2) If one of the sub-surfaces from the sub-block is inner, and if the sub-surface belongs the original block BA , then the sub-block is part of (BB −BA ); else the sub-block is part of (BA −BB ). After distinguishing, all triangles in inner sub-surfaces of subtractions have to reverse to obtain a valid topology of whole mesh model and make all the normal of facets outwards. Algorithm 4 Create Sub-blocks From Sub-surfaces Input: A set of sub-surfaces stored in m aSurfs Output: A set of sub-blocks stored in m aBlocks 1: while all sub-surfaces in m aSurfs are not tested completely do 2: find a untested sub-surface startSS as the starting one; 3: set startSS as being tested; 4: if startSS is a public sub-surface with boundary loop(s) then 5: continue; 6: end if 7: create a new empty sub-block newBlk; 8: add startSS into newBlk; 9: for the ith closed loop Li in startSS do 10: for each sub-surface SSi in m aSurfs do 11: if (SSi is untested and also owned only by Li ) and (SSi and startSS not come from same surface) then 12: set SSi as being tested; 13: add SSi into newBlk; break; 14: end if 15: end for 16: end for 17: add newBlk into m aBlocks; 18: end while
4.5
Examples
As described in Sect.4.1, the objective is to perform Boolean operations only over a pair of surfaces. Either of the surfaces can be open or closed. In this section, the Boolean operations of several pairs of surfaces including open-and-open(Fig.4.7), open-and-closed(Fig.4.8 and Fig.4.9) and closed-and-closed (Fig.4.10 and Fig.4.11) are presented to demonstrate the approach. The intersection of a pair of open triangulated surfaces is tested in Fig.4.7. Before considering the boundary outer loops of the original surfaces, four open intersection loops can be formed for each surface; and then the boundary loop is divided into five closed loops; hence five corresponding sub-surfaces can be created for each surface. 87
(a) Original open surfaces
(b) Sub-surfaces
Figure 4.7: Intersection of a pair of open surfaces
Figure 4.8: A planar mesh and Chinese lion before dividing
Figure 4.9: A planar mesh and Chinese lion after dividing
88
(a) Original cylinders
(b) Sub-surfaces of a cylinder
(d) Union
(c) Intersection
(e) Subtractions
Figure 4.10: Boolean operations of a pair of cylinders
The division of a planar meshed surface with a triangulated Chinese lion is presented to test the Booleans for a open surface with a closed surface. The model Chinese lion (Fig.4.8) is obtained from http://shapes.aim-at-shape.net/. From Fig.4.8, it can be seen that three closed loops can be formed in both the Chinese lion and the surface. Figure.9 displays the dividing results that four sub-surfaces can be created for both of original surfaces, and the lion is divided into four sub-blocks. To test Booleans on two closed surfaces, the examples of Boolean operations for a pair of cylinders (see Fig.4.10) and a pair of torus (see Fig.4.11) are given. After computing the intersection edges of triangles for cylinders, four soft closed (defined in Sect.4.4.4) intersection loops can be formed. Both the first vertex and the last vertex of each soft closed loop is shared by four intersection edges. Based on these soft closed loops, four sub-surfaces can be created for each cylinder, and then sub-blocks such as union, intersection and subtractions can be easily assembled and distinguished according to the sub-faces. As demonstrated in Fig.4.11, the Boolean operations is performed for a pair of torus which have the same inner radius. It is similar to that of cylinders but a little more complex. The above two examples only produced soft closed loops, a simple example in which hard closed loops are obtained is presented in Fig.4.5. 89
(a) Original pair of torus
(b) Union
(c) Intersection
(d) Subtractions
Figure 4.11: Boolean operations of a pair of torus
4.6
Remarks
A simple and robust approach to perform Boolean operations on a pair of manifold triangulated surfaces is presented in this chapter. The approach falls into the type of exact arithmetic methods in the aspect of computation. The Octree is used to locate and find potentially intersected triangles and adopt parallel algorithm to calculate the intersection lines of triangles. the intersection loops are defined and classified into categories of open, hard closed and soft closed ones, and then create sub-surfaces by growing while only the closed intersection loops are set as boundary loops of sub-surfaces and deemed as the initial advancing fronts. Sub-blocks are assembled very easily according to boundary loops of sub-surfaces, and then distinguished by comparing min and max coordinates of updated vertices. There are two main stages in the approach: the first, which is to calculate intersection lines of triangles and then merge and update the resulting surfaces, needs coordinates calculations; the second, which includes forming intersection loops, creating sub-surfaces, assembling and distinguishing sub-blocks, is only based on the cleared and updated topology of triangular meshes while without coordinate computations of geometric entities. Effectiveness of the approach has been illustrated by several test examples. A valuable work in future is to extend the approach to perform Boolean operations on non-manifold mesh models.
90
Chapter 5 Application 5.1
The Haut-Barr Castle
The Haut-Barr is a medieval castle, which was first built in 1100 on a rose-colored sandstone rock 460m above the valley of Zorn and the plain of Alsace in France. The rock outcrop at the Haut-Barr made of three consecutive rocks: the Septentrional Rock (labeled as 3 in Figure 5.1), the Median Rock (labeled as 2) and the Southernmost Rock that is best known as Markenfels (labeled as 1). Two of rock masses that labeled as 1 and 2, are joined by a foot bridge named Devil’s Bridge. Since the 12th century, the Haut-Barr Castle has been built by Rodolphe, bishop of Strasbourg; see more details in (Heitmann, 2013; HautBarr, 2013). A top view of the HautBarr and its location displayed in the Google Earth (GE) can be seen in Figure 5.2.
Figure 5.1: The Haut-Barr Castle (HautBarr, 2013) 91
(a) The top view of the Haut-Barr Castle
(b) The location of the Haut-Barr Castle
Figure 5.2: The Haut-Barr Castle displayed in Google Earth
92
5.2
The Outcrops
The shape of Haut-Barr displayed with GE in the top view is shown in Figure 5.2(a). The rock masses at the Haut-Barr is divided into four parts: those three separated rock masses labeled as 1 to 3 in Figure 5.1 and the base rock mass (labeled as 0). Figure 5.3 is the rough and planar wireframe model of the shape of the Haut-Barr, which is drawn according to the view in Figure 5.2(a). This line model is also composed of four parts.
1
2
0
3
Figure 5.3: The planar boundary of Haut-Barr Castle The above description is for acquiring the shape. Comparing to obtain the shape of Haut-Barr, the scale is much easier to determine: firstly a minimum bounding box is created, which virtually encloses the Haut-Barr; and the next thing needed to do is to determine the three parameters of the minimum bounding box: length, width and height. The acquiring of the scale of Haut-Barr is exactly to obtain these parameters. The measuring toolbar of GE can be very easily used to calculate the maximum length and width of Haut-Barr in meters. The altitude of the ground surface displaying on the screen can be simply obtained by moving the cursor to the right positions on the GE client. The average altitude of the rock masses is 460m. The height of the visible rock masses is just the difference of the maximum altitude, 460m, to the altitude of the terrain.
Figure 5.4: Contour map of the study area A small code was developed for extracting elevation data from GE (Mei et al., 2012). And a contour map of the terrain was created using these extracted scatter points (Figure 5.4). The average altitude of the terrain displayed in GE is 425m, thus the maximum visible length of the rock masses is 35m. This distance needs to be a little larger, i.e. 40m, with considering the underground parts of the rock masses. In summary, the scale of Haut-Barr, which is represented using a bounding box, consists of 255m, 70m and 40m in length, width and height, respectively. 93
(a)
(b)
Figure 5.5: The viewing of the outcrops at the Haut-Barr Castle in Google Earth
94
5.3
Implementation of Modeling
The heart of the forward modeling in the system RealModel is to simulate two basic sedimentary processes, i.e., the deposition and the erosion. When simulating the above two basic sedimentary processes within a geometric modeling system, the process of deposition is modeled via the intersecting of a pair of input surface meshes that represent an old and a new geological interface; and the process of erosion is modeled via cutting previously formed sets of polyhedrons that represent previously deposited sediments with an input surface that represents a newer geological interface, see the following Figure 5.6.
(a) The cutting and intersecting
(b) The erosion and deposition
Figure 5.6: The simulating of erosion and deposition by cutting and intersecting The input data of the system RealModel is a set of triangular surface meshes that are adopted to represent various geological interfaces. By intersecting and cutting those surfaces with others, several groups of polyhedrons will be created. A group of polyhedrons generated based on the same two geological interfaces is defined as a geological layer, which is also called a block. For instance, there are two layers (blocks) in the Figure 5.6(b). The components, i.e., polyhedrons, of a geological layer have the same rock properties such as material and age. The output data is a sedimentation model which consists of a set of geological layers. Noticeably, both the input geological interfaces (surface meshes) and the output sedimentation model (polyhedral mesh models) are created to be geologically reasonable, rather be as accurate as the real outcrops. The objective of the forward modeling in the system RealModel is to create geological reasonable models for sedimentary rocks, rather to create accurate or even the same sedimentation models that are acquired according to the outcrops. 95
For the rock masses at the Haut-Barr, the surface meshes that are used to represent various geological interfaces are created according to the geometries of the outcrops (see, Figure 5.5 and Figure 5.7). When building the sedimentation model, surfaces are added in the sequence of time / age, i.e., added from the oldest to the newest; and after adding each new surface, the two operations (i.e., the intersecting of two surfaces and the cutting of polyhedrons with the newly added surface) will be performed to simulate the two sedimentary processes, the erosion and the deposition, respectively. For the base rock labeled as 0 in the Figure 5.1, ten surface meshes are created, see Figure 5.8; and then by intersecting and cutting nine layers (blocks) are formed, as shown in Figure 5.9. Noticeably, a layer can be composed of (1) only a set of connected polyhedrons that have the same properties (see the 1st layer of the model displayed in Figure 5.9(b)), or (2) several subsets of connected polyhedrons of which each sub-set of polyhedrons is not connected to other sub-sets (see the 2nd layer of the model displayed in Figure 5.9(b)). For the separated three rock masses labeled as 1, 2, and 3 at the Haut-Barr, the input surface meshes and corresponding sedimentation models are also created, see the Figures 5.10, 5.11, and 5.12, respectively. After building the above three sub models, the final entire sedimentation model of the Haut-Barr can be obtained by merging the model of the base rock and the three models of the separated rock masses. Some details of the separated sub model and final whole model are listed in the Table 5.1. This modeling strategy that consists of building individual sub sedimentation model for each rock mass and then merging all sub models into the final entire sedimentation model can efficiently reduce the computation cost. This divide-and-conquer strategy is reasonable since the modeling for one separated rock mass, for instance the one labeled as 1, do not affect the modeling for the other two rock masses. The final entire sedimentation model of the rock masses at the Haut-Barr Castle is displayed in the Figure 5.13, which consists of 36 layers. Each layer is rendered with a distinguished color. Noticeably, among those 36 layers, probably several layers can be classified and considered as the same groups of layers that have the same properties; this is because different layers (sedimentary rocks) deposited at the three separated rock masses were properly produced by the same process of deposition in the same period, and became separated due to further erosion in later period. Table 5.1: Sedimentation models of the Haut-Barr Entities of Sedimentation models Rock masses Input surfaces Figure Vertex Polygon Polyhedron Layer #0 #1 #2 #3 All
10 9 10 10 39
39447 2891 8351 3353 52427
469425 26366 77930 30525 714768
96
65782 4433 13437 5142 88794
9 8 9 10 36
5.9 5.10 5.11 5.12 5.13
(a) Planar wire-frame model of the rock masses
(b) Triangular meshes of the planar wire-frame model
Figure 5.7: The input meshes for the modeling of the Haut-Barr Castle
97
(a)
(b)
Figure 5.8: The input surface meshes for modeling the rock mass labeled as 0
98
(a)
(b)
Figure 5.9: The sedimentation model of the rock mass labeled as 0
99
(a) The input surface meshes
(b) The generated sedimentation model
Figure 5.10: The modeling of the rock mass labeled as 1
100
(a) The input surface meshes
(b) The generated sedimentation model
Figure 5.11: The modeling of the rock mass labeled as 2
101
(a) The input surface meshes
(b) The generated sedimentation model
Figure 5.12: The modeling of the rock mass labeled as 3
102
(a)
(b)
Figure 5.13: The final sedimentation model of the Haut-Barr Castle
103
104
Chapter 6 Discussion and Conclusion 6.1
Discussion
The system RealModel is a software package for modeling and visualizing sedimentary rocks. The first feature of this system is that it can effectively and correctly to solve the problem which motivates to develop the system, i.e., to model and visualize sedimentary rocks. For a mature software package, it should have several key features, i.e., it is efficient, robust, and easy-to-use. However, when developing RealModel, although several efforts have been made to make the system as robust and fast as possible, the non-robustness issues still arise due to degenerate cases and floating-point arithmetic. Additionally, the system can only deal with the modeling when the faces / polygons of input surface meshes are less than one million. In order to make the software fast and robust, two API libraries, OpenMP and CORE are accepted. The OpenMP is used for the parallelization, while the CORE library is adopted to deal with the unexpected non-robustness issues caused by floating-point arithmetic.
6.1.1
The Efficiency / Speed in RealModel
Speed is one of the most important features that usually used to determine the capability of a software package. In RealModel, the bottleneck of speed is the intersection of triangular surface meshes. The procedure of computing the intersections are quite slow then there are lots of elements (i.e., triangles) in the surface meshes. Optimizations should be carried out to improve the entire speed of RealModel by reducing the time that costs on intersecting. In RealModel, two strategies have been adopted to make the intersecting as fast as possible: the first one is to reduce the intersection tests (also called collision detection tests) of geometric objects by using space partitioning techniques; and the other is to make the intersecting parallel by taking advantage of the API OpenMP . In the following paragraphs, the above two strategies will be introduced in details. 105
Speeding up by Space Partitioning As described above, a problem in modeling is to compute the intersection of triangles. If there are a huge number of triangles needed to compute their intersections, the computing could be very slow or even cannot be carried out in this case. An efficient solution to the above problem is to adopt the space partitioning. The basic ideas behind space partitioning are as follows: • Space is divided into cells (i.e. the subspaces) • Object primitives are placed into cells (e.g., Octree), see Figure 6.1(b) • Object primitives within the same cell are checked for collision, see Figure 6.1(c) • Pairs of primitives that do not share the same cell are not tested
The Figure.6.1 show a simple procedure of realizing the space partitioning. The basic idea of this strategy is easy to understand: there is no need to compute the intersection of a triangle with the any one of the rest; it only needs to compute a triangle with those who locate close to it. A pair of triangles that are far from with each other is not needed to compute their intersection. The further question perhaps is how to determine whether a pair of triangles is near or far with each other. This problem is solved by dividing the space occupied by all triangles into sets of various subspaces, and then put the triangles into those subspaces. Triangles within the same subspace are needed to check for intersection; and pairs of triangles that do not locate inside the same subspace are not needed to test. The easiest space partitioning is to divide the space into a structured grid. Each element of the grid, i.e., one of the subspaces, is a Cuboid or even a Cube. This method of partitioning is easy to realize in programming, i.e., to divide the distances in the X-, Y-, and Z- axis into 3 sets of intervals, respectively. The intervals in a same axis have equivalent length. The disadvantage of this kind of dividing is that plenty of subspaces are created; and the determination for checking which triangles locate within the same space is also time-consuming. A better partitioning is by using the spatial data structure Octree. Unlike the spatial structure grid, Octree is unstructured. The first step of creating the Octree is to divide the target space into 8 subspace (also called Node or Children), then put the geometric objects such as triangles into those 8 subspaces and check the number and density of the objects within the same subspace to decide whether it is needed to divide a subspace into 8 smaller subspace (i.e., the sub subspace). This procedure of dividing iterates until some kind of conditions or requirements like the number of objects within a subspace or the levels of all subspaces are met. Obviously, the advantage of taking advantage of Octree is that it is “smart” to decide whether it is needed to create the next level of subspaces for a previously created subspace. The disadvantage is that the establishment of Octree is more complicated than that of the grid. In RealModel, both of the above kinds of partitioning are implemented and tested. And another type of space partitioning, OBBTree, is directly accepted from the library RAPID. 106
The package RAPID calculates a hierarchical representation of polygonal models using tightfitting oriented bounding box trees (OBBTrees). Based on the space partitioning by using the OBBTress, RAPID is very efficient and accurate to find out all the intersected objects between very complex geometries. The library RAPID has been adopted and integrated in the RealModel.
(a)
(b)
(c)
Figure 6.1: The creation of Octree (Suter, 1999)
Speeding up by Parallelization In the above section, the solution for speeding up in RealModel by space partitioning is described. Besides the above one, another solution is also adopted in RealModel, i.e., speeding up by parallelization. There are several architechtures or models that are capable of implementing parallelization. Nowadays, the three most frequently used are: OpenMP (2013), MPI (2013), and CUDA-capable GPUs (CUDA, 2013). OpenMP is an API that supports multi-platform shared memory multiprocessing programming. MPI (Message Passing Interface) is a library specification designed for high performance on both massively parallel machines and on workstation clusters. CUDA is a parallel computing platform and programming model invented by NVIDIA. It enables dramatic increases in computing performance by harnessing the power of the Graphics Processing Unit (GPU). The OpenMP is relatively small and very easy to be used when programming. Moreover, the OpenMP is directly supported in the compiler IDE, Microsoft Visual Studio 2010 (VS2010). Since that RealModel is developed under VS2010, thus no additional initialization is needed to realize parallelization by using the OpenMP in RealModel. This application of parallelization based on OpenMP has been implemented in RealModel. The application example is to calculate the intersections of a huge number of pair of triangle. Obviously, the intersecting of a pair of triangles does not affect that of another pair, i.e., there are no mutual exclusions when computing the intersections of lots of triangle pair. This is the precondition of conducting parallelization for computing the intersections. 107
The parallelization can be very easily realized by (1) calling the OpenMP API, and (2) adding several very simple routines into the serial codes. The following piece of code is the sample for implementing the parallelization from serial code to parallel version. #pragma omp parallel for // Routine from OpenMP For each pair of triangles pi { // Original serial codes, now parallel Calculate the intersection of pi ; Save the intersection edge of pi if exists; }
6.1.2
Non-robustness Issues in RealModel
Non-robustness issues widely appear in software packages, especially in those involved geometric computations such as RealModel and lots of CAD / CAE software. Non-robustness can be roughly divided into numeric non-robustness and geometric non-robustness. The root cause of numeric non-robustness is the rounding-off error in floating-point arithmetic. In machine arithmetic, the real numbers have to be approximated by representable numbers. Thus, round-off errors arise, and inaccurate or even incorrect results appear. Ideally, the algorithms of computational geometry are designed for a machine model with exact real arithmetic. However, in fact, when implementing various geometric computations on computers, float-point arithmetic is accepted. And, floating point arithmetic is inaccurate by nature due to round-off error. Thus, floating point arithmetic for the assumed real arithmetic may cause implementations to fail. In Kettner et al. (2008), several classic examples of non-robustness in geometric computation are presented. In order to deal with the non-robustness issues in RealModel, an effective solution is to support the “Exact Geometric Computation” principle by using the multi-precision computation libraries such as LEAD and CORE. A very easily-used library is the CORE, the common C++ code can be transferred into robust code by simple accepting this CORE library. However, when supporting the CORE library in the entire procedure of modeling, it would be very slow. This is because geometric computations based on multi-precisions is much slower that computations based on only double-precision (double in C/C++) or single-precision (float in C/C++). A further solution to supporting the CORE library efficiently is to accept the ”Lazy” principle, i.e., to carry out the most important geometric computations such as triangles intersection using multi-precisions arithmetic while performing the less important computations such as calculating the boundary boxes or merging geometric models. In summary, the main idea behind the ”Lazy” principle is to implement the computing based on very expensive multi-precisions only when those geometric computations are quite important. 108
6.1.3
The User Interface in RealModel
A very friendly graphic user interface (GUI) has been developed in the RealModel. The GUI mainly has three important functionalities including the displaying of geometries, the input and output interface of data files, and the notification messages for indicating some information when modeling. The visualization of geometric entities in the system RealModel is implemented with OpenGL. All the displaying issues involving the OpenGL are carried out by using the glut / freeglut packages. The components for displaying with OpenGL in the system RealModel include the basic part which is developed for directly rendering geometric models and the advanced part which is developed for various displaying operations such as moving (panning), rotating, scale, and the settings of different viewpoints. As mentioned above, the basic part of displaying is to render various geometries directly, for instance, draw points, lines, polygons, or polyhedrons. These implementations of rendering the simple geometric entities are easy to realize with OpenGL. However, several useful techniques including Vertex Array, Display List, Multisampling, and Polygon Offset need to be adopted to improve the performance of rendering such as anti-aliasing, especially when rendering a large number of geometric entities. In the advanced Displaying, The most commonly used interactive operations for geometries include the moving (panning), rotating, and scaling, and different views of a same scene. These common operations have been implemented and integrated in the system RealModel. In addition, these are the created icon toolbars in the software RealModel. These toolbars are not the key parts , but it is needed for a mature scientific software. A common problematic phenomenon, aliasing, is normally arise when displaying objects in computers, which is rather bad when the resolution of a picture is low. In the developing of RealModel, to improve the quality of rendered pictures, a simplest technique, anti-aliasing, is accepted by taking advantage of graphics card. However, the speed of rendering large models that consist of millions of polygons is still very slow. Thus, more efficient approaches are needed to be designed to accelerating the rendering of large models while keeping pictures unaliased. The input / output interfaces include those for opening and saving data files of geological models. The input data for modeling are several sets of triangular surface meshes stored in .txt or .off file formats. The output data are also saved into .txt files. Additional conversation interfaces for other related modeling or visualizing software such as AutoCAD, ANSYS are also developed. In the future, more formats of data files are needed to be supported for importing and exporting geological models. The notification messages for indicating the some important information such as errors or progress or computing during modeling appear by means of (1) output message window, (2) progress toolbar, and (3) message dialog. These indicators are quite useful and user-friendly. In the future, to fulfil more functionality requirements, more output message windows or progress toolbars are needed to be designed in RealModel.
109
6.2
Conclusion
An integrated software package, RealModel, has been designed and developed for modeling and visualizing sedimentary rocks. The system RealModel is developed by using the MFC (Microsoft Foundation Class), STL (Standard Template Library), and OpenGL shading language. All routines in the system RealModel are written in C/C++. Several usefull packages or APIs including OpenMP (OpenMP, 2013), CORE (Karamcheti et al., 1999), and RAPID (Gottschalk et al., 1996) have been used. The input data of the system RealModel is a set of triangular surface meshes that represent various geological interfaces. By intersecting and cutting those surfaces with others, several groups of polyhedrons are created. A group of polyhedrons generated based on the same two geological interfaces is defined as a geological layer, which is also called a block. The components, i.e., polyhedrons, of a geological layer have the same properties such as material and age. The output data of the system RealModel is a sedimentation model which consists of a set of geological layers. The system RealModel is mainly composed of two parts: the data visualization and the geometric modeling. The visualization component is designed for friendly–used interactions, including various windows, menus and toolbars developed under the MFC paradigm, and displaying for geometries on the basis of the OpenGL. The modeling part, which is the key component of this system, consists of some basic and kernel functions of geometric computing. The visualization part of RealModel is performed by using MFC and OpenGL. All sub components of the user interfaces such as the main display window, input / output windows, interactive message dialogs, menus, and icon toolbars are created on the basis of the MFC. The geometric objects are rendered with OpenGL. Manipulations or operations to those geometries include zooming in or out, rotating, moving, and displaying in top, bottom, left, right, front, and back views. Several useful techniques such as Display Lists, Vertex Arrays, Polygon Offset, and Multisampling for anti-aliasing are used to improve the performance of rendering. The modeling part of RealModel is composed of: (1) a set of basic classes or functions, and (2) a set of kernel classes or functions. The most important but basic geometric algorithms are the intersections of basic geometric primitives such as the intersection of segment-segment, polygonpolygon in 2D, triangle-triangle in 3D, and plane-polyhedron. These basic geometric algorithms are the important basis for carrying out the kernel and complex geometric computations such as surface meshes intersecting and cutting polyhedrons with a surface mesh. An unavoidable issue in geometric computation is the robustness problem which derives from floating-point arithmetic. In RealModel, in order to deal with the robustness issue in geometric computation, the Exact Geometric Computation (EGC) principle is supported to avoid unexpected crashes or infinite loops. An application example has been performed to demonstrate the effectiveness of the system RealModel. The sedimentation model built by using the presented system RealModel is for the Haut-Barr Castle. The data on location, scale, and shape about the Haut-Barr Castle are acquired using the Google Earth (GE). 110
The rock masses at the Haut-Barr Castle are divided into 4 parts. When building the sedimentation model of the entire rock at Haut-Barr, separated sub-models are created independently for each part of rock mass by intersecting and cutting with surface meshes; and then the separated models are merged into the final model. This procedure of “Divide-and-Conquer (Merge)” is in order to speed up the modeling and reduce computation time cost. The built model is composed of 36 geological layers, which consists of about 700 thousands of polygons / faces and 80 thousands of polyhedrons. More details about the model are described in Chapter 5. The rendering of this sedimentation model in RealModel is slow; thus, some of the future work may focus on improving the rendering efficiency. As stated above, an effort is to make the rendering for large geological models as fast as possible. Currently, when rendering the sedimentation model built for the Haut-Barr Castle, it is too slow to perform those interactive operations such as moving, scaling, and rotating. One solution to the above mentioned problem is to render the large geological models by using of hidden surface removal; the basic idea behind the hidden surface removal is quite simple, i.e., to only display the visible geometric surfaces (the boundaries of geometries) and ignore the hidden surfaces that people cannot see. Another solution is to perform the rendering for big geological models within the frame of parallelization such as CUDA-enabled GPUs. Although the CUDAenabled GPUs is currently widely used for parallel scientific computing, but the original objective of developing the CUDA-enabled GPUs is for rendering objects. CUDA-enabled GUPs have the powerful capability of very fast rendering for large amount of objects. The improvement by optimizing the rendering in RealModel can take advantage of the CUDA-enable GPUs. Another effort of the future work is to improve the robustness of the RealModel. As discussed in the above section, the non-robustness issues appear due to floating-point arithmetic and degenerate cases (very special cases that people may have not consider). The first cause of the non-robustness, i.e., floating-point arithmetic, has been effectively avoided by supporting the Exact Geometric Computation (EGC) principle and adopting the library CORE. But this problem still exists and cannot be completely solved within the current computer arithmetic framework. The second cause of the non-robustness, those degenerate cases, can be completely solved by testing large number of modeling examples, finding the degenerate cases, and finally fixing those. Hence, in the future, more modeling applications should be carried out to test and improve the robustness / reliability of the system RealModel.
111
112
Appendix A Robustness in Geometric Computation† As one type of geometric modeling systems, 3D geological modeling system is also definitely sensitive to nonrobustness problems due to the numerical and the geometrical nature of adopted algorithms. The 3D geological modeling system could not be reliable without considering the robustness issues in geometric computation. In this chapter, the algorithmic robustness issues in geometric computation, including numerical and geometrical robustness will be addressed.
A.1
Why Non-robustness arise?
A.1.1
Types of Non-robustness
In general, the causes of robustness problems can be mainly classified into two categories: numeric precision and geometric degeneracy. Thus, the robustness problems can also be divided correspondingly into two types according to the causes. Numeric precision (numeric stability) problems arise due to the inexact computer arithmetic: when carrying out various computations on computers, the numbers adopted is limited-precision floating-point numbers or even integers, not the expected and exact real numbers which have arbitrary precisions in theory. Degeneracy refers to the special cases or conditions that are usually not considered during the generic implementation of algorithms and must be treated in problem-specific ways. Usually, when implementing algorithms, people assume their algorithms work based on the calculations using exact real numbers, and there are no degenerate cases. However, both of the assumptions are incorrect. In practice, the data type accepted for computations on computers is the floating-point number which is an approximated and inexact form of the expected exact real numbers. And unfortunately, degenerate situations cannot completely avoid and occur in many cases of geometric computation. A simple example of such degenerate case in geometric computation is that two points that ideally coincide in theory but in fact they do not. †
This chapter has been submitted and accepted to be published (Mei et al., 2014)
113
Both of the above-mentioned causes will lead to incorrect answers, and even algorithms crashes or getting into infinite loops. In the literature (Ericson, 2004), the source of numerical non-robustness is mainly divided as : Conversion and representation errors, Overflow and underflow errors, Round-off errors, Digit-cancellation errors, and Input errors. Numeric non-robustness would never arise if all computations are carried out using exact real numbers and arithmetic, rather than limited-precision computer arithmetic. However, this is just a wonderful dream. In order to understand well and finally address the robustness problems in geometric computation, it is quite necessary to have a deep insight of limited-precision computer arithmetic. The rest of this chapter will briefly describe the format of representing real numbers with fixed-precision floating-point numbers, the IEEE-754 floating-point formats, and some practical suggestions for computing with floating-point numbers robustly.
A.1.2
Error Source in Floating-point Arithmetic
In the field of mathematics, the definition of real number can be simply given as: a real number can be thought as a value that represents a quantity along an infinitely long line (i.e., the number line or the real line). The real numbers include √ all the rational numbers (such as integers and fractions) and the irrational numbers (such as 3 and π). Those real numbers that cannot be directly represented are approximated by the nearest representable numbers. The real numbers that are exactly represented on computers are called machine representable numbers. The formal definition of representable numbers is as follows: Representable numbers are numbers capable of being represented exactly in a given binary number format (Kirk and Wenmei, 2010). The format could either be an integer or floating point numbers. Representable numbers are often visually depicted on a number line (Figure.A.1).
0 (a) Fixed-point numbers are equally spaced on the number line
0 (b) Floating-point numbers are denser around zero on the number line
Figure A.1: Numbers spaced on the number line (Ericson, 2004) Generally, real numbers can be represented on computers with two representations: fixedpoint numbers and floating-point numbers. The most widely used floating-point representation format is that defined by the IEEE-754 standard (IEEE, 2008). Floating-point representations are not in decimal but binary format. It is clear that the floating-point numbers, and its arithmetic do not have the same properties as that of real numbers and the exact arithmetic using real numbers. 114
Why do most non-robustness problems occur? Answering this question simply, it is due to the unexpected error source that arises in floating-point arithmetic. Noticeably, this kind of error source is the main one of all types of error causes. It produces unexpected results in both numeric and geometric computations. Remark The error in floating-point arithmetic is mainly due to “rounding-off”. When using floating-point numbers, “rounding” needs to be carried out nearly all the time. The following are the most common three cases: 1. For the representable numbers with quite accurate (or can also say too accurate) precision, when taking this type of data into binary calculation on computers, it must to be represented with limited-precision (such as 32-bits or 64-bits) numbers, rather than arbitrary or too long precision (200-bits) numbers; thus when representing this type of real numbers, it must be rounded to the nearest machine numbers according to the limited-precision. 2. For the numbers that cannot be represented exactly by binary numbers, such as the irra√ tional numbers π and 3, they definitely need to be rounded off and represented by their nearest machine numbers. The error will certainly occur between the original numbers and their inexact approximated ones. 3. For the intermediate data obtained during calculations, they are expected to be more accurate than the input data, but this is impractical since that the precision for representing numbers is limited and the intermediate data must be also represented with the limitedprecision. The first and second cases state that some kinds of decimal numbers cannot be exactly represented in binary format. For instance, in the decimal floating-point representation, the number 0.1 can be exactly represented using a fixed number of digits; but, 0.1 is no longer able to be exactly representable in a binary floating-point representation, and will be expressed by the repeating fraction (0.0001100110011...). When this number is normalized and then rounded off to the IEEE-754 single-precision format (24 bits), the last least significant bit of the mantissa has been rounded up. Therefore, in the format of the IEEE-754 single-precision, the representation of 0.1 is a little bigger than 0.1 (Ericson, 2004). The intermediate data cannot be represented with precisions larger than that is allowed on computers. In other words, the intermediate data which supposed to be more accurate but in fact it cannot be more accurate. Consider multiplying two real numbers that represented with n bits, e.g., c=ab, in theory the result c needs higher precision to be represented than both a and b, but in practice, c must be rounded to n bits and thus will be inaccurate. The first and the second cases are the situations for the input data during calculations; the third one is the type for the intermediate data. All of the above three cases are due to the requirement of representing data on the computers. Since that computer arithmetic is based on limited-precision binary numbers. Either representable or un-representable input numbers should be converted and represented by the inexact binary numbers; and all intermediate data is all needed to be rounded and represented by the limited-precision binary numbers. In summary, most of the errors arise in floating-point arithmetic is due to “rounding-off”. 115
A.2
Solutions of Non-robustness
A.2.1
Comparing Floating-point Numbers
In computing, there are many situations that need to compare two floating-point numbers. And in geometric computations, comparison of floating-point values is also quite necessary; for example, in some geometric predicates, it needs to check whether two vertices are the same, and thus the coordinates of target points have to be compared. The comparison seems to be very easy, but in fact it is not as easy as it may be thought, see Code A.1. In integer arithmetic, it is possible and practical to compare two values directly using the following formula if(a==b) then {do something}. This is the exact way people usually consider and expect. However, unlike the integers, floating-point numbers by nature are not exact or accurate, and cannot be directly compared with equality. Giving an exact real number, and after converting and representing it with a specific format of floating-point representation, e.g., the IEEE-754 double-precision, the represented corresponding floating-point number is not exactly identical to the original number, but will be slightly bigger or smaller. This is due to the rounding-off error explained in the previous section of this chapter. The following C++ code simply demonstrates that the floating-point numbers cannot be compared directly. In order to create testing values that are mathematical equal, the number b is directly specified, and the other number a is obtained according to b but via a simple formula. #include using namespace std; int main(void) { double a = 1.80 * (1.0 + 1.0 / 10.0); double b = 1.98; cout cout if(a else else
nID[0]==m_aEdge[k]->nID[1]) && (m_aEdge[j]->nID[1]==m_aEdge[k]->nID[0]) ){ m_aEdge.GetAt(j)->flag = -1; m_aEdge.GetAt(k)->flag = -1; } } } // Create new triangles for(j = 0; j < m_aEdge.GetSize(); j++) { if(m_aEdge.GetAt(j)->flag != -1) { CTrgl * newTriangle = new CTrgl(); // Clock-wise newTriangle->nID[0] = m_aEdge.GetAt(j)->nID[0]; newTriangle->nID[1] = m_aEdge.GetAt(j)->nID[1]; newTriangle->nID[2] = i; surf->pTrgls.Add( newTriangle ); } } for(j = m_aEdge.GetSize() -1; j > -1; j--) { delete m_aEdge.GetAt(j); m_aEdge.RemoveAt(j); } } // Remove invalid triangles for(j = surf->pTrgls.GetSize() - 1; j > -1; j--) { for(k = 0; k < 3; k++) { nID[k] = surf->pTrgls.GetAt(j)->nID[k]; } if(nID[0] >= nNode || nID[1] >= nNode || nID[2] >= nNode){ delete surf->pTrgls.GetAt(j); surf->pTrgls.RemoveAt(j); } } }
Code B.2: Implementation of Bowyer-Watson Algorithm 137
B.2.2
Kriging
// Universal Kriging dP: data points iP: interpolation points void UniversalKriging(vector &dP, vector &iP) { int i, j, k, ndp = dP.size(), nip = iP.size(); int G = 10; // Groups for dividing distances int *LD = new int[G]; double DR1, DZ; double a[3]; // Coefficients of Spherical model double *AR = new double[G]; double *AZ = new double[G]; double *DR = new double[G + 1]; double *p, *A, *B, *C; // Matrices p = new double[(ndp - 1) * ndp / 2]; // Distance matrix A = new double[(ndp + 3) * (ndp + 3)]; // Coefficient matrix B = new double[(ndp + 3)]; C = new double[(ndp + 3)]; // Weights for(i = 0; i < (ndp + 3) * (ndp + 3); i++) A[i] = 0.0; long NumOfDis = 0; for(i = 0; i < ndp - 1; i++) { // Distance for(j = i + 1; j < ndp; j++) { p[NumOfDis] = sqrt( pow(dP[i].x - dP[j].x, 2) + pow(dP[i].y - dP[j].y, 2) ); A[i * (ndp + 3) + j] = p[NumOfDis]; // Upper part A[j * (ndp + 3) + i] = p[NumOfDis]; // Lower part NumOfDis++; } } qsort(p, NumOfDis, sizeof(double), cmp); // Sort for(i = 1; i RGB[i]; } glMyLight(); // Adding light source // Multisampling glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_MULTISAMPLE); glEnable(GL_MULTISAMPLE); // Create a new display list glNewList(list, GL_COMPILE); glLineWidth(0.5); // Set line width // For all vertices, adjust to screen coordinates float tx, ty, tz; int N = Surf->pNds.GetSize(); // Number GLfloat * vertices = new GLfloat[3*N]; for(i = 0; i < N; i++) { tx = Surf->pNds.GetAt(i)->x; ty = Surf->pNds.GetAt(i)->y; tz = Surf->pNds.GetAt(i)->z; vertices[i*3] = (tx - Crt->u) * Crt->Scale; vertices[i*3+1] = (ty - Crt->v) * Crt->Scale; vertices[i*3+2] = (tz - Crt->w) * Crt->Scale; } // Create a vertex array glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, vertices); // For each triangle of a surface mesh for(j = 0; j < Surf->pTrs.GetSize(); j++){
142
CTrgl * tr = Surf->pTrs.GetAt(j); // The jth triangle // Draw filled polygons with Polygon offset glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(1.0, 1.0); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); // Fill glColor3ub(RGB[0], RGB[1], RGB[2]); glBegin(GL_TRIANGLES); for(k = 0; k < 3; k++) { ID = tr->nID[k]; glArrayElement(ID); } glEnd(); glDisable(GL_POLYGON_OFFSET_FILL); // Draw wireframe polygons with white color glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); // Line glColor3ub(255, 255, 255); glBegin(GL_TRIANGLES); for(k = 0; k < 3; k++) { ID = tr->nID[k]; glArrayElement(ID); } glEnd(); } delete [] vertices; glEndList(); // End display list glDisable(GL_MULTISAMPLE); // End multisampling }
Code B.5: The displaying of surface meshes in RealModel
143
B.3.2
Displaying Blocks / Layers
void glCompileBlockGroupListBest(CCordnt* Crt, int list) { #define GL_MULTISAMPLE GLUT_MULTISAMPLE int i, j, k, t, ID, id_Nds, id_Lps, id_Phd; GLfloat fPoint0[3], fPoint1[3], fPoint2[3]; GLint RGB[3]; // RGB color for each BLOCK glMyLight(); // Adding light source // Multisampling glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_MULTISAMPLE); glEnable(GL_MULTISAMPLE); // Create a new display list glNewList(list, GL_COMPILE); glLineWidth(0.5); // Set line width // For all vertices, adjust to screen coordinates float tx, ty, tz; int N = m_aNds.GetSize(); // Number GLfloat * vertices = new GLfloat[3*N]; for(i = 0; i < N; i++) { tx = m_aNds.GetAt(i)->x; ty = m_aNds.GetAt(i)->y; tz = m_aNds.GetAt(i)->z; vertices[i*3] = (tx - Crt->u) * Crt->Scale; vertices[i*3+1] = (ty - Crt->v) * Crt->Scale; vertices[i*3+2] = (tz - Crt->w) * Crt->Scale; } // Create a vertex array glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, vertices); // For each BLOCK for(i = 0; i < m_aBlks.GetSize(); i++) { CBlock * blk = m_aBlks.GetAt(i); for(t = 0; t < 3; t++) { RGB[t] = blk->RGB[t]; } // For each POLYHEDRON of a BLOCK
144
for(j = 0; j < blk->iPhds.GetSize(); j++) { id_Phd = blk->iPhds.GetAt(j); CPohd * phd = m_aPhds.GetAt(id_Phd); // For each polygonal face of a POLYHEDRON for(k = 0; k < phd->iLps.GetSize(); k++) { id_Lps = phd->iLps.GetAt(k); CLoop * lp = m_aLps.GetAt(id_Lps); // Draw filled polygons with Polygon offset glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(1.0, 1.0); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glColor3ub(RGB[0], RGB[1], RGB[2]); glBegin(GL_POLYGON); for(t = 0; t < lp->iNds.GetSize(); t++) { ID = lp->iNds.GetAt(t); glArrayElement(ID); } glEnd(); glDisable(GL_POLYGON_OFFSET_FILL); // Draw wireframe polygons with white color glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glColor3ub(255, 255, 255); glBegin(GL_POLYGON); for(t = 0; t < lp->iNds.GetSize(); t++) { ID = lp->iNds.GetAt(t); glArrayElement(ID); } glEnd(); } } } delete [] vertices; glEndList(); // End display list glDisable(GL_MULTISAMPLE); // End multisampling }
Code B.6: The displaying of blocks / layers in RealModel
145
(a) Front view
(b) Back view
Figure B.1: Front and Back views for the scenes in Realodel 146
(a) Left view
(b) Right view
Figure B.2: Left and Right views for the scenes in Realodel 147
(a) Top view
(b) Bottom view
Figure B.3: Top and Bottom view for the scenes in Realodel 148
Bibliography Adams, B., Dutr´e, P., 2003. Interactive boolean operations on surfel-bounded solids, in: ACM Transactions on Graphics (TOG), ACM. pp. 651–656. Ashton, A.D., Hutton, E.W.H., Kettner, A.J., Xing, F., Kallumadikal, J., Nienhuis, J., Giosan, L., 2013. Progress in coupling models of coastline and fluvial dynamics. Computers & Geosciences 53, 21–29. Aurenhammer, F., 1991. Voronoi diagrams a survey of a fundamental geometric data structure. ACM Computing Surveys 23, 345–405. Berg, M.d., Cheong, O., Kreveld, M.v., Overmars, M., 2008. Computational Geometry: Algorithms and Applications. Springer-Verlag. Bitzer, K., 1999. Two-dimensional simulation of clastic and carbonate sedimentation, consolidation, subsidence, fluid flow, heat flow and solute transport during the formation of sedimentary basins. Computers & Geosciences 25, 431–447. Bitzer, K., Harbaugh, J.W., 1987. DEPOSIM: A Macintosh computer model for two-dimensional simulation of transport, deposition, erosion, and compaction of clastic sediments. Computers & Geosciences 13, 611–637. Bitzer, K., Salas, R., 2002. SIMSAFADIM: three-dimensional simulation of stratigraphic architecture and facies distribution modeling of carbonate sediments. Computers & Geosciences 28, 1177–1192. Bowyer, A., 1981. Computing dirichlet tessellations. The Computer Journal 24, 162–166. Briggs, L., Pollack, H., 1967. Digital model of evaporite sedimentation. Science 155, 2119– 2162. Bronshtein, I., Semendyayev, K., Musiol, G., Muehlig, H., 2007. Handbook of mathematics. Springer Verlag. Bull, L., Kirkby, M., 1997. Gully processes and modelling. Progress in Physical Geography 21, 354–374. Burgess, P.M., 2012. A brief review of developments in stratigraphic forward modelling, 20002009. Elsevier, Amsterdam. pp. 378–404. Burgess, P.M., 2013. CarboCAT: A cellular automata model of heterogeneous carbonate strata. Computers & Geosciences 53, 129–140. Burnikel, C., Fleischer, R., Mehlhorn, K., Schirra, S., 1999. Efficient exact geometric com149
putation made easy, in: Proceedings of the fifteenth annual symposium on Computational geometry, ACM. pp. 341–350. Burnikel, C., K¨onemann, J., Mehlhorn, K., N¨aher, S., Schirra, S., Uhrig, C., 1995. Exact geometric computation in LEDA, in: Proceedings of the eleventh annual symposium on Computational geometry, ACM. pp. 418–419. Campen, M., Kobbelt, L., 2010. Exact and robust (self-) intersections for polygonal meshes, in: Computer Graphics Forum, Wiley Online Library. pp. 397–406. Carmona, A., Clavera-Gispert, R., Gratacs, O., Hardy, S., 2010. Modelling syntectonic sedimentation: Combining adiscrete element model of tectonic deformation andaprocess-based sedimentary model in 3D. Mathematical Geosciences 42, 519–534. CGAL, 2013. Computational Geometry Algorithms Library. http://www.cgal.org. Chazelle, B., 1982. A theorem on polygon cutting with applications, in: Foundations of Computer Science, 1982. SFCS’08. 23rd Annual Symposium on, IEEE. pp. 339–349. Chazelle, B., 1991. Triangulating a simple polygon in linear time. Discrete & Computational Geometry 6, 485–524. Chen, M., Chen, X.Y., Tang, K., Yuen, M.M., 2010. Efficient boolean operation on manifold mesh surfaces. Journal, Computer-Aided Design and Applications 7, 405–415. Cheney, E., Kincaid, D., 2012. Numerical mathematics and computing. Brooks/Cole Publishing Company. Cheng, P., 2005. Research on Three-Dimensional Spatial Data Models and Algorithms in Geology and Mine. Ph.D. thesis. Wuhan University. Cignoni, P., Callieri, M., Corsini, M., Dellepiane, M., Ganovelli, F., Ranzuglia, G., 2008. Meshlab: an open-source mesh processing tool, in: Eurographics Italian Chapter Conference, The Eurographics Association. pp. 129–136. Cressie, N., 1990. The origins of Kriging. Mathematical Geology 22, 239–252. CSDMS, 2013. The Community Surface Dynamics Modeling System. http://csdms. colorado.edu. CUDA, 2013. http://www.nvidia.com/object/cuda_home_new.html. CUDA Samples, 2013. http://docs.nvidia.com/cuda/cuda-samples/. Dalman, R.A.F., Weltje, G.J., 2012. SimClast: An aggregated forward stratigraphic model of continental shelves. Computers & Geosciences 38, 115–126. Dawson, B., 2013. Comparing floating point number. http://www.cygnus-software. com/papers/comparingfloats/comparingfloats.htm. Delaunay, B., 1934. Sur la sph`ere vide. Izvestia Akademii Nauk SSSR, Otdelenie Matematicheskikh i Estestvennykh Nauk 6, 793–800. Demicco, R.V., 1998. CYCOPATH 2Da two-dimensional, forward model of cyclic sedimentation on carbonate platforms. Computers & Geosciences 24, 405–423. Devillers, O., Guigue, P., 2002. Faster Triangle-Triangle Intersection Tests. Technical Report
150
RR-4488. INRIA. ¨ Dirichlet, G.L., 1850. Uber die Reduktion der positiven quadratischen Formen mit drei unbestimmten ganzen Zahlen. Journal f¨ur die Reine und Angewandte Mathematik 40, 209–227. ElGindy, H., Everett, H., Toussaint, G., 1993. Slicing an ear using prune-and-search. Pattern Recognition Letters 14, 719–722. Ericson, C., 2004. Real-time collision detection. Morgan Kaufmann. Fabri, A., Giezeman, G.J., Kettner, L., Schirra, S., Sch¨onherr, S., 1998. On the Design of CGAL, the Computational Geometry Algorithms Library. Technical Report RR-3407. INRIA. Feng, H.Y., Pavlidis, T., 1975. Decomposition of polygons into simpler components: Feature generation for syntactic pattern recognition. Computers, IEEE Transactions on 100, 636–650. Fortune, S., 1987. A sweepline algorithm for Voronoi diagrams. Algorithmica 2, 153–174. Fortune, S., 2004. Voronoi diagrams and Delaunay triangulations, in: Goodman, J.E., O’Rourke, J. (Eds.), Handbook of Discrete and Computational Geometry. Chapman & Hall/CRC, Boca Raton, FL, pp. 513–528. Chapter 23. Franseen, E., 1991. Sedimentary Modeling: Computer Simulations and Methods for Improved Parameter Definition. Number 233 in Bulletin (Kansas State Geological Survey), Kansas Geological Survey. Fu, B., Newham, L.T.H., Ramos-Scharrn, C.E., 2010. A review of surface erosion and sediment delivery models for unsealed roads. Environmental Modelling & Software 25, 1–14. ´ Ruiz de Miras, J., Feito, F., 2011. Evaluation of boolean operations between free-form Garc´ıa, A., solids using extended simplicial chains and pn triangles. The Visual Computer 27, 531–541. GOCAD, 2013. http://www.gocad.org. Gottschalk, S., Lin, M.C., Manocha, D., 1996. OBBTree: a hierarchical structure for rapid interference detection, in: Proceedings of the 23rd annual conference on Computer graphics and interactive techniques, ACM. pp. 171–180. Gratac´os, O., Bitzer, K., Cabrera, L., Roca, E., 2009a. SIMSAFADIM-CLASTIC: A new approach to mathematical 3D forward simulation modelling for terrigenous and carbonate marine sedimentation. Geologica acta: an international earth science journal 7, 311–322. Gratac´os, O., Bitzer, K., Casamor, J.L., Cabrera, L., Calafat, A., Canals, M., Roca, E., 2009b. Simulating transport and deposition of clastic sediments in an elongate basin using the SIMSAFADIM-CLASTIC program: The Camarasa artificial lake case study (NE Spain). Sedimentary Geology 222, 16–26. Guigue, P., Devillers, O., 2003. Fast and robust triangle-triangle overlap test using orientation predicates. Journal of graphics tools 8, 25–32. Guo, K.B., Zhang, L.C., Wang, C.J., Huang, S.H., 2007. Boolean operations of stl models based on loop detection. The International Journal of Advanced Manufacturing Technology 33, 627–633. Hachenberger, P., Kettner, L., 2005. Boolean operations on 3d selective nef complexes: Optimized implementation and experiments, in: Proceedings of the 2005 ACM symposium on 151
Solid and physical modeling, ACM. pp. 163–174. Hajek, E.A., Wolinsky, M.A., 2012. Simplified process modeling of river avulsion and alluvial architecture: Connecting models and field data. Sedimentary Geology 257-260, 1–30. Harbaugh, J.W., Bonham-Carter, G., 1970. Computer simulation in geology. Wiley-Interscience. Harbaugh, J.W., Merriam, D.F., Davis, J.C., 2001. Geologic modeling and simulation: sedimentary systems. Springer. Hardy, S., Finch, E., 2006. Discrete element modelling of the influence of cover strength on basement-involved fault-propagation folding. Tectonophysics 415, 225–238. HautBarr, 2013. The Haut-Barr Castle. http://www.tourisme-alsace.com/en/ 221001403-Haut-Barr-Castle.html. Heitmann, T., 2013. The Haut-Barr Castle. http://thierry.heitmann.free.fr/ environs/english/hautbar1.htm. Held, M., 1997. ERIT – A collection of efficient and reliable intersection tests. Journal of Graphics Tools 2, 25–44. Held, M., 2001. FIST: Fast industrial-strength triangulation of polygons. Algorithmica 30, 563– 596. Ho-Le, K., 1988. Finite element mesh generation methods: a review and classification. Computer-aided design 20, 27–38. Hoffmann, C.M., 1989. Geometric and solid modeling: an introduction. Morgan Kaufmann Publishers Inc. Hoogendoorn, R.M., Overeem, I., Storms, J.E.A., 2008. Process-response modelling of fluviodeltaic stratigraphy. Computers & Geosciences 34, 1394–1416. Houlding, S., 1994. 3D geoscience modeling: computer techniques for geological characterization. Springer-Verlag. Hutton, E.W.H., Syvitski, J.P.M., 2008. Sedflux 2.0: An advanced process-response model that generates three-dimensional stratigraphy. Computers & Geosciences 34, 1319–1337. IEEE, 2008. IEEE standard for floating-point arithmetic. IEEE Std 754-2008 , 1 –58. Ijmker, J., Stauch, G., Dietze, E., Hartmann, K., Diekmann, B., Lockot, G., Opitz, S., Wnnemann, B., Lehmkuhl, F., 2012. Characterisation of transport processes and sedimentary deposits by statistical end-member mixing analysis of terrestrial sediments in the donggi cona lake catchment, ne tibetan plateau. Sedimentary Geology 281, 166–179. Karamcheti, V., Li, C., Pechtchanski, I., Yap, C., 1999. A core library for robust numeric and geometric computation, in: Proceedings of the fifteenth annual symposium on Computational geometry, ACM. pp. 351–359. Kettner, L., Mehlhorn, K., Pion, S., Schirra, S., Yap, C., 2008. Classroom examples of robustness problems in geometric computations. Computational Geometry 40, 61 – 78. Kirk, D., Wen-mei, W., 2010. Programming massively parallel processors: a hands-on approach. Morgan Kaufmann.
152
Knuth, D.E., 1997. The art of computer programming, volume 2 (3rd ed.): seminumerical algorithms. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA. Kombiadou, K., Krestenitis, Y.., 2011. Simulating the fate of mechanically eroded masses in the thermaikos gulf. Continental Shelf Research 31, 817–831. Krige, D.G., 1951a. A statistical approach to some basic mine valuation problems on the witwatersrand. Journal of the Chemical, Metallurgical and Mining Society of South Africa 52, 119–139. Krige, D.G., 1951b. A statistical approach to some mine valuation and allied problems on the Witwatersrand. Master’s thesis. University of the Witwatersrand. K.Yap, C., 1997. Towards exact geometric computation. Computational Geometry 7, 3 – 23. Invited talk in the proceedings of the 5th Canadian Conference on Computational Geometry, University of Waterloo, August 5-9, 1993. K.Yap, C., 2004. Robust geometric computation, in: Goodman, J.E., O’Rourke, J. (Eds.), Handbook of Discrete and Computational Geometry. Chapman & Hall/CRC, Boca Raton, FL, pp. 927 – 952. Chapter 41. Laigle, L., Joseph, P., de Marsily, G., Violette, S., 2013. 3-D process modelling of ancient stormdominated deposits by an event-based approach: Application to Pleistocene-to-modern Gulf of Lions deposits. Marine Geology 335, 177–199. Lavou, G., Tola, M., Dupont, F., 2012. MEPP - 3D Mesh Processing Platform, in: International Conference on Computer Graphics Theory and Applications (GRAPP). Lawson, C.L., 1977. Mathematical Software III; Software for C1 surface interpolation, Academic Press, New York, pp. 161–194. LEDA, 2013. Library for Efficient Data Types and Algorithms. http://www.mpi-inf. mpg.de/LEDA. Lee, D., Schachter, B., 1980. Two algorithms for constructing a Delaunay triangulation. International Journal of Computer and Information Sciences 9, 219–242. Li, C., 2001. Exact geometric computation: theory and applications. Ph.D. thesis. New York University. Li, C., Pion, S., Yap, C.K., 2005. Recent progress in exact geometric computation. Journal of Logic and Algebraic Programming 64, 85–111. Lo, S., 1985. A new mesh generation scheme for arbitrary planar domains. International Journal for Numerical Methods in Engineering 21, 1403–1426. Lo, S., Wang, W., 2005. Finite element mesh generation over intersecting curved surfaces by tracing of neighbours. Finite elements in analysis and design 41, 351–370. Mallet, J.L., 1989. Discrete smooth interpolation. ACM Transactions on Graphics (TOG) 8, 121–144. Mallet, J.L., 1992. Discrete smooth interpolation in geometric modelling. Computer-aided design 24, 178–191. Mallet, J.L., 2002. Geomodeling. Applied geostatistics series, Oxford University Press, USA. 153
Maselli, V., Hutton, E.W., Kettner, A.J., Syvitski, J.P.M., Trincardi, F., 2011. High-frequency sea level and sediment supply fluctuations during termination i: An integrated sequencestratigraphy and modeling approach from the adriatic sea (central mediterranean). Marine Geology 287, 54–70. Matheron, G., 1963. Principles of geostatistics. Economic geology 58, 1246–1266. Meagher, D., 1982. Geometric modeling using octree encoding. Computer Graphics and Image Processing 19, 129 – 147. Mehlhorn, K., N¨aher, S., 1999. LEDA: a platform for combinatorial and geometric computing. Cambridge University Press. Mehlhorn, K., Yap, C., 2004. Robust Geometric Computation. Still in preparation. Available at http://cs.nyu.edu/yap/book/egc/. Mei, G., 2009. ”Research on Mixed-element Mesh Generation Methodology Based on Sealed Geological Modeling”. Master’s thesis. China Univeristy of Geosciences (Beijing). Mei, G., 2014. Summary on several key techniques in 3D geological modeling. The Scientific World Journal 2014. Article ID 723832. Mei, G., Tipper, J.C., 2013. Simple and robust boolean operations for triangulated surfaces. arXiv:1308.4434. Mei, G., Tipper, J.C., Xu, N., 2012. Discrete surface modeling based on google earth: A case study, in: Proceeding of 2012 Computer Science and Network Technology (ICCSNT), pp. 1137–1141. Mei, G., Tipper, J.C., Xu, N., 2013. Ear-clipping based algorithms of generating high-quality polygon triangulation, in: Proceedings of the 2012 International Conference on Information Technology and Software Engineering, Springer Berlin Heidelberg. pp. 979–988. Mei, G., Tipper, J.C., Xu, N., 2014. Numerical robustness in geometric computation: An expository summary. Applied Mathematics & Information Sciences 8, 1 – 11. Meisters, G.H., 1975. Polygons have ears. American Mathematical Monthly , 648–651. Merritt, W.S., Letcher, R.A., Jakeman, A.J., 2003. A review of erosion and sediment transport models. Environmental Modelling & Software 18, 761–799. M¨obius, J., Kobbelt, L., 2012. Openflipper: an open source geometry processing and rendering framework, in: Proceedings of the 7th international conference on Curves and Surfaces, Springer-Verlag. pp. 488–500. M¨oller, T., 1997. A fast triangle-triangle intersection test. Journal of graphics tools 2, 25–30. M¨oller, T., Haines, E., Hoffman, N., 2008. Real-time rendering. AK Peters Limited. MPI, 2013. The Message Passing Interface. http://www.mcs.anl.gov/research/ projects/mpi/. Neumeier, U., Ferrarin, C., Amos, C.L., Umgiesser, G., Li, M.Z., 2008. Sedtrans05: An improved sediment-transport model for continental shelves and coastal waters with a new algorithm for cohesive sediments. Computers & Geosciences 34, 1223–1242. Okabe, A., Boots, B., Sugihara, K., Chiu, S.N., 2000. Spatial Tessellations: Concepts and 154
Applications of Voronoi Diagrams. Series in Probability and Statistics. 2nd ed. ed., John Wiley and Sons, Inc. Oliver, M.A., Webster, R., 1990. Kriging: a method of interpolation for geographical information systems. International Journal of Geographical Information System 4, 313–332. OpenMP, 2013. Open Multi-Processing. http://www.openmp.org. o’Rourke, J., 1998. Computational geometry in C. Cambridge University Press. Owen, S.J., 1998. A survey of unstructured mesh generation technology, in: 7th International Meshing Roundtable. Paola, C., 2000. Quantitative models of sedimentary basin filling. Sedimentology 47, 121–178. Paul Chew, L., 1989. Constrained delaunay triangulations. Algorithmica 4, 97–108. Pavic, D., Campen, M., Kobbelt, L., 2010. Hybrid booleans. Comput. Graph. Forum 29, 75–87. Peckham, S.D., Hutton, E.W.H., Norris, B., 2013. A component-based approach to integrated modeling in the geosciences: The design of CSDMS. Computers & Geosciences 53, 3–12. Pereira, A.M.B., de Arruda, M.C., Miranda, A.C.d.O., Lira, W.W.M., Martha, L.F., 2012. Boolean operations on multi-region solids for mesh generation. Engineering with Computers , 1–15. Pion, S., Fabri, A., 2011. A generic lazy evaluation scheme for exact geometric computations. Science of Computer Programming 76, 307–323. Prosser, I.P., Rustomji, P., 2000. Sediment transport capacity relations for overland flow. Progress in Physical Geography 24, 179–193. Rose, C., 1993. Erosion and Sedimentation, in: Hydrology and Water Management in the Humid Tropics. Cambridge University Press. Rouby, D., Braun, J., Robin, C., Dauteuil, O., Deschamps, F., 2013. Long-term stratigraphic evolution of atlantic-type passive margins: A numerical approach of interactions between surface processes, flexural isostasy and 3d thermal subsidence. Tectonophysics , –. Salesin, D., Stolfi, J., Guibas, L., 1989. Epsilon geometry: building robust algorithms from imprecise computations, in: Proceedings of the fifth annual symposium on Computational geometry, ACM. pp. 208–217. Sanford, L.P., 2008. Modeling a dynamically varying mixed sediment bed with erosion, deposition, bioturbation, consolidation, and armoring. Computers & Geosciences 34, 1263–1283. Schifko, M., J¨uttler, B., Kornberger, B., 2010. Industrial application of exact boolean operations for meshes, in: Proceedings of the 26th Spring Conference on Computer Graphics, ACM, New York, NY, USA. pp. 165–172. Schirra, S., 2000. Robustness and precision issues in geometric computation, in: Sack, J.R., Urrutia, J. (Eds.), Handbook of Computational Geometry. North-Holland, Amsterdam, pp. 597 – 632. Chapter 14. Schirra, S., 2004. Real numbers and robustness in computational geometry, in: Proceedings of the 6th Conference on Real Numbers and Computers, Springer Verlag, Dagstuhl, Germany. pp. 7–21. 155
Schneider, P., Eberly, D.H., 2002. Geometric tools for computer graphics. Morgan Kaufmann. Seidel, R., 1991. A simple and fast incremental randomized algorithm for computing trapezoidal decompositions and for triangulating polygons. Computational Geometry 1, 51–64. Shepard, D., 1968. A two-dimensional interpolation function for irregularly-spaced data, in: Proceedings of the 1968 23rd ACM national conference, ACM. pp. 517–524. Shewchuk, J., 1996. Robust adaptive floating-point geometric predicates, in: Proceedings of the twelfth annual symposium on Computational geometry, ACM. pp. 141–150. Shewchuk, J., 1997. Adaptive precision floating-point arithmetic and fast robust geometric predicates. Discrete Computational Geometry 18, 305–363. Shreiner, D., 2009. OpenGL Programming Guide: The Official Guide to Learning OpenGL, Versions 3.0 and 3.1 (7th Edition). Addison-Wesley. Smith, J., Dodgson, N., 2007. A topologically robust algorithm for boolean operations on polyhedral shapes using approximate arithmetic. Computer-Aided Design 39, 149–163. Strobel, J., Cannon, R., Christopher, G.S., Kendall, C.S., Biswas, G., Bezdek, J., 1989. Interactive (SEDPAK) simulation of clastic and carbonate sediments in shelf to basin settings. Computers & Geosciences 15, 1279–1290. Suter, J., 1999. Introduction to Octrees. http://www.flipcode.com/archives/ Introduction_To_Octrees.shtml. Syvitski, J.P.M., Hutton, E.W.H., 2001. 2D SEDFLUX 1.0C: an advanced process-response numerical model for the fill of marine sedimentary basins. Computers & Geosciences 27, 731–753. Tayebi, A., Gomez Perez, J., Gonzalez Diego, I., Catedra, F., 2011. Boolean operations implementation over 3d parametric surfaces to be included in the geometrical module of an electromagnetic solver, in: Antennas and Propagation (EUCAP), Proceedings of the 5th European Conference on, IEEE. pp. 2137–2141. Tetzlaff, D., Harbaugh, J., 1989. Simulating clastic sedimentation. Computer Methods in the Geosciences, Van Nostrand Reinhold, New York. Tian, H., 2008. An Approach to Build a 3D Sealed Engineering Geological Model Suitable for Numerical Simulation. Master’s thesis. China Univeristy of Geosciences (Beijing). Tipper, J.C., 1976a. A method and FORTRAN program for quantitative sampling in paleontology. Computers & Geosciences 1, 195–201. Tipper, J.C., 1976b. The study of geological objects in three dimensions by the computerized reconstruction of serial sections. The Journal of Geology 84, 476–484. Tipper, J.C., 1977a. A method and FORTRAN program for the computerized reconstruction of three-dimensional objects from serial sections. Computers & Geosciences 3, 579–599. Tipper, J.C., 1977b. Three-dimensional analysis of geological forms. The Journal of Geology 85, 591–611. Tipper, J.C., 1978. Computerized modeling for shape analysis in geology, in: Recent Advances in Geomathematics, An International Symposium, Pergamon Press. pp. 157–170. 156
Tipper, J.C., 1979a. An algol program for dissimilarity analysis: a divisive-omnithetic clustering technique. Computers & Geosciences 5, 1–13. Tipper, J.C., 1979b. Surface modelling techniques. Kansas Geological Survey. Tipper, J.C., 1990. A straightforward iterative algorithm for the planar Voronoi diagram. Information Processing Letters 34, 155 – 160. Tipper, J.C., 1991. FORTRAN programs to construct the planar Voronoi diagram. Computers & Geosciences 17, 597 – 632. Tipper, J.C., 2011. The geometric interrelationships of outcrops and rock bodies: Setting up and testing quantitative hypotheses, in: Martinsen, O.J., Pulham, A.J., Haughton, P.D.W., Sullivan, M.D. (Eds.), Outcrops Revitalized: Tools, Techniques and Applications. Concepts in Sedimentology and Paleontology, pp. 21–29. Toussaint, G., 1991. Efficient triangulation of simple polygons. The Visual Computer 7, 280– 295. Tropp, O., Tal, A., Shimshoni, I., 2006. A fast triangle to triangle intersection test for collision detection. Computer Animation and Virtual Worlds 17, 527–535. Van Den Bergen, G., 1997. Efficient collision detection of complex deformable models using aabb trees. Journal of Graphics Tools 2, 1–13. Voronoi, G., 1908. Nouvelles applications des param`etres continus a` la th´eorie des formes quadratiques. Deuxi`eme m´emoire. Recherches sur les parall´ello`edres primitifs. Journal f¨ur die reine und angewandte Mathematik (Crelles Journal) 1908, 198–287. Wang, C.C., 2011. Approximate boolean operations on large polyhedral solids with partial mesh reconstruction. Visualization and Computer Graphics, IEEE Transactions on 17, 836–849. Warner, J.C., Sherwood, C.R., Signell, R.P., Harris, C.K., Arango, H.G., 2008. Development of a three-dimensional, regional, coupled wave, current, and sediment-transport model. Computers & Geosciences 34, 1284–1306. Warrlich, G., Bosence, D., Waltham, D., Wood, C., Boylan, A., Badenas, B., 2008. 3d stratigraphic forward modelling for analysis and prediction of carbonate platform stratigraphies in exploration and production. Marine and Petroleum Geology 25, 35–58. Warrlich, G.M.D., Waltham, D.A., Bosence, D.W.J., 2002. Quantifying the sequence stratigraphy and drowning mechanisms of atolls using a new 3-D forward stratigraphic modelling program (CARBONATE 3D). Basin Research 14, 379–400. Watson, D.F., 1981. Computing the n-dimensional Delaunay tessellation with application to Voronoi polytopes. The Computer Journal 24, 167–172. Weltje, G.J., 2012. Quantitative models of sediment generation and provenance: State of the art and future developments. Sedimentary Geology 280, 4–20. Wheater, H.S., Jakeman, A.J., Beven, K.J., 1993. Progress and directions in rainfall-runoff modelling. John Wiley. pp. 101–132. Wikipedia, 2013. CUDA. http://en.wikipedia.org/wiki/CUDA. de Winter, I.L., Storms, J.E.A., Overeem, I., 2012. Numerical modeling of glacial sediment 157
production and transport during deglaciation. Geomorphology 167-168, 102–114. Wire-frame, 2013. http://en.wikipedia.org/wiki/Wire-frame_model. Xu, N., Duan, Q., Mei, G., Wu, X., Tian, H., 2010. 3D Geological Modeling and Programming. Geological Publishing House, Beijing. Yang, P., Qian, X., 2009. Direct boolean intersection between acquired and designed geometry. Computer-Aided Design 41, 81–94. Yu, J., 1992. Exact arithmetic solid modeling. Ph.D. thesis. Purdue University, Department of Computer Sciences. Zakrevsky, K., 2011. Geological 3D Modelling. EAGE Publications bv.
158