94
2D Triangulations in 2D Triangulations in http:// http:// www.cgal.org www.cgal.org Pierre Alliez Pierre Alliez Mariette Mariette Yvinec Yvinec

2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Embed Size (px)

Citation preview

Page 1: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

2D Triangulations in2D Triangulations in

http://http://www.cgal.orgwww.cgal.org

Pierre AlliezPierre Alliez

Mariette Mariette YvinecYvinec

Page 2: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

OutlineOutline•• SpecificationsSpecifications

–– DefinitionDefinition

–– Triangulations in CGALTriangulations in CGAL

–– FeaturesFeatures

•• RepresentationRepresentation

–– As a set of facesAs a set of faces

–– Representation based on vertices and cellsRepresentation based on vertices and cells

•• Software designSoftware design

–– Traits classTraits class

–– Triangulation data structureTriangulation data structure

•• AlgorithmsAlgorithms

–– Point locationPoint location

•• ExamplesExamples

•• ApplicationsApplications

Page 3: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

OutlineOutline•• SpecificationsSpecifications

–– DefinitionDefinition

–– Triangulations in CGALTriangulations in CGAL

–– FeaturesFeatures

•• RepresentationRepresentation

–– As a set of facesAs a set of faces

–– Representation based on vertices and cellsRepresentation based on vertices and cells

•• Software designSoftware design

–– Traits classTraits class

–– Triangulation data structureTriangulation data structure

•• AlgorithmsAlgorithms

–– Point locationPoint location

•• ExamplesExamples

•• ExercisesExercises

Page 4: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

DefinitionsDefinitions

•• A A 2D triangulation2D triangulation is a set is a set TT of triangular of triangular

facets such that:facets such that:

–– two facets are either disjoint or share a lower two facets are either disjoint or share a lower

dimensional face (edge or vertex).dimensional face (edge or vertex).

–– the set of facets in the set of facets in TT is connected for the is connected for the

adjacency relation.adjacency relation.

–– the domain the domain UUTT which is the union of facets in which is the union of facets in TT

has no singularity.has no singularity.

Page 5: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

DefinitionsDefinitions

•• A A simplicialsimplicial complex is a set complex is a set T T of of simplicessimplices such thatsuch that

–– any face of a simplex in any face of a simplex in T T is a simplex in is a simplex in TT

–– two two simplicessimplices in in T T either are disjoint or share a common either are disjoint or share a common

subfacesubface..

•• The dimension The dimension d d of a of a simplicialsimplicial complex is the complex is the

maximal dimension of its maximal dimension of its simplicessimplices..

•• A A simplicialsimplicial complex complex T T is pure if any simplex of is pure if any simplex of T T is is

included in a simplex of included in a simplex of T T with maximal dimension.with maximal dimension.

Page 6: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

DefinitionsDefinitions

•• Two simplexes in Two simplexes in T T with maximal dimension with maximal dimension d d are are

said to be adjacent if they share a (said to be adjacent if they share a (dd--1) 1) dimensional dimensional

subfacesubface. A . A simplicialsimplicial complex is connected if the complex is connected if the

adjacency relation defines a connected graph over adjacency relation defines a connected graph over

the set of the set of simplicessimplices of of T T with maximal dimension.with maximal dimension.

•• The union The union UUTT of all of all simplicessimplices in in T T is called the is called the

domain of domain of TT. .

•• A point A point p p in the domain of in the domain of T T is said to singular if its is said to singular if its

surrounding in surrounding in UUTT is neither a topological ball nor a is neither a topological ball nor a

topological disc.topological disc.

Page 7: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

2D Triangulations in CGAL2D Triangulations in CGAL

–– BasicBasic

–– DelaunayDelaunay

–– RegularRegular

–– ConstrainedConstrained

–– Constrained DelaunayConstrained Delaunay

Page 8: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Basic TriangulationBasic Triangulation

• Lazy incremental construction, no control over the shape of triangles

Page 9: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Delaunay TriangulationDelaunay Triangulation

•• Empty circle propertyEmpty circle property

Page 10: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Regular TriangulationRegular Triangulation

•• Generalization of Delaunay Generalization of Delaunay

