1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>NeL: NL3D::CStripifier class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.6 -->
<div class="qindex"> <form class="search" action="search.php" method="get">
<a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a> | <span class="search"><u>S</u>earch for <input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div>
<h1>NL3D::CStripifier Class Reference</h1><code>#include <<a class="el" href="a06474.html">stripifier.h</a>></code>
<p>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Wrapper to NVidia(tm) Stripifier <dl compact><dt><b>Author:</b></dt><dd>Lionel Berenguier <p>
Nevrax France </dd></dl>
<dl compact><dt><b>Date:</b></dt><dd>2001 </dd></dl>
<p>
<p>
Definition at line <a class="el" href="a06474.html#l00043">43</a> of file <a class="el" href="a06474.html">stripifier.h</a>.<table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top> </td><td class="memItemRight" valign=bottom><a class="el" href="a03456.html#NL3D_1_1CStripifiera0">CStripifier</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Constructor. <a href="#NL3D_1_1CStripifiera0"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03456.html#NL3D_1_1CStripifiera1">optimizeTriangles</a> (const <a class="el" href="a03105.html">CPrimitiveBlock</a> &<a class="el" href="a04223.html#a647">in</a>, <a class="el" href="a03105.html">CPrimitiveBlock</a> &out, <a class="el" href="a04558.html#a15">uint</a> cacheSize=10)</td></tr>
</table>
<hr><h2>Constructor & Destructor Documentation</h2>
<a class="anchor" name="NL3D_1_1CStripifiera0" doxytag="NL3D::CStripifier::CStripifier" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> NL3D::CStripifier::CStripifier </td>
<td class="md" valign="top">( </td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top"> ) </td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Constructor.
<p>
<p>
Definition at line <a class="el" href="a06473.html#l00042">42</a> of file <a class="el" href="a06473.html">stripifier.cpp</a>.
<p>
<div class="fragment"><pre>00043 {
00044 }
</pre></div> </td>
</tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="NL3D_1_1CStripifiera1" doxytag="NL3D::CStripifier::optimizeTriangles" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void NL3D::CStripifier::optimizeTriangles </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const <a class="el" href="a03105.html">CPrimitiveBlock</a> & </td>
<td class="mdname" nowrap> <em>in</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap><a class="el" href="a03105.html">CPrimitiveBlock</a> & </td>
<td class="mdname" nowrap> <em>out</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> </td>
<td class="mdname" nowrap> <em>cacheSize</em> = 10</td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
reorganize triangles to get efficiency of GPU vertex-cache. Default vertex cache is 10. out get the same list of triangles, but in different order. any list of lines / quads in out are not modified. NB: &in == &out is possible.
<p>
Definition at line <a class="el" href="a06473.html#l00196">196</a> of file <a class="el" href="a06473.html">stripifier.cpp</a>.
<p>
References <a class="el" href="a06473.html#l00190">NL3D::CCornerNode::FaceId</a>, <a class="el" href="a06473.html#l00134">NL3D::CVertexCache::getVertexInCache()</a>, <a class="el" href="a05646.html#l01122">in</a>, <a class="el" href="a06473.html#l00188">NL3D::CCornerNode::Next</a>, <a class="el" href="a06197.html#l00109">NL3D::CPrimitiveBlock::reserveTri()</a>, <a class="el" href="a06197.html#l00114">NL3D::CPrimitiveBlock::setNumTri()</a>, <a class="el" href="a05981.html#l00104">sint</a>, <a class="el" href="a06473.html#l00139">NL3D::CVertexCache::tempTouchVertex()</a>, <a class="el" href="a05981.html#l00105">uint</a>, <a class="el" href="a06473.html#l00161">NL3D::COrderFace::v</a>, <a class="el" href="a05646.html#l00237">v</a>, and <a class="el" href="a06473.html#l00191">NL3D::CCornerNode::VertexId</a>.
<p>
Referenced by <a class="el" href="a06011.html#l00093">NL3D::CMeshMRMSkinnedGeom::CLod::optimizeTriangleOrder()</a>, <a class="el" href="a06005.html#l00164">NL3D::CMeshMRMGeom::CLod::optimizeTriangleOrder()</a>, and <a class="el" href="a05989.html#l00153">NL3D::CMeshGeom::optimizeTriangleOrder()</a>.
<p>
<div class="fragment"><pre>00197 {
00198 vector<COrderFace> inFaces;
00199 <a class="code" href="a04558.html#a14">sint</a> i;
00200 <a class="code" href="a04558.html#a14">sint</a> numTris= <a class="code" href="a04223.html#a647">in</a>.getNumTri();
00201
00202 <span class="comment">// TestYoyo: All the same tri => perfect vertex caching...</span>
00203 <span class="comment">/*out.setNumTri(numTris);</span>
00204 <span class="comment"> for(i=0;i< numTris; i++)</span>
00205 <span class="comment"> {</span>
00206 <span class="comment"> uint32 v0= *(in.getTriPointer()+0);</span>
00207 <span class="comment"> uint32 v1= *(in.getTriPointer()+1);</span>
00208 <span class="comment"> uint32 v2= *(in.getTriPointer()+2);</span>
00209 <span class="comment"> out.setTri(i, v0, v1, v2);</span>
00210 <span class="comment"> }</span>
00211 <span class="comment"> return;*/</span>
00212
00213
00214 <span class="comment">// prepare inIndices.</span>
00215 <span class="comment">//--------------------</span>
00216 inFaces.resize(numTris);
00217 <span class="keywordflow">for</span>(i=0;i< numTris; i++)
00218 {
00219 inFaces[i].v[0]= <a class="code" href="a04223.html#a647">in</a>.getTriPointer()[i*3 + 0];
00220 inFaces[i].v[1]= <a class="code" href="a04223.html#a647">in</a>.getTriPointer()[i*3 + 1];
00221 inFaces[i].v[2]= <a class="code" href="a04223.html#a647">in</a>.getTriPointer()[i*3 + 2];
00222 inFaces[i].Inserted= <span class="keyword">false</span>;
00223 }
00224
00225
00226 <span class="comment">// build our cache, and compute max number of vertices.</span>
00227 <span class="comment">//--------------------</span>
00228 <span class="keywordtype">int</span> numVerts=0;
00229 <span class="keywordflow">for</span> (i = 0; i < numTris; i++)
00230 {
00231 numVerts= max(numVerts, (<span class="keywordtype">int</span>)inFaces[i].<a class="code" href="a04223.html#a576">v</a>[0]);
00232 numVerts= max(numVerts, (<span class="keywordtype">int</span>)inFaces[i].<a class="code" href="a04223.html#a576">v</a>[1]);
00233 numVerts= max(numVerts, (<span class="keywordtype">int</span>)inFaces[i].<a class="code" href="a04223.html#a576">v</a>[2]);
00234 }
00235 numVerts++;
00236 CVertexCache vertexCache(cacheSize, numVerts);
00237
00238
00239 <span class="comment">// Compute vertex connectivity.</span>
00240 <span class="comment">//--------------------</span>
00241 vector<CCornerNode*> vertexConnectivity;
00242 vector<CCornerNode> cornerAllocator;
00243 cornerAllocator.resize(numTris * 3);
00244 vertexConnectivity.resize(numVerts, NULL);
00245 <span class="comment">// For all triangles.</span>
00246 <span class="keywordflow">for</span> (i = 0; i < numTris; i++)
00247 {
00248 COrderFace *ordFace= &inFaces[i];
00249 <span class="comment">// For each corner, allocate and fill</span>
00250 <span class="keywordflow">for</span>(<a class="code" href="a04558.html#a14">sint</a> j=0; j<3;j++)
00251 {
00252 <a class="code" href="a04558.html#a14">sint</a> vertexId= ordFace->v[j];
00253
00254 <span class="comment">// allocate a corner</span>
00255 CCornerNode *corner= &cornerAllocator[i*3 + j];
00256
00257 <span class="comment">// fill it.</span>
00258 corner->FaceId= i;
00259 corner->VertexId= vertexId;
00260 <span class="comment">// Link it to the vertex list of faces.</span>
00261 corner->Next= vertexConnectivity[vertexId];
00262 vertexConnectivity[vertexId]= corner;
00263 }
00264 }
00265
00266
00267 <span class="comment">// build output optimized triangles</span>
00268 <span class="comment">//--------------------</span>
00269 out.setNumTri(0);
00270 out.reserveTri(numTris);
00271
00272 <span class="keywordflow">for</span>(i=0; i<numTris; i++)
00273 {
00274 <span class="comment">// force insertion of the ith face.</span>
00275 <a class="code" href="a04558.html#a14">sint</a> nextToInsert= i;
00276 <span class="keywordtype">bool</span> nextToInsertFound= <span class="keyword">true</span>;
00277 <span class="keywordflow">while</span>( nextToInsertFound )
00278 {
00279 nextToInsertFound= <span class="keyword">false</span>;
00280
00281 <span class="comment">// if the face is not yet inserted.</span>
00282 <span class="keywordflow">if</span>(!inFaces[nextToInsert].Inserted)
00283 {
00284 <span class="comment">// must insert this face.</span>
00285 inFaces[nextToInsert].insertInPB(out, vertexCache);
00286
00287 <a class="code" href="a04558.html#a14">sint</a> minC= 3;
00288
00289 <span class="comment">// look only for faces which use vertices in VertexCache, to get a face with at least one vertex.</span>
00290 <span class="keywordflow">for</span>(<a class="code" href="a04558.html#a15">uint</a> j=0; j<cacheSize; j++)
00291 {
00292 <span class="comment">// get a vertex from the vertex cache.</span>
00293 <a class="code" href="a04558.html#a15">uint</a> vertexId= vertexCache.getVertexInCache(j);
00294 <span class="comment">// if empty entry</span>
00295 <span class="keywordflow">if</span>(vertexId==0xFFFFFFFF)
00296 <span class="keywordflow">continue</span>;
00297
00298 <span class="comment">// parse list of faces which use this vertex.</span>
00299 CCornerNode *corner= vertexConnectivity[vertexId];
00300 <span class="keywordflow">while</span>(corner)
00301 {
00302 <a class="code" href="a04558.html#a15">uint</a> faceId= corner->FaceId;
00303
00304 <span class="comment">// if the face is not yet inserted.</span>
00305 <span class="keywordflow">if</span>(!inFaces[faceId].Inserted)
00306 {
00307 <a class="code" href="a04558.html#a14">sint</a> c= inFaces[faceId].countCacheMiss(vertexCache);
00308 <span class="comment">// insert first any face which don't add any vertex in the cache.</span>
00309 <span class="keywordflow">if</span>(c==0)
00310 {
00311 inFaces[faceId].insertInPB(out, vertexCache);
00312 }
00313 <span class="comment">// else the one which add the minimum of vertex possible: nextToInsert</span>
00314 <span class="keywordflow">else</span>
00315 {
00316 <span class="comment">// Add cost of faces that use vertices pushed out (better results...)</span>
00317 <a class="code" href="a04558.html#a15">uint</a> numVOut= c;
00318 <a class="code" href="a04558.html#a15">uint</a> k;
00319 <span class="keywordflow">for</span>(k=cacheSize-numVOut; k<cacheSize; k++)
00320 {
00321 <a class="code" href="a04558.html#a15">uint</a> vertexOutId= vertexCache.getVertexInCache(k);
00322 <span class="keywordflow">if</span>(vertexOutId==0xFFFFFFFF)
00323 <span class="keywordflow">continue</span>;
00324 <span class="comment">// TempRemove the vertex from the cache</span>
00325 vertexCache.tempTouchVertex(vertexOutId, <span class="keyword">false</span>);
00326 }
00327 <span class="comment">// parse all faces that still use those out vertices.</span>
00328 <span class="keywordflow">for</span>(k=cacheSize-numVOut; k<cacheSize; k++)
00329 {
00330 <a class="code" href="a04558.html#a15">uint</a> vertexOutId= vertexCache.getVertexInCache(k);
00331 <span class="keywordflow">if</span>(vertexOutId==0xFFFFFFFF)
00332 <span class="keywordflow">continue</span>;
00333 CCornerNode *cornerOut= vertexConnectivity[vertexOutId];
00334 <span class="keywordflow">while</span>(cornerOut)
00335 {
00336 <a class="code" href="a04558.html#a15">uint</a> faceOutId= cornerOut->FaceId;
00337
00338 <span class="comment">// if the face is not yet inserted AND not the one treated</span>
00339 <span class="keywordflow">if</span>(!inFaces[faceOutId].Inserted && faceOutId!=faceId)
00340 {
00341 <span class="comment">// Add cache miss of this face</span>
00342 c+= inFaces[faceOutId].countCacheMiss(vertexCache);
00343 }
00344
00345 <span class="comment">// next corner</span>
00346 cornerOut= cornerOut->Next;
00347 }
00348 }
00349 <span class="comment">// reset touch</span>
00350 <span class="keywordflow">for</span>(k=cacheSize-numVOut; k<cacheSize; k++)
00351 {
00352 <a class="code" href="a04558.html#a15">uint</a> vertexOutId= vertexCache.getVertexInCache(k);
00353 <span class="keywordflow">if</span>(vertexOutId==0xFFFFFFFF)
00354 <span class="keywordflow">continue</span>;
00355 <span class="comment">// restore TempTouch the vertex from the cache</span>
00356 vertexCache.tempTouchVertex(vertexOutId, <span class="keyword">true</span>);
00357 }
00358
00359
00360 <span class="comment">// take the minimum cost</span>
00361 <span class="keywordflow">if</span>(c<minC)
00362 {
00363 nextToInsert= faceId;
00364 nextToInsertFound= <span class="keyword">true</span>;
00365 minC= c;
00366 }
00367 }
00368 }
00369
00370 <span class="comment">// next corner</span>
00371 corner= corner->Next;
00372 }
00373
00374 }
00375
00376 <span class="comment">// if nextToInsertFound, then nextToInsert has the face which add the minimum of vertex possible in the cache</span>
00377 }
00378 }
00379
00380 }
00381
00382 }
</pre></div> </td>
</tr>
</table>
<hr>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="a06474.html">stripifier.h</a><li><a class="el" href="a06473.html">stripifier.cpp</a></ul>
<hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 07:47:29 2004 for NeL by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 >
</a>1.3.6 </small></address>
</body>
</html>
|