40 #include "glimports.h"
41 #include "sampleComp.h"
42 #include "sampleCompTop.h"
43 #include "sampleCompBot.h"
44 #include "sampleCompRight.h"
48 #define max(a,b) ((a>b)? a:b)
49 #define min(a,b) ((a>b)? b:a)
51 void sampleConnectedComp(Real* topVertex, Real* botVertex,
53 Int leftStartIndex, Int leftEndIndex,
55 Int rightStartIndex, Int rightEndIndex,
58 Int gridIndex1, Int gridIndex2,
59 Int up_leftCornerWhere,
60 Int up_leftCornerIndex,
61 Int up_rightCornerWhere,
62 Int up_rightCornerIndex,
63 Int down_leftCornerWhere,
64 Int down_leftCornerIndex,
65 Int down_rightCornerWhere,
66 Int down_rightCornerIndex,
72 sampleCompLeft(topVertex, botVertex,
74 leftStartIndex, leftEndIndex,
76 rightStartIndex, rightEndIndex,
87 sampleCompRight(topVertex, botVertex,
89 leftStartIndex, leftEndIndex,
94 gridIndex1, gridIndex2,
97 down_rightCornerWhere,
98 down_rightCornerIndex,
102 sampleCompTop(topVertex,
116 sampleCompBot(botVertex,
124 down_leftCornerWhere,
125 down_leftCornerIndex,
126 down_rightCornerWhere,
127 down_rightCornerIndex,
133 rbArray->insert(
new rectBlock(leftGridChain, rightGridChain, gridIndex1, gridIndex2));
142 void sampleCompLeft(Real* topVertex, Real* botVertex,
144 Int leftStartIndex, Int leftEndIndex,
146 Int rightStartIndex, Int rightEndIndex,
148 Int gridIndex1, Int gridIndex2,
149 Int up_leftCornerWhere,
150 Int up_leftCornerIndex,
151 Int down_leftCornerWhere,
152 Int down_leftCornerIndex,
160 Int gridMidIndex1 = 0, gridMidIndex2 = 0;
165 midIndex1 = leftChain->findIndexBelowGen(
166 leftGridChain->get_v_value(gridIndex1),
171 if(midIndex1<= leftEndIndex && gridIndex1<gridIndex2)
172 if(leftChain->getVertex(midIndex1)[1] >= leftGridChain->get_v_value(gridIndex2))
174 midIndex2 = leftChain->findIndexAboveGen(
175 leftGridChain->get_v_value(gridIndex2),
178 gridMidIndex1 = leftGridChain->lookfor(leftChain->getVertex(midIndex1)[1],
179 gridIndex1, gridIndex2);
180 gridMidIndex2 = 1+leftGridChain->lookfor(leftChain->getVertex(midIndex2)[1],
181 gridMidIndex1, gridIndex2);
190 Int cornerRightUpEnd;
191 Int cornerRightDownStart;
192 if(up_leftCornerWhere == 0)
194 cornerTop = leftChain->getVertex(up_leftCornerIndex);
195 cornerLeftStart = up_leftCornerIndex+1;
196 cornerRightUpEnd = -1;
198 else if(up_leftCornerWhere == 1)
200 cornerTop = topVertex;
201 cornerLeftStart = leftStartIndex;
202 cornerRightUpEnd = -1;
206 cornerTop = topVertex;
207 cornerLeftStart = leftStartIndex;
208 cornerRightUpEnd = up_leftCornerIndex;
211 if(down_leftCornerWhere == 0)
213 cornerBot = leftChain->getVertex(down_leftCornerIndex);
214 cornerLeftEnd = down_leftCornerIndex-1;
215 cornerRightDownStart = rightEndIndex+1;
217 else if(down_leftCornerWhere == 1)
219 cornerBot = botVertex;
220 cornerLeftEnd = leftEndIndex;
221 cornerRightDownStart = rightEndIndex+1;
225 cornerBot = botVertex;
226 cornerLeftEnd = leftEndIndex;
227 cornerRightDownStart = down_leftCornerIndex;
237 sampleLeftSingleTrimEdgeRegionGen(cornerTop, leftChain->getVertex(midIndex1),
251 sampleLeftSingleTrimEdgeRegionGen(leftChain->getVertex(midIndex2),
262 cornerRightDownStart,
267 sampleLeftStripRecF(leftChain,
277 sampleLeftSingleTrimEdgeRegionGen(cornerTop, cornerBot,
287 cornerRightDownStart,
293 void sampleLeftSingleTrimEdgeRegionGen(Real topVert[2], Real botVert[2],
316 max(0,rightUpEnd - rightUpBegin+1)+
317 max(0,rightDownEnd - rightDownBegin+1));
320 for(i=rightUpBegin; i<= rightUpEnd; i++)
321 vArray.appendVertex(rightChain->getVertex(i));
326 vArray.appendVertex(gridChain->get_vertex(gridBeginIndex));
328 for(k=1, i=gridBeginIndex+1; i<=gridEndIndex; i++, k++)
330 vArray.appendVertex(gridChain->get_vertex(i));
334 if(gridChain->getUlineIndex(i) < gridChain->getUlineIndex(i-1))
337 pStream->insert(gridChain->get_vertex(i-1));
338 for(j=gridChain->getUlineIndex(i); j<= gridChain->getUlineIndex(i-1); j++)
339 pStream->insert(gridChain->getGrid()->get_u_value(j), gridChain->get_v_value(i));
340 pStream->end(PRIMITIVE_STREAM_FAN);
342 else if(gridChain->getUlineIndex(i) > gridChain->getUlineIndex(i-1))
345 pStream->insert(gridChain->get_vertex(i));
346 for(j=gridChain->getUlineIndex(i); j>= gridChain->getUlineIndex(i-1); j--)
347 pStream->insert(gridChain->getGrid()->get_u_value(j), gridChain->get_v_value(i-1));
348 pStream->end(PRIMITIVE_STREAM_FAN);
354 for(i=rightDownBegin; i<= rightDownEnd; i++)
355 vArray.appendVertex(rightChain->getVertex(i));
357 monoTriangulationRecGen(topVert, botVert,
358 leftChain, leftStart, leftEnd,
359 &vArray, 0, vArray.getNumElements()-1,