triangulation.triangulation.

•• Defined for a set of Defined for a set of weighted weighted

pointspoints. Each weighted point . Each weighted point

can be considered as a sphere can be considered as a sphere

whose square radius is equal whose square radius is equal

to the weight. The regular to the weight. The regular

triangulation is the dual of the triangulation is the dual of the

power diagram.power diagram.

Page 11: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Constrained TriangulationConstrained Triangulation

•• Allows to Allows to enforce edgesenforce edges..

Page 12: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Constrained Delaunay Constrained Delaunay

TriangulationTriangulation

•• Constrained triangulation which is Constrained triangulation which is as much as much

Delaunay as possibleDelaunay as possible. Each triangle satisfies the . Each triangle satisfies the

constrained empty circle property: Its constrained empty circle property: Its

circumscribing circle encloses no vertex visible from circumscribing circle encloses no vertex visible from

the interior of the triangle, where enforced edges the interior of the triangle, where enforced edges

are considered as visibility obstacles.are considered as visibility obstacles.

Page 13: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Derivation Tree (2D)Derivation Tree (2D)

Page 14: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

General FeaturesGeneral Features

•• Traversal:Traversal:

–– going from a face to its neighborsgoing from a face to its neighbors

–– iterators to visit all faces of a triangulationiterators to visit all faces of a triangulation

–– circulators to visit all faces around a vertex or all faces circulators to visit all faces around a vertex or all faces

intersected by a line.intersected by a line.

•• Point location queryPoint location query

•• Insertion, removal, flips:Insertion, removal, flips:

–– Features adapted to each type of triangulations (e.g., the Features adapted to each type of triangulations (e.g., the

insertions and deletions in a Delaunay triangulation maintain thinsertions and deletions in a Delaunay triangulation maintain the e

empty circle property).empty circle property).

Page 15: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Additional FeaturesAdditional Features

•• For some triangulationsFor some triangulations

Page 16: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Additional FeaturesAdditional Features

• Example for constrained and Delaunayconstrained triangulations:

– Insertion and removal of constraints

Page 17: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Additional FeaturesAdditional Features

•• For For Delaunay triangulationDelaunay triangulation

–– Nearest neighbor queriesNearest neighbor queries

–– Voronoi diagramVoronoi diagram

Point p = dual(face)

Page 18: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Traversal (1)Traversal (1)

•• IteratorsIterators

–– All faces All faces iteratoriterator

–– All vertices All vertices iteratoriterator

–– All edges All edges iteratoriterator

Page 19: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Traversal (2)Traversal (2)

•• CirculatorsCirculators

–– Face circulatorFace circulator

•• faces incident to a vertexfaces incident to a vertex

–– Edge circulatorEdge circulator

•• edges incident to a vertexedges incident to a vertex

–– Vertex circulatorVertex circulator

•• vertices incident to a vertexvertices incident to a vertex

Page 20: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Traversal (3)Traversal (3)

•• Line face circulatorLine face circulator

Page 21: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Point Location & InsertionPoint Location & Insertion

Page 22: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Edge FlipEdge Flip

Page 23: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

OutlineOutline•• SpecificationsSpecifications

–– DefinitionDefinition

–– Triangulations in CGALTriangulations in CGAL

–– FeaturesFeatures

•• RepresentationRepresentation

–– As a set of facesAs a set of faces

–– Representation based on vertices and cellsRepresentation based on vertices and cells

•• Software designSoftware design

–– Traits classTraits class

–– Triangulation data structureTriangulation data structure

•• AlgorithmsAlgorithms

–– Point locationPoint location

•• ExamplesExamples

•• ExercisesExercises

Page 24: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Triangulations as a Set of FacesTriangulations as a Set of Faces

• All triangulations in CGAL tile the convex hull of their vertices. Triangulated polygonal regions can

be obtained through constrained triangulations.

Page 25: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Triangulations as a Set of FacesTriangulations as a Set of Faces

• All triangulations in CGAL tile the convex hull of their vertices. Triangulated polygonal regions can

be obtained through constrained triangulations.

• An imaginary vertex (so-called infinite vertex is added).

