Institutionen för systemteknik Department of Electrical ...655691/FULLTEXT01.pdf · The surface...

124
Institutionen för systemteknik Department of Electrical Engineering Examensarbete Automatic mesh repair Examensarbete utfört i Informationskodning vid Tekniska högskolan vid Linköpings universitet av Agnes Larsson LiTH-ISY-EX--13/4720--SE Linköping 2013 Department of Electrical Engineering Linköpings tekniska högskola Linköpings universitet Linköpings universitet SE-581 83 Linköping, Sweden 581 83 Linköping

Transcript of Institutionen för systemteknik Department of Electrical ...655691/FULLTEXT01.pdf · The surface...

  • Institutionen för systemteknikDepartment of Electrical Engineering

    Examensarbete

    Automatic mesh repair

    Examensarbete utfört i Informationskodningvid Tekniska högskolan vid Linköpings universitet

    av

    Agnes Larsson

    LiTH-ISY-EX--13/4720--SE

    Linköping 2013

    Department of Electrical Engineering Linköpings tekniska högskolaLinköpings universitet Linköpings universitetSE-581 83 Linköping, Sweden 581 83 Linköping

  • Automatic mesh repair

    Examensarbete utfört i Informationskodningvid Tekniska högskolan vid Linköpings universitet

    av

    Agnes Larsson

    LiTH-ISY-EX--13/4720--SE

    Handledare: Jens Ogniewskiisy, Linköpings universitet

    Jimmie WestConfigura

    Examinator: Ingemar Ragnemalmisy, Linköpings universitet

    Linköping, 30 september 2013

  • Avdelning, InstitutionDivision, Department

    InformationskodningDepartment of Electrical EngineeringSE-581 83 Linköping

    DatumDate

    2013-09-30

    SpråkLanguage

    � Svenska/Swedish

    � Engelska/English

    RapporttypReport category

    � Licentiatavhandling

    � Examensarbete

    � C-uppsats

    � D-uppsats

    � Övrig rapport

    URL för elektronisk version

    ISBN

    ISRN

    LiTH-ISY-EX--13/4720--SE

    Serietitel och serienummerTitle of series, numbering

    ISSN

    TitelTitle

    Automatisk reparering av 3D-modeller

    Automatic mesh repair

    FörfattareAuthor

    Agnes Larsson

    SammanfattningAbstract

    To handle broken 3D models can be a very time consuming problem. Several methods aimingfor automatic mesh repair have been presented in the recent years. This thesis gives anextensive evaluation of automatic mesh repair algorithms, presents a mesh repair pipelineand describes an implemented automatic mesh repair algorithm.

    The presented pipeline for automatic mesh repair includes three main steps: octree gener-ation, surface reconstruction and ray casting. Ray casting is for removal of hidden objects.The pipeline also includes a pre processing step for removal of intersecting triangles and apost processing step for error detection.

    The implemented algorithm presented in this thesis is a volumetric method for mesh repair.It generates an octree in which data from the input model is saved. Before creation of theoutput, the octree data will be patched to remove inconsistencies. The surface reconstructionis done with a method called Manifold Dual Contouring. First new vertices are created fromthe information saved in the octree. Then there is a possibility to cluster vertices together fordecimation of the output. Thanks to a special Manifold criterion, the output is guaranteedto be manifold. Furthermore the output will have sharp and clear edges and corners thanksto the use of Singular Value Decomposition during determination of the positions of the newvertices.

    NyckelordKeywords Automatic mesh repair, Manifold Dual Contouring, Jacobi Rotations, Octree

  • Abstract

    To handle broken 3D models can be a very time consuming prob-lem. Several methods aiming for automatic mesh repair have beenpresented in the recent years. This thesis gives an extensive evalu-ation of automatic mesh repair algorithms, presents a mesh repairpipeline and describes an implemented automatic mesh repair algo-rithm.

    The presented pipeline for automatic mesh repair includes threemain steps: octree generation, surface reconstruction and ray cast-ing. Ray casting is for removal of hidden objects. The pipeline alsoincludes a pre processing step for removal of intersecting trianglesand a post processing step for error detection.

    The implemented algorithm presented in this thesis is a volumetricmethod for mesh repair. It generates an octree in which data fromthe input model is saved. Before creation of the output, the octreedata will be patched to remove inconsistencies. The surface recon-struction is done with a method called Manifold Dual Contouring.First new vertices are created from the information saved in the oc-tree. Then there is a possibility to cluster vertices together for dec-imation of the output. Thanks to a special Manifold criterion, theoutput is guaranteed to be manifold. Furthermore the output willhave sharp and clear edges and corners thanks to the use of Singu-lar Value Decomposition during determination of the positions ofthe new vertices.

    iii

  • Acknowledgments

    I would like to thank Jimmie West at Configura for always lettingme ask questions, for all the valuable discussions on programmingand the mesh repair topic and for reviewing this report. I wouldalso like to thank Viktor Smedby, Jens Ogniewski and Joel Janssonfor reviewing this report. Furthermore, I want to thank IngemarRagnemalm for supporting me during this master thesis project.

    Linköping, September 2013Agnes Larsson

    v

  • Contents

    List of Figures x

    List of Tables xii

    1 Introduction 11.1 Problem . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Goal . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.3 Limitations . . . . . . . . . . . . . . . . . . . . . . . . 21.4 Time plan . . . . . . . . . . . . . . . . . . . . . . . . . 21.5 Contributions . . . . . . . . . . . . . . . . . . . . . . 21.6 Configura . . . . . . . . . . . . . . . . . . . . . . . . . 3

    1.6.1 CET . . . . . . . . . . . . . . . . . . . . . . . . 31.6.2 CM . . . . . . . . . . . . . . . . . . . . . . . . 4

    1.7 Technical specification . . . . . . . . . . . . . . . . . 41.8 Structure . . . . . . . . . . . . . . . . . . . . . . . . . 41.9 Abbreviations . . . . . . . . . . . . . . . . . . . . . . 4

    2 Background 72.1 Computer graphics . . . . . . . . . . . . . . . . . . . 72.2 Relevant concepts . . . . . . . . . . . . . . . . . . . . 8

    2.2.1 A mesh repair overview . . . . . . . . . . . . . 82.2.2 Remeshing . . . . . . . . . . . . . . . . . . . . 82.2.3 Grids . . . . . . . . . . . . . . . . . . . . . . . 92.2.4 Isosurface . . . . . . . . . . . . . . . . . . . . . 10

    2.3 Mesh repair . . . . . . . . . . . . . . . . . . . . . . . . 112.3.1 Mesh errors . . . . . . . . . . . . . . . . . . . . 112.3.2 Surface-based methods . . . . . . . . . . . . . 13

    vii

  • viii CONTENTS

    2.3.3 Volume-based methods . . . . . . . . . . . . . 15

    3 Evaluation and related work 193.1 Related work . . . . . . . . . . . . . . . . . . . . . . . 20

    3.1.1 Surface-based methods . . . . . . . . . . . . . 213.1.2 Volume-based methods . . . . . . . . . . . . . 233.1.3 A combination between the surface-based and

    volume based approaches . . . . . . . . . . . . 303.1.4 Contouring methods . . . . . . . . . . . . . . 313.1.5 Methods based on expanding objects inside the

    input model . . . . . . . . . . . . . . . . . . . 363.1.6 Previous thesis workers at Configura working

    with the same problem . . . . . . . . . . . . . 413.2 Prestudy conclusion . . . . . . . . . . . . . . . . . . . 42

    4 Mesh repair system 454.1 The mesh repair pipeline . . . . . . . . . . . . . . . . 454.2 The implemented system . . . . . . . . . . . . . . . . 46

    4.2.1 System information . . . . . . . . . . . . . . . 47

    5 Robust repair of polygonal models 495.1 Scan-conversion . . . . . . . . . . . . . . . . . . . . . 495.2 Sign generation . . . . . . . . . . . . . . . . . . . . . . 505.3 Surface reconstruction . . . . . . . . . . . . . . . . . 53

    6 Manifold dual contouring 55

    7 Singular value decomposition with Jacobi rotations 597.1 Singular value decomposition . . . . . . . . . . . . . 59

    7.1.1 Eigenvalue decomposition . . . . . . . . . . . 607.2 Jacobi rotations . . . . . . . . . . . . . . . . . . . . . . 61

    8 Implementation 638.1 Patching . . . . . . . . . . . . . . . . . . . . . . . . . . 63

    8.1.1 Detection of problem areas . . . . . . . . . . . 638.1.2 Patching of problem areas . . . . . . . . . . . 64

    8.2 Manifold dual contouring . . . . . . . . . . . . . . . . 688.2.1 Vertex Clustering . . . . . . . . . . . . . . . . 698.2.2 Polygonalization . . . . . . . . . . . . . . . . . 76

  • 9 Results 779.1 Repairing results . . . . . . . . . . . . . . . . . . . . . 77

    9.1.1 Overall results . . . . . . . . . . . . . . . . . . 779.1.2 Results for the new patch method . . . . . . . 799.1.3 Singular value decomposition results . . . . . 809.1.4 Vertex clustering results . . . . . . . . . . . . 80

    9.2 Performance . . . . . . . . . . . . . . . . . . . . . . . 81

    10 Discussion 9110.1 Patching . . . . . . . . . . . . . . . . . . . . . . . . . . 9210.2 Manifold dual contouring . . . . . . . . . . . . . . . . 92

    10.2.1 Singular value decomposition . . . . . . . . . 9210.2.2 Vertex clustering . . . . . . . . . . . . . . . . . 93

    10.3 Time and memory complexity . . . . . . . . . . . . . 94

    11 Conclusion and future work 9511.1 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 95

    11.1.1 Automatic mesh repair evaluation . . . . . . . 9511.1.2 The mesh repair pipeline . . . . . . . . . . . . 9611.1.3 Implemented automatic mesh repair method 96

    11.2 Future work . . . . . . . . . . . . . . . . . . . . . . . 9711.2.1 Removal of unseen objects . . . . . . . . . . . 9711.2.2 Error detection . . . . . . . . . . . . . . . . . . 9711.2.3 Processing of several models at the same time 9811.2.4 Reduce time and memory complexity . . . . . 9811.2.5 Automatic calculation of octree depth . . . . 9811.2.6 Possibility to have leaf nodes at different oc-

    tree depths . . . . . . . . . . . . . . . . . . . . 9911.2.7 Octree refinement . . . . . . . . . . . . . . . . 99

    Bibliography 101

    ix

  • x LIST OF FIGURES

    List of Figures

    2.1 A triangle mesh. . . . . . . . . . . . . . . . . . . . . . 82.2 Octree . . . . . . . . . . . . . . . . . . . . . . . . . . . 102.3 T-junction . . . . . . . . . . . . . . . . . . . . . . . . . 122.4 Hanging triangles . . . . . . . . . . . . . . . . . . . . 132.5 Different mesh errors . . . . . . . . . . . . . . . . . . 142.6 Noise and aliasing . . . . . . . . . . . . . . . . . . . . 15

    3.1 Cutting and stitching . . . . . . . . . . . . . . . . . . 223.2 A chair part healed at different depths in PolyMender. 253.3 Expanding cylinders . . . . . . . . . . . . . . . . . . . 273.4 Base cases of Marching Cubes . . . . . . . . . . . . . 323.5 Dual grid . . . . . . . . . . . . . . . . . . . . . . . . . 333.6 Dual Marching Cubes result . . . . . . . . . . . . . . 343.7 Dual contouring . . . . . . . . . . . . . . . . . . . . . 353.8 Competing Fronts . . . . . . . . . . . . . . . . . . . . 363.9 Testing of the Screened Poisson Surface Reconstruc-

    tion algorithm at different depths. . . . . . . . . . . . 393.10 Carwing and growing from inside . . . . . . . . . . . 403.11 Topological simplification of isosurfaces result . . . . 413.12 The input model with a large hole. . . . . . . . . . . 443.13 Old patching result . . . . . . . . . . . . . . . . . . . 44

    4.1 Mesh repair pipeline . . . . . . . . . . . . . . . . . . 464.2 One voxel with eight corners, 12 edges and six faces. 48

    5.1 The primal edges of an octree node are marked withred. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

    5.2 Quads . . . . . . . . . . . . . . . . . . . . . . . . . . . 515.3 Ju’s patching method . . . . . . . . . . . . . . . . . . 52

  • LIST OF FIGURES xi

    5.4 Results of Ju’s method . . . . . . . . . . . . . . . . . . 53

    6.1 Vertex clustering in 2D . . . . . . . . . . . . . . . . . 56

    7.1 The Jacobi rotation matrix. . . . . . . . . . . . . . . . 61

    8.1 Edge boundary . . . . . . . . . . . . . . . . . . . . . . 648.2 Split border cycle . . . . . . . . . . . . . . . . . . . . 668.3 Splitting plane . . . . . . . . . . . . . . . . . . . . . . 678.4 The input model with a hole. . . . . . . . . . . . . . . 688.5 City block paths . . . . . . . . . . . . . . . . . . . . . 688.6 Intersected edges update. . . . . . . . . . . . . . . . . 69

    9.1 The input model with bad normals. . . . . . . . . . . 789.2 Healed with octree depth 7. . . . . . . . . . . . . . . 789.3 Healed with octree depth 8. . . . . . . . . . . . . . . 789.4 Healed in PolyMender with octree depth 8. . . . . . . 789.5 PolyMender results . . . . . . . . . . . . . . . . . . . 839.6 Healed with octree depth 10 in PolyMender. . . . . . 839.7 Healed with octree depth 8, using the approach de-

    scribed in this thesis. . . . . . . . . . . . . . . . . . . 839.8 Healed with octree depth 9, using the approach de-

    scribed in this thesis. . . . . . . . . . . . . . . . . . . 839.9 The input chair back model. . . . . . . . . . . . . . . 849.10 The chair back healed with octree depth 9 in Poly-

    Mender. . . . . . . . . . . . . . . . . . . . . . . . . . . 849.11 The chair back healed with octree depth 9, using the

    approach described in this thesis. . . . . . . . . . . . 849.12 The input model. . . . . . . . . . . . . . . . . . . . . . 859.13 Healed with octree depth 3, using the approach de-

    scribed in this thesis. . . . . . . . . . . . . . . . . . . 859.14 Healed with octree depth 6, using the approach de-

    scribed in this thesis. . . . . . . . . . . . . . . . . . . 859.15 Healed with octree depth 8, using the approach de-

    scribed in this thesis. . . . . . . . . . . . . . . . . . . 859.16 Output triangles . . . . . . . . . . . . . . . . . . . . . 869.17 The sphere patched with the new method. . . . . . . 869.18 The sphere patched with the old method. . . . . . . . 869.19 The input model. . . . . . . . . . . . . . . . . . . . . . 87

  • 9.20 Healed without SVD, the approach described in thisthesis was used. . . . . . . . . . . . . . . . . . . . . . 87

    9.21 Healed with SVD, the approach described in this the-sis was used. . . . . . . . . . . . . . . . . . . . . . . . 87

    9.22 Healed in PolyMender. . . . . . . . . . . . . . . . . . 879.23 Edge detail . . . . . . . . . . . . . . . . . . . . . . . . 889.24 Detail of an edge. The model is healed with Poly-

    Mender. . . . . . . . . . . . . . . . . . . . . . . . . . . 889.25 The black rectangle marks were the edge detail is lo-

    cated on the 3D model. . . . . . . . . . . . . . . . . . 889.26 The edge detail on the input model. . . . . . . . . . . 889.27 Processed without clustering. . . . . . . . . . . . . . 899.28 Processed and decimated with error threshold 0.1. . 89

    List of Tables

    9.1 Vertex clustering results . . . . . . . . . . . . . . . . 819.2 Total processing time . . . . . . . . . . . . . . . . . . 819.3 Block processing time . . . . . . . . . . . . . . . . . . 829.4 Total number of triangles . . . . . . . . . . . . . . . . 82

    xii

  • 1Introduction

    This report presents an extensive evaluation of the mesh repair area,a proposed mesh repair pipeline and an implemented automaticmesh repair algorithm.

    1.1 Problem

    Every day Configura handles a large amount of 3D-models, somewhich are incorrect. For example, the 3D-models may contain holesand incorrectly directed triangle normals. The incorrect 3D modelsmake the work at Configura more complicated and time consum-ing. Therefore Configura needs a robust and automatic mesh repairalgorithm. Mesh repair is a broad and complex area. There are lotsof published mesh repair solutions, lots of them are not robust forall cases. How do the different algorithms work and what results dothey give? A clear and detailed mesh repair pipeline is needed.

    1.2 Goal

    The goal of this thesis work is to develop and implement an au-tomatic mesh repair pipeline for polygonal 3D models. Different

    1

  • 2 1 Introduction

    mesh repair approaches should also be evaluated. Errors that thealgorithm preferably should handle are listed and described in sec-tion 2.3.1. The project should give an overview of the mesh repairresearch of today.

    1.3 Limitations

    The goal is not to develop a completely new algorithm. The aim isto evaluate already existing algorithms and construct a mesh repairpipeline from the evaluation. The pipeline may include new algo-rithms, but if already existing algorithms satisfy the constraints ofthe project, these algorithms will be used.

    To make a working healing algorithm is of higher priority than mak-ing a fast algorithm, but a short processing time is, despite that, ap-preciated.

    1.4 Time plan

    The project is restricted to 20 weeks. Five weeks are used for re-search and evaluation. 12 weeks are used for implementation andthe remaining three weeks are used for writing of the thesis thesis.

    1.5 Contributions

    The main contributions of this thesis work are an extensive eval-uation of the mesh repair area, a clear and extensive mesh repairpipeline that solves all the mesh errors that Configura wants to healand a mesh repair software that can repair several broken models.

    Several mesh repair algorithms have been evaluated and the eval-uation has led to a carefully designed mesh repair pipeline. Thepipeline is presented in chapter 4. This pipeline handles all errorspresented in section 2.3.1. The developed mesh repair software han-dles all errors except from removal of unseen objects. However,time and memory complexity have to be reduced for handling ofvery complex 3D models.

  • 1.6 Configura 3

    No user interaction is needed during the processing of a mesh inthe developed mesh repair algorithm. It is also possible to auto-matically repair models that consist of several sub models. Witha sufficiently high octree depth the output will be manifold. Badnormals are corrected and there is a possibility to turn on triangledecimation, which will be performed during the mesh repair pro-cess. The triangle decimation can reduce the amount of triangles inthe output model significantly.

    Singular value decomposition is implemented in the mesh repairsoftware for calculating positions of new vertices, this gives sharperand clearer edges in the output model.

    The evaluation explains several different mesh repair approachesand discusses their drawbacks and benefits. The evaluation can behelpful for anyone trying to solve the automatic mesh repair prob-lem.

    1.6 Configura

    Configura is a globally operating Swedish company with headquar-ters in Linköping. Configura also has offices in Gothenburg, Swe-den, Grand Rapids, Michigan, USA, and Kuala Lumpur, Malaysia.Configura creates Parametric Graphical Configuration (PGC) soft-ware solutions and serves in commercial furniture, kitchen and bath,material handling and industrial machinery markets. Configurahas two platforms: CET and the original platform Configura.

    1.6.1 CET

    CET designer is a software application for designing and renderingenvironments such as commercial furniture, offices and kitchens.CET designer is not only used by design people, it is also used bysales, marketing and customer service people. CET Designer canalso calculate the environment cost. Another advantage is that CETDesigner supports importation of drawings from AutoCAD.

  • 4 1 Introduction

    1.6.2 CM

    CM is the programming language used for CET. CM stands for Con-figura Magic and is an object-oriented language that belongs to theJava/C#/C++ family of languages. CM is uniquely adapted to thePGC problem domain and has extensible syntax and support for in-cremental development. The programmer can change functionalityand classes while the application is running. A garbage collector isused for removing sources for fatal programming mistakes.

    1.7 Technical specification

    The implemented mesh repair application and all tests are executedon an Intel Core i7 2.67 GHz CPU with a NVIDIA GeForce GTX 280GPU and with 6 GB RAM.

    1.8 Structure

    This chapter described the goal and contributions of this thesis. Italso gave information on the company Configura. The next chaptertreats the mesh repair area by describing relevant concepts. Somecomputer graphics concepts are also reviewed. Chapter 3 includesevaluation and information on related work. After that followsa chapter that describes the existing mesh repair system and theplanned mesh repair pipeline. The three following chapters de-scribe the methods used in the implemented mesh repair algorithm:the method described by Ju [Ju, 2004] for octree and sign generation,Manifold Dual Contouring and Singular Value Decomposition. Af-ter that follows a chapter that describes the actual implementation,and then the results of the implemented algorithm are presented.Finally follows a chapter for discussion and a chapter that addressesthe conclusions and the future work ideas of this project.

    1.9 Abbreviations

    CPU Central Processing Unit

  • 1.9 Abbreviations 5

    GPU Graphics Processing Unit

    DC Dual Contouring

    MDC Manifold Dual Contouring

    QEF Quadratic Error Function

    SVD Singular Value Decomposition

    EVD Eigenvalue Decomposition

    DMC Dual Marching Cubes

    PGC Parametric Graphical Configuration

  • 2Background

    This chapter includes relevant background information. Section2.1 describes some computer graphics concepts and section 2.2 de-scribes relevant mesh repair concepts. After these two sections fol-low sections that further describe the mesh repair problem. Meth-ods developed for solving this problem are described in chapter 3.

    2.1 Computer graphics

    This section reviews some basic concepts of computer graphics. Fur-ther relevant concepts are described in section 2.2.

    A vertex is a corner point of a polygon. A polygon mesh is a set ofpolygons that form a shape. Triangles are the most common poly-gons used in computer graphic meshes, however quad meshes alsoexist. Figure 2.1 shows a polygon model and how its triangles arelocated. The word voxel is widely used in this thesis. A voxel canbe seen as a pixel in 3D, i.e. a volume element.

    The concept manifold is widely used in this thesis. A manifold poly-gon mesh means, in this thesis, that the mesh is watertight. If thereis water inside the mesh, the water will be kept in the mesh if themesh is manifold. Hermite Data is another concept that occurs fre-

    7

  • 8 2 Background

    quently in this thesis. Hermite Data consists of two vectors: a posi-tion of an intersection point on an edge and the surface normal inthat point.

    Figure 2.1: A triangle mesh.

    Polygonal models are the most common way to represent 3D mod-els [Attene et al., 2013]. Therefore this project focuses on polygonalmodels. Furthermore it focuses on polygonal models that use trian-gles as their building blocks.

    2.2 Relevant concepts

    This section describes concepts relevant for mesh repair, for exam-ple different tree structures. The concept of remeshing is also de-scribed and compared to the mesh repair concept.

    2.2.1 A mesh repair overview

    Mesh repair algorithms aim to, as the name tells, repair brokenmeshes. Typical errors that mesh repair algorithms can handle arefor example holes and incorrect polygon normals. Since the meshrepair concept is the main topic of this thesis, nearly all chaptershandles this subject. Background information about mesh repair ispresented in section 2.3.

    2.2.2 Remeshing

    Remeshing is a technique for improving the mesh quality. Meshquality refers, for example, to sampling-density, size and regularity.The goals of remeshing are in general mesh simplification (i.e. re-duce the number of polygons) and mesh quality improvement. In

  • 2.2 Relevant concepts 9

    remeshing algorithms the input, in general, is assumed to alreadybe manifold. In mesh repair algorithms, however, this is not as-sumed. [Botsch et al., 2010]

    2.2.3 Grids

    Several mesh repair algorithms convert the input model to a volu-metric representation. This section describes different volumetricrepresentations that can be used to implement and accelerate differ-ent mesh repair algorithms. However, some of them, especially theoctree, are more common.

    Uniform grid

    In a uniform grid, all voxels in the grid are of equal size. [Holmlid,2010] Unfortunately several troubles occurs due to that all nodesare of equal size. For example the grid may be too coarse with re-spect to the input object’s geometry. [Ericson, 2004].

    A Cartesian grid is an uniform grid where the nodes are unit cubes.In 2D, the nodes are unit quads. The vertices of a Cartesian grid areinteger points.

    Tree data structures

    This section gives an overview of tree data structures. Christer Eric-son describes different tree data structures in his book Real-timeCollision Detection [Ericson, 2004]. In mesh repair, these struc-tures are used for making the processing time shorter. The treesorts the data, which makes it easier to search for the data, i.e. theprocessing time is reduced. Octrees are the most common tree datastructure in the mesh repair area.

    BSP tree BSP tree stands for binary space-partitioning tree. It re-cursively divides the space into pairs of subspaces. The partitioningis made with dividing hyper planes with dimension (n - 1), wherethe space that is partitioned is of dimension n.

    It is uncommon to use BSP-trees in the mesh repair area. However,Botsch et al. [Botsch et al., 2010] discuss a volumetric mesh repairalgorithm from year 1997 that converts the input polygon soup intoa BSP-tree.

  • 10 2 Background

    Octree An octree is a tree data structure where each compositenode has eight children. The root node of an octree is usually thesmallest axis-aligned voxel that completely encloses the world. Allnodes, or voxels, of an octree are axis-aligned. Figure 2.2 [Timber-wolf, 2013] shows a typical octree structure.

    Figure 2.2: The tree structure of an octree. [Timberwolf, 2013]

    Adaptive grid The sampling of the implicit function to a grid canbe done adaptively. I.e. a higher sampling rate is used only in thevicinity of the input surface. Only the octree voxels that are inter-sected by the surface will be refined. [Botsch et al., 2010]

    Restricted octree In a restricted octree, adjacent voxels in the oc-tree cannot differ by more than one level of refinement. [Holmlid,2010]

    2.2.4 Isosurface

    Let a set of points satisfy the following function: f(x,y,z) = c. Thefunction f(x,y,z) is called the implicit function and c is called the iso-

  • 2.3 Mesh repair 11

    value. The surface, consisting of the set of points mentioned above,is called an isosurface. A point p lies on the surface if f(p) = c. If f(a)< c and f(b) > c, the points a and b lie on different sides of the sur-face. [Holmlid, 2010] The basic concept of implicit or volumetricrepresentations of models is to mark each 3D point to lie either in-side, outside or on the isosurface. If the function f(p) is continuous,the isosurface is free from holes. It is common that f(p) is sampledin a voxel grid. [Botsch et al., 2010]

    2.3 Mesh repair

    The mesh repair algorithms can be classified as being either surfaceoriented or volumetric [Botsch et al., 2010]. These categories areexplained below, in section 2.3.2 and 2.3.3. Examples of typicalmethods in these categories are mentioned in section 3.1. Therealso exist mesh repair algorithms that are a combination of surface-based and volume-based methods. [Bischoff and Kobbelt, 2005] isan example of such a method. Surface-oriented methods are alsocalled local approaches in the literature, and volumetric methodsare also called global approaches in the literature.

    Another group of methods are based on growing objects inside theinput model. These methods often first convert the input model toa point cloud, and then an output surface is created from that pointcloud. [Ju, 2009] In section 3.1, three methods of this group will bedescribed.

    2.3.1 Mesh errors

    This section describes different mesh errors. Below follows a listof the mesh errors that Configura wants to be resolved. Figure 2.5[Botsch et al., 2010] shows a number of mesh artifacts. Figure 2.3shows a T-junction, which means that a vertex lies in the interior ofan edge of another polygon. Figure 2.4 [Ju, 2004] shows a modelwith hanging triangles.

    Repair

    • Remove redundant vertices, e.g. several vertices at the same

  • 12 2 Background

    position or isolated vertices

    • Remove overlapping and intersecting triangles

    • Remove hanging triangles

    • Remove T-junctions

    • Remove degenerate triangles, a degenerate triangle is a trian-gle with zero area, i.e. a point or a line.

    • Correct reversed normals

    Control, features and visual fidelity

    • Fill in unwanted holes

    • Keep wanted holes

    • Produce manifold (watertight) result

    • Removal of unseen features

    • Preserve sharp corners and edges

    • Controllable time complexity

    • Controllable output resolution / multiresolution

    Complexity

    • Time complexity

    • Memory complexity

    Figure 2.3: T-junction.

  • 2.3 Mesh repair 13

    Figure 2.4: Hanging triangles. [Ju, 2004]

    Figure 2.6 [Attene et al., 2013] shows two problems that a 3D modelcan have: noise and feature chamfering or aliasing. Sharp cornersand edges are not preserved. Several remeshing and contouringalgorithms have restrictions on were the new vertices can be placed.For example a precalculated table may be used, as in the MarchingCubes algorithm. This leads to that sharp corners and edges arenot preserved and the output surface consists therefore of aliasingartifacts. This gives an unsatisfactory visual result.

    2.3.2 Surface-based methods

    These methods try to resolve the inconsistencies by perturbing theinput only slightly. No new mesh is created. Surface oriented algo-rithms often have problems when handling special cases, for exam-ple intersections. They operate directly on the input data. [Bischoffand Kobbelt, 2005] They search for errors on the input model, andonce an error is found, the error is corrected by surgeries. [Ju, 2009]Surface-based methods are acting on local parts of the mesh. Theymodify the geometry in a small region around the artifacts. There-fore, surface-based repair algorithms preserve the polygonal meshstructure in regions that are not near the artifacts. Cutting andstitching [Gueziec et al., 2001] is an example of a local method.These methods, as mentioned above, only add few changes to theinput’s topology. This leads to that only a few additional trianglesare added. [Botsch et al., 2010]

    However, surface oriented methods often get problems with robust-ness and speed when the input model has too many triangles. Sur-

  • 14 2 Background

    Figure 2.5: Different mesh errors. [Botsch et al., 2010]

    face oriented methods generally are specified on one specific prob-lem, therefore it is hard to find a surface-based method that cantreat all the different mesh artifact problems without a vast amountof time consumption. [Karlberg and Persson, 2011] Another draw-back with surface oriented methods is that they usually require thatthe input model already satisfies certain quality requirements. Oth-erwise the output may be invalid. Surface oriented algorithms arerarely completely automatic, in general user interaction and man-ual post-processing are needed. [Botsch et al., 2010]

  • 2.3 Mesh repair 15

    Figure 2.6: Left: Noise problems. Right: Feature chamfer-ing/aliasing. [Attene et al., 2013]

    Usually, surface oriented methods try to resolve gaps and holesproblems. The gaps and holes are detected, and then filled. Com-plex, or non-manifold, edges are also resolved by several surfaceoriented methods. [Ju, 2009]

    According to Attene et al. [Attene et al., 2013], surface-based meth-ods are suitable to use when the input model only has few errorsand when a very high robustness is not needed.

    2.3.3 Volume-based methods

    Volumetric algorithms convert the input model to a volumetric rep-resentation. Then, the output model is extracted from the volu-metric representation. [Botsch et al., 2010] In general, volumetricalgorithms guarantee manifold meshes. They process a global re-sampling, i.e. they extract a completely new model. Techniquesfor extracting a new surface from the volumetric representation arefor example Marching Cubes and Dual Contouring. [Bischoff andKobbelt, 2005] A problem with volumetric methods is that they of-ten produce over-tessellated outputs. [Karlberg and Persson, 2011]Examples of volumetric representations used in model repair in-clude regular Cartesian grids, adaptive octrees, kd-trees, BSP-treesand Delaunay triangulations. Some of these concepts are describedin section 2.2. BSP-trees seem not to be used in newer repair algo-rithms. Probably this is due to that it is hard to accomplish a robustand efficient computation of the combinatorial structure of the BSPtree. Usually volumetric algorithms are completely automatic. Adrawback with volumetric algorithms is that the resampling of the

  • 16 2 Background

    model often introduces aliasing artifacts and loss of model features.[Botsch et al., 2010] According to a new survey (from 2013) [Atteneet al., 2013], volumetric methods should be chosen if robustness isan important requirement.

    Since volumetric methods in general handle a large amount of differ-ent errors, it is often more important to examine what requirementsthe method has on the input model.

    Some volumetric methods use flooding (inward or outward) for dis-cretizing an object into a grid (e.g. an octree or a uniform grid).However, flooding is limited to identify a single inside (for outwardflooding) or outside (for inward flooding) region. Therefore, flood-ing techniques cannot detect multiple object components or cavitiesinside an object. A big drawback with flooding methods is, unfor-tunately, that they will fail to generate signs for inside and outsideif there are holes or gaps in the model. Then these models can’tseparate inside and outside. [Ju, 2009]

    Volumetric methods that can handle gaps and holes are generallydivided into two categories: the ones that rely on the orientation ofthe polygons, and the ones that do not. The latter is more suitablefor repairing polygon soups, and the former is better on hole-fillingwhen the polygons have a correct orientation. [Ju, 2009]

    Orientation-dependent methods

    Since these methods rely on the polygon normals, the polygonsshould be consistently oriented. I.e. these methods are not appro-priate for correcting inconsistent normals. However, if the polygonsare consistently oriented, the orientations will give extra hints whendetermining the grid point signs. Therefore, the sign generation ismore reliable for these methods. Methods in this category use thesigned distance from a grid point to the polygons. The signed dis-tance is used for sign generation and smoothing. Algorithms in thiscategory are bad at correcting normals, but good at filling holes.[Ju, 2009] Inconsistent normals are more common than holes onConfigura, therefore these kind of algorithms are not considered asinteresting.

  • 2.3 Mesh repair 17

    Orientation-independent methods

    This kind of methods rely only on the location and connectivity ofthe vertices in the input model. Ju [Ju, 2009] suggests to dividethese methods into two groups: global and local ones. The globalmethods calculate the sign at each grid point by tests involving thewhole model or optimization on the whole grid. The local meth-ods only modify a small region on the grid. The small region isusually where gaps and holes are located. They leave the rest ofthe grid (with it’s inside/outside signs) unmodified. The method byNooruddin and Turk [Nooruddin and Turk, 2003] and the methodby Hornung and Kobbelt [Hornung and Kobbelt, 2006] are exam-ples of global methods. The method developed by Ju [Ju, 2004] andthe method presented by Bischoff et al. [Bischoff et al., 2005] areexamples of local methods.

  • 3Evaluation and related work

    This chapter presents an evaluation of the mesh repair area. Dif-ferent related algorithms are described and evaluated. The chapterends with a prestudy conclusion section. First, relevant conceptsfor the actual evaluation and analysis process are described.

    Attene et al. [Attene et al., 2013] present a general strategy on whatto do if a 3D model probably needs to be healed:

    1. Determine the characteristics and defects of the input model

    2. Determine which requirements you have on the input model

    3. Decide if it is necessary to heal the input model

    4. Check if there is an algorithm to heal the input directly

    5. If there does not exist any direct repair algorithms, check ifseveral algorithms can be used for healing the input

    6. If that is not possible, there is a gap in the state-of-the-art

    When analyzing repair algorithms, there are three important thingsthat should be taken into consideration:

    • What requirements do the repairing method have on the inputmodel?

    19

  • 20 3 Evaluation and related work

    • Which errors do the method heal?

    • Which new errors are introduced by the method?

    It is common that an algorithm works well - but only on a very lim-ited amount of errors. This is particularly true for surface-basedmethods. In this evaluation a greater emphasis has been placed onmethods that handle a larger amount of mesh errors. Furthermore,it is, in this case, important to analyze how automatic the differen re-pair approaches are. In this analysis it is also interesting how manyparameters that have to be set before processing. Parameters witha reasonable default value, however, will in general not make thealgorithm less automatic. One repair algorithm that is deselected,partly due to that it needs user impact during the processing, is themethod presented by Hetroy [Hetroy et al., 2011].

    According to the requirements on the input model, several algo-rithms have been deselected due to too many requirements. If arepairing method requires that several errors are already resolved,that method is not interesting in this project since a very broadand general approach should be implemented. For example sev-eral methods require correct normals. Another method that wasdeselected is Atomic Volumes for Mesh Completion presented byPodolak and Rusinkiewicz [Podolak and Rusinkiewicz, 2005]. Thatmethod requires the input model to be free of degeneracies, self-intersections and singularities. If the input is not, the output is notguaranteed to be manifold.

    3.1 Related work

    This section presents works done in the area of mesh repair. Eachmethod will first be described and then evaluated. The descriptiontypically tells how the method works and which theoretical benefitsand drawbacks the method has. The evaluation of each method dis-cusses the method and its benefits and drawbacks. The evaluationalso tells if the method seems to be interesting for this mesh repairproject or not.

  • 3.1 Related work 21

    3.1.1 Surface-based methods

    This section describes different surface-based mesh repair algorithms.However, this thesis focus more on the volume-based methods, sincetheir features are better suited to the requirements of Configura.

    Cutting and stitching

    Gueziec et al. [Gueziec et al., 2001] present a cutting and stitchingmethod for converting sets of polygons to manifold surfaces.

    Method description The cutting algorithm detects areas with er-rors and cuts the input surface along the edges of the error area.Image A in figure 3.1 [Gueziec et al., 2001] shows a bad part ofthe input model, and image B in figure 3.1 shows where the inputmodel will be cut. Image C shows the model after cutting. Thestitching part of the method is needed since the cutting method maycreate areas with boundary edges. The stitching method joins twoboundary edges. The stitching can be performed by either pinchingor snapping. Pinching is described in image D, and snapping in im-age E. The pinching method zips the boundary, i.e. edges along thesame boundary are pinched together. Only edges that were cut dur-ing the cut operation are seen as stitchable. The snapping method,however, allows to stich all edges. The snapping method zips to-gether edges that belongs to different boundaries.

    Thanks to the stitching, the output is guaranteed to be manifold.However, more than one output manifold surface may be producedfrom an input surface. According to the authors, this method canhandle all topological artifacts without user intervention. Further-more, this method requires no parameters [Attene et al., 2013].

    Method evaluation That the method is automatic, without inputparameters and that it guarantees a manifold output are two strongbenefits. However, the method is not developed for repairing orien-tation errors. Bad normals are the most common error at Configura,and therefore this method is not interesting.

    A more modern surface-based method for model repair

    Guangshuai et al. [Guangshuai et al., 2009] present a surface-basedmethod for mesh repair. Since it is surface oriented, the algorithm

  • 22 3 Evaluation and related work

    Figure 3.1: The different parts of cutting and stitching. A,Band C: cutting. D: pinching. E: snapping. [Gueziec et al., 2001]

    operates directly on the input data.

    Method description The method includes five processes:

    1. Consistent normal orientation

    2. Hole filling on a surface

    3. Manifolds mapping on a surface for resolving complex edgesand singular vertices (by using pinching and snapping)

    4. Gap bridging between surface patches

    5. Mesh topology simplification

    The authors state that one benefit with their algorithm is that itpreserves the features of the original mesh. The algorithm can alsohandle several different mesh errors. According to the authors, thismethod handles the following mesh errors:

    1. Corrects bad normals

  • 3.1 Related work 23

    2. Repairs holes

    3. Repairs gaps

    4. Simplifies the mesh topology

    5. Removes complex edges (i.e. edges with two or more neigh-bouring faces)

    6. Removes singular vertices, see figure 2.5

    Method Evaluation One drawback with this method is actually thatthe algorithm is surface oriented. According to Botsch et al. [Botschet al., 2010] that probably means that the algorithm has problemswith robustness and time complexity. However, the authors statesthat their method is robust. According to the time complexity, noprocessing time results are presented in the article. Another draw-back is that there were no possibilities to test software built on thismethod during the evaluation. Due to these drawbacks, the methodis deselected.

    3.1.2 Volume-based methods

    Below follows descriptions of different volume-based mesh repairmethods. Several volumetric methods demands that the input sur-face already has a correct surface orientation. Since bad normalsare one of the greatest problems for Configura, these methods arenot considered as interesting. Examples of methods that demands acorrect surface orientation in the input mesh are: [Guo et al., 2006],[Sagawa and Ikeuchi, 2008] and [Shen et al., 2004].

    Volumetric repair on regular grids

    Nooruddin and Turk proposed an early volumetric technique [Noorud-din and Turk, 2003] to resolve gaps, overlaps and intersections. Italso resolves topological artifacts by using morphological operations.

    Method description The method is based on a rectilinear voxelgrid. Each voxel contains a value in the range from zero to one.If the value equals one, it means that the voxel is completely in-side the input model, and if it equals zero it means that the voxelis outside the model. Values between zero and one means that thecurrent voxel is near the surface of the input model. The voxels in

  • 24 3 Evaluation and related work

    the grid are therefore classified as inside or outside. When all vox-els are classified, a volumetric representation has been generated.Then Marching Cubes is used to extract a new surface from thisvolumetric representation. Naturally, the surface is placed betweenthe outside and inside voxels.

    Unfortunately, the classification of inside and outside voxels in thismethod is usually not reliable. Another drawback is that the algo-rithm is not feature sensitive. [Botsch et al., 2010] An advantagewith the method is that it has no requirements on the input model[Attene et al., 2013].

    Method evaluation Due to the above mentioned drawbacks of thismethod, the method is not interesting for this mesh repair project.However, this method was one of the first volumetric repair meth-ods, and therefore it is important for the mesh repair development.Thanks to the conversion into a volumetric representation, this methodcan handle several mesh degeneracies.

    Robust repair of polygonal models

    This algorithm, presented by Ju [Ju, 2004], is an octree based volu-metric method that uses Dual Contouring [Ju et al., 2002] or March-ing cubes for creating the output model. Input to the algorithm arethe input model and a parameter that states which maximum octreedepth that should be used.

    Method description The algorithm generates a completely new out-put model. The method includes three main parts: scan-conversion,sign generation and surface reconstruction. In the first part, thescan-conversion, an octree is created. Intersected octree leaf nodeedges are recorded during this part. In the sign-generation part,signs that are consistent with the intersected edges are generated.If there are inconsistent octree leaf nodes, a patching is performedbefore the sign generation. The signs tell if the octree node cornersare inside or outside the input model. In the surface reconstructionpart the new output model is created by contouring. The contour-ing concept is described in section 3.1.4 on page 31.

    According to testing made during the thesis work, see below, andto Ju [Ju et al., 2002], this algorithm can handle the following mesh

  • 3.1 Related work 25

    errors:

    1. T-junctions

    2. Incompatible face orientation

    3. Hanging triangles

    4. Wanted holes are not removed

    5. Time and memory complexity controllable

    6. Degenerate triangles

    7. Gaps and holes

    Method evaluation Ju has developed a free software for testing thismethod, the software is called PolyMender. PolyMender can bedownloaded at Ju’s homepage [Ju, 2013]. Different 3D models havebeen processed in PolyMender during the evaluation. Figure 3.2shows the result of a test model that most of the free mesh repairapplications have several issues with.

    Figure 3.2: A chair part healed at different depths in Poly-Mender.

    One great benefit with this method is that there was a possibilityto test it and that the result often was good. The testing showedthat this algorithm could handle several different errors, see the listabove. Furthermore, the method has no requirements on the inputmodel.

  • 26 3 Evaluation and related work

    One drawback with this method is that it cannot handle unseenfeatures. Another drawback is that manifoldness is not guaranteedwhen Dual Contouring is used for creating the output model. How-ever, it is possible to change to another contouring method, likeManifold Dual Contouring [Schaefer et al., 2007]. One more draw-back is that it produces an over-tesselated output. During testingof PolyMender, it was tried to use a decimation algorithm as a postprocessing step. The result was satisfying. The decimation programthat was used is called qSlim [Garland, 2013] . Another drawbackis that this method can not handle overlapping or intersecting trian-gles.

    Thanks to the good testing results, this method, together with Man-ifold Dual Contouring for avoiding manifold problems, is the onethat is implemented in this project.

    Volumetric repair on adaptive grids

    The method described in the article Automatic restoration of poly-gon models by Bischoff et al. [Bischoff et al., 2005] is an example ofa volumetric repair method on an adaptive grid.

    Method description This method is octree based. Since the octreeis adaptive, the octree will have a higher resolution where the inputmodel has a high geometric complexity. The method has three in-puts: an unstructured set of triangles Ti (corresponding to the meshthat should be repaired), a tolerance value � and a threshold valueρ. The algorithm generates a new triangle mesh that approximatesthe original input mesh at least up to the tolerance �. If the originalmesh has gaps or holes that are larger than � but smaller than ρ ,these will be fixed. The algorithm proceeds in six steps:

    1. Generate adaptive octree

    2. Octree refinement

    3. Morphological operations for fixing holes (expanding cylin-ders)

    4. Calculate the connectivity of the mesh by using an extensionof dual contouring

  • 3.1 Related work 27

    5. Calculate the vertex positions of the output mesh (surface ge-ometry reconstruction)

    6. Mesh optimization

    The octree depth k is calculated from the tolerance value � and fromthe bounding box of the input model. See equation 3.1 and 3.2.Thanks to this determination of the octree depth, the size of thesmallest leaf nodes is smaller than � and there is at least s layers ofempty voxels along the faces of the octree root node.

    M :=max(|xi |, |yi |, |zi |) (3.1)M is the input model’s maximum absolute coordinate value.

    k − 1 < log2(M/�+ s) + 1 ≤ k (3.2)

    Holes in the input model are removed by expanding cylinders aroundthe boundary edges, see figure 3.3. In this paper, a boundary edge isan edge that belongs to exactly one triangle. For generating the newoutput model, this method uses an extension of the dual contour-ing method presented by Ju et al. [Ju et al., 2002]. This extensionguarantees manifold output meshes.

    Figure 3.3: Hole filling with expanding cylinders.

    According to the authors of this algorithm, it produces fewer trian-gles than the method by Tao Ju [Ju, 2004]. Another benefit stated

  • 28 3 Evaluation and related work

    by the authors is that the algorithm generates a manifold output. Ina survey by Veleba and Felkel [Veleba and Felkel, 2007] one morebenefit is stated for this method, namely that the algorithm doesnot give away the original model completely, since the vertex coor-dinates are kept from the input model to the output model. Accord-ing to Veleba and Felkel, giving away the original model completelyis the main disadvantage of the voxelization. Attene et al. [Atteneet al., 2013] address one additional benefit, namely that the methoddoes not have any requirements on the input model.

    Drawbacks with this method is that it removes wanted features inthe object and that it produces an over-tesselated output-mesh. Thismeans that, as in [Ju, 2004], decimation is needed. Another draw-back is that there is no software to test this method. Furthermore,the method may introduce degeneracies [Attene et al., 2013].

    According to the authors, this algorithm handles the following arti-facts:

    1. Degenerate triangles

    2. Incompatible face orientation

    3. Non-manifold vertices and edges

    4. Overlapping and penetrating polygons

    5. Internal redundant geometry

    6. Gaps and holes up to the maximum size ρ

    Method evaluation This method is one of the most interesting meth-ods for this mesh repair project. It has several benefits and theresults presented in the article are promising. It seems like thismethod and the method by Ju [Ju, 2004] are very promising. Sinceit was not possible to test this method, the method by Ju is preferred.However, it is a good idea to take inspiration from this method, es-pecially when optimizing the algorithm that will be implementedbased on Ju’s method.

  • 3.1 Related work 29

    Robust reconstruction of watertight 3D models fromnon-uniformly sampled point clouds without normal information

    Hornung and Kobbelt [Hornung and Kobbelt, 2006] present a methodfor reconstructing a watertight 3D triangle mesh from an unori-ented point cloud.

    Method description The method is volumetric. No informationabout local surface orientation is needed since an unsigned distancefunction is used. Another benefit with the use of an unsigned dis-tance function is that artifacts due to topological noise are avoided.According to the article, the reconstructed models are manifold andof low genus. The concept of genus is described in section 3.1.5.

    The input to the algorithm is a point cloud. The points in the cloudare samples of a surface. In the vicinity of the samples, a confidencemap will be determined. The map shows the probability of the sur-face being in a specific part of the 3D space. The confidence valuesare computed as an unsigned distance function over all voxels in avolumetric grid. Given the grid of confidence, a minimal set of vox-els is calculated. This set represents a closed surface with maximumconfidence, i.e. it is an approximation of the output surface.

    The algorithm can handle non-uniformly sampled point clouds. Thatmeans that even if the point cloud has hole areas, i.e. areas with avery low density of points, the output will be manifold.

    When the optimal approximation of the output surface is found, ithas to be converted to a triangle mesh.

    Method evaluation There exists several methods that solves theproblem of converting point clouds to manifold meshes. This al-gorithm is one of them. Some of these may be used for mesh repair;however, it is probably better to use solutions that are adapted forthe models that Configura wants to heal. Configura wants to healbroken 3D models, not reconstruct point clouds. There is a possibil-ity to convert the input model to a point cloud; however, that wouldprobably lead to a loss of useful information.

  • 30 3 Evaluation and related work

    3.1.3 A combination between the surface-based andvolume based approaches

    Bischoff and Kobbelt [Bischoff and Kobbelt, 2005] present a meshrepair method that combines the advantages of surface-based meth-ods and volumetric methods.

    Method description The method uses a voxel grid, but completelynew mesh parts are only created in defective voxels. Therefore, thestructure of the input model is preserved. Several surface-basedmethods introduce intersections while closing gaps, this methoddoes not have this drawback [Attene et al., 2013]. However, it mayintroduce degeneracies, as several other methods also do.

    The basic functions of this method can be described in three steps.First, regions with artifacts are identified. After that, new meshparts are created by a volumetric reconstruction algorithm in theseparts of the model. Finally, the reconstructed components are joinedwith the unchanged parts of the mesh.

    Below follows a list of characteristics of this algorithm. However, itshould be observed that this algorithm has not been tested duringthis project.

    • Preserves the input structure

    • Closes gaps up to a diameter that is defined by the user

    • Resolves intersections and overlaps

    • Resolves bad orientation problems

    • The output is manifold

    • The performance of this algorithm is better than pure volu-metric algorithms, since this algorithm does not reconstructall parts of the input model

    The method has two input parameters: gap width and an error-tolerance value. The output will stay within the error-toleranceto the input model. Two parameters make the algorithm less au-tomatic, which is a drawback. The gap width parameter may alsoimply that the algorithm has problems with repairing large holes.

  • 3.1 Related work 31

    It seems like this method is more adapted for gap closing than holefilling.

    Method evaluation It is interesting to combine surface-based andvolumetric methods. However, this method is not selected in thisproject, mainly due to that it seems to be reasonable to believethat this model cannot handle larger holes. Furthermore, severalof the test models at Configura have problems with bad normals,and these errors are widely spread over the whole model, see forexample figure 9.9 on page 84. Therefore, very large parts of theinput model will have to be reconstructed and, if this method isused, then be joined together again. This may introduce new errors.This method is probably better to use when the errors are not thatdensely and continuously spread over the input model.

    3.1.4 Contouring methods

    Contouring is the conversion from a volumetric representation (e.g.an octree) to a triangle mesh [Holmlid, 2010]. Contouring can alsobe called iso-surfacing [Ju, 2009]. Several surface reconstructionmethods have been presented. This section presents different con-touring methods, for example the classical method Marching Cubes.

    Marching cubes

    The Marching cubes algorithm, presented by [Lorensen and Cline,1987], is a well-known contouring method.

    Method description The method creates a new output mesh froman implicit function by marching, i.e. iterating, over a uniformvoxel grid. The grid and the implicit function correspond to theinput model. If all corners of a voxel have the same sign, the voxelis completely inside or outside the input surface. Then no trianglesare generated. If the corners have different signs, triangles and ver-tices will be created according to the Marching Cubes triangulationtable, see figure 3.4. Since a voxel has eight corners and since acorner can be either positive or negative (i.e. either inside or out-side), there are 28 possible configurations. However, many of theseare equivalent to each other. There are only 15 unique cases, whichcan be seen in figure 3.4. The remaining 241 cases can be found byreflection, inversion or rotation [Botsch et al., 2010].

  • 32 3 Evaluation and related work

    After iteration over all voxels in the grid, a number of triangles havebeen created. The union of these triangles gives the final mesh.

    Figure 3.4: The 15 base configurations of the Marching Cubestriangulation table. Depending on the corner signs, differenttriangles and vertices will be generated.

    The original Marching Cubes algorithm has several issues. One dis-advantage is that it has problems with degenerate triangles. Sur-faces created by using Marching cubes may also have holes andtopological inconsistencies. This is due to ambiguous faces. Someof the basic configurations described in figure 3.4 are ambiguous.[Newman and Hong, 2006] According to Kahzdan et al. [Kazhdanet al., 2007] the surface constructed by Marching Cubes always willbe connected if a uniform grid is used. However, the result will bepoor if the grid is adaptive since there will be holes in the outputsurface in areas where neighbouring voxel grids are at different treelevels.

    Method evaluation Due to the drawbacks of Marching Cubes thatwere mentioned above, Marching cubes is not an interesting methodfor this project.

    Dual marching cubes

    The Dual Marching Cubes (DMC) algorithm developed by ScottSchaefer and Joe Warren [Schaefer and Warren, 2004] is an improve-ment of the original Marching Cubes algorithm. One improvementis that DMC, in contrast to Marching cubes, also works on adaptivegrids.

  • 3.1 Related work 33

    Method description The basic idea with DMC is to construct a newgrid from the adaptive grid (an octree). Figure 3.5 shows how anew grid can be created from a quad tree. The new grid is called adual grid. As can be seen in the figure, the cells of the dual grid arenot always squares. And the same holds for the 3D case. However,the cells will be topologically equivalent to voxels since coincidingvertices and collapsed edges will be duplicated. Therefore, the stan-dard Marching cubes lookup table, presented in section 3.1.4, canbe used when the output surface is generated. DMC can be imple-mented with three main parts: Creation of dual vertices, construc-tion of the dual grid and Marching Cubes. Each octree voxel hasone dual vertex. During the dual grid construction the dual ver-tices corresponding to the eight voxels that shares one corner arebound together. This leads to that topological cubes are created.The corners of a topological cube are the dual vertices that corre-sponds to octree voxels that share one specific octree corner. Figure3.5 [Holmlid, 2010] shows a 2D case. Each quad tree corner (blackpoint) is encircled by a topological square. This means that fourdual vertices are bounded together around the quadtree corner. Itworks in the same way in the 3D case, but with eight dual verticesin one topological cube. [Holmlid, 2010]

    Figure 3.5: The connectivity of a dual grid constructed froma quadtree. The dual grid is red and the quadtree is black.[Holmlid, 2010]

    There are several benefits with the DMC algorithm. One advantageis that there are no inter-cell dependencies, which reduces the al-gorithm complexity. This may also lead to a reduced process time.Another advantage is that the output is guaranteed to be manifold.

  • 34 3 Evaluation and related work

    A drawback with the algorithm is that polygons with a very small,or even zero, area may be created. Furthermore, one problem withthe DMC algorithm is that topological holes may be generated. Notethat a topological hole is not the same as a hole. The output is stillmanifold, but new "correct" holes will be introduced to the outputsurface. See for example figure 3.6 [Kazhdan et al., 2007].

    Figure 3.6: A mesh reconstructed by using Dual MarchingCubes. Several topological holes have unfortunately been gen-erated. [Kazhdan et al., 2007]

    Method evaluation This method risks to introduce two new errors:degenerated triangles and topological holes. Therefore, other con-touring methods are more suitable for this project.

    Dual contouring

    This section describes the dual contouring method proposed by Juet al. [Ju et al., 2002].

    Method description Dual Contouring includes two main steps:

    1. A vertex is generated for each voxel in the octree that exhibitsa sign change. The position of the vertex will be the x thatminimizes the quadratic error function in equation 3.3.

    2. For each voxel edge that has different signs on its two corners,generate a quad that connects the four vertices (from 1.) cor-responding to the four voxels containing the edge. See figure3.7.

  • 3.1 Related work 35

    E[x] =∑i

    (ni(x − pi))2 (3.3)

    Equation 3.3 shows a quadratic error function. ni is the unit normalof the input model in the intersection point with the octree, and piis the intersection point.

    Figure 3.7: Dual Contouring: A quad (pink), that connects thevertices (blue) of the four octree leaf voxels, is created.

    Method evaluation Dual Contouring is a popular contouring al-gorithm. However, there exists a promising improvement of thismethod: Manifold dual contouring. The latter guarantees that theoutput is manifold and furthermore it decimates the output, there-fore Manifold dual contouring is more suitable for this project.

    Manifold dual contouring

    Schaefer et al. [Schaefer et al., 2007] present a contouring methodcalled Manifold Dual Contouring (MDC). This method is describedin chapter 6. Two great andvantages with MDC is that it guaranteesa manifold output and that it decimates the model.

  • 36 3 Evaluation and related work

    3.1.5 Methods based on expanding objects inside theinput model

    In this section three different methods will be presented.

    Competing fronts for coarse-to-fine surface reconstruction

    Sharf et al. [Sharf et al., 2006] present a method for reconstructinga surface from a point cloud. According to the article, the algorithmis robust to missing data in broken areas.

    Method description The method uses a deformable object that growsinside the point cloud. See figure 3.8 [Sharf et al., 2006] for a visual-ization of the method. However, this method is mainly for surfacereconstruction, not for mesh repair. The deformable object is ini-

    Figure 3.8: Left: The broken input model. Two images in themiddle: The deformable object grows inside the point cloudof the input model. Right: The reconstructed surface. [Sharfet al., 2006]

    tialized as a small sphere inside the point cloud of the input model.The vertices of the sphere moves in outward normal direction to-ward the input point cloud. The movement is based on a distancemap of the point cloud. The distance map is saved in an adaptive3D grid. When a part of the deformable object needs to pass trougha narrow region, finer levels of the octree will be used thanks toits adaptive behaviour. A vertex will stop moving if it is close toa point in the point cloud or if the deformable object is about topass through a sparse region of the point cloud, for example a re-gion where the input model has a hole. When several vertices have

  • 3.1 Related work 37

    stopped moving, the deformable object may be divided into severalpatches. Each such patch is called a front, and they will continueto move independently. New positions for all fronts’ vertices arecomputed in each iteration. First the coarse parts of the input meshwill be reconstructed, and then the finer parts.

    The authors mention five elements that make this algorithm suc-cessful:

    • Competing fronts

    • Smooth fronts

    • Outward movement

    • Adaptive dynamic mesh

    • Final fitting

    The Competing fronts element relates to the coarse-to-fine evolve-ment of the fronts. First, all vertices of the deformable object moveas one front. After a while, when some vertices have stopped, thefront is split into several competing fronts. Thanks to this prop-erty, this method gives the possibility to reconstruct the surface ingrowing level-of-details. Fronts that are faster from the input pointcloud will move faster than fronts that are near the point cloud.

    For avoiding overlaps and self-intersections, smooth fronts are used.A property of the fronts is that they always move in outward nor-mal direction. The movement is dependent of the unsigned dis-tance field, which lets the vertices move both up-hill and down-hill.Thanks to this property, a front can move from a narrow region to abroader one.

    The Adaptive dynamic mesh element of the algorithm gives theoutput model, the reconstructed surface, a high quality. Thanks tothis property, the resolution of the mesh will adapt to local charac-teristics of the input model.

    When all vertices of the deformable object have stopped, i.e. whenthe evolution process is finished, it is time for the Final fitting. Thefinal surface is reconstructed by using a Moving Least Square pro-jection. In regions with missing points in the point cloud, for ex-

  • 38 3 Evaluation and related work

    ample holes, the final surface is interpolated with a least-square-mesh. During the interpolation, the vertices from the Moving LeastSquare projection are used as constraints. Moving least squares is amethod for reconstructing continuous functions from unorganizedpoints. In computer graphics it is used for reconstructing a surfacefrom a set of points. Least squared meshes are described in an arti-cle by Sorkine and Cohen-Or [Sorkine and Cohen-Or, 2004]. Leastsquare meshes are meshes that approximate a set of control pointsin a least-squares manner.

    Method evaluation According to the article [Sharf et al., 2006] thisalgorithm seems to be promising. It repairs holes and guaranteeswater-tightness. However, the main author, Andrei Sharf, wrote thefollowing in an e-mail [Sharf, 2013] to the author of this thesis: "Imyself would take the core algorithms from there but redesign theevolution technique and projection from scratch.". In the same e-mail, he also asked if the Poisson Reconstruction method had beentested. He said the following about that method: "It is supposedto be state-of-the-art. But it depends on the specific models you areworking with.". The Poisson Reconstruction method gave unsatisfac-tory results, as can be seen in section 3.1.5. Therefore, this methodwas not considered as interesting for the mesh repair project either.

    Screened poisson surface reconstruction

    This method by Kazhdan and Hoppe [Kazhdan and Hoppe, 2013] is,according to Andrei Sharf [Sharf, 2013], the state-of-the-art methodfor reconstructing surfaces from point clouds. However, Sharf alsostated that it depends on the input models.

    Method description According to the authors of the Poisson recon-struction paper [Kazhdan and Hoppe, 2013], the Poisson surface re-construction creates manifold output surfaces from the input pointcloud. This means that the input model that we want to heal canbe converted to a point cloud, and then the Poisson reconstructionalgorithm can reconstruct a new, watertight surface from the points.The points of the point cloud are used as interpolation constraints.This algorithm will not be described further, since the tests that wasdone during the evaluation gave bad results, see below.

  • 3.1 Related work 39

    Method evaluation The code of the Screened Poisson Surface Re-construction is available online [Microsoft, 2013]. Thus it was possi-ble to test the method during this thesis work on one of Configura’stest models. The result was not satisfying, as can be seen in figure3.9. Probably this test model was not a model suitable for this al-gorithm. Therefore, Screened poisson surface reconstruction is notinteresting for this mesh repair project. Furthermore, is is better touse a method that is adapted for broken polygonal meshes as input,not point clouds.

    Figure 3.9: Testing of the Screened Poisson Surface Reconstruc-tion algorithm at different depths.

    Topological simplification of isosurfaces in volumetric data usingoctrees

    This section describes the method presented by Vanderhyde andSzymczak in 2007 [Vanderhyde and Szymczak, 2008].

    Method description The method has one shrinking procedure andone growing procedure. Both procedures use the distance to theinput surface. There is a choice whether to use the result of shrink-ing or the result of growing. The choice can be done manually orautomatically. The algorithm starts with one surface inside the iso-surface, and one surface outside the isosurface. The isosurface cor-responds to the input model. The surface inside the isosurface willbe expanded, and the surface completely outside the isosurface willbe contracted. The expansion and contraction is done on a voxel-by-voxel basis. This algorithm is a volumetric method that, according

  • 40 3 Evaluation and related work

    to the article, can patch holes and remove topological noise. Fur-thermore, the algorithm prevents topology changes on the surface.The volume is represented in an octree format, which improves theperformance of the algorithm. The result of the algorithm is twosurfaces.

    This method builds on an earlier work [Szymczak and Vanderhyde,2003] by the same authors. In the earlier work, a bounding box ofthe input model is determined. Then this bounding box is filledwith voxels. Then voxels are carved from the boundary until theinput surface is reached. A local check is also used for making surethat a voxel would not be removed if that would change the topol-ogy. What has been described above can be seen as if the inputmodel was shrink-wrapped in plastic.

    The new approach, presented in [Vanderhyde and Szymczak, 2008],also uses a growing approach that adds voxels until the input sur-face is reached. As in the earlier method, a local check is used everytime a voxel is added. The check is to make sure that the topologywill be unchanged when the voxel is added. This procedure can bedescribed as if a balloon was inflated inside the input model. In fig-ure 3.10 [Vanderhyde and Szymczak, 2008] the results from carvingand growing can be seen.

    Figure 3.10: Left: The input model. Center: Results from thegrowing procedure. Right: Results from the carving procedure.[Vanderhyde and Szymczak, 2008]

    After either the result from the carving or the result from the grow-ing has been chosen, the voxels of the result will be adjusted. Thisis to not limit the algorithm to only handle genus-0 models. Thegenus of a surface can in a simple way be explained as the num-

  • 3.1 Related work 41

    ber of holes in a surface. A sphere has for example genus 0, anda ring has genus 1. Therefore, the problems with the results in fig-ure 3.10 can be handled. Figure 3.11 [Vanderhyde and Szymczak,2008] from the article shows how the handles can be opened, andthus the ugly patching on the right result model in figure 3.10 canbe avoided.

    Figure 3.11: Results for the Topological simplification of iso-surfaces method. In each image, one more handle is opened.[Vanderhyde and Szymczak, 2008]

    Method evaluation Since no software for testing this method wasfound, the evaluation of this method is only based on theory andresults from the authors of the article [Vanderhyde and Szymczak,2008]. Since no other methods of this category have worked in a sat-isfactory manner, this method was deselected. However, the theoryis still interesting. Another drawback is that the method requiresuser influence for each component in each input model. This is dueto that each component needs a seed voxel, and that voxel has tobe specified by the user. This will make it harder to process severalmodels at the same time. Even though this only has to be done asa first step of the process, the user has to be active for every model,which is undesirable.

    3.1.6 Previous thesis workers at Configura workingwith the same problem

    As a part of the evaluation procedure of this thesis work, the pre-vious thesis workers’ algorithm was evaluated. The previous the-sis workers at Configura, Magnus Karlberg and Daniel Persson, im-plemented Ju’s method [Ju, 2004] with Marching Cubes. However,

  • 42 3 Evaluation and related work

    their patching step does not work for all input models, see figure3.13. Their mesh repair pipeline is presented in their thesis [Karl-berg and Persson, 2011]. Their octree creation and sign generationgives correct results.

    3.2 Prestudy conclusion

    This section concludes the evaluation and related work chapter. Eachdescribed related work has been evaluated, and this section willsummarize these evaluations which will lead to a preliminary studyconclusion. The background chapter, i.e. chapter 2, is also a partof the preliminary study and, therefore, these conclusions concernthat chapter too.

    The evaluation led to a mesh repair pipeline, presented in chapter4. The method for octree creation, patching and sign generationpresented by Ju [Ju, 2004] is used together with Manifold Dual Con-touring [Schaefer et al., 2007].

    A volumetric repair approach is used since it fulfills more of Con-figura’s requirements than what a surface-based method would do.Surface-based methods have in general problems with robustnessand speed, and usually they can not handle more than a few mesherrors. If they do handle many mesh errors, they probably will bevery time consuming. Furthermore, there are nearly no automaticrepair algorithms out today which are surface-based. That proba-bly means that it is hard to implement a surface-based method thatboth heals several errors and is completely automatic. Volumetricbased methods handle more kinds of mesh errors in general. Inaddition to that they in general produce a manifold output, whichis an important feature for Configura. It is easier to obtain a com-pletely error free mesh if a completely new mesh is created than ifan already existing mesh is patched on lots of different places.

    An octree is used for the volumetric representation of the mesh. Oc-trees are efficient and the most common volumetric representationsin mesh repair. The large issues with uniform grids mean that auniform grid is of no interest for this mesh repair project. It is obvi-ous that a more adaptive kind of grid, like an octree, is needed for

  • 3.2 Prestudy conclusion 43

    representing the input volume.

    Among the volumetric methods, the method developed by Ju is se-lected. It seems to be a satisfying method since it repairs a verylarge amount of the errors that Configura wants the algorithm tohandle. Furthermore, there is a possibility to test the algorithm inan easy manner thanks to the software PolyMender. Tests of Ju’salgorithm together with mesh simplifications give good results.

    Methods using shrinking or growing deformable objects are notseen as interesting due to bad testing results, see for example sec-tion 3.1.5.

    Several methods reconstruct surfaces from point clouds. It is pos-sible to convert the broken input model to a point cloud, and thenheal it by reconstructing it from the point cloud. However, it seemsodd to throw away a lot of useful information about the input model.Methods that reconstruct surfaces from pointclouds are thereforenot seen as interesting during this project. However, they may workvery well for more suitable applications.

    Manifold Dual Contouring (MDC) is selected for creating the newoutput mesh from the patched octree. MDC guarantees a manifoldoutput, which is an important advantage. Furthermore, it simpli-fies the output model. That is a good feature since Ju’s methodhas problems with over-tesselated outputs. In addition to the re-duction of memory complexity, the testing of PolyMender togetherwith the mesh simplification software qSlim showed that mesh sim-plification can increase the output model’s visual quality. The DualMarching Cubes algorithm is also an interesting solution. However,it does introduce topological holes, as can be seen in figure 3.6. Fur-thermore, it is advantageous to use the Hermite Data informationsince more information will probably give an output model that ismore similar to the input model. In contrast to MDC, Dual March-ing Cubes does not use Hermite Data.

    The previous thesis workers at Configura did partially choose thesame mesh repair pipeline as was chosen during this thesis work.Therefore, some parts from their algorithm are reused, especiallythe octree creation and the sign generation. The contouring algo-

  • 44 3 Evaluation and related work

    rithm is completely substituted from Marching Cubes to ManifoldDual Contouring for obtaining a manifold output in all cases. As de-scribed in section 3.1.4 Marching cubes may introduce holes in theoutput surface. Furthermore, the patching part is largely changedsince the previous patching did not work in all cases. See for exam-ple figure 3.13.

    Figure 3.12: The inputmodel with a large hole.

    Figure 3.13: The outputmodel repaired with thepatching from the previ-ous thesis workers. Man-ifold dual contouring isused for surface recon-struction. The red mark-ings show nodes that areinconsistent after repair.

  • 4Mesh repair system

    This chapter provides an overview of the complete mesh repair sys-tem. The different parts of the system will be described further inchapter 5, 6, 7 and 8 .

    4.1 The mesh repair pipeline

    During this thesis work, a mesh repair pipeline has been developed.The pipeline is described in this section.

    As seen in figure 4.1, the planned system consists of five blocks. Thecurrent version of the system, which is described below, consistsof the Octree generation block and the Manifold Dual Contouringblock.

    The first block, removal of intersecting triangles, is probably re-solved by the implemented method described in section 4.2. There-fore this block should have the lowest priority. However, this blockstill is a part of the mesh repair pipeline, since if there would be anyproblems with intersecting triangles, then this preprocessing step isnecessary.

    The pipeline includes two post processing steps: removal of unseen

    45

  • 46 4 Mesh repair system

    Figure 4.1: The mesh repair pipeline developed during thisthesis work.

    objects by using ray casting, and error detection. The ray castingshould remove unseen objects, which is a feature that Configurawants, and it can also decimate the output. How the ray castingcould be implemented is described in section 11.2. The purposeof the error detection is to automatically detect models which wererepaired in an unsatisfactory manner. This would make the meshrepair software even more automatic and faster to use.

    4.2 The implemented system

    This sections holds an overview of the current mesh repair system,i.e. the method inspired by Tao Ju and the Manifold Dual Contour-ing. According to the theory, the current system should resolve

  • 4.2 The implemented system 47

    the errors listed below. Actually only one important thing is left,namely to remove unseen objects. As described in section 4.1, thisis a part of the planned system pipeline and can probably be solvedwith ray casting. The current system can handle models that con-sists of several meshes. The Octree generation part handles the fol-lowing requirements:

    • Bad normals

    • Unwanted holes

    • Keep wanted holes

    • T-junctions

    • Hanging triangles

    • Processing time and memory controllable

    • Probably overlapping triangles

    The Manifold Dual Contouring step should handle the followingmesh errors:

    • Decimation

    • Manifold output

    • Degenerate triangles

    • Redundant vertices

    The Manifold Dual Contouring is implemented as a separate block,therefore it is easy to change to another contouring method.

    4.2.1 System information

    This sections presents relevant information about the implementedsystem. For example the octree node definitions and informationabout input parameters.

    In this project the octree object has an input parameter called octreedepth. This is the maximal depth of the octree. Three kinds of oc-tree nodes are used: composite, leaf and empty nodes. A compositenode is an internal tree node with eight children. Furthermore, acomposite node is intersected by the input model. An empty node

  • 48 4 Mesh repair system

    is a node without children that is not intersected by the input 3Dmodel. A leaf node is a node at the maximum depth that is inter-sected by the input 3D model. Since the leaf node is at the maxi-mum depth, it has no children.

    The concepts of corners, edges and faces of octree voxels are widelyused in this thesis. Figure 4.2 explains these concepts.

    Figure 4.2: One voxel with eight corners, 12 edges and sixfaces.

  • 5Robust repair of polygonal

    models

    Ju [Ju, 2004] presents a volumetric method for repairing polygonalmodels. The method includes three main parts: scan-conversion,sign generation and surface reconstruction.

    5.1 Scan-conversion

    In this part, an octree grid that records edges intersecting the in-put model is constructed. The intersected edges are important forthe sign generation part. Ju suggests a method based on the sepa-rating axis theorem for finding the intersection points between theoctree grid edges and the input model. Extra information can besaved in the intersected edges, for example the polygon normalfor the input model in the intersection point. The extra informa-tion may be used in the surface-reconstruction part, depending onwhich surface-reconstruction method is used. The extra informa-tion is only saved in the node’s primal edges, see figure 5.1. This isdone to avoid duplicates.

    Ju suggests that the octree is constructed using a recursive method.If a node is intersected by the input model, and the max depth ofthe octree has not been reached, the node will be divided into eight

    49

  • 50 5 Robust repair of polygonal models

    Figure 5.1: The primal edges of an octree node are marked withred.

    child nodes. If the max depth of the octree has been reached, theintersected node will be a leaf node. A node with children is calleda composite node. A node that does not intersect the input model iscalled an empty node.

    5.2 Sign generation

    In this part of the model repair pipeline, every grid point (i.e. voxelcorner in the octree) will get a sign that shows if the corner is insideor outside the model. The sign generation part is, according to Ju,divided into three parts. Ju calls the parts Detect boundary cycles,Patch boundary cycles and Generate signs. The goal of the signgeneration is to modify the set of intersected edges to a set that onlyincludes edges that have a consistent sign configuration.

    First, in the detect boundary cycles part, a dual surface is constructed.The dual surface consists of quads, one for each intersected edge.Figure 5.2 shows an example of a dual surface of a sphere. Everyquad is perpendicular to and located at the center of the correspond-ing intersected node edge. Boundary edges are quad edges that con-sists of an odd number of quads. Each boundary edge is dual to avoxel face on the octree that contains an odd number of intersected

  • 5.2 Sign generation 51

    edges, i.e. an inconsistent voxel face. An edge dual to a face meansthat the edge intersects the center of the face, and that the edgeis perpendicular to the face. Adjacent boundary edges will mergeinto boundary cycles. Therefore the boundary cycles encircle theproblem areas, i.e. the areas with inconsistent octree nodes. An in-consistent octree node is a node, or voxel, that has at least one facewith an odd number of intersected edges.

    Figure 5.2: Quads and octree for a spherical 3D model. Thequads are intersecting the center of the intersected voxel edges.

    In the patch boundary cycles part, the following will be done accord-ing to Ju. If a boundary cycle is empty, it will be filled (i.e. quadsare added), and if a boundary cycle is encircling quads, these quadswill be removed. When a quad is removed, the corresponding inter-sected edge will be changed to non-intersected. If quads are added,the corresponding edges to the new quads will be marked as inter-sected. Therefore the set of intersected edges has been updated after

  • 52 5 Robust repair of polygonal models

    the two first blocks of the sign generation part. Figure 5.3 [Ju, 2004]shows the different steps in the patching procedure.

    Figure 5.3: a: The input model with a hole on the top. b: In-tersected edges and the dual surface. The bold black line is aborder cycle around the problem area. c: The patched dual sur-face. New intersected edges have been added to the top of themesh. d: The repaired output model. [Ju, 2004]

    The third block of the sign-generation is the actual generating signsblock. Before this block, the dual surface, i.e. the quad surface, waspatched. The patching, with help of boundary cycles, is necessarysince otherwise the generate signs block won’t give a correct result.The patching affects the sign generation since the patching updatesthe set of intersected edges. Ju suggests a recursive method for gen-erating signs. The left corner in the most left leaf node in the octreewill get the given sign s. Then the rest of the corners in that nodeand the corners in the rest of the nodes in the octree will get theirsigns depending on the intersected edges. If there is an intersected

  • 5.3 Surface reconstruction 53

    edge, the sign will be multiplied by (-1). It is thus the set of inter-sected edges that determines the signs.

    5.3 Surface reconstruction

    In this part, Ju shows results from the dual contouring method[Ju et al., 2002] and from the marching cubes method [Lorensenand Cline, 1987]. Ju shows that dual contouring gives a better re-sult for the models that were tested. For the surface-reconstructionpart, the input will be an octree with signs in the node corners. In-formation about intersected edges, and the intersection points onthe edges, is also important for the surface reconstruction methods.Marching cubes and Dual Contouring are described in the back-ground section of this thesis. Figure 5.4 [Ju, 2004] shows a modelthat