Presentation is loading. Please wait.

Presentation is loading. Please wait.

3D Polyhedral Surfaces in Pierre Alliez.

Similar presentations


Presentation on theme: "3D Polyhedral Surfaces in Pierre Alliez."— Presentation transcript:

1 3D Polyhedral Surfaces in http://www.cgal.org Pierre Alliez

2 http://www.cgal.org Outline MotivationsMotivations DefinitionDefinition Halfedge Data StructureHalfedge Data Structure TraversalTraversal Euler OperatorsEuler Operators CustomizationCustomization Incremental BuilderIncremental Builder File I/OFile I/O ExamplesExamples ApplicationsApplications ExercisesExercises

3 http://www.cgal.org Motivations From rendering... –Static –Compact storage in array –Traversal over all facets –Attributes per facet/vertex

4 http://www.cgal.org Motivations...to algorithms on meshes –Dynamic pointer updates –Dynamic storage in lists –Traversal over incidences

5 http://www.cgal.org Design Goal Method: paradigm of Generic Programming Example: STL

6 http://www.cgal.org Definition Polyhedral Surface: boundary representation of a polyhedron in IR 3.

7 http://www.cgal.org Polyhedral Surface Represented by three sets V,E,F and an incidence relation on them, restricted to orientable 2- manifolds with boundary. V = Vertices in IR 3 E = Edges, straight line segments. F = Facets, simple, planar polygons without holes. Can be extended: edges to curves, facets to curved surfaces.

8 http://www.cgal.org Polyhedral Surface Represented by three sets V,E,F and an incidence relation on them, restricted to orientable 2- manifolds with boundary.  Edge-based data structure ?

9 http://www.cgal.org Edge-centered Data Structures

10 http://www.cgal.org Winged-Edge Data Structure

11 http://www.cgal.org Quad-Edge Data Structure

12 http://www.cgal.org Halfedge Data Structure

13 http://www.cgal.org VE-Structure

14 http://www.cgal.org Halfedges Require: Oriented surface Idea: Consider 2/4 ways of accessing an edge

15 http://www.cgal.org Halfedge Associated with: 1 vertex1 vertex 1 edge1 edge 1 facet1 facet 3 references: vertexvertex opposite halfedgeopposite halfedge facetfacet

16 http://www.cgal.org Halfedges Geometry: verticesverticesAttributes: on verticeson vertices on halfedgeson halfedges on facetson facetsConnectivity: halfedges onlyhalfedges only

17 http://www.cgal.org Building Blocks

18 http://www.cgal.org

19 http://www.cgal.org Polyhedral Surfaces Building blocks assembled with C++ templates

20 http://www.cgal.org Polyhedral Surface

21 http://www.cgal.org Default Polyhedron

22 http://www.cgal.org typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_3 Point_3; typedef CGAL::Polyhedron_3 Polyhedron; typedef Polyhedron::Vertex_iterator Vertex_iterator; int main() { Point_3 p( 1.0, 0.0, 0.0); Point_3 p( 1.0, 0.0, 0.0); Point_3 q( 0.0, 1.0, 0.0); Point_3 q( 0.0, 1.0, 0.0); Point_3 r( 0.0, 0.0, 1.0); Point_3 r( 0.0, 0.0, 1.0); Point_3 s( 0.0, 0.0, 0.0); Point_3 s( 0.0, 0.0, 0.0); Polyhedron P; Polyhedron P; P.make_tetrahedron( p, q, r, s); P.make_tetrahedron( p, q, r, s); for (Vertex_iterator v = P.vertices_begin(); for (Vertex_iterator v = P.vertices_begin(); v != P.vertices_end(); ++v) v != P.vertices_end(); ++v) std::cout point() point() << std::endl;}

23 http://www.cgal.org Flexible Data Structure