Page 26: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Triangulations as a Set of FacesTriangulations as a Set of Faces

• All triangulations in CGAL tile the convex hull of their vertices. Triangulated polygonal regions can

be obtained through constrained triangulations.

• An imaginary vertex (so-called infinite vertex is added).

– Any face is a triangle.

– Any edge is incident to two exactly 2 faces.

– The set of faces is equivalent to a 2D topological sphere.

Page 27: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Triangulations as a Set of FacesTriangulations as a Set of Faces

In any dimension,

the set of faces is

combinatorically

equivalent to a

triangulatedsphere.

00

11

22

33

Page 28: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

RepresentationRepresentation

•• The internal representation is based on The internal representation is based on

facesfaces and and verticesvertices..

•• Edges are Edges are implicitlyimplicitly representedrepresented

•• VertexVertex–– Face* v_faceFace* v_face

•• FaceFace–– Vertex* vertex[3]Vertex* vertex[3]

–– Face* neighbor[3]Face* neighbor[3]

Page 29: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

RepresentationRepresentation

•• functions functions cw(icw(i) ) & & ccw(iccw(i))

Page 30: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

RepresentationRepresentation

•• From one face to anotherFrom one face to another

Page 31: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

RepresentationRepresentation

•• Around a vertexAround a vertex

Page 32: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

OutlineOutline•• SpecificationsSpecifications

–– DefinitionDefinition

–– Triangulations in CGALTriangulations in CGAL

–– FeaturesFeatures

•• RepresentationRepresentation

–– As a set of facesAs a set of faces

–– Representation based on vertices and cellsRepresentation based on vertices and cells

•• Software designSoftware design

–– Traits classTraits class

–– Triangulation data structureTriangulation data structure

•• AlgorithmsAlgorithms

–– Point locationPoint location

•• ExamplesExamples

•• ExercisesExercises

Page 33: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Software DesignSoftware Design

• CGAL classes are parameterized by one or more template parameters:–– Polygon_2<Polygon_2<TraitsTraits, Container>, Container>

–– Polyhedron_3<Polyhedron_3<TraitsTraits, HDS>, HDS>

–– Planar_map_2<Planar_map_2<Dcel,Dcel,TraitsTraits>>

–– Arrangement_2<Arrangement_2<Dcel,Dcel,TraitsTraits,Base,Base node>node>

–– Min_circle_2<Min_circle_2<TraitsTraits>>

–– Point_set_2<Point_set_2<TraitsTraits>>

–– Range_tree_k<Range_tree_k<TraitsTraits>>

Page 34: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Triangulation ClassesTriangulation Classes

Triangulation_2<Triangulation_2<TraitsTraits, , TDSTDS>>

Triangulation_3<Triangulation_3<TraitsTraits, , TDSTDS>>

•• TraitsTraits

–– Geometric traitsGeometric traits

•• TDSTDS

–– Triangulation Data StructureTriangulation Data Structure

Page 35: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Geometric TraitsGeometric Traits

•• Geometric Geometric traits classestraits classes provide :provide :

–– Basic geometric objectsBasic geometric objects

–– Predicates and ConstructorsPredicates and Constructors

•• Requirements for traits are documentedRequirements for traits are documented

–– basic library data structures and algorithms can basic library data structures and algorithms can

be used with userbe used with user--defined objectsdefined objects

•• Default traits classes are providedDefault traits classes are provided

Page 36: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Traits Class for Traits Class for

Delaunay TriangulationDelaunay Triangulation

•• Requirements:Requirements:

–– PointPoint

–– SegmentSegment

–– TriangleTriangle

–– LineLine

–– RayRay

–– orientation testorientation test

–– in circle testin circle test

–– circumcentercircumcenter

–– bisectorbisector

Page 37: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Traits Class for Traits Class for

Delaunay TriangulationDelaunay Triangulation

•• Default traits class:Default traits class:–– Triangulation_euclidean_traits_2<Triangulation_euclidean_traits_2<KernelKernel>>

•• Delaunay triangulation of 2D points:Delaunay triangulation of 2D points:–– typedeftypedef Cartesian<Cartesian<doubledouble> > KernelKernel;;

