KiCad PCB EDA Suite
test_cases.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
5  * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
31 #include <wx/debug.h>
38 
39 //#ifdef DEBUG
40 #if 0
41 static bool s_Run_Test_Cases = true;
42 
44 {
45  if( s_Run_Test_Cases == false)
46  return;
47 
48  s_Run_Test_Cases = true;
49 
50  // Test CBBOX2D
51  // /////////////////////////////////////////////////////////////////////////
52  CBBOX2D bbox2d_A;
53  CBBOX2D bbox2d_B;
54 
55  // Test a not initialized box conditions
56  /*
57  wxASSERT( bbox2d_A.IsInitialized() == false );
58  wxASSERT( bbox2d_A.Area() == 0.0f );
59  wxASSERT( bbox2d_A.GetCenter() == SFVEC2F( 0.0f, 0.0f ) );
60  wxASSERT( bbox2d_A.GetExtent() == SFVEC2F( 0.0f, 0.0f ) );
61  wxASSERT( bbox2d_A.Inside( SFVEC2F( 0.0f, 0.0f ) ) == false );
62  wxASSERT( bbox2d_A.Max() == SFVEC2F( 0.0f, 0.0f ) );
63  wxASSERT( bbox2d_A.Min() == SFVEC2F( 0.0f, 0.0f ) );
64  wxASSERT( bbox2d_A.Intersects( bbox2d_B ) == false );
65  wxASSERT( bbox2d_A.Intersects( bbox2d_A ) == false );
66  wxASSERT( bbox2d_A.MaxDimension() == 0 );
67  wxASSERT( bbox2d_A.Perimeter() == 0.0f );
68  */
69  bbox2d_A.Set( SFVEC2F(1.0f, -1.0f), SFVEC2F(-1.0f, 1.0f) );
70 
71  wxASSERT( bbox2d_A.IsInitialized() == true );
72  wxASSERT( bbox2d_A.Area() == 4.0f );
73  wxASSERT( bbox2d_A.GetCenter() == SFVEC2F( 0.0f, 0.0f ) );
74  wxASSERT( bbox2d_A.GetExtent() == SFVEC2F( 2.0f, 2.0f ) );
75  wxASSERT( bbox2d_A.Inside( SFVEC2F( 0.0f, 0.0f ) ) == true );
76  wxASSERT( bbox2d_A.Max() == SFVEC2F( 1.0f, 1.0f ) );
77  wxASSERT( bbox2d_A.Min() == SFVEC2F(-1.0f,-1.0f ) );
78  //wxASSERT( bbox2d_A.Intersects( bbox2d_B ) == false );
79  wxASSERT( bbox2d_A.Intersects( bbox2d_A ) == true );
80  wxASSERT( bbox2d_A.MaxDimension() == 0 );
81  wxASSERT( bbox2d_A.Perimeter() == 8.0f );
82 
83  bbox2d_A.Scale( 2.0f );
84 
85  wxASSERT( bbox2d_A.IsInitialized() == true );
86  wxASSERT( bbox2d_A.Area() == 16.0f );
87  wxASSERT( bbox2d_A.GetCenter() == SFVEC2F( 0.0f, 0.0f ) );
88  wxASSERT( bbox2d_A.GetExtent() == SFVEC2F( 4.0f, 4.0f ) );
89  wxASSERT( bbox2d_A.Inside( SFVEC2F( 0.0f, 0.0f ) ) == true );
90  wxASSERT( bbox2d_A.Max() == SFVEC2F( 2.0f, 2.0f ) );
91  wxASSERT( bbox2d_A.Min() == SFVEC2F(-2.0f,-2.0f ) );
92  //wxASSERT( bbox2d_A.Intersects( bbox2d_B ) == false );
93  wxASSERT( bbox2d_A.Intersects( bbox2d_A ) == true );
94  wxASSERT( bbox2d_A.MaxDimension() == 0 );
95  wxASSERT( bbox2d_A.Perimeter() == 16.0f );
96 
97  bbox2d_B.Set( SFVEC2F(2.1f, 2.0f), SFVEC2F( 3.0f, 3.0f) );
98  wxASSERT( bbox2d_A.Intersects( bbox2d_B ) == false );
99  bbox2d_B.Set( SFVEC2F(2.0f, 2.1f), SFVEC2F( 3.0f, 3.0f) );
100  wxASSERT( bbox2d_A.Intersects( bbox2d_B ) == false );
101  bbox2d_B.Set( SFVEC2F(2.1f, 2.1f), SFVEC2F( 3.0f, 3.0f) );
102  wxASSERT( bbox2d_A.Intersects( bbox2d_B ) == false );
103 
104  bbox2d_B.Set( SFVEC2F(2.0f, 2.0f), SFVEC2F( 3.0f, 3.0f) );
105  wxASSERT( bbox2d_A.Intersects( bbox2d_B ) == true );
106 
107  bbox2d_A.Union( bbox2d_B );
108 
109  wxASSERT( bbox2d_A.IsInitialized() == true );
110  wxASSERT( bbox2d_A.Area() == 25.0f );
111  wxASSERT( bbox2d_A.GetCenter() == SFVEC2F( 0.5f, 0.5f ) );
112  wxASSERT( bbox2d_A.GetExtent() == SFVEC2F( 5.0f, 5.0f ) );
113  wxASSERT( bbox2d_A.Inside( SFVEC2F( 0.0f, 0.0f ) ) == true );
114  wxASSERT( bbox2d_A.Inside( SFVEC2F( 3.0f, 3.0f ) ) == true );
115  wxASSERT( bbox2d_A.Inside( SFVEC2F(-2.0f,-2.0f ) ) == true );
116  wxASSERT( bbox2d_A.Max() == SFVEC2F( 3.0f, 3.0f ) );
117  wxASSERT( bbox2d_A.Min() == SFVEC2F(-2.0f,-2.0f ) );
118  wxASSERT( bbox2d_A.Intersects( bbox2d_B ) == true );
119  wxASSERT( bbox2d_A.Intersects( bbox2d_A ) == true );
120  wxASSERT( bbox2d_A.MaxDimension() == 0 );
121  wxASSERT( bbox2d_A.Perimeter() == 20.0f );
122 
123  bbox2d_A.Set( SFVEC2F(-1.0f, -1.0f), SFVEC2F(1.0f, 1.0f) );
124  bbox2d_B.Set( SFVEC2F(-2.0f, -2.0f), SFVEC2F(2.0f, 2.0f) );
125  wxASSERT( bbox2d_A.Intersects( bbox2d_B ) == true );
126  wxASSERT( bbox2d_B.Intersects( bbox2d_A ) == true );
127 
128  bbox2d_B.Set( SFVEC2F( 1.0f, 1.0f), SFVEC2F(1.0f, 1.0f) );
129  wxASSERT( bbox2d_A.Intersects( bbox2d_B ) == true );
130 
131  bbox2d_B.Set( SFVEC2F( 1.1f, 1.1f), SFVEC2F(2.0f, 2.0f) );
132  wxASSERT( bbox2d_A.Intersects( bbox2d_B ) == false );
133 
134  bbox2d_B.Set( SFVEC2F(-0.5f, -0.5f), SFVEC2F(0.5f, 0.5f) );
135  wxASSERT( bbox2d_A.Intersects( bbox2d_B ) == true );
136 
137 
138  // Test CFILLEDCIRCLE2D
139  // /////////////////////////////////////////////////////////////////////////
140 
141  CFILLEDCIRCLE2D filledCircle2d( SFVEC2F( 2.0f, 2.0f ), 1.0f );
142 
143  wxASSERT( filledCircle2d.IsPointInside( SFVEC2F( 2.0f, 2.0f ) ) == true );
144 
145  wxASSERT( filledCircle2d.IsPointInside( SFVEC2F( 2.0f, 3.0f ) ) == true );
146  wxASSERT( filledCircle2d.IsPointInside( SFVEC2F( 3.0f, 2.0f ) ) == true );
147  wxASSERT( filledCircle2d.IsPointInside( SFVEC2F( 1.0f, 2.0f ) ) == true );
148  wxASSERT( filledCircle2d.IsPointInside( SFVEC2F( 2.0f, 1.0f ) ) == true );
149 
150  wxASSERT( filledCircle2d.IsPointInside( SFVEC2F( 2.8f, 2.8f ) ) == false );
151  wxASSERT( filledCircle2d.IsPointInside( SFVEC2F( 2.6f, 2.6f ) ) == true );
152  wxASSERT( filledCircle2d.IsPointInside( SFVEC2F( 1.2f, 1.2f ) ) == false );
153 
154  bbox2d_B.Set( SFVEC2F( 0.0f, 0.0f), SFVEC2F( 4.0f, 4.0f) );
155  wxASSERT( filledCircle2d.Intersects( bbox2d_B ) == true );
156 
157  bbox2d_B.Set( SFVEC2F( 1.5f, 1.5f), SFVEC2F( 2.5f, 2.5f) );
158  wxASSERT( filledCircle2d.Intersects( bbox2d_B ) == true );
159 
160  // A box that does not intersect the sphere but still intersect the bbox of the sphere
161  bbox2d_B.Set( SFVEC2F( 0.0f, 0.0f), SFVEC2F( 1.2f, 1.2f) );
162  wxASSERT( filledCircle2d.Intersects( bbox2d_B ) == false );
163 
164  bbox2d_B.Set( SFVEC2F(-1.0f, -1.0f), SFVEC2F( 0.5f, 0.5f) );
165  wxASSERT( filledCircle2d.Intersects( bbox2d_B ) == false );
166 
167  bbox2d_B.Set( SFVEC2F( 0.0f, 0.0f), SFVEC2F( 2.0f, 2.0f) );
168  wxASSERT( filledCircle2d.Intersects( bbox2d_B ) == true );
169 
170  bbox2d_B.Set( SFVEC2F( 0.0f, 0.0f), SFVEC2F( 2.0f, 4.0f) );
171  wxASSERT( filledCircle2d.Intersects( bbox2d_B ) == true );
172 
173  bbox2d_B.Set( SFVEC2F( 2.0f, 0.0f), SFVEC2F( 4.0f, 4.0f) );
174  wxASSERT( filledCircle2d.Intersects( bbox2d_B ) == true );
175 
176  bbox2d_B.Set( SFVEC2F( 0.0f, 2.0f), SFVEC2F( 4.0f, 4.0f) );
177  wxASSERT( filledCircle2d.Intersects( bbox2d_B ) == true );
178 
179  bbox2d_B.Set( SFVEC2F( 0.0f, 0.0f), SFVEC2F( 4.0f, 2.0f) );
180  wxASSERT( filledCircle2d.Intersects( bbox2d_B ) == true );
181 
182 
183  // Test CROUNDSEGMENT2D
184  // /////////////////////////////////////////////////////////////////////////
185 
186  CROUNDSEGMENT2D roundSegment2d( SFVEC2F(-1.0f, 0.0f), SFVEC2F( 1.0f, 0.0f), 2.0f);
187 
188  wxASSERT( roundSegment2d.IsPointInside( SFVEC2F( 0.0f, 0.0f ) ) == true );
189  wxASSERT( roundSegment2d.IsPointInside( SFVEC2F( 1.0f, 0.0f ) ) == true );
190  wxASSERT( roundSegment2d.IsPointInside( SFVEC2F(-1.0f, 0.0f ) ) == true );
191  wxASSERT( roundSegment2d.IsPointInside( SFVEC2F(-2.0f, 0.0f ) ) == true );
192  wxASSERT( roundSegment2d.IsPointInside( SFVEC2F( 2.0f, 0.0f ) ) == true );
193  wxASSERT( roundSegment2d.IsPointInside( SFVEC2F( 0.0f, 1.0f ) ) == true );
194  wxASSERT( roundSegment2d.IsPointInside( SFVEC2F( 0.0f,-1.0f ) ) == true );
195  wxASSERT( roundSegment2d.IsPointInside( SFVEC2F( 0.0f, 1.1f ) ) == false );
196  wxASSERT( roundSegment2d.IsPointInside( SFVEC2F( 0.0f,-1.1f ) ) == false );
197  wxASSERT( roundSegment2d.IsPointInside( SFVEC2F( 2.1f, 0.0f ) ) == false );
198  wxASSERT( roundSegment2d.IsPointInside( SFVEC2F( 2.1f, 0.0f ) ) == false );
199 
200  wxASSERT( roundSegment2d.IsPointInside( SFVEC2F( 1.8f, 0.8f ) ) == false );
201  wxASSERT( roundSegment2d.IsPointInside( SFVEC2F( 1.8f,-0.8f ) ) == false );
202 
203  wxASSERT( roundSegment2d.IsPointInside( SFVEC2F(-1.8f, 0.8f ) ) == false );
204  wxASSERT( roundSegment2d.IsPointInside( SFVEC2F(-1.8f,-0.8f ) ) == false );
205 
206  wxASSERT( roundSegment2d.IsPointInside( SFVEC2F( 1.6f, 0.6f ) ) == true );
207  wxASSERT( roundSegment2d.IsPointInside( SFVEC2F( 1.6f,-0.6f ) ) == true );
208 
209  wxASSERT( roundSegment2d.IsPointInside( SFVEC2F(-1.6f, 0.6f ) ) == true );
210  wxASSERT( roundSegment2d.IsPointInside( SFVEC2F(-1.6f,-0.6f ) ) == true );
211 
212  bbox2d_A.Set( SFVEC2F(-2.0f,-1.0f), SFVEC2F( 2.0f, 1.0f) );
213  wxASSERT( roundSegment2d.Intersects( bbox2d_A ) == true );
214 
215  bbox2d_A.Set( SFVEC2F(-2.1f,-1.1f), SFVEC2F( 2.1f, 1.1f) );
216  wxASSERT( roundSegment2d.Intersects( bbox2d_A ) == true );
217 
218  bbox2d_A.Set( SFVEC2F(-1.9f,-0.9f), SFVEC2F( 1.9f, 0.9f) );
219  wxASSERT( roundSegment2d.Intersects( bbox2d_A ) == true );
220 
221  bbox2d_A.Set( SFVEC2F(-1.0f,-1.0f), SFVEC2F( 1.0f, 1.0f) );
222  wxASSERT( roundSegment2d.Intersects( bbox2d_A ) == true );
223 
224  bbox2d_A.Set( SFVEC2F(-1.0f,-0.5f), SFVEC2F( 1.0f, 0.5f) );
225  wxASSERT( roundSegment2d.Intersects( bbox2d_A ) == true );
226 
227  bbox2d_A.Set( SFVEC2F(-4.0f,-0.5f), SFVEC2F(-3.0f, 0.5f) );
228  wxASSERT( roundSegment2d.Intersects( bbox2d_A ) == false );
229 
230  bbox2d_A.Set( SFVEC2F( 1.8f, 0.8f), SFVEC2F( 2.0f, 1.0f) );
231  wxASSERT( roundSegment2d.Intersects( bbox2d_A ) == false );
232 
233  bbox2d_A.Set( SFVEC2F(-2.0f, 0.8f), SFVEC2F(-1.8f, 1.0f) );
234  wxASSERT( roundSegment2d.Intersects( bbox2d_A ) == false );
235 
236  bbox2d_A.Set( SFVEC2F(-2.0f,-1.0f), SFVEC2F(-1.8f,-0.8f) );
237  wxASSERT( roundSegment2d.Intersects( bbox2d_A ) == false );
238 
239  // Test CPOLYGON2D
240  // /////////////////////////////////////////////////////////////////////////
242 #if 0
243  // Test Frustum
244  // /////////////////////////////////////////////////////////////////////////
245  {
246  CFRUSTUM frustum;
247 
248  SFVEC3F ori = SFVEC3F(0.0, 0.0, 0.0);
249 
250  float z = 10.0;
251 /*
252  const RAY topLeft( ori, glm::normalize( SFVEC3F(+1.0,-1.0, z) - ori ) );
253  const RAY topRight( ori, glm::normalize( SFVEC3F(-1.0,-1.0, z) - ori ) );
254  const RAY bottomLeft( ori, glm::normalize( SFVEC3F(+1.0,+1.0, z) - ori ) );
255  const RAY bottomRight( ori, glm::normalize( SFVEC3F(-1.0,+1.0, z) - ori ) );
256 */
257 /*
258  const RAY topLeft( ori, glm::normalize( SFVEC3F(+1.0,+1.0, z) - ori ) );
259  const RAY topRight( ori, glm::normalize( SFVEC3F(-1.0,+1.0, z) - ori ) );
260  const RAY bottomLeft( ori, glm::normalize( SFVEC3F(+1.0,-1.0, z) - ori ) );
261  const RAY bottomRight( ori, glm::normalize( SFVEC3F(-1.0,-1.0, z) - ori ) );
262 */
263 /*
264  const RAY topLeft( ori, glm::normalize( SFVEC3F(-1.0,-1.0, z) - ori ) );
265  const RAY topRight( ori, glm::normalize( SFVEC3F(+1.0,-1.0, z) - ori ) );
266  const RAY bottomLeft( ori, glm::normalize( SFVEC3F(-1.0,+1.0, z) - ori ) );
267  const RAY bottomRight( ori, glm::normalize( SFVEC3F(+1.0,+1.0, z) - ori ) );
268 */
269 /*
270  const RAY topLeft( ori, glm::normalize( SFVEC3F(-1.0,+1.0, z) - ori ) );
271  const RAY topRight( ori, glm::normalize( SFVEC3F(+1.0,+1.0, z) - ori ) );
272  const RAY bottomLeft( ori, glm::normalize( SFVEC3F(-1.0,-1.0, z) - ori ) );
273  const RAY bottomRight( ori, glm::normalize( SFVEC3F(+1.0,-1.0, z) - ori ) );
274 */
275 /*
276  const RAY topLeft( ori, glm::normalize( ori - SFVEC3F(+1.0,-1.0, z) ) );
277  const RAY topRight( ori, glm::normalize( ori - SFVEC3F(-1.0,-1.0, z) ) );
278  const RAY bottomLeft( ori, glm::normalize( ori - SFVEC3F(+1.0,+1.0, z) ) );
279  const RAY bottomRight( ori, glm::normalize( ori - SFVEC3F(-1.0,+1.0, z) ) );
280 */
281 /*
282  const RAY topLeft( ori, glm::normalize( ori - SFVEC3F(-1.0,-1.0, z) ) );
283  const RAY topRight( ori, glm::normalize( ori - SFVEC3F(+1.0,-1.0, z) ) );
284  const RAY bottomLeft( ori, glm::normalize( ori - SFVEC3F(-1.0,+1.0, z) ) );
285  const RAY bottomRight( ori, glm::normalize( ori - SFVEC3F(+1.0,+1.0, z) ) );
286 */
287 /*
288  const RAY topLeft( ori, glm::normalize( ori - SFVEC3F(-1.0,+1.0, z) ) );
289  const RAY topRight( ori, glm::normalize( ori - SFVEC3F(+1.0,+1.0, z) ) );
290  const RAY bottomLeft( ori, glm::normalize( ori - SFVEC3F(-1.0,-1.0, z) ) );
291  const RAY bottomRight( ori, glm::normalize( ori - SFVEC3F(+1.0,-1.0, z) ) );
292 */
293 
294  const RAY topLeft( ori, glm::normalize( ori - SFVEC3F(+1.0,+1.0, z) ) );
295  const RAY topRight( ori, glm::normalize( ori - SFVEC3F(-1.0,+1.0, z) ) );
296  const RAY bottomLeft( ori, glm::normalize( ori - SFVEC3F(+1.0,-1.0, z) ) );
297  const RAY bottomRight( ori, glm::normalize( ori - SFVEC3F(-1.0,-1.0, z) ) );
298 
299 
300 
301  frustum.GenerateFrustum( topLeft, topRight, bottomLeft, bottomRight );
302 
303  CBBOX bbox3d;
304 
305  bbox3d.Set( SFVEC3F(-1.0f, -1.0f, z), SFVEC3F(+1.0f,+1.0f, z + 1.0f) );
306  wxASSERT( frustum.Intersect( bbox3d ) == true );
307 
308  bbox3d.Set( SFVEC3F(-1.0f, -1.0f, z+z), SFVEC3F(+1.0f,+1.0f, z+z + 1.0f) );
309  wxASSERT( frustum.Intersect( bbox3d ) == true );
310 
311  bbox3d.Set( SFVEC3F(-1.0f, -1.0f, 1.0f), SFVEC3F(0.0f,0.0f, 2.0f) );
312  wxASSERT( frustum.Intersect( bbox3d ) == true );
313 
314  bbox3d.Set( SFVEC3F(-1.0f, -1.0f, -z-1.0f), SFVEC3F(+1.0f,+1.0f, -z) );
315  wxASSERT( frustum.Intersect( bbox3d ) == false );
316 
317  bbox3d.Set( SFVEC3F(z-1.0f, z-1.0f, 0.0), SFVEC3F(z+1.0f,z+1.0f, 1.0) );
318  wxASSERT( frustum.Intersect( bbox3d ) == false );
319 
320  bbox3d.Set( SFVEC3F(-z, -z, 0.0), SFVEC3F( -1.0f,-1.0f, 1.0f) );
321  wxASSERT( frustum.Intersect( bbox3d ) == false );
322 
323  bbox3d.Set( SFVEC3F(-z, -z, -1.0f), SFVEC3F(+z,+z, 1.0f) );
324  wxASSERT( frustum.Intersect( bbox3d ) == true );
325 
326  bbox3d.Set( SFVEC3F(-z, -z, z-1), SFVEC3F(+z,+z, z+1.0f) );
327  wxASSERT( frustum.Intersect( bbox3d ) == true );
328 
329  bbox3d.Set( SFVEC3F( 0.5, 0.5, 0.0), SFVEC3F( 2.0, 2.0, z) );
330  wxASSERT( frustum.Intersect( bbox3d ) == true );
331 
332  bbox3d.Set( SFVEC3F( 1.1, 1.0, 0.0), SFVEC3F( 2.0, 2.0, z) );
333  wxASSERT( frustum.Intersect( bbox3d ) == false );
334  }
335  {
336  CFRUSTUM frustum;
337 
338  float z = 10.0;
339 
340  SFVEC3F ori = SFVEC3F(0.0, 0.0, z);
341 
342  const RAY topLeft( ori, glm::normalize( SFVEC3F(-1.0, 1.0, 0.0) - ori ) );
343  const RAY topRight( ori, glm::normalize( SFVEC3F(+1.0, 1.0, 0.0) - ori ) );
344  const RAY bottomLeft( ori, glm::normalize( SFVEC3F(-1.0,-1.0, 0.0) - ori ) );
345  const RAY bottomRight( ori, glm::normalize( SFVEC3F(+1.0,-1.0, 0.0) - ori ) );
346 
347  frustum.GenerateFrustum( topLeft, topRight, bottomLeft, bottomRight );
348 
349  CBBOX bbox3d;
350 
351  bbox3d.Set( SFVEC3F(-1.0f, -1.0f, -z), SFVEC3F(+1.0f,+1.0f, -z + 1.0f) );
352  wxASSERT( frustum.Intersect( bbox3d ) == true );
353 
354  bbox3d.Set( SFVEC3F(-1.0f, -1.0f, -(z+z)), SFVEC3F(+1.0f,+1.0f, -(z+z + 1.0f)) );
355  wxASSERT( frustum.Intersect( bbox3d ) == true );
356 
357  bbox3d.Set( SFVEC3F(-1.0f, -1.0f, 1.0f), SFVEC3F(0.0f,0.0f, 2.0f) );
358  wxASSERT( frustum.Intersect( bbox3d ) == true );
359 
360  // !TODO: The frustum alg is not excluse all the the situations
361  //bbox3d.Set( SFVEC3F(-1.0f, -1.0f, z+1.0f), SFVEC3F(+1.0f,+1.0f, +z+2.0f) );
362  //wxASSERT( frustum.Intersect( bbox3d ) == false );
363 
364  bbox3d.Set( SFVEC3F(z-1.0f, z-1.0f, 0.0), SFVEC3F(z+1.0f,z+1.0f, 1.0) );
365  wxASSERT( frustum.Intersect( bbox3d ) == false );
366 
367  bbox3d.Set( SFVEC3F(-z, -z, 0.0), SFVEC3F( -1.0f,-1.0f, 1.0f) );
368  wxASSERT( frustum.Intersect( bbox3d ) == false );
369 
370  bbox3d.Set( SFVEC3F(-z, -z, -1.0f), SFVEC3F(+z,+z, 1.0f) );
371  wxASSERT( frustum.Intersect( bbox3d ) == true );
372 
373  bbox3d.Set( SFVEC3F(-z, -z, -(z-1)), SFVEC3F(+z,+z, -(z+1.0f)) );
374  wxASSERT( frustum.Intersect( bbox3d ) == true );
375 
376  bbox3d.Set( SFVEC3F( 0.5, 0.5, 0.0), SFVEC3F( 2.0, 2.0, z) );
377  wxASSERT( frustum.Intersect( bbox3d ) == true );
378 
379  bbox3d.Set( SFVEC3F( 1.1, 1.0, 0.0), SFVEC3F( 2.0, 2.0, z) );
380  wxASSERT( frustum.Intersect( bbox3d ) == false );
381  }
382 #endif
383 }
384 #endif
bool IsInitialized() const
Function IsInitialized check if this bounding box is already initialized.
Definition: cbbox2d.cpp:79
void Union(const SFVEC2F &aPoint)
Function Union recalculate the bounding box adding a point.
Definition: cbbox2d.cpp:95
void GenerateFrustum(const RAY &topLeft, const RAY &topRight, const RAY &bottomLeft, const RAY &bottomRight)
GenerateFrustum.
Definition: cfrustum.cpp:42
float Perimeter() const
Function Perimeter.
Definition: cbbox2d.cpp:144
Class CBBOX manages a bounding box defined by two SFVEC2F min max points.
Definition: cbbox2d.h:40
Definition: ray.h:43
void Set(const SFVEC3F &aPbMin, const SFVEC3F &aPbMax)
Function Set Set bounding box with new parameters.
Definition: cbbox.cpp:67
bool Intersects(const CBBOX2D &aBBox) const
Function Intersects test if a bounding box intersects this box.
Definition: cbbox2d.cpp:213
void Run_3d_viewer_test_cases()
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
void Scale(float aScale)
Function Scale scales a bounding box by its center.
Definition: cbbox2d.cpp:152
void Set(const SFVEC2F &aPbMin, const SFVEC2F &aPbMax)
Function Set Set bounding box with new parameters.
Definition: cbbox2d.cpp:61
implements a frustum that is used to test ray pack tests
float Area() const
Function Area calculate the area of a bounding box.
Definition: cbbox2d.cpp:234
bool Intersect(const CBBOX &aBBox) const
Intersect - Intersects a bbox with this frustum.
Definition: cfrustum.cpp:65
2D Bounding Box class definition
void Polygon2d_TestModule()
SFVEC2F GetCenter() const
Function GetCenter return the center point of the bounding box.
Definition: cbbox2d.cpp:121
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
unsigned int MaxDimension() const
Function MaxDimension.
Definition: cbbox2d.cpp:133
bool Inside(const SFVEC2F &aPoint) const
Function Inside check is a point is inside this bounding box.
Definition: cbbox2d.cpp:225
const SFVEC2F & Min() const
Function Min return the minimun vertex pointer.
Definition: cbbox2d.h:176
SFVEC2F GetExtent() const
Function GetExtent.
Definition: cbbox2d.cpp:127
Class CBBOX manages a bounding box defined by two SFVEC3F min max points.
Definition: cbbox.h:40
Bounding Box class definition.
const SFVEC2F & Max() const
Function Max return the maximum vertex pointer.
Definition: cbbox2d.h:183