24 http://www.cgal.org Flexible Polyhedral Surfaces template < class PolyhedronTraits_3, class PolyhedronTraits_3, class PolyhedronItems_3 = CGAL::Polyhedron_items_3, class PolyhedronItems_3 = CGAL::Polyhedron_items_3, template template class HalfedgeDS = CGAL::HalfedgeDS_default, class HalfedgeDS = CGAL::HalfedgeDS_default, class Alloc = CGAL_ALLOCATOR(int)> class Alloc = CGAL_ALLOCATOR(int)> class Polyhedron_3;

25 http://www.cgal.org Default Polyhedron typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_3 Point_3; typedef CGAL::Polyhedron_3 Polyhedron; typedef Polyhedron::Vertex_iterator Vertex_iterator; int main() { Point_3 p( 1.0, 0.0, 0.0); Point_3 p( 1.0, 0.0, 0.0); Point_3 q( 0.0, 1.0, 0.0); Point_3 q( 0.0, 1.0, 0.0); Point_3 r( 0.0, 0.0, 1.0); Point_3 r( 0.0, 0.0, 1.0); Point_3 s( 0.0, 0.0, 0.0); Point_3 s( 0.0, 0.0, 0.0); Polyhedron P; Polyhedron P; P.make_tetrahedron( p, q, r, s); P.make_tetrahedron( p, q, r, s); for ( Vertex_iterator v = P.vertices_begin(); for ( Vertex_iterator v = P.vertices_begin(); v != P.vertices_end(); ++v) v != P.vertices_end(); ++v) std::cout point() point() << std::endl;}

26 http://www.cgal.org Euler Operators Preserve the Euler-Poincaré equationPreserve the Euler-Poincaré equation Abstract from direct pointer manipulationsAbstract from direct pointer manipulations Halfedge_handle P.split_facet(Halfedge_handle h,Halfedge_handle g)

27 http://www.cgal.org Euler Operators Halfedge_handle P.split_vertex ( Halfedge_handle h, Halfedge_handle g Halfedge_handle P.join_vertex ( Halfedge_handle h)

28 http://www.cgal.org Euler Operators

29 http://www.cgal.org Modifying the Genus

30 http://www.cgal.org Modifying Facets & Holes

31 http://www.cgal.org Create a Cube with Euler Operator Halfedge_handle h = P.make_tetrahedron( Point(1,0,0), Point(0,0,1), Point(1,0,0), Point(0,0,1), Point(0,0,0), Point(0,1,0)); Point(0,0,0), Point(0,1,0)); Halfedge_handle g = h->next()->opposite()->next(); (a)

32 http://www.cgal.org Create a Cube with Euler Operator Halfedge_handle h = P.make_tetrahedron( Point(1,0,0), Point(0,0,1), Point(1,0,0), Point(0,0,1), Point(0,0,0), Point(0,1,0)); Point(0,0,0), Point(0,1,0)); Halfedge_handle g = h->next()->opposite()->next(); (a) P.split_edge( h->next()); P.split_edge( g->next()); P.split_edge( g); (b)

33 http://www.cgal.org Create a Cube with Euler Operator h->next()->vertex()->point() = Point( 1, 0, 1); g->next()->vertex()->point() = Point( 0, 1, 1); g->opposite()->vertex()->point() = Point( 1, 1, 0); (c)

34 http://www.cgal.org Create a Cube with Euler Operator h->next()->vertex()->point() = Point( 1, 0, 1); g->next()->vertex()->point() = Point( 0, 1, 1); g->opposite()->vertex()->point() = Point( 1, 1, 0); (c) Halfedge_handle f = P.split_facet( g->next(), g->next()->next()->next()); (d) g->next()->next()->next()); (d)

35 http://www.cgal.org Create a Cube with Euler Operator h->next()->vertex()->point() = Point( 1, 0, 1); g->next()->vertex()->point() = Point( 0, 1, 1); g->opposite()->vertex()->point() = Point( 1, 1, 0); (c) Halfedge_handle f = P.split_facet( g->next(), g->next()->next()->next()); (d) g->next()->next()->next()); (d) Halfedge_handle e = P.split_edge( f); e->vertex()->point() = Point( 1, 1, 1); (e)