–– typedeftypedef Triangulation_euclidean_traits_2<Triangulation_euclidean_traits_2<KernelKernel> > TraitsTraits;;

–– typedeftypedef Delaunay_triangulation_2<Delaunay_triangulation_2<TraitsTraits> Triangulation;> Triangulation;

Page 38: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Predicates for Predicates for

Delaunay TriangulationDelaunay Triangulation

Page 39: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Traits Class for TerrainsTraits Class for Terrains

NeedsNeeds

–– 3D points3D points

–– orientationorientation

–– in circlein circle

–– on x and y coordinateson x and y coordinates

Triangulation_euclidean_traits_xy_3<Triangulation_euclidean_traits_xy_3<KernelKernel>>

DefinitionDefinition::

typedeftypedef Cartesian<double> Cartesian<double> KernelKernel;;

typedeftypedef Triangulation Triangulation euclideaneuclidean traits traits xyxy 3<3<KernelKernel> Traits;> Traits;

typedeftypedef Delaunay triangulation 2<Traits> Triangulation;Delaunay triangulation 2<Traits> Triangulation;

Page 40: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Software DesignSoftware Design

template< class Gt, class Tds>

Triangulation_2 ;

template<class Vb, class Fb>

Triangulation_data_structure_2;

Page 41: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Triangulation DesignTriangulation Design

Vertex baseVertex base

Vertex base :: PointVertex base :: Point

Vertex baseVertex base( Point p, void* f)( Point p, void* f)

Point Point pointpoint();();

void* void* faceface();();

void* void* set pointset point();();

void* void* set faceset face();();

Face baseFace base

Face baseFace base(void* v0, void* v1, void* v2,(void* v0, void* v1, void* v2,

void* n0, void* n1, void* n2)void* n0, void* n1, void* n2)

void* void* vertexvertex(int(int i);i);

void* void* neighborneighbor(int(int i);i);

void* void* set set vertexvertex(int(int i, void* v);i, void* v);

void* void* set set neighborneighbor(int(int i, void* f);i, void* f);

Page 42: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Triangulation Data StructureTriangulation Data Structure

TdsTds<<Vb,FbVb,Fb>>

Types:Types:

•• TdsTds<<Vb,FbVb,Fb>::Vertex inherits from >::Vertex inherits from VbVb

•• TdsTds<<Vb,FbVb,Fb>::Face inherits from >::Face inherits from FbFb

•• TdsTds<<Vb,FbVb,Fb>::Face >::Face iteratoriterator

•• TdsTds<<Vb,FbVb,Fb>::Edge >::Edge iteratoriterator

•• TdsTds<<Vb,FbVb,Fb>::Vertex >::Vertex iteratoriterator

•• TdsTds<<Vb,FbVb,Fb>::Face circulator>::Face circulator

•• TdsTds<<Vb,FbVb,Fb>::Edge circulator>::Edge circulator

•• TdsTds<<Vb,FbVb,Fb>::Vertex circulator>::Vertex circulator

Page 43: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Combinatorial OperationsCombinatorial Operations

void void insert_in_face insert_in_face (Vertex* v,Face* f)(Vertex* v,Face* f)

void void insert_in_edge insert_in_edge (Vertex* v, Face* f, (Vertex* v, Face* f, intint i)i)

void void remove_degre_3 remove_degre_3 (Vertex* v);(Vertex* v);

Page 44: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Combinatorial OperationsCombinatorial Operations

void void flip flip (Face* f, (Face* f, intint i);i);

void void split vertex split vertex (Vertex*, Face* f1, Face* f2)(Vertex*, Face* f1, Face* f2)

void void join vertices join vertices (Vertex* v1, vertex* v2)(Vertex* v1, vertex* v2)

Page 45: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

The Triangulation ClassThe Triangulation Class

CGAL::Triangulation 2<CGAL::Triangulation 2<GtGt, , TdsTds >>

typedeftypedef GtGt geometric_traits;geometric_traits;

typedeftypedef TdsTds Triangulation_data_structure;Triangulation_data_structure;

typedeftypedef Triangulation_2<Triangulation_2<GtGt, , TdsTds > Triangulation;> Triangulation;

