Docsity

Algorithm for Converting Non-Manifold Curves to Manifold Polyloops in CS 6491 Project 2 - , Study Guides, Projects, Research of Computer Graphics

Toggle sidebar
bg1
CS 6491 – Theoretical Foundations and Practical Algorithms for 3d
Modeling, Graphics and Animation
PROJECT 2 – CLEANING OF USER DRAWN POLYLOOP
Sneha Chandrababu {[email protected]}
Revathi Balakrishnan{[email protected]}
1. OBJECTIVE
The user of the applet is allowed to draw a non manifold polyloop with a lot of self
intersections and fish tails on the tool draw area. The tool has to take the user through the
steps of execution converting this hand drawn non manifold curve to manifold polyloop with
all unnecessary loops and all intersections removed. Then the loops are re-sampled to
make the spacing uniform. The resulting 2D region R may have more than one components
and may have holes in the components.
2. METAPHOR
Each edge is a lane on the highway.
Each vertex is a landmark on the highway.
Each intersection is a crossing and is made a landmark.
A Tree edge is a unique lane leading to a new landmark.
A Back edge is a lane leading to an already visited landmark.
I take out the map of the place(map of polyloop) and mark all the crossings I need to
pass. These crossings are also inserted into my landmarks list at the proper order. I drive
down the highway and remember the lanes I travelled. As I drive I divide the lanes into two
sets of lanes. One set comprises of lanes that lead to new landmarks (tree edges). Another
set comprising of lanes leading to a landmark I’ve already seen (back edges).
Now I sit down and check out all the loops in the map using the landmarks, back
edges and tree edges. One unique property of tree edges is that its union does not give
any loops. And back edges give me the number of loops in the map. So to get each loop, I
pick a back edge and move along unique tree edges starting at one of the 2 landmarks of
the back edge and leading to the other landmark of the same back edge.
After getting this set of loops, I eliminate those loops that are too small when
compared to the other loops. Then I create a new landmark at the crossings of the
remaining loops such that I get isolated and disjoint loops in the map.
By starting to drive from each landmark iteratively I can get all the unique manifold
loops in the map.
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Algorithm for Converting Non-Manifold Curves to Manifold Polyloops in CS 6491 Project 2 - and more Study Guides, Projects, Research Computer Graphics in PDF only on Docsity!

CS 6491 – Theoretical Foundations and Practical Algorithms for 3d

Modeling, Graphics and Animation

PROJECT 2 – CLEANING OF USER DRAWN POLYLOOP

Sneha Chandrababu {[email protected]}

Revathi Balakrishnan{[email protected]}

1. OBJECTIVE

The user of the applet is allowed to draw a non manifold polyloop with a lot of self intersections and fish tails on the tool draw area. The tool has to take the user through the steps of execution converting this hand drawn non manifold curve to manifold polyloop with all unnecessary loops and all intersections removed. Then the loops are re-sampled to make the spacing uniform. The resulting 2D region R may have more than one components and may have holes in the components.

2. METAPHOR

Each edge is a lane on the highway. Each vertex is a landmark on the highway. Each intersection is a crossing and is made a landmark. A Tree edge is a unique lane leading to a new landmark. A Back edge is a lane leading to an already visited landmark.

I take out the map of the place(map of polyloop) and mark all the crossings I need to pass. These crossings are also inserted into my landmarks list at the proper order. I drive down the highway and remember the lanes I travelled. As I drive I divide the lanes into two sets of lanes. One set comprises of lanes that lead to new landmarks (tree edges). Another set comprising of lanes leading to a landmark I’ve already seen (back edges). Now I sit down and check out all the loops in the map using the landmarks, back edges and tree edges. One unique property of tree edges is that its union does not give any loops. And back edges give me the number of loops in the map. So to get each loop, I pick a back edge and move along unique tree edges starting at one of the 2 landmarks of the back edge and leading to the other landmark of the same back edge. After getting this set of loops, I eliminate those loops that are too small when compared to the other loops. Then I create a new landmark at the crossings of the remaining loops such that I get isolated and disjoint loops in the map. By starting to drive from each landmark iteratively I can get all the unique manifold loops in the map.

