sampleMonoPoly.h revision f220fa62
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*/
32
33#ifndef _SAMPLEMONOPOLY_H
34#define _SAMPLEMONOPOLY_H
35
36#include "monoTriangulation.h"
37#include "gridWrap.h"
38#include "rectBlock.h"
39
40
41void  triangulateXYMono(Int n_upper, Real upperVerts[][2],
42		       Int n_lower, Real lowerVerts[][2],
43		       primStream* pStream);
44
45void stripOfFanLeft(vertexArray* leftChain,
46		     Int largeIndex,
47		     Int smallIndex,
48		     gridWrap* grid,
49		     Int vlineIndex,
50		     Int ulineSmallIndex,
51		     Int ulineLargeIndex,
52		     primStream* pStream,
53		    Int gridLineUp
54		     );
55void sampleLeftOneGridStep(vertexArray* leftChain,
56		  Int beginLeftIndex,
57		  Int endLeftIndex,
58		  gridBoundaryChain* leftGridChain,
59		  Int leftGridChainStartIndex,
60		  primStream* pStream
61		  );
62
63void sampleLeftSingleTrimEdgeRegion(Real upperVert[2], Real lowerVert[2],
64				    gridBoundaryChain* gridChain,
65				    Int beginIndex,
66				    Int endIndex,
67				    primStream* pStream);
68
69void sampleLeftStripRec(vertexArray* leftChain,
70		     Int topLeftIndex,
71		     Int botLeftIndex,
72		     gridBoundaryChain* leftGridChain,
73		     Int leftGridChainStartIndex,
74		     Int leftGridChainEndIndex,
75			primStream* pStream
76		     );
77
78void sampleLeftStrip(vertexArray* leftChain,
79		     Int topLeftIndex,
80		     Int botLeftIndex,
81		     gridBoundaryChain* leftGridChain,
82		     Int leftGridChainStartIndex,
83		     Int leftGridChainEndIndex,
84		     primStream* pStream
85		     );
86
87void findLeftGridIndices(directedLine* topEdge, Int firstGridIndex, Int lastGridIndex, gridWrap* grid,  Int* ret_indices, Int* ret_inner);
88
89void findRightGridIndices(directedLine* topEdge, Int firstGridIndex, Int lastGridIndex, gridWrap* grid,  Int* ret_indices, Int* ret_inner);
90
91void sampleMonoPoly(directedLine* polygon, gridWrap* grid, Int ulinear, Int vlinear, primStream *pStream, rectBlockArray* rbArray);
92
93void sampleMonoPolyRec(
94		       Real* topVertex,
95		       Real* botVertex,
96		       vertexArray* leftChain,
97		       Int leftStartIndex,
98		       vertexArray* rightChain,
99		       Int rightStartIndex,
100		       gridBoundaryChain* leftGridChain,
101		       gridBoundaryChain* rightGridChain,
102		       Int gridStartIndex,
103		       primStream* pStream,
104		       rectBlockArray* rbArray
105		       );
106
107void sampleLeftStripRecF(vertexArray* leftChain,
108		     Int topLeftIndex,
109		     Int botLeftIndex,
110		     gridBoundaryChain* leftGridChain,
111		     Int leftGridChainStartIndex,
112		     Int leftGridChainEndIndex,
113			primStream* pStream
114		     );
115
116void findUpCorners(Real *topVertex,
117		   vertexArray *leftChain,
118		   Int leftChainStartIndex, Int leftChainEndIndex,
119		   vertexArray *rightChain,
120		   Int rightChainStartIndex, Int rightChainEndIndex,
121		   Real v,
122		   Real uleft,
123		   Real uright,
124		   Int& ret_leftCornerWhere,
125		   Int& ret_leftCornerIndex,
126		   Int& ret_rightCornerWhere,
127		   Int& ret_rightCornerIndex
128		   );
129void findDownCorners(Real *botVertex,
130		   vertexArray *leftChain, Int leftChainStartIndex, Int leftChainEndIndex,
131		   vertexArray *rightChain, Int rightChainStartIndex, Int rightChainEndIndex,
132		   Real v,
133		   Real uleft,
134		   Real uright,
135		   Int& ret_leftCornerWhere,
136		   Int& ret_leftCornerIndex,
137		   Int& ret_rightCornerWhere,
138		   Int& ret_rightCornerIndex
139		   );
140void findNeck(vertexArray *leftChain, Int botLeftIndex,
141	      vertexArray *rightChain, Int botRightIndex,
142	      Int& leftLastIndex, /*left point of the neck*/
143	      Int& rightLastIndex /*right point of the neck*/
144	      );
145
146Int findNeckF(vertexArray *leftChain, Int botLeftIndex,
147	       vertexArray *rightChain, Int botRightIndex,
148	       gridBoundaryChain* leftGridChain,
149	       gridBoundaryChain* rightGridChain,
150	       Int gridStartIndex,
151	       Int& neckLeft,
152	       Int& neckRight);
153
154void findTopAndBot(directedLine* polygon,
155		   directedLine*& topV,
156		   directedLine*& botV);
157void findGridChains(directedLine* top, directedLine* bot,
158		    gridWrap* grid,
159		    gridBoundaryChain*& leftGridChain,
160		    gridBoundaryChain*& rightGridChain);
161void toVertexArrays(directedLine* topV, directedLine* botV, vertexArray& leftChain, vertexArray& rightChain);
162
163void drawCorners(
164		 Real* topV, Real* botV,
165		 vertexArray* leftChain,
166		 vertexArray* rightChain,
167		 gridBoundaryChain* leftGridChain,
168		 gridBoundaryChain* rightGridChain,
169		 Int gridIndex1,
170		 Int gridIndex2,
171		 Int leftCornerWhere,
172		 Int leftCornerIndex,
173		 Int rightCornerWhere,
174		 Int rightCornerIndex,
175		 Int bot_leftCornerWhere,
176		 Int bot_leftCornerIndex,
177		 Int bot_rightCornerWhere,
178		 Int bot_rightCornerIndex);
179
180Int checkMiddle(vertexArray* chain, Int begin, Int end,
181		Real vup, Real vbelow);
182
183#endif
184
185