aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/cluster_8cpp-source.html
blob: 3713dec93fc601a20fccc1d7f202639a789dd8b6 (plain)
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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
	<TITLE>nevrax.org : docs</TITLE>
	<LINK REL=stylesheet TYPE="text/css" HREF="/inc/css/nevrax.css">
	<link href="doxygen.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY MARGINHEIGHT="0" MARGINWIDTH="0">

<!-- uplinks -->
<TABLE CELLSPACING=0 CELLPADDING=0  BORDER=0>
 <TR>
        <TD WIDTH=16><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=140 BGCOLOR=#dddddd><IMG  SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=16><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF='/'><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
        <TD><IMG  width=6 height=14  SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF='/'><b>nevrax.com</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
 </TR>
</TABLE> 

<!-- banner Nevrax -->
<TABLE CELLSPACING=0 CELLPADDING=0  BORDER=0 WIDTH=100%>
 <TR><TD  BGCOLOR="#000000" BACKGROUND="/inc/img/black_banner.jpg"><A HREF=""><IMG  SRC="/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
</TABLE>

<!-- main table -->
<TABLE CELLSPACING=0 CELLPADDING=0  BORDER=0 height=100%>
 <TR>
	<TD WIDTH=16><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
	<TD WIDTH=140   BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG  SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">

		<!------ Begin Box ------>
		<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0  cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
		<FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td  colspan=2 bgcolor=#FFFFFF>
		<TABLE cellspacing=0 cellpadding=1 border=0>
			<tr><td ALIGN=middle><a  class='linkbox' href="/news/" TITLE="Rubrique news"><img width=13 height=15  hspace=5 border=0 src=/inc/img/picto-news.gif ALT=#></A></td><td><a  class='linkbox' href="/news/" TITLE="News">News</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/mail/" TITLE="Rubrique mail"><img width=15 height=11  hspace=5 border=0 src=/inc/img/picto-mail.gif ALT=#></A></td><td><a  class='linkbox' href="/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/docs/" TITLE="Rubrique docs"><img width=14 height=16  hspace=5 border=0 src=/inc/img/picto-docs.gif ALT=#></A></td><td><a  class='linkbox' href="/docs/" TITLE="Documentation">Documentation</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/cvs/" TITLE="Rubrique cvs"><img width=13 height=17  hspace=5 border=0 src=/inc/img/picto-cvs.gif ALT=#></A></td><td><a  class='linkbox' href="/cvs/" TITLE="CVS Web">CVS</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/bugs/" TITLE="Rubrique bugs"><img width=20 height=16  hspace=5 border=0 src=/inc/img/picto-bugs.gif ALT=#></A></td><td><a  class='linkbox' href="/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/GPL.php3" TITLE="Rubrique license"><img  width=18 height=12   hspace=5 border=0 src=/inc/img/picto-gpl.gif ALT=#></A></td><td><a  class='linkbox' href="/GPL.php3" TITLE="License">License</a></td></tr>
		</TABLE>
		</TD></TR></TABLE></TD></TR></TABLE>
		<!------ End Box  ------>

	</TD>
	<TD WIDTH=15><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
	<TD ALIGN=left valign=top><IMG  SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">

<!-- title -->
<TABLE  background="/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0  BORDER=0 width=100%><tr><td>
<A HREF="/docs/"><img src="/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
</td><td><IMG  SRC="/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
</td></tr></table>
&nbsp;

<!-- block -->
<TABLE  bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0  BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="/inc/img/reddots.gif"></TD>
	<TD><B>Documentation</B></TD>
	<TD ALIGN=RIGHT>&nbsp;</td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindexRef" doxygen="_cgi:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