TypesTypes

Gt::Gt::Point_2Point_2

Gt::Gt::Segment_2Segment_2

Gt::Gt::Triangle_2Triangle_2

Triangulation::Triangulation::Vertex Vertex inherits from inherits from Tds::VertexTds::Vertex

Triangulation::Triangulation::Face Face inherits from inherits from Tds::FaceTds::Face

Triangulation::Triangulation::Vertex_handleVertex_handle

Triangulation::Triangulation::Face_handleFace_handle

typedeftypedef pair<Face handle, pair<Face handle, intint> > Edge Edge ;;

Triangulation::Triangulation::Face_iteratorFace_iterator

Triangulation::Triangulation::Edge_iteratorEdge_iterator

Triangulation::Triangulation::Vertex_iteratorVertex_iterator

Triangulation::Triangulation::Line_face_circulatorLine_face_circulator

Triangulation::Triangulation::Face_circulatorFace_circulator

Triangulation::Triangulation::Edge_circulatorEdge_circulator

Triangulation::Triangulation::Vertex_circulatorVertex_circulator

Page 46: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

High Level FunctionsHigh Level Functions

enumenum Locate_type {Locate_type { VERTEX=0, EDGE, FACE, VERTEX=0, EDGE, FACE,

OUTSIDE_CONVEX_HULL, OUTSIDE_CONVEX_HULL,

OUTSIDE_AFFINE_HULL}OUTSIDE_AFFINE_HULL}

Face_handle Face_handle locatelocate(( Point query, Point query,

Locate_type& Locate_type& ltlt,,

intint& & lili,,

Face_handle h =Face_handle() );Face_handle h =Face_handle() );

Vertex_handle Vertex_handle insertinsert(Point p)(Point p)

void void removeremove(Vertex_handle v)(Vertex_handle v)

Page 47: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

InsertionInsertion

Vertex handle insert (Point p)

{

Locate type lt; int li;

Face handle loc = locate(p, lt, li);

switch(lt)

{

case VERTEX : return f->vertex(li);

case EDGE :return insert_in_edge( p, loc,li);

case FACE :return insert_in_face(v,loc);

case OUTSIDE CH :return insert_outside ch(p,loc);

case OUTSIDE AH :return insert_outside ah(p);

}

}

Page 48: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

PerformancesPerformances

Kilimandjaro elevation contour

lines (38K segments)

Page 49: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Related ComponentsRelated Components•• Voronoi diagramVoronoi diagram

•• Elevation (through traits class)Elevation (through traits class)

Courtesy IPF,Vienna University of Technology & Inpho GmbH

Page 50: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

OutlineOutline•• SpecificationsSpecifications

–– DefinitionDefinition

–– Triangulations in CGALTriangulations in CGAL

–– FeaturesFeatures

•• RepresentationRepresentation

–– As a set of facesAs a set of faces

–– Representation based on vertices and cellsRepresentation based on vertices and cells

•• Software designSoftware design

–– Traits classTraits class

–– Triangulation data structureTriangulation data structure

•• AlgorithmsAlgorithms

–– Point locationPoint location

•• ExamplesExamples

•• ExercisesExercises

Page 51: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Algorithms for TriangulationAlgorithms for Triangulation

•• All CGAL triangulations are built through All CGAL triangulations are built through

incremental incremental onon--line insertion of vertices. line insertion of vertices.

•• The main algorithmic issue is therefore to deal with The main algorithmic issue is therefore to deal with

pointpoint locationlocation. .

•• CGAL CGAL offers different algorithms :offers different algorithms :

–– linewalklinewalk

–– Zigzag walkZigzag walk

–– jump and walk strategyjump and walk strategy

–– the Delaunay hierarchythe Delaunay hierarchy

Page 52: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Efficient LocalizationEfficient Localization

•• Delaunay HierarchyDelaunay Hierarchy

Page 53: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

OutlineOutline•• SpecificationsSpecifications

–– DefinitionDefinition

–– Triangulations in CGALTriangulations in CGAL

–– FeaturesFeatures

•• RepresentationRepresentation

