Strips: Triangle and Quad Jyun-Ming Chen Reference: 1, 212.

Slides:



Advertisements
Similar presentations
CSE 211 Discrete Mathematics
Advertisements

Chapter 5: Tree Constructions
Lecture 15. Graph Algorithms
Algorithms (and Datastructures) Lecture 3 MAS 714 part 2 Hartmut Klauck.
Great Theoretical Ideas in Computer Science
Chapter 8 Topics in Graph Theory
CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
Introduction to Graph Theory Instructor: Dr. Chaudhary Department of Computer Science Millersville University Reading Assignment Chapter 1.
22C:19 Discrete Math Graphs Fall 2014 Sukumar Ghosh.
Graph-02.
Introduction to Graphs
Minimum Spanning Tree Sarah Brubaker Tuesday 4/22/8.
CS 206 Introduction to Computer Science II 03 / 27 / 2009 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 11 / 07 / 2008 Instructor: Michael Eckmann.
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
Compressing the Property Mapping of Polygon Meshes Martin Isenburg Jack Snoeyink University of North Carolina at Chapel Hill.
CS 206 Introduction to Computer Science II 11 / 05 / 2008 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 03 / 25 / 2009 Instructor: Michael Eckmann.
ECE669 L10: Graph Applications March 2, 2004 ECE 669 Parallel Computer Architecture Lecture 10 Graph Applications.
ECE 250 Algorithms and Data Structures Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,
Discrete Mathematics Lecture 9 Alexander Bukharovich New York University.
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley.
C o n f i d e n t i a l HOME NEXT Subject Name: Data Structure Using C Unit Title: Graphs.
GRAPH Learning Outcomes Students should be able to:
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Surface Simplification Using Quadric Error Metrics Michael Garland Paul S. Heckbert.
Graph Theoretic Concepts. What is a graph? A set of vertices (or nodes) linked by edges Mathematically, we often write G = (V,E)  V: set of vertices,
Graph Theory Topics to be covered:
COSC 2007 Data Structures II Chapter 14 Graphs III.
© 2015 JW Ryder CSCI 203 Data Structures1. © 2015 JW Ryder CSCI 203 Data Structures2.
Mesh Data Structure. Meshes Boundary edge: adjacent to 1 face Regular edge: adjacent to 2 faces Singular edge: adjacent to >2 faces Mesh: straight-line.
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
Image Synthesis Rabie A. Ramadan, PhD 1. 2 About my self Rabie A. Ramadan My website and publications
Unit – V Graph theory. Representation of Graphs Graph G (V, E,  ) V Set of vertices ESet of edges  Function that assigns vertices {v, w} to each edge.
1.5 Graph Theory. Graph Theory The Branch of mathematics in which graphs and networks are used to solve problems.
CIRCUITS, PATHS, AND SCHEDULES Euler and Königsberg.
Graphs. Graphs Similar to the graphs you’ve known since the 5 th grade: line graphs, bar graphs, etc., but more general. Those mathematical graphs are.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 13: Graphs Data Abstraction & Problem Solving with C++
© 2006 Pearson Addison-Wesley. All rights reserved 14 A-1 Chapter 14 Graphs.
Introduction to Graph Theory Lecture 17: Graph Searching Algorithms.
Graphs. Graph Definitions A graph G is denoted by G = (V, E) where  V is the set of vertices or nodes of the graph  E is the set of edges or arcs connecting.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
1 GRAPH Learning Outcomes Students should be able to: Explain basic terminology of a graph Identify Euler and Hamiltonian cycle Represent graphs using.
CSE 589 Applied Algorithms Spring 1999 Prim’s Algorithm for MST Load Balance Spanning Tree Hamiltonian Path.
1 GRAPHS – Definitions A graph G = (V, E) consists of –a set of vertices, V, and –a set of edges, E, where each edge is a pair (v,w) s.t. v,w  V Vertices.
Code: BCA302 Data Structures with C Prof. (Dr.) Monalisa Banerjee By.
Graphs. Representations of graphs : undirected graph An undirected graph G have five vertices and seven edges An adjacency-list representation of G The.
Graphs: Definitions and Basic Properties
Basic Concepts Graphs For more notes and topics visit:
Redraw these graphs so that none of the line intersect except at the vertices B C D E F G H.
Discrete Mathematicsq
SULE SOLMAZ BEYZA AYTAR
Topological Sort (topological order)
Discrete Maths 9. Graphs Objective
More Graph Algorithms.
Graph Algorithm.
Graph Theory.
Graphs Chapter 11 Objectives Upon completion you will be able to:
Outline This topic covers Prim’s algorithm:
Graphs Part 2 Adjacency Matrix
A path that uses every vertex of the graph exactly once.
Graphs.
ITEC 2620M Introduction to Data Structures
Chapter 15 Graphs © 2006 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley.
CSE 417: Algorithms and Computational Complexity
Euler circuit Theorem 1 If a graph G has an Eulerian path, then it must have exactly two odd vertices. Theorem 2 If a graph G has an Eulerian circuit,
Dominating Set By Eric Wengert.
GRAPHS.
Presentation transcript:

Strips: Triangle and Quad Jyun-Ming Chen Reference: 1, 212

CGTopics, Spring From Blue BookBlue Book GL_TRIANGLE_STRIP For odd n, vertices n, n+1, and n+2 define triangle n. For even n, vertices n+1, n, and n+2 define triangle n. GL_QUAD_STRIP Vertices 2n-1, 2n, 2n+2, and 2n+1 define quadrilateral n.

CGTopics, Spring Using Strips Reduce number of glVertex calls Each glVertex call send a data through pipeline: matrix multiplication, … 4  6v instead of 12v 3  : 8v instead of 12v In general, n  : (n+2) v n  : (2n+2) v In general, n  : (n+2) v n  : (2n+2) v

CGTopics, Spring Syntax Sequence of vertices: follow the arrows separating the triangles ac bd e f abcdef [abc,bcd,cde,def] [abc,cbd,cde,edf] alternate winding; interpret as …. GL_TRIANGLE_STRIP For odd n, vertices n, n+1, and n+2 define triangle n. For even n, vertices n+1, n, and n+2 define triangle n.

CGTopics, Spring Swap Sometimes, additional vertices need to be added (known as swap) a b d e f c [abc,cbd,cdc,cde,cef] abcdcef [abc,bcd,cdc,dce,cef] alternate winding A penalty: need one more vertex for the swap Swap is a penalty; but breaking into two strips is more costly

CGTopics, Spring Key Difference (swap) Common edges Head-tail connected: no swap Strut exists: swap! ac bd e f a b d e f c

CGTopics, Spring Fan: a strip with many swaps b c d e a bacadae (bac, aca, cad, ada, dae) The same geometry can be given by a triangle fan: aedcb

CGTopics, Spring Exercise How can this strip be made? a b d c f g h i j e Algorithmically, how does one construct a strip given a set of connected triangles?

CGTopics, Spring Other Topics of Triangle Strips Winding: determined by the first triangle Related: glFrontFace, glCullFace Shading: Smooth: specify normal vector preceding each vertex Flat: only send (face) normal before the face- defining vertex

CGTopics, Spring Example ac bd e f abcdef (4 , 6v) All triangles are CW-winded abcdef (4 , 6v) All triangles are CCW-winded a c b e d f

CGTopics, Spring Example (Swap) abcxcdef (5 , 8v) All triangles are CCW-winded a c b e d f x ac bd e f aabcdef (4 , 7v) All triangles are CCW-winded

CGTopics, Spring Example (flat shading) ac bd e f Begin v(a) v(b) n(T 1 ), v(c) n(T 2 ), v(d) n(T 3 ), v(e) n(T 4 ), v(f) End T1T1 T2T2 T3T3 T4T4

CGTopics, Spring Remark: Flat Shading According to spec, the color/normal of flat shaded polygon depends on the last primitive-defining vertex So the code should work fine if glShadeModel(GL_FLAT) is specified However, if the shade model is changed to GL_SMOOTH, the normal vectors will be assigned to either (0,0,1) or (-1,0,0) depending on the order of traversal. Be careful! This code can be problematic!

Stripification New word for “ strip generation ”