36 http://www.cgal.org Create a Cube with Euler Operator h->next()->vertex()->point() = Point( 1, 0, 1); g->next()->vertex()->point() = Point( 0, 1, 1); g->opposite()->vertex()->point() = Point( 1, 1, 0); (c) Halfedge_handle f = P.split_facet( g->next(), g->next()->next()->next()); (d) g->next()->next()->next()); (d) Halfedge_handle e = P.split_edge( f); e->vertex()->point() = Point( 1, 1, 1); (e) P.split_facet( e, f->next()->next()); (f)

37 http://www.cgal.org Extending Primitives typedef CGAL::Polyhedron_3< Traits, CGAL::Polyhedron_items_3, CGAL::HalfedgeDS_default> Polyhedron; class Polyhedron_items_3 { public: template template struct Vertex_wrapper { typedef typename Traits::Point_3 Point; typedef CGAL::HalfedgeDS_vertex_base Vertex; }; template template struct Halfedge_wrapper { typedef CGAL::HalfedgeDS_halfedge_base Halfedge; }; template template struct Face_wrapper { typedef typename Traits::Plane_3 Plane; typedef CGAL::HalfedgeDS_face_base Face; };};

38 http://www.cgal.org Add Color to Facets template template struct CFace : public CGAL::HalfedgeDS_face_base { CGAL::Color color; CGAL::Color color;}; //... typedef CGAL::Simple_cartesian Kernel; typedef CGAL::Polyhedron_3 Polyhedron; typedef Polyhedron::Halfedge_handle Halfedge_handle; int main() { Polyhedron P; Polyhedron P; Halfedge_handle h = P.make_tetrahedron(); Halfedge_handle h = P.make_tetrahedron(); h->facet()->color = CGAL::RED; h->facet()->color = CGAL::RED; return 0; return 0;}

39 http://www.cgal.org Add Color to Facets template template struct CFace : public CGAL::HalfedgeDS_face_base { CGAL::Color color; CGAL::Color color;}; struct CItems : public CGAL::Polyhedron_items_3 { template template struct Face_wrapper { struct Face_wrapper { typedef CFace Face; typedef CFace Face; }; };}; typedef CGAL::Simple_cartesian Kernel; typedef CGAL::Polyhedron_3 Polyhedron;

40 http://www.cgal.org Add Vertex_handle to Facets template template struct VFace : public CGAL::HalfedgeDS_face_base { typedef typename Refs::Vertex_handle Vertex_handle; typedef typename Refs::Vertex_handle Vertex_handle; Vertex_handle vertex_ref; Vertex_handle vertex_ref;};

41 http://www.cgal.org Incremental Builder Uses the modifier design to access the internal HDSUses the modifier design to access the internal HDS

42 http://www.cgal.org Make Triangle with Incremental Builder template template struct Mk_triangle : public CGAL::Modifier_base { void operator()( HDS& hds) {// Postcond: ‘hds' valid void operator()( HDS& hds) {// Postcond: ‘hds' valid CGAL::Polyhedron_incremental_builder_3 B(hds); CGAL::Polyhedron_incremental_builder_3 B(hds); B.begin_surface( 3, 1, 6); B.begin_surface( 3, 1, 6); typedef typename HDS::Vertex Vertex; typedef typename HDS::Vertex Vertex; typedef typename Vertex::Point Point; typedef typename Vertex::Point Point; B.add_vertex( Point( 0, 0, 0)); B.add_vertex( Point( 0, 0, 0)); B.add_vertex( Point( 1, 0, 0)); B.add_vertex( Point( 1, 0, 0)); B.add_vertex( Point( 0, 1, 0)); B.add_vertex( Point( 0, 1, 0)); B.begin_facet(); B.begin_facet(); B.add_vertex_to_facet( 0); B.add_vertex_to_facet( 0); B.add_vertex_to_facet( 1); B.add_vertex_to_facet( 1); B.add_vertex_to_facet( 2); B.add_vertex_to_facet( 2); B.end_facet(); B.end_facet(); B.end_surface(); B.end_surface(); }};

