p l polygon filling filli
play

P l Polygon Filling Filli Werner Purgathofer Werner Purgathofer - PowerPoint PPT Presentation

Einfhrung in Visual Computing g p g 186.822 P l Polygon Filling Filli Werner Purgathofer Werner Purgathofer Linked Lists fl flexible data structure ibl d x 1 x 2 pointer data (link to next element) (link to next element) list^


  1. Einführung in Visual Computing g p g 186.822 P l Polygon Filling Filli Werner Purgathofer Werner Purgathofer

  2. Linked Lists fl flexible data structure ibl d … x 1 x 2 pointer data (link to next element) (link to next element) list^ list^.next^ list … … … x 1 x 2 x 1 x 2 x 1 x 2 list^.next list^.next^.next Werner Purgathofer / Einf. in Visual Computing 2

  3. Linked Lists: Removal of First Element list 1 1 2 2 3 3 4 4 5 5 list = list^.next Werner Purgathofer / Einf. in Visual Computing 3

  4. Linked Lists: Inserting New First Element g list 1 1 2 2 3 3 4 4 5 5 new 0 new^.next = list Werner Purgathofer / Einf. in Visual Computing 4

  5. Linked Lists: Inserting New 1 st Element g list 1 1 2 2 3 3 4 4 5 5 new 0 new^.next = list list = new Werner Purgathofer / Einf. in Visual Computing 5

  6. Linked Lists: Exchanging Elements 2 & 4 g g help last2 last1 list list 1 2 3 4 5 help = last1^ next^ next help = last1 .next .next Werner Purgathofer / Einf. in Visual Computing 6

  7. Linked Lists: Exchanging Elements 2 & 4 g g help last2 last1 list list 1 2 3 4 5 help = last1^ next^ next help = last1 .next .next last1^.next^.next = last2^.next^.next Werner Purgathofer / Einf. in Visual Computing 7

  8. Linked Lists: Exchanging Elements 2 & 4 g g help last2 last1 list list 1 2 3 4 5 help = last1^ next^ next help = last1 .next .next last1^.next^.next = last2^.next^.next last2^.next^.next = help Werner Purgathofer / Einf. in Visual Computing 8

  9. Linked Lists: Exchanging Elements 2 & 4 g g help last2 last1 list list 1 2 3 4 5 help = last1^ next^ next help = last1 .next .next last1^.next^.next = last2^.next^.next last2^.next^.next = help help = last1^.next Werner Purgathofer / Einf. in Visual Computing 9

  10. Linked Lists: Exchanging Elements 2 & 4 g g help last2 last1 list list 1 2 3 4 5 help = last1^ next^ next help = last1 .next .next last1^.next^.next = last2^.next^.next ast . e t . e t ast . e t . e t last2^.next^.next = help help = last1^.next l last1^.next = last2^.next 1^ l 2^ Werner Purgathofer / Einf. in Visual Computing 10

  11. Linked Lists: Exchanging Elements 2 & 4 g g help last2 last1 list list 1 2 3 4 5 help = last1^ next^ next help = last1 .next .next last1^.next^.next = last2^.next^.next ast . e t . e t ast . e t . e t last2^.next^.next = help help = last1^.next l last1^.next = last2^.next 1^ l 2^ last2^ next = help last2 .next = help Werner Purgathofer / Einf. in Visual Computing 11

  12. Repetition: What is Inside a Polygon? p yg odd-even rule odd even rule nonzero-winding- number rule nonzero winding number rule ??? ??? Werner Purgathofer / Einf. in Visual Computing 12

  13. Inside ‐ Outside Tests area ‐ filling algorithms filli l i h “interior” “exterior” for self intersecting polygons? “interior”, “exterior” for self ‐ intersecting polygons? odd ‐ even rule odd even rule nonzero ‐ winding ‐ number rule g same result for simple polygons Werner Purgathofer / Einf. in Visual Computing 13

  14. What is Inside?: Odd ‐ Even Rule inside/outside switches at every edge i id / id i h d straight line to the outside: t i ht li t th t id even # edge intersections = outside even # edge intersections = outside odd # edge intersections = inside odd # edge intersections inside 4 3 2 2 1 2 1 2 1 4 3 1 1 2 2 3 Werner Purgathofer / Einf. in Visual Computing 14

  15. What is Inside?: Nonzero Winding Number g point is inside if polygon surrounds it i i i id if l d i straight line to the outside: t i ht li t th t id same # edges up and down = outside same # edges up and down = outside different # edges up and down = inside different # edges up and down inside Werner Purgathofer / Einf. in Visual Computing 15

  16. Fill ‐ Area Primitives for polygon area (solid color patterned) for polygon area (solid ‐ color, patterned) scan ‐ line polygon fill algorithm sca e po ygo a go intersection points located and sorted consecutive pairs define interior span attention with vertex intersections attention with vertex intersections exploit coherence (incremental calculations) exploit coherence (incremental calculations) flood fill algorithm Werner Purgathofer / Einf. in Visual Computing 16

  17. Scan ‐ Line Fill: Sorted Edge Table g E E y E x D 1/m DE D D B B y B x C 1/m CB y D x C 1/m CD C C F F y E x F 1/m FE y x 1/m y F x A 1/m AF y F x A 1/m AF y B x A 1/m AB y B x A 1/m AB A The sorted edge table contains all polygon edges Th t d d t bl t i ll l d sorted by lowest y value sorted by lowest y-value y y max x start 1/m x t t 1/m Werner Purgathofer / Einf. in Visual Computing 17

  18. Scan ‐ Line Fill: Sorted Edge Table g sort all edges by smallest y ‐ value t ll d b ll t l edge entry: edge entry: [max y ‐ value, x ‐ intercept, inverse slope] [ y p p ] y B x C 1/m CB y B x C 1/m CB y D x C 1/m CD y D x C 1/m CD active ‐ edge list for each scan line for each scan line contains all edges crossed by that scan line contains all edges crossed by that scan line incremental update consecutive intersection pairs (spans) filled Werner Purgathofer / Einf. in Visual Computing 18

  19. Sorted Edge Table E E y E x D 1/m DE D D B B y B x C 1/m CB y D x C 1/m CD C C F F y y E x F 1/m FE x 1/m y F x A 1/m AF y F x A 1/m AF y B x A 1/m AB y B x A 1/m AB A The sorted edge table contains all polygon edges Th t d d t bl t i ll l d sorted by lowest y value sorted by lowest y-value y y max x start 1/m x t t 1/m Werner Purgathofer / Einf. in Visual Computing 19

  20. Sorted Edge Table / Active Edge List E E y E x D 1/m DE D D B B y B x C 1/m CB y D x C 1/m CD C C F F y E x F 1/m FE y x 1/m y F x A 1/m AF y F x A 1/m AF y B x A 1/m AB y B x A 1/m AB A Active Edge List When processing from bottom to t top, keep a list of all active edges k li t f ll ti d Werner Purgathofer / Einf. in Visual Computing 20

  21. Sorted Edge Table / Active Edge List E E y E x D 1/m DE D D B B y B x C 1/m CB y D x C 1/m CD C C F F y y E x F 1/m FE x 1/m y F x A 1/m AF y F x A 1/m AF y B x A 1/m AB y B x A 1/m AB A Active Edge List incremental update! y F x A 1/m AF y B x A 1/m AB Werner Purgathofer / Einf. in Visual Computing 21

  22. Sorted Edge Table / Active Edge List E E y E x D 1/m DE D D B B y B x C 1/m CB y D x C 1/m CD C C F F y y E x F 1/m FE x 1/m y F x A 1/m AF y F x A 1/m AF y B x A 1/m AB y B x A 1/m AB A Active Edge List y F x A 1/m AF y B x A 1/m AB Werner Purgathofer / Einf. in Visual Computing 22

  23. Sorted Edge Table / Active Edge List E E y E x D 1/m DE D D B B y B x C 1/m CB y D x C 1/m CD C C F F y y E x F 1/m FE x 1/m y F x A 1/m AF y F x A 1/m AF y B x A 1/m AB y B x A 1/m AB A Active Edge List y E x F 1/m FE y B x A 1/m AB Werner Purgathofer / Einf. in Visual Computing 23

  24. Sorted Edge Table / Active Edge List E E y E x D 1/m DE D D B B y B x C 1/m CB y D x C 1/m CD C C F F y y E x F 1/m FE x 1/m y F x A 1/m AF y F x A 1/m AF y B x A 1/m AB y B x A 1/m AB A Active Edge List y E x F 1/m FE y B x A 1/m AB Werner Purgathofer / Einf. in Visual Computing 24

  25. Sorted Edge Table / Active Edge List E E y E x D 1/m DE D D B B y B x C 1/m CB y D x C 1/m CD C C F F y y E x F 1/m FE x 1/m y F x A 1/m AF y F x A 1/m AF y B x A 1/m AB y B x A 1/m AB A Active Edge List y E x F 1/m FE y B x A 1/m AB Werner Purgathofer / Einf. in Visual Computing 25

  26. Sorted Edge Table / Active Edge List E E y E x D 1/m DE D D B B y B x C 1/m CB y D x C 1/m CD C C F F y y E x F 1/m FE x 1/m y F x A 1/m AF y F x A 1/m AF y B x A 1/m AB y B x A 1/m AB A Active Edge List y E x F 1/m FE y B x A 1/m AB y B x C 1/m CB y D x C 1/m CD Werner Purgathofer / Einf. in Visual Computing 26

  27. Sorted Edge Table / Active Edge List E E y E x D 1/m DE D D B B y B x C 1/m CB y D x C 1/m CD C C F F y y E x F 1/m FE x 1/m y F x A 1/m AF y F x A 1/m AF y B x A 1/m AB y B x A 1/m AB A Active Edge List y E x F 1/m FE y B x A 1/m AB y B x C 1/m CB y D x C 1/m CD Werner Purgathofer / Einf. in Visual Computing 27

  28. Sorted Edge Table / Active Edge List E E y E x D 1/m DE D D B B y B x C 1/m CB y D x C 1/m CD C C F F y y E x F 1/m FE x 1/m y F x A 1/m AF y F x A 1/m AF y B x A 1/m AB y B x A 1/m AB A Active Edge List y E x F 1/m FE y D x C 1/m CD Werner Purgathofer / Einf. in Visual Computing 28

  29. Sorted Edge Table / Active Edge List E E y E x D 1/m DE D D B B y B x C 1/m CB y D x C 1/m CD C C F F y y E x F 1/m FE x 1/m y F x A 1/m AF y F x A 1/m AF y B x A 1/m AB y B x A 1/m AB A Active Edge List y E x F 1/m FE y D x C 1/m CD Werner Purgathofer / Einf. in Visual Computing 29

  30. Sorted Edge Table / Active Edge List E E y E x D 1/m DE D D B B y B x C 1/m CB y D x C 1/m CD C C F F y y E x F 1/m FE x 1/m y F x A 1/m AF y F x A 1/m AF y B x A 1/m AB y B x A 1/m AB A Active Edge List y E x F 1/m FE y E x D 1/m DE Werner Purgathofer / Einf. in Visual Computing 30

  31. Sorted Edge Table / Active Edge List E E y E x D 1/m DE D D B B y B x C 1/m CB y D x C 1/m CD C C F F y y E x F 1/m FE x 1/m y F x A 1/m AF y F x A 1/m AF y B x A 1/m AB y B x A 1/m AB A Active Edge List y E x F 1/m FE y E x D 1/m DE Werner Purgathofer / Einf. in Visual Computing 31

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend