Data Structure of Triangle Meshes

Slides:



Advertisements
Similar presentations
EXAMPLES (Arrays). Example Many engineering and scientific applications represent data as a 2-dimensional grid of values; say brightness of pixels in.
Advertisements

Introduction to Graph Theory Instructor: Dr. Chaudhary Department of Computer Science Millersville University Reading Assignment Chapter 1.
Map Overlay Algorithm. Birch forest Wolves Map 1: Vegetation Map 2: Animals.
Review Binary Search Trees Operations on Binary Search Tree
CompSci 102 Discrete Math for Computer Science April 19, 2012 Prof. Rodger Lecture adapted from Bruce Maggs/Lecture developed at Carnegie Mellon, primarily.
Data Structures Using C++
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 CHAPTER 4 - PART 2 GRAPHS 1.
One of the most important problems is Computational Geometry is to find an efficient way to decide, given a subdivision of E n and a point P, in which.
Overlay of Two Subdivisions
CS447/ Realistic Rendering -- Solids Modeling -- Introduction to 2D and 3D Computer Graphics.
Convex Grid Drawings of 3-Connected Plane Graphs Erik van de Pol.
Connected Components, Directed Graphs, Topological Sort Lecture 25 COMP171 Fall 2006.
Point Location Computational Geometry, WS 2007/08 Lecture 5 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für.
CS 106 Introduction to Computer Science I 03 / 03 / 2008 Instructor: Michael Eckmann.
Alyce Brady CS 510: Computer Algorithms Depth-First Graph Traversal Algorithm.
PA1 Supplementary notes 1 Programming assignment You need to implement the following: 1. Display basic mesh Information Find the number of vertices, edges,
Lecture 6: Point Location Computational Geometry Prof. Dr. Th. Ottmann 1 Point Location 1.Trapezoidal decomposition. 2.A search structure. 3.Randomized,
Connected Components, Directed graphs, Topological sort COMP171 Fall 2005.
Graph Implementations Chapter 29 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
CS CS 175 – Week 4 Triangle Mesh Smoothing Discrete Differential Geometry.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 20: Binary Trees.
Course notes CS2606: Data Structures and Object-Oriented Development Graphs Department of Computer Science Virginia Tech Spring 2008 (The following notes.
Mesh Representation, part I
UNC Chapel Hill M. C. Lin Point Location Reading: Chapter 6 of the Textbook Driving Applications –Knowing Where You Are in GIS Related Applications –Triangulation.
4/15/04© University of Wisconsin, CS559 Spring 2004 Last Time More modeling: –Hierarchical modeling –Instancing and Parametric Instancing –Constructive.
Manuel Mesters - Subdivision Surfaces computer graphics & visualization Seminar Computer Graphics Geometric representation and processing: Subdivision.
CSEB114: PRINCIPLE OF PROGRAMMING Chapter 8: Arrays.
CS200 Algorithms and Data StructuresColorado State University Part 10. Graphs CS 200 Algorithms and Data Structures 1.
1 Chapter Elementary Notions and Notations.
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.
Lecture 14 Graph Representations. Graph Representation – How do we represent a graph internally? – Two ways adjacency matrix list – Adjacency Matrix For.
ANALYSIS AND IMPLEMENTATION OF GRAPH COLORING ALGORITHMS FOR REGISTER ALLOCATION By, Sumeeth K. C Vasanth K.
§3 Dynamic Programming 3. Optimal Binary Search Tree —— The best for static searching (without insertion and deletion) Given N words w 1 < w 2 < ……
Subdivision Schemes Basic idea: Start with something coarse, and refine it into smaller pieces for rendering –We have seen how subdivision may be used.
Chapter 8: Arrays Introduction to arrays Declaring arrays Initializing arrays Examples using arrays Relationship with pointers Array passing to a function.
Graphs. Definitions A graph is two sets. A graph is two sets. –A set of nodes or vertices V –A set of edges E Edges connect nodes. Edges connect nodes.
Many of the figures from this book may be reproduced free of charge in scholarly articles, proceedings, and presentations, provided only that the following.
Lee Byung-Gook Dongseo Univ.
1 Subdivision. 2 Subdivision for game Why? Large model require many memory for storage Need to dynamically tessellated during game play Make surface modeling.
Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Subdivision Surfaces Greg Humphreys University of Virginia CS 445, Fall 2003.
CS 106 Introduction to Computer Science I 03 / 02 / 2007 Instructor: Michael Eckmann.
Review Sorting algorithms Selection Sort Insertion Sort Bubble Sort Merge Sort Quick Sort.
Introducing Arrays. Too Many Variables?  Remember, a variable is a data structure that can hold a single value at any given time.  What if I want to.
February 17, 2005Lecture 6: Point Location Point Location (most slides by Sergi Elizalde and David Pritchard)
Great Theoretical Ideas in Computer Science for Some.
COMPSCI 102 Introduction to Discrete Mathematics.
ECE 250 Algorithms and Data Structures Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,
CS 202, Spring 2003 Fundamental Structures of Computer Science II Bilkent University1 Graph Algorithms CS 202 – Fundamental Structures of Computer Science.
Graphs A New Data Structure

3.1 Clustering Finding a good clustering of the points is a fundamental issue in computing a representative simplicial complex. Mapper does not place any.
Computational Geometry
Computer Graphics Filling.
CSE 373 Topological Sort Graph Traversals
Graph Traversals Some algorithms require that every vertex of a graph be visited exactly once. The order in which the vertices are visited may be important,
Chapter 28 Weighted Graphs and Applications
Data Structure of Triangle Meshes
Graph Implementations
Lecture 3 : Isosurface Extraction
Volume Graphics (lecture 4 : Isosurface Extraction)
Fundamental Structures of Computer Science II
By Yogesh Neopaney Assistant Professor Department of Computer Science
3D Modeling, Graphics, and Animation
Data Structures & Algorithms
Fundamental Structures of Computer Science II
Discrete Mathematics for Computer Science
22C:21 Problem 2.3 Solution Outline.
Chapter 9 Graph algorithms
Last Time B-splines Project 3 was made available
Presentation transcript:

Data Structure of Triangle Meshes Yutaka Ohtake Department of Precision Engineering The University of Tokyo

Contents Adjacent vertex lists Adjacent face lists Face mates Example of usage : computing Laplacians Adjacent face lists Example of usage : computing vertex normals Face mates Example of usage : linear subdivision

Adjacent Vertex Lists (vertex-to-vertices) At each vertex, we store the neighboring vertices. List 0 : {1,5,6,7} List 1 : {5,2,0} … (Please complete here) 1 2 5 6 7 3 4 8

Data Structure Two dimensional array with varying their lengths. int *listSizes; int **adLists; void printAdjacentList(int i){ int size = listSizes[i]; int* list = adLists[i]; for(int j=0; j<size; j++){ printf(“%d-th vertex is adjacent to %d-th vertex\n”, list[j], i); }

Algorithm of List Construction For each triangle (A, B, C) Append A to B's list Append B to C's list Append C to A's list Actually, the above can not compute the correct lists in some cases. Please indicate such cases.

Implementation (For the people who do not like std::vector) 1. Count the size of lists for memory allocation. listSizes = new int[numVertices]; for(int i=0; i<numVertices; i++) listSizes[i] = 0; for(int i=0; i<numTriangles; i++) for(int j=0; j<3; j++) listSizes[triangles[i][j]]++; adLists = new int*[numVertices]; for(int i=0; i<numVertices; i++){ adLists[i] = new int[listSizes[i]]; } 2. Construct the list. for(int i=0; i<numTriangles; i++){ int* t = triangles[i]; for(int j=0; j<3; j++) adLists[t[j]][listSizes[t[j]]++] = t[(j+1)%3]; }

Computing Laplacians (Re-visited) Using adjacent vertex lists, you can compute Laplacian at a vertex without traversing all triangles. Please re-implement Laplacian smoothing by using adjacent lists

Contents Adjacent vertex lists Adjacent face lists Face mates Example of usage : computing Laplacians Adjacent face lists Example of usage : computing vertex normals Face mates Example of usage : linear subdivision

Adjacent Face Lists (vertex-to-faces) At each vertex, we store the neighboring triangles. List 0 : {0,4,5} List 1 : {1,0} … (Please complete here) 1 2 1 5 4 2 5 3 6 7 3 6 8 7 4 8

Data Structure Same as vertex-to-vertices list. int *listSizes; int **adLists; void printAdjacentList(int i){ int size = listSizes[i]; int* list = adLists[i]; for(int j=0; j<size; j++){ printf(“%d-th triangle is adjacent to %d-th vertex\n”, list[j], i); }

Algorithm of List Construction For each triangle (A, B, C) Append the triangle ID to B's list Append the triangle ID to C's list Append the triangle ID to A's list Please implement the above. Then re-implement vertex normal computation by using the list for vertex-to-triangles.

Contents Adjacent vertex lists Adjacent face lists Face mates Example of usage : computing Laplacians Adjacent face lists Example of usage : computing vertex normals Face mates Example of usage : linear subdivision

Face mates (face-to-faces) At each triangle, we store the three triangles sharing the edges. 9 0-th triangle (0,3,1): [4,9,1] 1-st triangle (0,4,3): [2,0,-1] … (Please complete here) 9 4 1 1 3 4 2 5 3 2 8 5 6 8 7 6 7 No mate

Algorithm of Mate Construction Construct the adjacent face lists. For the i-th triangle (A,B,C) Set mate for A to the triangle (not i-th) containing B in the C's list Set mate for B to the triangle (not i-th) containing C in the A's list Set mate for C to the triangle (not i-th) containing A in the B's list C i Mate for A A B

Vertex ID to be searched Implementation int (*mates)[3]; void constructFaceMates(){ constructAdjacentFaceLists(); mates = new int[numTriangles][3]; for(int i=0; i<numTriagles; i++){ for(int j=0; j<3; j++){ mate[i][j] = -1; int v = triangles[i][(j+1)%3]; int size = listSizes[triangles[i][(j+2)%3]]; int* list = adLists[triangles[i][(j+2)%3]]; for(int k=0; k<size; k++){ if(list[k] == i) continue; int *tk = triangles[list[k]]; if(tk[0] == v || tk[1] == v || tk[2] == v){ mate[i][j] = list[k]; break; } Vertex ID to be searched

Edges Let’s consider only 2-manifold meshes Edges are shared by one or two triangles Inner edge (shared by two triangles) Boundary edge (shared by one triangles) Non-manifold edge (shared by more than tree triangles) We can identify them using mate data.

Counting Edges Please complete the function for counting edges. int numEdges; void countEdges(){ constructFaceMates(); numEdges = 0; //Increment #edges by traversing mates for(int i=0; i<numTriangles; i++){ //??? }

Assigning Edge IDs to Triangles From each triangle, we store the three edge IDs. Numbering edges are not unique. 8 0-th triangle (5,4,2): [5,4,1] 1-st triangle (6,5,2): [4,10,7] … (Please complete here) 1 6 3 2 9 3 2 11 5 3 5 7 4 6 1 1 4 10 4 5 2

Assigning Edge IDs Please complete the function for assigning edge IDs. int (*edgeIDs)[3]; int numEdges; void assignEdgeIDs(){ constructFaceMates(); numEdges = 0; edgeIDs = new int[numTriangles][3]; for(int i=0; i<numTriangles; i++){ //??? } HINT : you can do it together with counting #edges.

1-to-4 linear subdivision Mesh Subdivision Triangles are subdivided using a certain rule. 1-to-4 linear subdivision

#vertices and #triangles after 1-to-4 subdivision #(new triangles) = 4 times #(old triangles) #(new vertices) = #(old vertices) + #(old edges) Old mesh New mesh

Vertex IDs of New Mesh ID of a new vertex on an old edge = ID of the old edge + #(old vertices) Denoted by V A Subdivided four triangles (A, D+V, E+V) … (Please complete here) D E B F C

Algorithm of 1-to-4 Linear Subdivision Compute edge IDs with counting #edges Allocate memory for the new vertices and triangles Compute the new vertex positions Create the new triangles Update the mesh data

Implementation //Step 1. assignEdgeIDs(); //Step 2. float (*newVerteces)[3] = new float[numVertices + numEdges]; int (*newTriangles)[3] = new int[4*numTriangles]; //Step 3. (Complete here) //Step 4. (Complete here) //Step 5. delete[] vertices; delete[] triangles; vertices = newVertices; triangles = newTriangles; numVertices += numEdges; numTriangles *= 4;