43 http://www.cgal.org Make Triangle with Incremental Builder main() { Polyhedron P; Polyhedron P; Mk_triangle triangle; Mk_triangle triangle; P.delegate( triangle); P.delegate( triangle); return 0; return 0;}

44 http://www.cgal.org Traversal

45 http://www.cgal.org Iterators

46 http://www.cgal.org Iterators and Circulators

47 http://www.cgal.org Iteration Vertex_iterator iter; for(iter = polyhedron.vertices_begin(); iter != polyhedron.vertices_end(); iter++){ Vertex_handle hVertex = iter; // do something with hVertex }

48 http://www.cgal.org Circulation // circulate around hFacet Halfedge_around_facet_circulator circ = hFacet->facet_begin(); Halfedge_around_facet_circulator end = circ; CGAL_For_all(circ,end){ Halfedge_handle hHalfedge = circ; // do something with hHalfedge }

49 http://www.cgal.org Circulation // circulate around hVertex Halfedge_around_vertex_circulator circ = hVertex->vertex_begin(); Halfedge_around_vertex_circulator end = circ; CGAL_For_all(circ,end){ Halfedge_handle hHalfedge = circ; // do something with hHalfedge }

50 http://www.cgal.org File I/O I/O: OFF indexed format Output: vrml1-2, iv, geomview OFF 6 6 0 0.000000 1.686000 0.000000 1.192000 0.000000 -1.192000 -1.192000 0.000000 -1.192000 -1.192000 0.000000 1.192000 1.192000 0.000000 1.192000 0.000000 -1.68600 0.000000 3 0 4 1 3 1 5 2 3 2 3 0 3 1 2 0 3 3 4 0 3 3 2 5

51 http://www.cgal.org Applications RenderingRendering Subdivision SurfacesSubdivision Surfaces Algorithms on MeshesAlgorithms on Meshes –Simplification –Approximation –Remeshing –Smoothing –Compression Etc.Etc.

52 http://www.cgal.org Warm-Up Exercices

53 http://www.cgal.org Highlight Boundary Edges Notes: bool halfedge->is_border(); // change color ::glColor3f(r,g,b); // in [0.0f-1.0f] // Assemble primitive

54 http://www.cgal.org Render all Facets as Polygons typedef Polyhedron::Facet_iterator Facet_iterator; typedef Polyhedron::Halfedge_around_facet_circulator Halfedge_facet_circulator; Halfedge_facet_circulator; for (Facet_iterator i = P.facets_begin(); i != P.facets_end(); i != P.facets_end(); ++i) ++i){ Halfedge_facet_circulator j = i->facet_begin(); Halfedge_facet_circulator j = i->facet_begin(); ::glBegin(GL_POLYGON); ::glBegin(GL_POLYGON); do do ::glVertex3d(j->vertex()->point().x(), ::glVertex3d(j->vertex()->point().x(), j->vertex()->point().y(), j->vertex()->point().y(), j->vertex()->point().z()); j->vertex()->point().z()); while( ++j != i->facet_begin()); while( ++j != i->facet_begin()); ::glEnd(); ::glEnd();}

55 http://www.cgal.org Exercices Around Combinatorics

56 http://www.cgal.org Combinatorial Genus Enumerate connected componentsEnumerate connected components Enumerate boundariesEnumerate boundaries Deduce genus using Euler formulaDeduce genus using Euler formula

57 http://www.cgal.org Exercices Around Geometry

58 http://www.cgal.org Discrete Laplacian

59 http://www.cgal.org valence(vertex)

60 http://www.cgal.org int nbv = size_of_vertices(); std::vector dx(nbv); iterate on vertices dx[i] = Vector_3(0,0,0); // init circulate around current vertex... // (compute displacements) iterate on vertices apply displacements

61 http://www.cgal.org Advanced

62 http://www.cgal.org Dualization primal dual

63 http://www.cgal.org Dualization using Incremental Builder


Download ppt "3D Polyhedral Surfaces in Pierre Alliez."

Similar presentations


Ads by Google