–– As a set of facesAs a set of faces

–– Representation based on vertices and cellsRepresentation based on vertices and cells

•• Software designSoftware design

–– Traits classTraits class

–– Triangulation data structureTriangulation data structure

•• AlgorithmsAlgorithms

–– Point locationPoint location

•• ExamplesExamples

•• ExercisesExercises

Page 54: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

#include <CGAL/Cartesian.h>#include <CGAL/Cartesian.h>

#include <CGAL/Triangulation_2.h>#include <CGAL/Triangulation_2.h>

using using namespace CGAL;namespace CGAL;

usingusing namespace std;namespace std;

typedeftypedef Cartesian<Cartesian<doubledouble> > KernelKernel;;

typedeftypedef Triangulation_2<Triangulation_2<KernelKernel> Triangulation;> Triangulation;

typedeftypedef Triangulation::Vertex_circulator Vertex_circulator;Triangulation::Vertex_circulator Vertex_circulator;

typedeftypedef KernelKernel::Point_2 Point;::Point_2 Point;

Triangulation t;Triangulation t;

Point p;Point p;

whilewhile(cin(cin >> p) t.insert(p);>> p) t.insert(p);

Vertex_circulator Vertex_circulator vcvc = t.incident_vertices(t.infinite_vertex());= t.incident_vertices(t.infinite_vertex());

Vertex_circulator Vertex_circulator done(vcdone(vc););

dodo

coutcout << << vcvc-->point();>point();

whilewhile(++vc(++vc != done);!= done);

Page 55: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Drawing Generators...Drawing Generators...

template <template <classclass kernel, kernel, classclass TDS>TDS>

classclass DT2 : DT2 : publicpublic CGAL::Delaunay_triangulation_2<kernel,TDS>CGAL::Delaunay_triangulation_2<kernel,TDS>

{{

public:public:

voidvoid gl_draw_generatorsgl_draw_generators()()

{{

::::glBeginglBegin(GL_POINTS(GL_POINTS););

Point_iteratorPoint_iterator it;it;

for(it = points_begin();for(it = points_begin();

it != points_end(); it != points_end();

it++) it++)

{{

const Point& p = *it;const Point& p = *it;

::glVertex2f(p.x(),p.y());::glVertex2f(p.x(),p.y());

}}

::::glEndglEnd();();

}}

}}

Page 56: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Drawing Delaunay Edges...Drawing Delaunay Edges...

voidvoid gl_draw_delaunay_edgesgl_draw_delaunay_edges()()

{{

::::glBeginglBegin(GL_LINES(GL_LINES););

Edge_iteratorEdge_iterator it;it;

forfor(it(it = edges_begin(); = edges_begin();

it != edges_end(); it != edges_end();

it++) it++)

{{

// edge = // edge = std::pairstd::pair<<Face_handle,intFace_handle,int>>

Edge& edge = *it;Edge& edge = *it;

constconst Point& p1 = Point& p1 = edge.firstedge.first-->>vertex(ccw(edge.secondvertex(ccw(edge.second))))-->point();>point();

constconst Point& p2 = Point& p2 = edge.firstedge.first-->>vertex(cw(edge.secondvertex(cw(edge.second))))-->point();>point();

::::glVertex2fglVertex2f(p1.x(), p1.y());(p1.x(), p1.y());

::::glVertex2fglVertex2f(p2.x(), p2.y());(p2.x(), p2.y());

}}

::::glEndglEnd();();

}}

Page 57: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Drawing Voronoi EdgesDrawing Voronoi Edges

voidvoid gl_draw_voronoi_edgesgl_draw_voronoi_edges()() {{

::::glBeginglBegin(GL_LINES(GL_LINES););

Edge_iteratorEdge_iterator hEdgehEdge;;

forfor(hEdge(hEdge = edges_begin(); = edges_begin(); hEdgehEdge != edges_end(); != edges_end(); hEdgehEdge++) ++)

{{

CGAL::Object object = CGAL::Object object = dual(hEdgedual(hEdge););

Segment segment; Segment segment;

Ray ray;Ray ray;

Point source, target;Point source, target;

ifif(CGAL::assign(segment,object)) (CGAL::assign(segment,object))

{{

source = segment.source(); source = segment.source();

target = segment.target();target = segment.target();

}}

else ifelse if(CGAL::assign(ray,object)) (CGAL::assign(ray,object))

{{

source = ray.source();source = ray.source();

target = ray.point(1);target = ray.point(1);

}}

::::glVertex2fglVertex2f(source.x(),source.y());(source.x(),source.y());

::::glVertex2fglVertex2f(target.x(),target.y());(target.x(),target.y());

}}

::::glEndglEnd(); }(); }