3. NOTATIONS & APPROACH

The entire map is considered as an undirected graph. The aim is to construct a directed graph with all the cycles identified by making use of the Depth-first search (DFS) algorithm from the starting point in the graph. If there exists a directed path in the tree from v1 to v2, then v1 is a predecessor (parent) of v2 and v2 is a descendant (child) of v. In one iteration through the vertices starting from one node, each child can have only one parent but one parent can have many children. A node-node adjacency structure is an n × n matrix such that entry aij = 1 if node i is adjacent to node j and 0 otherwise. A node-edge adjacency structure lists for each node, the nodes adjacent to it. Also the parent of each node is identified. A tree edge is a unique edge leading from a parent to a child node. A back edge is an edge from one node to an already visited node. Hence the union of all the tree edges gives a directed tree. The union of each back edge with a unique set of tree edges gives a cycle.

4. DATA STRUCTURES

Pt [ ] P is the array containing the non manifold polyloop in the order of vertices drawn by the user. Pt [ ] Pwithcrossings is the array containing to geometric values of the sampled points and the crossings. Int[ ] Porderedindex is the array of index ids of Pwithcrossings after inserting vertices at the intersecting edges. Int[ ][ ] TreeEdge is the array of edges in the polyloop which do not make any cycles. Int[ ][ ] BackEdge[][] is the array of edges in the polyloop which represent the cycles in the polyloop. int[ ][ ] VertexAdjacencyMatrix contains the list of adjacent vertices for each vertex. Also it has info of whether a vertex is visited and the parent of each vertex. Float[ ] AreaofLoops is the array of cycle areas along with the orientation of the loops(+ve or –ve). Boolean[ ] LooptobeRemoved contains info of which loops are to be retained and which are to be removed.

5. ALGORITHM 1. Get the sampling points of the polyloop in an array say Points. 2. Walk through Points and compute the intersections. a. For each edge (Points[i], Points[i+1]) in the array check if it intersects with any of the previous edges. b. If there is an intersection, increment the number of points in the array and insert the new point in between both the current edge and the intersecting edge.

b. Pick a different color for each loop and color the loop.

  1. Repeat steps [5-7] iteratively for each of the computed loops till all the loops are manifold. [1]
  2. Compute the area of the loops. a. It is the sum of the signed areas of trapezoids between each oriented edge and its orthogonal projection (shadow) on the x-axis

x

a

b

ax b (^) x

ay

by

area( a , b ):=(ay+by)(bx –ax)/

  1. Crop the loops that are too small. a. Compute the total area of all the loops. b. Find the ratio of the area of the loop i and the area of all the loops. c. If the ratio is less than .1 mark the loop as removed. Don’t draw this loop.
  2. Separate the intersection points of the loops that are remaining by inserting a new point which is the average of the neighboring points of the intersecting point in each loop.
  3. Resample the manifold loops and color the interior of the loop areas without the holes a. Find the relative position of each loop that is remaining w.r.t the neighboring loops(ray tracing) and paint them depending on whether it is contained within a bigger loop(hole) or not. 7. IMPLEMENTATION

Let us go step by step on how this algorithm works on the following loop: a. The sampling points are stored in array P[ ]. b. We store the order of vertices from P[ ] to array Porderedindex[ ] and the geometry of the vertices in Pwithcrossings [ ]. c. We iterate through Porderedindex and do edge/edge intersection test and compute the intersections in the polyloop.

Fig 1: User drawn polyloop

Porderedindex [0]= 0

Porderedindex [1]= 1

Porderedindex [2]= 16