<hr><h1>cluster.cpp</h1><a href="cluster_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 
00007 <font class="comment">/* Copyright, 2001 Nevrax Ltd.</font>
00008 <font class="comment"> *</font>
00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
00013 <font class="comment"> * any later version.</font>
00014 <font class="comment"></font>
00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00018 <font class="comment"> * General Public License for more details.</font>
00019 <font class="comment"></font>
00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
00023 <font class="comment"> * MA 02111-1307, USA.</font>
00024 <font class="comment"> */</font>
00025 
00026 <font class="preprocessor">#include "<a class="code" href="std3d_8h.html">std3d.h</a>"</font>
00027 
00028 <font class="preprocessor">#include "<a class="code" href="cluster_8h.html">3d/cluster.h</a>"</font>
00029 <font class="preprocessor">#include "<a class="code" href="portal_8h.html">3d/portal.h</a>"</font>
00030 <font class="preprocessor">#include "<a class="code" href="stream_8h.html">nel/misc/stream.h</a>"</font>
00031 <font class="preprocessor">#include "<a class="code" href="scene_8h.html">3d/scene.h</a>"</font>
00032 <font class="preprocessor">#include "<a class="code" href="transform__shape_8h.html">3d/transform_shape.h</a>"</font>
00033 <font class="preprocessor">#include "<a class="code" href="mesh__instance_8h.html">3d/mesh_instance.h</a>"</font>
00034 <font class="preprocessor">#include "<a class="code" href="scene__group_8h.html">3d/scene_group.h</a>"</font>
00035 
00036 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
00037 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
00038 
00039 <font class="keyword">namespace </font>NL3D 
00040 {
00041 
00042 <font class="comment">// 0.5 cm of precision</font>
<a name="l00043"></a><a class="code" href="cluster_8cpp.html#a0">00043</a> <font class="preprocessor">#define CLUSTERPRECISION 0.005</font>
00044 <font class="preprocessor"></font>
00045 
00046 <font class="comment">// ***************************************************************************</font>
<a name="l00047"></a><a class="code" href="classNL3D_1_1CCluster.html#a0">00047</a> CCluster::CCluster ()
00048 {
00049         <a class="code" href="classNL3D_1_1CCluster.html#o0">_Obs</a> = NULL;
00050         <a class="code" href="classNL3D_1_1CCluster.html#m2">FatherVisible</a> = <a class="code" href="classNL3D_1_1CCluster.html#m3">VisibleFromFather</a> = <font class="keyword">false</font>;
00051         <a class="code" href="classNL3D_1_1CCluster.html#m4">Father</a> = NULL;
00052 }
00053 
00054 
00055 <font class="comment">// ***************************************************************************</font>
<a name="l00056"></a><a class="code" href="classNL3D_1_1CCluster.html#a1">00056</a> CCluster::~CCluster()
00057 {
00058         <a class="code" href="classNL3D_1_1CCluster.html#c0">unlinkFromClusterTree</a>();
00059 }
00060 
00061 
00062 <font class="comment">// ***************************************************************************</font>
<a name="l00063"></a><a class="code" href="classNL3D_1_1CCluster.html#c1">00063</a> <font class="keywordtype">void</font> CCluster::unlinkFromParent()
00064 {
00065         <font class="comment">// unlink from father sons list</font>
00066         <font class="keywordflow">if</font> (Father)
00067         {
00068                  <a class="code" href="classNL3D_1_1CCluster.html#m4">Father</a>-&gt;Children.erase(std::remove(<a class="code" href="classNL3D_1_1CCluster.html#m4">Father</a>-&gt;Children.begin(), <a class="code" href="classNL3D_1_1CCluster.html#m4">Father</a>-&gt;Children.end(), <font class="keyword">this</font>), <a class="code" href="classNL3D_1_1CCluster.html#m4">Father</a>-&gt;Children.end());
00069                  <a class="code" href="classNL3D_1_1CCluster.html#m4">Father</a> = NULL;
00070         }
00071 }
00072 
00073 <font class="comment">// ***************************************************************************</font>
<a name="l00074"></a><a class="code" href="classNL3D_1_1CCluster.html#c2">00074</a> <font class="keywordtype">void</font> CCluster::unlinkSons()
00075 {
00076         <font class="comment">// tells all sons that they have no more father</font>
00077         <font class="keywordflow">for</font>(uint k = 0; k &lt; <a class="code" href="classNL3D_1_1CCluster.html#m5">Children</a>.size(); ++k)
00078         {
00079                 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CCluster.html#m5">Children</a>[k]-&gt;Father == <font class="keyword">this</font>)
00080                 {
00081                         <a class="code" href="classNL3D_1_1CCluster.html#m5">Children</a>[k]-&gt;Father = NULL;
00082                 }
00083         }
00084         <a class="code" href="namespaceNLMISC.html#a222">NLMISC::contReset</a>(<a class="code" href="classNL3D_1_1CCluster.html#m5">Children</a>);
00085 }
00086 
00087 
00088 
00089 <font class="comment">// ***************************************************************************</font>
<a name="l00090"></a><a class="code" href="classNL3D_1_1CCluster.html#c0">00090</a> <font class="keywordtype">void</font> CCluster::unlinkFromClusterTree()
00091 {
00092         <a class="code" href="classNL3D_1_1CCluster.html#c1">unlinkFromParent</a>();
00093         <a class="code" href="classNL3D_1_1CCluster.html#c2">unlinkSons</a>();   
00094 }
00095 
00096 
00097 
00098 <font class="comment">// ***************************************************************************</font>
<a name="l00099"></a><a class="code" href="classNL3D_1_1CCluster.html#d0">00099</a> <font class="keywordtype">void</font> CCluster::registerBasic ()
00100 {
00101         CMOT::registerModel (<a class="code" href="namespaceNL3D.html#a26">ClusterId</a>, 0, CCluster::creator);
00102         CMOT::registerObs (<a class="code" href="namespaceNL3D.html#a25">ClipTravId</a>, <a class="code" href="namespaceNL3D.html#a26">ClusterId</a>, CClusterClipObs::creator);
00103         CMOT::registerObs (<a class="code" href="namespaceNL3D.html#a41">HrcTravId</a>, <a class="code" href="namespaceNL3D.html#a26">ClusterId</a>, CClusterHrcObs::creator);
00104 }
00105 
00106 <font class="comment">// ***************************************************************************</font>
<a name="l00107"></a><a class="code" href="classNL3D_1_1CCluster.html#a2">00107</a> <font class="keywordtype">bool</font> CCluster::makeVolume (CVector&amp; p1, CVector&amp; p2, CVector&amp; p3)
00108 {
00109         uint i;
00110         <font class="comment">// Check if the plane is not close to a plane that already define the cluster</font>
00111         <font class="keywordflow">for</font> (i = 0; i &lt; <a class="code" href="classNL3D_1_1CCluster.html#o3">_LocalVolume</a>.size(); ++i)
00112         {
00113                 <font class="keywordtype">float</font> f1 = fabsf (<a class="code" href="classNL3D_1_1CCluster.html#o3">_LocalVolume</a>[i]*p1);
00114                 <font class="keywordtype">float</font> f2 = fabsf (<a class="code" href="classNL3D_1_1CCluster.html#o3">_LocalVolume</a>[i]*p2);
00115                 <font class="keywordtype">float</font> f3 = fabsf (<a class="code" href="classNL3D_1_1CCluster.html#o3">_LocalVolume</a>[i]*p3);
00116                 <font class="keywordflow">if</font> ((f1 &lt; <a class="code" href="cluster_8cpp.html#a0">CLUSTERPRECISION</a>) &amp;&amp; (f2 &lt; <a class="code" href="cluster_8cpp.html#a0">CLUSTERPRECISION</a>) &amp;&amp; (f3 &lt; <a class="code" href="cluster_8cpp.html#a0">CLUSTERPRECISION</a>))
00117                         <font class="keywordflow">return</font> <font class="keyword">true</font>;
00118         }
00119         <font class="comment">// Check if we want to add a triangle not completely in the predefined volume</font>
00120         <font class="keywordflow">for</font> (i = 0; i &lt; <a class="code" href="classNL3D_1_1CCluster.html#o3">_LocalVolume</a>.size(); ++i)
00121         {
00122                 <font class="keywordtype">float</font> f1 = <a class="code" href="classNL3D_1_1CCluster.html#o3">_LocalVolume</a>[i]*p1;
00123                 <font class="keywordtype">float</font> f2 = <a class="code" href="classNL3D_1_1CCluster.html#o3">_LocalVolume</a>[i]*p2;
00124                 <font class="keywordtype">float</font> f3 = <a class="code" href="classNL3D_1_1CCluster.html#o3">_LocalVolume</a>[i]*p3;
00125                 <font class="keywordflow">if</font> ((f1 &gt; <a class="code" href="cluster_8cpp.html#a0">CLUSTERPRECISION</a>) &amp;&amp; (f2 &gt; <a class="code" href="cluster_8cpp.html#a0">CLUSTERPRECISION</a>) &amp;&amp; (f3 &gt; <a class="code" href="cluster_8cpp.html#a0">CLUSTERPRECISION</a>))
00126                         <font class="keywordflow">return</font> <font class="keyword">false</font>;
00127         }
00128         <font class="comment">// Build volume</font>
00129         CPlane p;
00130         p.make (p1, p2, p3);
00131         p.normalize();
00132         <a class="code" href="classNL3D_1_1CCluster.html#o3">_LocalVolume</a>.push_back (p);
00133         <font class="comment">// Build BBox   </font>
00134         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CCluster.html#o3">_LocalVolume</a>.size() == 1)
00135                 <a class="code" href="classNL3D_1_1CCluster.html#o2">_LocalBBox</a>.<a class="code" href="classNLMISC_1_1CAABBox.html#z263_0">setCenter</a>(p1);
00136         <font class="keywordflow">else</font>
00137                 <a class="code" href="classNL3D_1_1CCluster.html#o2">_LocalBBox</a>.<a class="code" href="classNLMISC_1_1CAABBox.html#z263_4">extend</a>(p1);
00138         <a class="code" href="classNL3D_1_1CCluster.html#o2">_LocalBBox</a>.<a class="code" href="classNLMISC_1_1CAABBox.html#z263_4">extend</a>(p2);
00139         <a class="code" href="classNL3D_1_1CCluster.html#o2">_LocalBBox</a>.<a class="code" href="classNLMISC_1_1CAABBox.html#z263_4">extend</a>(p3);
00140         <a class="code" href="classNL3D_1_1CCluster.html#o5">_Volume</a> = <a class="code" href="classNL3D_1_1CCluster.html#o3">_LocalVolume</a>;
00141         <a class="code" href="classNL3D_1_1CCluster.html#o4">_BBox</a> = <a class="code" href="classNL3D_1_1CCluster.html#o2">_LocalBBox</a>;
00142         <font class="keywordflow">return</font> <font class="keyword">true</font>;
00143 }
00144 
00145 <font class="comment">// ***************************************************************************</font>
<a name="l00146"></a><a class="code" href="classNL3D_1_1CCluster.html#a4">00146</a> <font class="keywordtype">bool</font> CCluster::isIn (CVector&amp; p)
00147 {
00148         <font class="keywordflow">for</font> (uint i = 0; i &lt; <a class="code" href="classNL3D_1_1CCluster.html#o5">_Volume</a>.size(); ++i)
00149                 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CCluster.html#o5">_Volume</a>[i]*p &gt; <a class="code" href="cluster_8cpp.html#a0">CLUSTERPRECISION</a>)
00150                         <font class="keywordflow">return</font> <font class="keyword">false</font>;
00151         <font class="keywordflow">return</font> <font class="keyword">true</font>;
00152 }
00153 
00154 
00155 <font class="comment">// ***************************************************************************</font>
<a name="l00156"></a><a class="code" href="classNL3D_1_1CCluster.html#a5">00156</a> <font class="keywordtype">bool</font> CCluster::isIn (CAABBox&amp; b)
00157 {
00158         <font class="keywordflow">for</font> (uint i = 0; i &lt; <a class="code" href="classNL3D_1_1CCluster.html#o5">_Volume</a>.size(); ++i)
00159         {
00160                 <font class="keywordflow">if</font> (!b.clipBack (<a class="code" href="classNL3D_1_1CCluster.html#o5">_Volume</a>[i]))
00161                         <font class="keywordflow">return</font> <font class="keyword">false</font>;
00162         }
00163         <font class="keywordflow">return</font> <font class="keyword">true</font>;
00164 }
00165 
00166 <font class="comment">// ***************************************************************************</font>
<a name="l00167"></a><a class="code" href="classNL3D_1_1CCluster.html#a6">00167</a> <font class="keywordtype">bool</font> CCluster::isIn (<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>&amp; center, <font class="keywordtype">float</font> size)
00168 {
00169         <font class="keywordflow">for</font> (uint i = 0; i &lt; <a class="code" href="classNL3D_1_1CCluster.html#o5">_Volume</a>.size(); ++i)
00170                 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CCluster.html#o5">_Volume</a>[i]*center &gt; size)
00171                         <font class="keywordflow">return</font> <font class="keyword">false</font>;
00172         <font class="keywordflow">return</font> <font class="keyword">true</font>;
00173 }
00174 
00175 <font class="comment">// ***************************************************************************</font>
<a name="l00176"></a><a class="code" href="classNL3D_1_1CCluster.html#a8">00176</a> <font class="keywordtype">void</font> CCluster::resetPortalLinks ()
00177 {
00178         <a class="code" href="classNL3D_1_1CCluster.html#o1">_Portals</a>.clear();
00179 }
00180 
00181 <font class="comment">// ***************************************************************************</font>
<a name="l00182"></a><a class="code" href="classNL3D_1_1CCluster.html#a9">00182</a> <font class="keywordtype">void</font> CCluster::link (CPortal* portal)
00183 {
00184         <a class="code" href="classNL3D_1_1CCluster.html#o1">_Portals</a>.push_back (portal);
00185 }
00186 
00187 <font class="comment">// ***************************************************************************</font>
<a name="l00188"></a><a class="code" href="classNL3D_1_1CCluster.html#a10">00188</a> <font class="keywordtype">void</font> CCluster::unlink (CPortal* portal)
00189 {
00190         uint32 pos;
00191         <font class="keywordflow">for</font> (pos = 0; pos &lt; <a class="code" href="classNL3D_1_1CCluster.html#o1">_Portals</a>.size(); ++pos)
00192         {
00193                 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CCluster.html#o1">_Portals</a>[pos] == portal)
00194                         <font class="keywordflow">break</font>;
00195         }
00196         <font class="keywordflow">if</font> (pos &lt; <a class="code" href="classNL3D_1_1CCluster.html#o1">_Portals</a>.size())
00197                 <a class="code" href="classNL3D_1_1CCluster.html#o1">_Portals</a>.erase (<a class="code" href="classNL3D_1_1CCluster.html#o1">_Portals</a>.begin()+pos);
00198 }
00199 
00200 <font class="comment">// ***************************************************************************</font>
<a name="l00201"></a><a class="code" href="classNL3D_1_1CCluster.html#a14">00201</a> <font class="keywordtype">void</font> CCluster::serial (IStream&amp;f)
00202 {
00203         sint version = f.serialVersion (1);
00204 
00205         <font class="keywordflow">if</font> (version &gt;= 1)
00206                 f.serial (<a class="code" href="classNL3D_1_1CCluster.html#m1">Name</a>);
00207         
00208         f.serialCont (<a class="code" href="classNL3D_1_1CCluster.html#o3">_LocalVolume</a>);
00209         f.serial (<a class="code" href="classNL3D_1_1CCluster.html#o2">_LocalBBox</a>);
00210         f.serial (<a class="code" href="classNL3D_1_1CCluster.html#m2">FatherVisible</a>);
00211         f.serial (<a class="code" href="classNL3D_1_1CCluster.html#m3">VisibleFromFather</a>);
00212         <font class="keywordflow">if</font> (f.isReading())
00213         {
00214                 <a class="code" href="classNL3D_1_1CCluster.html#o5">_Volume</a> = <a class="code" href="classNL3D_1_1CCluster.html#o3">_LocalVolume</a>;
00215                 <a class="code" href="classNL3D_1_1CCluster.html#o4">_BBox</a> = <a class="code" href="classNL3D_1_1CCluster.html#o2">_LocalBBox</a>;
00216         }
00217 }
00218 
00219 <font class="comment">// ***************************************************************************</font>
<a name="l00220"></a><a class="code" href="classNL3D_1_1CCluster.html#a15">00220</a> <font class="keywordtype">void</font> CCluster::setWorldMatrix (<font class="keyword">const</font> CMatrix &amp;WM)
00221 {
00222         uint32 i;
00223         CMatrix invWM = WM;
00224         invWM.invert();
00225 
00226         <font class="comment">// Transform the volume</font>
00227         <font class="keywordflow">for</font> (i = 0; i &lt; <a class="code" href="classNL3D_1_1CCluster.html#o3">_LocalVolume</a>.size(); ++i)
00228                 <a class="code" href="classNL3D_1_1CCluster.html#o5">_Volume</a>[i] = <a class="code" href="classNL3D_1_1CCluster.html#o3">_LocalVolume</a>[i] * invWM;
00229 
00230         <a class="code" href="classNL3D_1_1CCluster.html#o4">_BBox</a> = <a class="code" href="classNLMISC_1_1CAABBox.html#z266_3">NLMISC::CAABBox::transformAABBox</a>(WM, <a class="code" href="classNL3D_1_1CCluster.html#o2">_LocalBBox</a>);
00231 
00232         <font class="comment">// Transform the bounding box</font>
00233         <font class="comment">/*CVector p[8];</font>
00234 <font class="comment">        p[0].x = _LocalBBox.getMin().x;</font>
00235 <font class="comment">        p[0].y = _LocalBBox.getMin().y;</font>
00236 <font class="comment">        p[0].z = _LocalBBox.getMin().z;</font>
00237 <font class="comment"></font>
00238 <font class="comment">        p[1].x = _LocalBBox.getMax().x;</font>
00239 <font class="comment">        p[1].y = _LocalBBox.getMin().y;</font>
00240 <font class="comment">        p[1].z = _LocalBBox.getMin().z;</font>
00241 <font class="comment"></font>
00242 <font class="comment">        p[2].x = _LocalBBox.getMin().x;</font>
00243 <font class="comment">        p[2].y = _LocalBBox.getMax().y;</font>
00244 <font class="comment">        p[2].z = _LocalBBox.getMin().z;</font>
00245 <font class="comment"></font>
00246 <font class="comment">        p[3].x = _LocalBBox.getMax().x;</font>
00247 <font class="comment">        p[3].y = _LocalBBox.getMax().y;</font>
00248 <font class="comment">        p[3].z = _LocalBBox.getMin().z;</font>
00249 <font class="comment"></font>
00250 <font class="comment">        p[4].x = _LocalBBox.getMin().x;</font>
00251 <font class="comment">        p[4].y = _LocalBBox.getMin().y;</font>
00252 <font class="comment">        p[4].z = _LocalBBox.getMax().z;</font>
00253 <font class="comment"></font>
00254 <font class="comment">        p[5].x = _LocalBBox.getMax().x;</font>
00255 <font class="comment">        p[5].y = _LocalBBox.getMin().y;</font>
00256 <font class="comment">        p[5].z = _LocalBBox.getMax().z;</font>
00257 <font class="comment"></font>
00258 <font class="comment">        p[6].x = _LocalBBox.getMin().x;</font>
00259 <font class="comment">        p[6].y = _LocalBBox.getMax().y;</font>
00260 <font class="comment">        p[6].z = _LocalBBox.getMax().z;</font>
00261 <font class="comment"></font>
00262 <font class="comment">        p[7].x = _LocalBBox.getMax().x;</font>
00263 <font class="comment">        p[7].y = _LocalBBox.getMax().y;</font>
00264 <font class="comment">        p[7].z = _LocalBBox.getMax().z;</font>
00265 <font class="comment"></font>
00266 <font class="comment">        for (i = 0; i &lt; 8; ++i)</font>
00267 <font class="comment">                p[i] = WM.mulPoint(p[i]);</font>
00268 <font class="comment"></font>
00269 <font class="comment">        CAABBox boxTemp;</font>
00270 <font class="comment"></font>
00271 <font class="comment">        boxTemp.setCenter(p[0]);</font>
00272 <font class="comment">        for (i = 1; i &lt; 8; ++i)</font>
00273 <font class="comment">                boxTemp.extend(p[i]);</font>
00274 <font class="comment">        _BBox = boxTemp;*/</font>
00275 }
00276 
00277 <font class="comment">// ***************************************************************************</font>
<a name="l00278"></a><a class="code" href="classNL3D_1_1CCluster.html#a13">00278</a> CClusterClipObs *CCluster::getClipObs()
00279 {
00280         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CCluster.html#o0">_Obs</a> == NULL)
00281                 <a class="code" href="classNL3D_1_1CCluster.html#o0">_Obs</a> = (CClusterClipObs*)<a class="code" href="classNL3D_1_1IModel.html#b3">getObs</a> (<a class="code" href="namespaceNL3D.html#a25">ClipTravId</a>);
00282         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CCluster.html#o0">_Obs</a>;
00283 }
00284 
00285 <font class="comment">// ---------------------------------------------------------------------------</font>
00286 <font class="comment">// Observer HRC</font>
00287 <font class="comment">// ---------------------------------------------------------------------------</font>
00288 
00289 <font class="comment">// ***************************************************************************</font>
<a name="l00290"></a><a class="code" href="classNL3D_1_1CClusterHrcObs.html#a0">00290</a> <font class="keywordtype">void</font> CClusterHrcObs::traverse (IObs *caller)
00291 {
00292         CTransformHrcObs::traverse (caller);
00293 
00294         <a class="code" href="classNL3D_1_1CClusterHrcObs.html#l0">CCluster</a> *pCluster = static_cast&lt;CCluster*&gt;(this-&gt;<a class="code" href="classNL3D_1_1IObs.html#m0">Model</a>);
00295 
00296         pCluster-&gt;setWorldMatrix (<a class="code" href="classNL3D_1_1IBaseHrcObs.html#z460_0">WorldMatrix</a>);
00297 
00298         <font class="keywordflow">for</font> (uint32 i = 0; i &lt; pCluster-&gt;getNbPortals(); ++i)
00299         {
00300                 CPortal *pPortal = pCluster-&gt;getPortal(i);
00301                 pPortal-&gt;setWorldMatrix (<a class="code" href="classNL3D_1_1IBaseHrcObs.html#z460_0">WorldMatrix</a>);
00302         }
00303 
00304         <font class="comment">// Re affect the cluster to the accelerator if not the root</font>
00305         <font class="keywordflow">if</font> (!pCluster-&gt;isRoot())
00306         {
00307                 pCluster-&gt;Group-&gt;_ClipTrav-&gt;Accel.erase (pCluster-&gt;AccelIt);
00308                 pCluster-&gt;Group-&gt;_ClipTrav-&gt;registerCluster (pCluster);
00309         }
00310 }
00311 
00312 <font class="comment">// ---------------------------------------------------------------------------</font>
00313 <font class="comment">// Observer CLIP</font>
00314 <font class="comment">// ---------------------------------------------------------------------------</font>
00315 
00316 <font class="comment">// ***************************************************************************</font>
<a name="l00317"></a><a class="code" href="classNL3D_1_1CClusterClipObs.html#a0">00317</a> CClusterClipObs::CClusterClipObs ()
00318 {
00319         <a class="code" href="classNL3D_1_1CClusterClipObs.html#o0">Visited</a> = <font class="keyword">false</font>;
00320 }
00321 
00322 <font class="comment">// ***************************************************************************</font>
<a name="l00323"></a><a class="code" href="classNL3D_1_1CClusterClipObs.html#a1">00323</a> <font class="keywordtype">bool</font> CClusterClipObs::clip (IBaseClipObs *caller)
00324 {
00325         <font class="keywordflow">return</font> <font class="keyword">true</font>;
00326 }
00327 
00328 <font class="comment">// ***************************************************************************</font>
<a name="l00329"></a><a class="code" href="classNL3D_1_1CClusterClipObs.html#a2">00329</a> <font class="keywordtype">void</font> CClusterClipObs::traverse (IObs *caller)
00330 {
00331         <a class="code" href="debug_8h.html#a6">nlassert</a>(!caller || dynamic_cast&lt;IBaseClipObs*&gt;(caller));
00332 
00333         <font class="keywordflow">if</font> (Visited)
00334                 <font class="keywordflow">return</font>;
00335         <a class="code" href="classNL3D_1_1CClusterClipObs.html#o0">Visited</a> = <font class="keyword">true</font>;
00336         <font class="comment">// The cluster is visible because we are in it</font>
00337         <font class="comment">// So clip the models attached (with MOT links) to the cluster</font>
00338         <a class="code" href="classNL3D_1_1IObs.html#z620_0">traverseSons</a>();
00339 
00340         <font class="comment">// And look through portals</font>
00341         <a class="code" href="classNL3D_1_1CClusterClipObs.html#l0">CCluster</a> *pCluster = static_cast&lt;CCluster*&gt;(this-&gt;<a class="code" href="classNL3D_1_1IObs.html#m0">Model</a>);
00342         uint32 i;
00343         <font class="keywordflow">for</font> (i = 0; i &lt; pCluster-&gt;getNbPortals(); ++i)
00344         {
00345                 CPortal*pPortal = pCluster-&gt;getPortal (i);
00346                 vector&lt;CPlane&gt; WorldPyrTemp = (static_cast&lt;CClipTrav*&gt;(Trav))-&gt;WorldPyramid;
00347                 <font class="keywordtype">bool</font> backfaceclipped = <font class="keyword">false</font>;
00348                 <a class="code" href="classNL3D_1_1CClusterClipObs.html#l0">CCluster</a> *pOtherSideCluster;
00349                 <font class="keywordflow">if</font> (pPortal-&gt;getCluster(0) == pCluster)
00350                         pOtherSideCluster = pPortal-&gt;getCluster (1);
00351                 <font class="keywordflow">else</font>
00352                         pOtherSideCluster = pPortal-&gt;getCluster (0);
00353 
00354                 <font class="keywordflow">if</font> (pCluster-&gt;Father != NULL)
00355                 <font class="keywordflow">if</font> (caller == pCluster-&gt;Father-&gt;getClipObs()) <font class="comment">// If the caller is the father</font>
00356                 <font class="keywordflow">if</font> (pCluster-&gt;VisibleFromFather)
00357                         <font class="comment">// Backface clipping</font>
00358                         <font class="keywordflow">if</font>( !pPortal-&gt;isInFront( (static_cast&lt;CClipTrav*&gt;(<a class="code" href="classNL3D_1_1IObs.html#m1">Trav</a>))-&gt;CamPos ))
00359                                 backfaceclipped = <font class="keyword">true</font>;
00360 
00361                 <font class="keywordflow">if</font> (!backfaceclipped)
00362                 <font class="keywordflow">if</font> (pPortal-&gt;clipPyramid ((static_cast&lt;CClipTrav*&gt;(<a class="code" href="classNL3D_1_1IObs.html#m1">Trav</a>))-&gt;CamPos,
00363                                                                 (static_cast&lt;CClipTrav*&gt;(<a class="code" href="classNL3D_1_1IObs.html#m1">Trav</a>))-&gt;WorldPyramid))
00364                 {
00365                         <a class="code" href="classNL3D_1_1CClusterClipObs.html#a0">CClusterClipObs</a> *pObserver = pOtherSideCluster-&gt;getClipObs();
00366                         pObserver-&gt;traverse (<font class="keyword">this</font>);
00367                 }
00368 
00369                 (static_cast&lt;CClipTrav*&gt;(Trav))-&gt;WorldPyramid = WorldPyrTemp;
00370         }
00371 
00372         <font class="comment">// Link up in hierarchy</font>
00373         <font class="keywordflow">if</font> ((pCluster-&gt;FatherVisible)&amp;&amp;(pCluster-&gt;Father != NULL))
00374         {
00375                 <a class="code" href="classNL3D_1_1CClusterClipObs.html#a0">CClusterClipObs</a> *pObserver = pCluster-&gt;Father-&gt;getClipObs();
00376                 pObserver-&gt;traverse (<font class="keyword">this</font>);
00377         }
00378 
00379         <font class="comment">// Link down in hierarchy</font>
00380         <font class="keywordflow">for</font> (i = 0; i &lt; pCluster-&gt;Children.size(); ++i)
00381         <font class="keywordflow">if</font> (pCluster-&gt;Children[i]-&gt;VisibleFromFather)
00382         {
00383                 <a class="code" href="classNL3D_1_1CClusterClipObs.html#a0">CClusterClipObs</a> *pObserver = pCluster-&gt;Children[i]-&gt;getClipObs();
00384                 pObserver-&gt;traverse (<font class="keyword">this</font>);
00385         }
00386 
00387         <a class="code" href="classNL3D_1_1CClusterClipObs.html#o0">Visited</a> = <font class="keyword">false</font>;
00388 }
00389 
00390 
00391 <font class="comment">// ***************************************************************************</font>
<a name="l00392"></a><a class="code" href="classNL3D_1_1CCluster.html#a3">00392</a> <font class="keywordtype">void</font> CCluster::applyMatrix(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CMatrix.html">NLMISC::CMatrix</a> &amp;m)
00393 {
00394         uint32 i;
00395         CMatrix invM = m;
00396         invM.<a class="code" href="classNLMISC_1_1CMatrix.html#z293_6">invert</a>();
00397         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CCluster.html#o5">_Volume</a>.size() == <a class="code" href="classNL3D_1_1CCluster.html#o3">_LocalVolume</a>.size());
00398 
00399         <font class="comment">// Transform the volume</font>
00400         <font class="keywordflow">for</font> (i = 0; i &lt; <a class="code" href="classNL3D_1_1CCluster.html#o3">_LocalVolume</a>.size(); ++i)
00401         {       
00402                 <a class="code" href="classNL3D_1_1CCluster.html#o5">_Volume</a>[i] = <a class="code" href="classNL3D_1_1CCluster.html#o5">_Volume</a>[i] * invM;
00403                 <a class="code" href="classNL3D_1_1CCluster.html#o3">_LocalVolume</a>[i] = <a class="code" href="classNL3D_1_1CCluster.html#o3">_LocalVolume</a>[i] * invM;
00404         }
00405 
00406         <font class="comment">// Transform the bounding boxes </font>
00407         <a class="code" href="classNL3D_1_1CCluster.html#o4">_BBox</a> = <a class="code" href="classNLMISC_1_1CAABBox.html#z266_3">NLMISC::CAABBox::transformAABBox</a>(m, <a class="code" href="classNL3D_1_1CCluster.html#o4">_BBox</a>);
00408         <a class="code" href="classNL3D_1_1CCluster.html#o2">_LocalBBox</a> = <a class="code" href="classNLMISC_1_1CAABBox.html#z266_3">NLMISC::CAABBox::transformAABBox</a>(m, <a class="code" href="classNL3D_1_1CCluster.html#o2">_LocalBBox</a>);   
00409 }
00410 
00411 
00412 } <font class="comment">// NL3D</font>
</pre></div>

<!-- footer -->
<BR><FONT Size=+5>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT>
</TD>
<TD WIDTH=15><IMG  SRC=/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>