Page 58: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

DemoDemo

Page 59: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

ApplicationsApplications

•• MeshingMeshing

–– rendering, simulationrendering, simulation

•• RemeshingRemeshing

–– reverse engineeringreverse engineering

•• Efficient locationEfficient location

•• Placement of streamlinesPlacement of streamlines

–– scientific visualizationscientific visualization

•• ......

Page 60: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Reverse EngineeringReverse Engineering

1.1.Digitizing physical objectsDigitizing physical objects

The Digital Michelangelo ProjectThe Digital Michelangelo Project

point setpoint set

Page 61: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Reverse EngineeringReverse Engineering

1.1.Digitizing physical objectsDigitizing physical objects

2.2.Representing the resulting dense point Representing the resulting dense point

set with:set with:

–– discrete surfacediscrete surface

•• e.g. triangle meshe.g. triangle mesh

–– mathematical surfacemathematical surface

•• implicit functionimplicit function

•• ∑∑ rradial basis functionsadial basis functions

•• NURBS patchesNURBS patches

•• etc.etc.

Page 62: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

A Typical PipelineA Typical Pipeline•• DigitizationDigitization

–– physical object physical object --> point set> point set

•• ReconstructionReconstruction

–– point set point set --> surface> surface

•• Resampling / RemeshingResampling / Remeshing

•• ProcessingProcessing

–– e.g. denoising, smoothing, fairinge.g. denoising, smoothing, fairing

•• Segmentation / StructuringSegmentation / Structuring

•• EditingEditing

•• Storage & TransmissionStorage & Transmission

•• Simulation and/or VisualizationSimulation and/or Visualization

•• Browsing & RetrievalBrowsing & Retrieval

•• 3D Printing3D Printing

physical

digital

physical

Page 63: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

DefinitionDefinition

•• IsotropicIsotropic sampling:sampling:

–– Locally uniform in all directionsLocally uniform in all directions

–– Generate compact elementsGenerate compact elements

–– Used for simulation and processingUsed for simulation and processing

Page 64: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

IsotropicIsotropic SamplingSampling??

Page 65: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

1.1.Global ParameterizationGlobal Parameterization

Page 66: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Conformal MappingConformal Mapping

““A A wellwell--shapedshaped element in parameter space will not element in parameter space will not

be deformed too much once lifted in embedding be deformed too much once lifted in embedding

space”space”

Page 67: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

2.2.Initial Initial SampleSample RepartitionRepartition

Voronoi diagram

Page 68: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

3.3.Precise Precise SampleSample PlacementPlacement

LloydLloyd

centroidal Voronoi diagram

Page 69: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Uniform RemeshingUniform Remeshing

50kV50kV

Page 70: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

NonNon--uniformuniform RemeshingRemeshing

Page 71: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

Placement of StreamlinesPlacement of Streamlines

AbdelkrimAbdelkrim MebarkiMebarki, 2004, 2004

Page 72: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing
Page 73: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing
Page 74: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing
Page 75: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing
Page 76: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing
Page 77: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing
Page 78: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing
Page 79: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing
Page 80: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing
Page 81: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing
Page 82: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing
Page 83: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing
Page 84: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing
Page 85: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing
Page 86: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing
Page 87: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing
Page 88: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing
Page 89: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing
Page 90: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing
Page 91: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing
Page 92: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing
Page 93: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing
Page 94: 2D Triangulations in · • All triangulations in CGAL tile the convex hull of ... be used with user-defined objects ... • Resampling / Remeshing • Processing

ExercicesExercices