160 likes | 714 Views
Introduction to Polygons. Convex A region S is convex iff for any x1 and x2 in S, the straight line segment connecting x1 and x2 is also contained in S. The convex hull of an object S is the smallest H such that S . Scan Line Polygon Fill Algorithms. A standard output primitive in ge
E N D
1. Introduction to Polygons Different types of Polygons
Simple Convex
Simple Concave
Non-simple : self-intersecting
With holes
2. Introduction to Polygons Convex
A region S is convex iff for any x1 and x2 in S, the straight line segment connecting x1 and x2 is also contained in S. The convex hull of an object S is the smallest H such that S
3. Scan Line Polygon Fill Algorithms A standard output primitive in general graphics package is a solid color or patterned polygon area:
There are two basic approaches to filling on raster systems.
Determine overlap Intervals for scan lines that cross that area.
Start from a given interior point and paint outward from this point until we encounter the boundary
The first approach is mostly used in general graphics packages, however second approach is used in applications having complex boundaries and interactive painting systems
4. Seed Fill Algorithm These algorithms assume that at least one pixel interior to a polygon or region is known
Regions maybe interior or boundary defined
5. A Simple Seed Fill Algorithm Push the seed pixel onto the stack
While the stack is not empty
Pop a pixel from the stack
Set the pixel to the required value
For each of the 4 connected pixels
Adjacent to the current pixel, check if it is a boundary pixel or if it has already been set to the required value.
In either case ignore it. Otherwise push it onto the stack
The algorithm can be implemented using 8 connected pixels
It also works with holes in the polygons
6. Scan Line Polygon Fill Algorithm
7. Scan Line Polygon Fill Algorithm In the given example ( previous slide) , four pixel intersections define stretches from x=10 to x=14 and x=18 to x=24
Some scan-Line intersections at polygon vertices require special handling:
A scan Line passing through a vertex intersects two polygon edges at that position, adding two points to the list of intersections for the scan Line
In the given example , scan Line y intersects five polygon edges and the scan Line y intersects 4 edges although it also passes through a vertex
y correctly identifies internal pixel spans ,but need some extra processing
8. Scan line Polygon Fill Algorithm One way to resolve this is also to shorten some polygon edges to split those vertices that should be counted as one intersection
When the end point y coordinates of the two edges are increasing , the y value of the upper endpoint for the current edge is decreased by 1
When the endpoint y values are monotonically decreasing, we decrease the y coordinate of the upper endpoint of the edge following the current edge
9. Scan Line Polygon Fill Algorithm
10. Scan Line Polygon Fill Algorithm The topological difference between scan Line y and scan Line y'