dri: Rework planar image interface
[mesa.git] / src / glu / sgi / libnurbs / nurbtess / partitionY.h
1 /*
2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice including the dates of first publication and
13 * either this permission notice or a reference to
14 * http://oss.sgi.com/projects/FreeB/
15 * shall be included in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
22 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 *
25 * Except as contained in this notice, the name of Silicon Graphics, Inc.
26 * shall not be used in advertising or otherwise to promote the sale, use or
27 * other dealings in this Software without prior written authorization from
28 * Silicon Graphics, Inc.
29 */
30 /*
31 *partitionY.h:
32 *partition a polygon into a Y-monotone polygon:
33 * A polygon is Y-monotone if the boundary can be split into two polygon chains
34 *A and B such that each chain is Y-monotonic that is the intersection of any
35 *horizontal line intersects each chain has at most one connected componenets
36 * (empty, single point or a single line).
37 *
38 * A vertex is a cusp if both its ajacent vertices are either at or above v,
39 *or both at or below v. In addition, at least one of the ajacent verteces is
40 *strictly below or above v.
41 * A vertex is a relex vertex if the internals angle is strictly greater than
42 *180. In other words, if the signed area is negative:
43 *(x1, y1), (x2, y2), (x3, y3) are the three vertices along a polygon, the
44 *order is such that left hand side is inside the polygon. Then (x2,y2) is
45 *reflex if:
46 * (x2-x1, y2-y1) cross (x3-x1, y3-y1) <0.
47 *A vertex is an interior cusp if it is a cusp and a reflex.
48 *A vertex is an exterior cusp if it is a cusp but not a reflex.
49 *
50 */
51
52 #ifndef _PARTITIONY_H
53 #define _PARTITIONY_H
54
55 #include "directedLine.h"
56
57 /*whether an edge is below a vertex*/
58 Int isBelow(directedLine *v, directedLine *e);
59
60 /*whether an edge is above a vertex*/
61 Int isAbove(directedLine *v, directedLine *e);
62
63 /*not-cusp,
64 *inerior cusp
65 *exterior cusp
66 */
67 Int cuspType(directedLine *v);
68
69 /*used in trapezoidalization*/
70 typedef struct sweepRange{
71 directedLine *left;
72 Int leftType; /*either a vertex (leftType=0) or an edge (leftType =1) */
73 directedLine *right;
74 Int rightType; /*either a vertex (rightType=0) or an edge (rightType =1) */
75 } sweepRange;
76
77 sweepRange* sweepRangeMake(directedLine* left, Int leftType,
78 directedLine* right, Int rightType);
79
80 void sweepRangeDelete(sweepRange* range);
81 Int sweepRangeEqual(sweepRange* sr1, sweepRange* sr2);
82
83 /*given a set of simple polygons where the interior
84 *is decided by left-hand principle,
85 *return a range (sight) for each vertex. This is called
86 *Trapezoidalization.
87 */
88 void sweepY(Int nVertices, directedLine **sortedVerteces, sweepRange** ret_ranges);
89
90
91 directedLine* partitionY(directedLine *polygons, sampledLine **retSampledLines);
92
93 void findDiagonals(Int total_num_edges, directedLine** sortedVertices, sweepRange** ranges, Int& num_diagonals, directedLine** diagonal_vertices);
94
95 directedLine** DBGfindDiagonals(directedLine *polygons, Int& num_diagonals);
96
97 #endif