Porderedindex[3]= 2 Porderedindex[4]= 3 Porderedindex[5]= 4 Porderedindex[6]= 5 Porderedindex[7]= 6 Porderedindex[8]= 7 Porderedindex[9]= 8 Porderedindex[10]= 9 Porderedindex[11]= 10 Porderedindex[12]= 11 Porderedindex[13]= 16 Porderedindex[14]= 12 Porderedindex[15]= 13 Porderedindex[16]= 14 Porderedindex[17]= 15

ADJACENCY MATRIX

Point Visited Parent Adj 1 Visited Adj 2 Visited Adj 3 Visited Adj 4 Visited 0 1 15 1 1 15 0 - - - - 1 1 0 16 1 0 0 - - - - 2 1 16 3 1 16 0 - - - - 3 1 2 4 1 2 0 - - - - 4 1 3 5 1 3 0 - - - - 5 1 4 6 1 4 0 - - - - 6 1 5 7 1 5 0 - - - - 7 1 6 8 1 6 0 - - - - 8 1 7 9 1 7 0 - - - - 9 1 8 10 1 8 0 - - - - 10 1 9 11 1 9 0 - - - - 11 1 10 16 1 10 0 - - - - 12 1 16 13 1 16 0 - - - - 13 1 12 14 1 12 0 - - - - 14 1 13 15 1 13 0 - - - -

Fig 2: Polyloop with Intersection point as

E1interE2 = !((P[i].rightContained(P[j], P[(j+1)%vn]) && P[(i+1)%vn].rightContained(P[j], P[(j+1)%vn])) || (!P[i].rightContained(P[j], P[(j+1)%vn]) && !P[(i+1)%vn].rightContained(P[j], P[(j+1)%vn])));

9. DEBUGGING TOOLS

 All code written for these functionality is within the comment lines:

/Reva & Sne Code Starts/

/Reva & Sne Code Ends/

 If the code is run in the processing tool, further debug prints can be enabled.  The oriented area of all loops is printed on the top left of the applet.  The Vertex id’s of intersections are displayed with “showIntersections” toggle.  Sufficient help is provided in the first screen of the applet.

It shows all the vertices of the

polyloop.

Removes the loops with smaller area

and refines the intersections

It shows all the vertex ID of the

polyloop.

It shows all loops in different colors.

It shows all intersections of the

polyloop as large red/black points.

10. LINK TO THE REPORT, APPLET & SOURCE CODE

http://www.coc.gatech.edu/~revavare/MyHomepage/CompGraph/CS6491.html

11. LIMITATIONS IN IMPLEMENTATION

There are some limitations in the implementation of the cleaning up of the algorithm:

1. Merge vertices & Split Edges at Vertices This is a good feature that removes ambiguities by merging vertices that are too close or overlapping and splitting edges at a vertex very near it. 2. Coloring the manifold loops (holes). This feature assumes that the polyloop after cleaning is the boundary of a polygon S and colors the interior of S. This can be done by ray tracing to find out whether any loop is a hole in the polygon. 3. Iterative calling of this algorithm for each polyloop. By iteratively calling this algorithm for each resulting polyloop we can get hold of all the possible cycles in the user drawn polyloop. If there are common edges between two loops single iteration wouldn’t identify all the loops correctly. The following star shaped loop represents this limitation:

12. REFERENCES

[1] “Cycles in an Undirected Graph” https://www.me.utexas.edu/~bard/IP/Handouts/cycles.pdf

[2] “2D Geometry for Computer Graphics", Jarek Rossignac,2006.

[3] “Polyloop Curves for Computer Graphics”,Jarek Rossignac, 2006.

[4] “2D Topology for Computer Graphics”, Jarek Rossignac, 2006.

[5] Basic Linear Algebra , by Dan Sunday, softSurfer.com

[6] Intersection of Lines, Segments and Planes(2D and 3D)

http://www.geometryalgorithms.com/Archive/algorithm_0104/algorithm_0104B.htm