CGTopics, Spring Greedy Stripping (SGI) Each triangle associated with an adjacency number (degree in dual graph) Start from the triangle with lowest degree, collect along the path with uncollected & fewer degree triangle Tend to minimize leaving isolated triangles

Details (OpenMesh) Assign each face with the following integer property: degree (face valence); collected For triangular mesh, four possible values for degree: 0 (isolated), 1, 2, 3 No need to sort; just start from any triangle with degree 1. When exhausted, start with degree 2, then degree 3. Output degree 0 triangle as GL_TRIANGLES Collect the triangle.idx into an STL vector Degree update When a triangle is collected, decrement the degree of its neighbors CGTopics, Spring

CGTopics, Spring Degree Update

CGTopics, Spring Supplement Strip collection is related to finding Hamliton paths in the dual graph While a single Hamilton path seems impossible, longer strips are preferred (for better rendering speed) Wikipedia: In the mathematical field of graph theory, a Hamiltonian path (or traceable path) is a path in an undirected graph which visits each vertex exactly once.

CGTopics, Spring Stripification (Kommann) Starting triangle: one with least number of adjacency that are not part of any strip Idea: process isolated triangles first Step Evaluate the weight all neighboring triangles; choose the one with minimum weight to continue the strip

CGTopics, Spring Kommann (cont) Weight evaluation Face Connectivity: 0,1,2 (# of triangles not visited) – include poorly connected triangles first Node connectivity: use connectivity of nodes of the current triangle to decide which side to add: +1 for highest connected node, -1 for all other nodes Swap required: +1(yes), -1(no)

CGTopics, Spring Weight assignment References: 1, 212

CGTopics, Spring Strip for a Cube

CGTopics, Spring Quad strip Syntax Winding (consistent) Shading smooth shading: averaging vertex colors Flat shading: the color of the last defining vertex GL_QUAD_STRIP Vertices 2n-1, 2n, 2n+2, and 2n+1 define quadrilateral n. Compare GL_QUADS Vertices 4n-3, 4n-2, 4n-1, and 4n define quadrilateral n.

CGTopics, Spring Example (quadstrip) Quads are formed as (0,1,3,2) and (2,3,5,4) Using quadstrip: we give 0,1,2,3,4,5 Using quads: we need to give 0,1,3,2, 2,3,5,4

1. Add the vertices of the   (i=1) to the strip. From the “stand alone” vertex 2. Increment i, adding  i 3. Consider the existence of  i  If no, add the “ other v ” of  i If yes, find the common vertex between  i  &  i-1  If the common vertex is the last (tail) vertex in the strip, add the “ other v ” of  i  If not, add the common vertex to the strip (swap), then add the “ other v ” of  i 4. Proceed to step 2, until all triangles have been added CGTopics, Spring Algorithm: Strip construction Assuming all triangles are CCW-oriented i=1 Stand-alone

Step 1 Stand alone vertex Find the common vertices between D1 & D2 Take the one that’s left alone CGTopics, Spring

Step 3 Cases No Di+1 Add “other v” Di+1 (with swap) Di+1 (with no swap) CGTopics, Spring i-1 i other v i-1 i other v i+1 i-1 i other v i+1

CGTopics, Spring Example a b d c f g h i j e Add   acb Add   acbcd Add   acbcdce Add   acbcdcef Add   acbcdcefg Add   acbcdcefgh Add   acbcdcefghgi Add   acbcdcefghgij If the common vertex between  i  &  i-1 is not end of strip, swap is needed Input: triangles to be put in a strip (  1-8 ) Output: the vertices forming the strip (the 13 vertices)

CGTopics, Spring Remark The underlying data structure should be able to answer these queries efficiently Stand-alone vertex of triangle “ other-v ” of a triangle Common vertex of two triangles For Kommann stripification  Number of unvisited neighbors of a triangle  Number of triangles connecting to a vertex

[Tagging] CGTopics, Spring xxxx 0001 & 000x IsTagged ClearTag xxxx 1110 & xxx0 SetTag xxxx 0001 | xxx1 ToggleTag xxxx 0001 ^ xxxx A quicker way to find the intersection of two sets

Stripifier by OpenMesh OpenMesh/Tools/Utils The strips generated are not as good CGTopics, Spring

Stripifier CGTopics, Spring