source: src/Shapes/unittests/BaseShapesUnitTest.cpp@ 571d04

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since 571d04 was 571d04, checked in by Frederik Heber <heber@…>, 13 years ago

Renamed ShapeUnitTest -> BaseShapesUnitTest.

  • Property mode set to 100644
File size: 24.2 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/*
9 * BaseShapesUnitTest.cpp
10 *
11 * Created on: Jun 18, 2010
12 * Author: crueger
13 */
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20#include <cppunit/CompilerOutputter.h>
21#include <cppunit/extensions/TestFactoryRegistry.h>
22#include <cppunit/ui/text/TestRunner.h>
23
24#include <cmath>
25
26#ifdef HAVE_TESTRUNNER
27#include "UnitTestMain.hpp"
28#endif /*HAVE_TESTRUNNER*/
29
30#include "CodePatterns/Assert.hpp"
31
32#include "Helpers/defs.hpp"
33#include "LinearAlgebra/Vector.hpp"
34#include "Shapes/BaseShapes.hpp"
35#include "Shapes/Shape.hpp"
36
37#include "BaseShapesUnitTest.hpp"
38
39// Registers the fixture into the 'registry'
40CPPUNIT_TEST_SUITE_REGISTRATION( BaseShapesTest );
41
42void BaseShapesTest::setUp()
43{
44 // failing asserts should be thrown
45 ASSERT_DO(Assert::Throw);
46
47 v000 = 0*unitVec[0]+0*unitVec[1]+0*unitVec[2];
48 v100 = 1*unitVec[0]+0*unitVec[1]+0*unitVec[2];
49 v200 = -1*unitVec[0]+0*unitVec[1]+0*unitVec[2];
50 v010 = 0*unitVec[0]+1*unitVec[1]+0*unitVec[2];
51 v110 = 1*unitVec[0]+1*unitVec[1]+0*unitVec[2];
52 v210 = -1*unitVec[0]+1*unitVec[1]+0*unitVec[2];
53 v020 = 0*unitVec[0]-1*unitVec[1]+0*unitVec[2];
54 v120 = 1*unitVec[0]-1*unitVec[1]+0*unitVec[2];
55 v220 = -1*unitVec[0]-1*unitVec[1]+0*unitVec[2];
56 v001 = 0*unitVec[0]+0*unitVec[1]+1*unitVec[2];
57 v101 = 1*unitVec[0]+0*unitVec[1]+1*unitVec[2];
58 v201 = -1*unitVec[0]+0*unitVec[1]+1*unitVec[2];
59 v011 = 0*unitVec[0]+1*unitVec[1]+1*unitVec[2];
60 v111 = 1*unitVec[0]+1*unitVec[1]+1*unitVec[2];
61 v211 = -1*unitVec[0]+1*unitVec[1]+1*unitVec[2];
62 v021 = 0*unitVec[0]-1*unitVec[1]+1*unitVec[2];
63 v121 = 1*unitVec[0]-1*unitVec[1]+1*unitVec[2];
64 v221 = -1*unitVec[0]-1*unitVec[1]+1*unitVec[2];
65 v002 = 0*unitVec[0]+0*unitVec[1]-1*unitVec[2];
66 v102 = 1*unitVec[0]+0*unitVec[1]-1*unitVec[2];
67 v202 = -1*unitVec[0]+0*unitVec[1]-1*unitVec[2];
68 v012 = 0*unitVec[0]+1*unitVec[1]-1*unitVec[2];
69 v112 = 1*unitVec[0]+1*unitVec[1]-1*unitVec[2];
70 v212 = -1*unitVec[0]+1*unitVec[1]-1*unitVec[2];
71 v022 = 0*unitVec[0]-1*unitVec[1]-1*unitVec[2];
72 v122 = 1*unitVec[0]-1*unitVec[1]-1*unitVec[2];
73 v222 = -1*unitVec[0]-1*unitVec[1]-1*unitVec[2];
74}
75
76void BaseShapesTest::tearDown()
77{}
78
79
80void BaseShapesTest::baseShapesTest(){
81 CPPUNIT_ASSERT(!Nowhere().isInside(v000));
82 CPPUNIT_ASSERT(!Nowhere().isInside(v100));
83 CPPUNIT_ASSERT(!Nowhere().isInside(v200));
84 CPPUNIT_ASSERT(!Nowhere().isInside(v010));
85 CPPUNIT_ASSERT(!Nowhere().isInside(v110));
86 CPPUNIT_ASSERT(!Nowhere().isInside(v210));
87 CPPUNIT_ASSERT(!Nowhere().isInside(v020));
88 CPPUNIT_ASSERT(!Nowhere().isInside(v120));
89 CPPUNIT_ASSERT(!Nowhere().isInside(v220));
90 CPPUNIT_ASSERT(!Nowhere().isInside(v001));
91 CPPUNIT_ASSERT(!Nowhere().isInside(v101));
92 CPPUNIT_ASSERT(!Nowhere().isInside(v201));
93 CPPUNIT_ASSERT(!Nowhere().isInside(v011));
94 CPPUNIT_ASSERT(!Nowhere().isInside(v111));
95 CPPUNIT_ASSERT(!Nowhere().isInside(v211));
96 CPPUNIT_ASSERT(!Nowhere().isInside(v021));
97 CPPUNIT_ASSERT(!Nowhere().isInside(v121));
98 CPPUNIT_ASSERT(!Nowhere().isInside(v221));
99 CPPUNIT_ASSERT(!Nowhere().isInside(v002));
100 CPPUNIT_ASSERT(!Nowhere().isInside(v102));
101 CPPUNIT_ASSERT(!Nowhere().isInside(v202));
102 CPPUNIT_ASSERT(!Nowhere().isInside(v012));
103 CPPUNIT_ASSERT(!Nowhere().isInside(v112));
104 CPPUNIT_ASSERT(!Nowhere().isInside(v212));
105 CPPUNIT_ASSERT(!Nowhere().isInside(v022));
106 CPPUNIT_ASSERT(!Nowhere().isInside(v122));
107 CPPUNIT_ASSERT(!Nowhere().isInside(v222));
108
109 CPPUNIT_ASSERT(Everywhere().isInside(v000));
110 CPPUNIT_ASSERT(Everywhere().isInside(v100));
111 CPPUNIT_ASSERT(Everywhere().isInside(v200));
112 CPPUNIT_ASSERT(Everywhere().isInside(v010));
113 CPPUNIT_ASSERT(Everywhere().isInside(v110));
114 CPPUNIT_ASSERT(Everywhere().isInside(v210));
115 CPPUNIT_ASSERT(Everywhere().isInside(v020));
116 CPPUNIT_ASSERT(Everywhere().isInside(v120));
117 CPPUNIT_ASSERT(Everywhere().isInside(v220));
118 CPPUNIT_ASSERT(Everywhere().isInside(v001));
119 CPPUNIT_ASSERT(Everywhere().isInside(v101));
120 CPPUNIT_ASSERT(Everywhere().isInside(v201));
121 CPPUNIT_ASSERT(Everywhere().isInside(v011));
122 CPPUNIT_ASSERT(Everywhere().isInside(v111));
123 CPPUNIT_ASSERT(Everywhere().isInside(v211));
124 CPPUNIT_ASSERT(Everywhere().isInside(v021));
125 CPPUNIT_ASSERT(Everywhere().isInside(v121));
126 CPPUNIT_ASSERT(Everywhere().isInside(v221));
127 CPPUNIT_ASSERT(Everywhere().isInside(v002));
128 CPPUNIT_ASSERT(Everywhere().isInside(v102));
129 CPPUNIT_ASSERT(Everywhere().isInside(v202));
130 CPPUNIT_ASSERT(Everywhere().isInside(v012));
131 CPPUNIT_ASSERT(Everywhere().isInside(v112));
132 CPPUNIT_ASSERT(Everywhere().isInside(v212));
133 CPPUNIT_ASSERT(Everywhere().isInside(v022));
134 CPPUNIT_ASSERT(Everywhere().isInside(v122));
135 CPPUNIT_ASSERT(Everywhere().isInside(v222));
136
137 Shape s1 = Sphere();
138
139 CPPUNIT_ASSERT(s1.isInside(v000));
140 CPPUNIT_ASSERT(s1.isInside(v100));
141 CPPUNIT_ASSERT(s1.isInside(v200));
142 CPPUNIT_ASSERT(s1.isInside(v010));
143 CPPUNIT_ASSERT(!s1.isInside(v110));
144 CPPUNIT_ASSERT(!s1.isInside(v210));
145 CPPUNIT_ASSERT(s1.isInside(v020));
146 CPPUNIT_ASSERT(!s1.isInside(v120));
147 CPPUNIT_ASSERT(!s1.isInside(v220));
148 CPPUNIT_ASSERT(s1.isInside(v001));
149 CPPUNIT_ASSERT(!s1.isInside(v101));
150 CPPUNIT_ASSERT(!s1.isInside(v201));
151 CPPUNIT_ASSERT(!s1.isInside(v011));
152 CPPUNIT_ASSERT(!s1.isInside(v111));
153 CPPUNIT_ASSERT(!s1.isInside(v211));
154 CPPUNIT_ASSERT(!s1.isInside(v021));
155 CPPUNIT_ASSERT(!s1.isInside(v121));
156 CPPUNIT_ASSERT(!s1.isInside(v221));
157 CPPUNIT_ASSERT(s1.isInside(v002));
158 CPPUNIT_ASSERT(!s1.isInside(v102));
159 CPPUNIT_ASSERT(!s1.isInside(v202));
160 CPPUNIT_ASSERT(!s1.isInside(v012));
161 CPPUNIT_ASSERT(!s1.isInside(v112));
162 CPPUNIT_ASSERT(!s1.isInside(v212));
163 CPPUNIT_ASSERT(!s1.isInside(v022));
164 CPPUNIT_ASSERT(!s1.isInside(v122));
165 CPPUNIT_ASSERT(!s1.isInside(v222));
166
167 Shape s2 = Cuboid();
168
169 CPPUNIT_ASSERT(s2.isInside(v000));
170 CPPUNIT_ASSERT(s2.isInside(v100));
171 CPPUNIT_ASSERT(!s2.isInside(v200));
172 CPPUNIT_ASSERT(s2.isInside(v010));
173 CPPUNIT_ASSERT(s2.isInside(v110));
174 CPPUNIT_ASSERT(!s2.isInside(v210));
175 CPPUNIT_ASSERT(!s2.isInside(v020));
176 CPPUNIT_ASSERT(!s2.isInside(v120));
177 CPPUNIT_ASSERT(!s2.isInside(v220));
178 CPPUNIT_ASSERT(s2.isInside(v001));
179 CPPUNIT_ASSERT(s2.isInside(v101));
180 CPPUNIT_ASSERT(!s2.isInside(v201));
181 CPPUNIT_ASSERT(s2.isInside(v011));
182 CPPUNIT_ASSERT(s2.isInside(v111));
183 CPPUNIT_ASSERT(!s2.isInside(v211));
184 CPPUNIT_ASSERT(!s2.isInside(v021));
185 CPPUNIT_ASSERT(!s2.isInside(v121));
186 CPPUNIT_ASSERT(!s2.isInside(v221));
187 CPPUNIT_ASSERT(!s2.isInside(v002));
188 CPPUNIT_ASSERT(!s2.isInside(v102));
189 CPPUNIT_ASSERT(!s2.isInside(v202));
190 CPPUNIT_ASSERT(!s2.isInside(v012));
191 CPPUNIT_ASSERT(!s2.isInside(v112));
192 CPPUNIT_ASSERT(!s2.isInside(v212));
193 CPPUNIT_ASSERT(!s2.isInside(v022));
194 CPPUNIT_ASSERT(!s2.isInside(v122));
195 CPPUNIT_ASSERT(!s2.isInside(v222));
196}
197
198void BaseShapesTest::surfaceTest(){
199 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v000));
200 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v100));
201 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v200));
202 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v010));
203 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v110));
204 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v210));
205 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v020));
206 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v120));
207 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v220));
208 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v001));
209 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v101));
210 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v201));
211 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v011));
212 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v111));
213 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v211));
214 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v021));
215 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v121));
216 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v221));
217 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v002));
218 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v102));
219 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v202));
220 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v012));
221 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v112));
222 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v212));
223 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v022));
224 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v122));
225 CPPUNIT_ASSERT(!Nowhere().isOnSurface(v222));
226
227 CPPUNIT_ASSERT(Cuboid().isOnSurface(v000));
228 CPPUNIT_ASSERT(Cuboid().isOnSurface(v100));
229 CPPUNIT_ASSERT(!Cuboid().isOnSurface(v200));
230 CPPUNIT_ASSERT(Cuboid().isOnSurface(v010));
231 CPPUNIT_ASSERT(Cuboid().isOnSurface(v110));
232 CPPUNIT_ASSERT(!Cuboid().isOnSurface(v210));
233 CPPUNIT_ASSERT(!Cuboid().isOnSurface(v020));
234 CPPUNIT_ASSERT(!Cuboid().isOnSurface(v120));
235 CPPUNIT_ASSERT(!Cuboid().isOnSurface(v220));
236 CPPUNIT_ASSERT(Cuboid().isOnSurface(v001));
237 CPPUNIT_ASSERT(Cuboid().isOnSurface(v101));
238 CPPUNIT_ASSERT(!Cuboid().isOnSurface(v201));
239 CPPUNIT_ASSERT(Cuboid().isOnSurface(v011));
240 CPPUNIT_ASSERT(Cuboid().isOnSurface(v111));
241 CPPUNIT_ASSERT(!Cuboid().isOnSurface(v211));
242 CPPUNIT_ASSERT(!Cuboid().isOnSurface(v021));
243 CPPUNIT_ASSERT(!Cuboid().isOnSurface(v121));
244 CPPUNIT_ASSERT(!Cuboid().isOnSurface(v221));
245 CPPUNIT_ASSERT(!Cuboid().isOnSurface(v002));
246 CPPUNIT_ASSERT(!Cuboid().isOnSurface(v102));
247 CPPUNIT_ASSERT(!Cuboid().isOnSurface(v202));
248 CPPUNIT_ASSERT(!Cuboid().isOnSurface(v012));
249 CPPUNIT_ASSERT(!Cuboid().isOnSurface(v112));
250 CPPUNIT_ASSERT(!Cuboid().isOnSurface(v212));
251 CPPUNIT_ASSERT(!Cuboid().isOnSurface(v022));
252 CPPUNIT_ASSERT(!Cuboid().isOnSurface(v122));
253 CPPUNIT_ASSERT(!Cuboid().isOnSurface(v222));
254
255 CPPUNIT_ASSERT(!Sphere().isOnSurface(v000));
256 CPPUNIT_ASSERT(Sphere().isOnSurface(v100));
257 CPPUNIT_ASSERT(Sphere().isOnSurface(v200));
258 CPPUNIT_ASSERT(Sphere().isOnSurface(v010));
259 CPPUNIT_ASSERT(!Sphere().isOnSurface(v110));
260 CPPUNIT_ASSERT(!Sphere().isOnSurface(v210));
261 CPPUNIT_ASSERT(Sphere().isOnSurface(v020));
262 CPPUNIT_ASSERT(!Sphere().isOnSurface(v120));
263 CPPUNIT_ASSERT(!Sphere().isOnSurface(v220));
264 CPPUNIT_ASSERT(Sphere().isOnSurface(v001));
265 CPPUNIT_ASSERT(!Sphere().isOnSurface(v101));
266 CPPUNIT_ASSERT(!Sphere().isOnSurface(v201));
267 CPPUNIT_ASSERT(!Sphere().isOnSurface(v011));
268 CPPUNIT_ASSERT(!Sphere().isOnSurface(v111));
269 CPPUNIT_ASSERT(!Sphere().isOnSurface(v211));
270 CPPUNIT_ASSERT(!Sphere().isOnSurface(v021));
271 CPPUNIT_ASSERT(!Sphere().isOnSurface(v121));
272 CPPUNIT_ASSERT(!Sphere().isOnSurface(v221));
273 CPPUNIT_ASSERT(Sphere().isOnSurface(v002));
274 CPPUNIT_ASSERT(!Sphere().isOnSurface(v102));
275 CPPUNIT_ASSERT(!Sphere().isOnSurface(v202));
276 CPPUNIT_ASSERT(!Sphere().isOnSurface(v012));
277 CPPUNIT_ASSERT(!Sphere().isOnSurface(v112));
278 CPPUNIT_ASSERT(!Sphere().isOnSurface(v212));
279 CPPUNIT_ASSERT(!Sphere().isOnSurface(v022));
280 CPPUNIT_ASSERT(!Sphere().isOnSurface(v122));
281 CPPUNIT_ASSERT(!Sphere().isOnSurface(v222));
282}
283
284void BaseShapesTest::assignmentTest(){
285 Shape s1 = Nowhere();
286 s1 = Everywhere();
287
288 CPPUNIT_ASSERT(s1.isInside(v000));
289 CPPUNIT_ASSERT(s1.isInside(v100));
290 CPPUNIT_ASSERT(s1.isInside(v200));
291 CPPUNIT_ASSERT(s1.isInside(v010));
292 CPPUNIT_ASSERT(s1.isInside(v110));
293 CPPUNIT_ASSERT(s1.isInside(v210));
294 CPPUNIT_ASSERT(s1.isInside(v020));
295 CPPUNIT_ASSERT(s1.isInside(v120));
296 CPPUNIT_ASSERT(s1.isInside(v220));
297 CPPUNIT_ASSERT(s1.isInside(v001));
298 CPPUNIT_ASSERT(s1.isInside(v101));
299 CPPUNIT_ASSERT(s1.isInside(v201));
300 CPPUNIT_ASSERT(s1.isInside(v011));
301 CPPUNIT_ASSERT(s1.isInside(v111));
302 CPPUNIT_ASSERT(s1.isInside(v211));
303 CPPUNIT_ASSERT(s1.isInside(v021));
304 CPPUNIT_ASSERT(s1.isInside(v121));
305 CPPUNIT_ASSERT(s1.isInside(v221));
306 CPPUNIT_ASSERT(s1.isInside(v002));
307 CPPUNIT_ASSERT(s1.isInside(v102));
308 CPPUNIT_ASSERT(s1.isInside(v202));
309 CPPUNIT_ASSERT(s1.isInside(v012));
310 CPPUNIT_ASSERT(s1.isInside(v112));
311 CPPUNIT_ASSERT(s1.isInside(v212));
312 CPPUNIT_ASSERT(s1.isInside(v022));
313 CPPUNIT_ASSERT(s1.isInside(v122));
314 CPPUNIT_ASSERT(s1.isInside(v222));
315
316 Shape s2 = Everywhere();
317 s2 = Nowhere();
318
319 CPPUNIT_ASSERT(!s2.isInside(v000));
320 CPPUNIT_ASSERT(!s2.isInside(v100));
321 CPPUNIT_ASSERT(!s2.isInside(v200));
322 CPPUNIT_ASSERT(!s2.isInside(v010));
323 CPPUNIT_ASSERT(!s2.isInside(v110));
324 CPPUNIT_ASSERT(!s2.isInside(v210));
325 CPPUNIT_ASSERT(!s2.isInside(v020));
326 CPPUNIT_ASSERT(!s2.isInside(v120));
327 CPPUNIT_ASSERT(!s2.isInside(v220));
328 CPPUNIT_ASSERT(!s2.isInside(v001));
329 CPPUNIT_ASSERT(!s2.isInside(v101));
330 CPPUNIT_ASSERT(!s2.isInside(v201));
331 CPPUNIT_ASSERT(!s2.isInside(v011));
332 CPPUNIT_ASSERT(!s2.isInside(v111));
333 CPPUNIT_ASSERT(!s2.isInside(v211));
334 CPPUNIT_ASSERT(!s2.isInside(v021));
335 CPPUNIT_ASSERT(!s2.isInside(v121));
336 CPPUNIT_ASSERT(!s2.isInside(v221));
337 CPPUNIT_ASSERT(!s2.isInside(v002));
338 CPPUNIT_ASSERT(!s2.isInside(v102));
339 CPPUNIT_ASSERT(!s2.isInside(v202));
340 CPPUNIT_ASSERT(!s2.isInside(v012));
341 CPPUNIT_ASSERT(!s2.isInside(v112));
342 CPPUNIT_ASSERT(!s2.isInside(v212));
343 CPPUNIT_ASSERT(!s2.isInside(v022));
344 CPPUNIT_ASSERT(!s2.isInside(v122));
345 CPPUNIT_ASSERT(!s2.isInside(v222));
346
347}
348
349void BaseShapesTest::operatorTest(){
350 {
351 Shape s1 = !Nowhere();
352 CPPUNIT_ASSERT(s1.isInside(v000));
353 CPPUNIT_ASSERT(s1.isInside(v100));
354 CPPUNIT_ASSERT(s1.isInside(v200));
355 CPPUNIT_ASSERT(s1.isInside(v010));
356 CPPUNIT_ASSERT(s1.isInside(v110));
357 CPPUNIT_ASSERT(s1.isInside(v210));
358 CPPUNIT_ASSERT(s1.isInside(v020));
359 CPPUNIT_ASSERT(s1.isInside(v120));
360 CPPUNIT_ASSERT(s1.isInside(v220));
361 CPPUNIT_ASSERT(s1.isInside(v001));
362 CPPUNIT_ASSERT(s1.isInside(v101));
363 CPPUNIT_ASSERT(s1.isInside(v201));
364 CPPUNIT_ASSERT(s1.isInside(v011));
365 CPPUNIT_ASSERT(s1.isInside(v111));
366 CPPUNIT_ASSERT(s1.isInside(v211));
367 CPPUNIT_ASSERT(s1.isInside(v021));
368 CPPUNIT_ASSERT(s1.isInside(v121));
369 CPPUNIT_ASSERT(s1.isInside(v221));
370 CPPUNIT_ASSERT(s1.isInside(v002));
371 CPPUNIT_ASSERT(s1.isInside(v102));
372 CPPUNIT_ASSERT(s1.isInside(v202));
373 CPPUNIT_ASSERT(s1.isInside(v012));
374 CPPUNIT_ASSERT(s1.isInside(v112));
375 CPPUNIT_ASSERT(s1.isInside(v212));
376 CPPUNIT_ASSERT(s1.isInside(v022));
377 CPPUNIT_ASSERT(s1.isInside(v122));
378 CPPUNIT_ASSERT(s1.isInside(v222));
379
380 Shape s2 = !Everywhere();
381 CPPUNIT_ASSERT(!s2.isInside(v000));
382 CPPUNIT_ASSERT(!s2.isInside(v100));
383 CPPUNIT_ASSERT(!s2.isInside(v200));
384 CPPUNIT_ASSERT(!s2.isInside(v010));
385 CPPUNIT_ASSERT(!s2.isInside(v110));
386 CPPUNIT_ASSERT(!s2.isInside(v210));
387 CPPUNIT_ASSERT(!s2.isInside(v020));
388 CPPUNIT_ASSERT(!s2.isInside(v120));
389 CPPUNIT_ASSERT(!s2.isInside(v220));
390 CPPUNIT_ASSERT(!s2.isInside(v001));
391 CPPUNIT_ASSERT(!s2.isInside(v101));
392 CPPUNIT_ASSERT(!s2.isInside(v201));
393 CPPUNIT_ASSERT(!s2.isInside(v011));
394 CPPUNIT_ASSERT(!s2.isInside(v111));
395 CPPUNIT_ASSERT(!s2.isInside(v211));
396 CPPUNIT_ASSERT(!s2.isInside(v021));
397 CPPUNIT_ASSERT(!s2.isInside(v121));
398 CPPUNIT_ASSERT(!s2.isInside(v221));
399 CPPUNIT_ASSERT(!s2.isInside(v002));
400 CPPUNIT_ASSERT(!s2.isInside(v102));
401 CPPUNIT_ASSERT(!s2.isInside(v202));
402 CPPUNIT_ASSERT(!s2.isInside(v012));
403 CPPUNIT_ASSERT(!s2.isInside(v112));
404 CPPUNIT_ASSERT(!s2.isInside(v212));
405 CPPUNIT_ASSERT(!s2.isInside(v022));
406 CPPUNIT_ASSERT(!s2.isInside(v122));
407 CPPUNIT_ASSERT(!s2.isInside(v222));
408 }
409
410 {
411 Shape s1 = Nowhere() || Everywhere();
412 CPPUNIT_ASSERT(s1.isInside(v000));
413 CPPUNIT_ASSERT(s1.isInside(v100));
414 CPPUNIT_ASSERT(s1.isInside(v200));
415 CPPUNIT_ASSERT(s1.isInside(v010));
416 CPPUNIT_ASSERT(s1.isInside(v110));
417 CPPUNIT_ASSERT(s1.isInside(v210));
418 CPPUNIT_ASSERT(s1.isInside(v020));
419 CPPUNIT_ASSERT(s1.isInside(v120));
420 CPPUNIT_ASSERT(s1.isInside(v220));
421 CPPUNIT_ASSERT(s1.isInside(v001));
422 CPPUNIT_ASSERT(s1.isInside(v101));
423 CPPUNIT_ASSERT(s1.isInside(v201));
424 CPPUNIT_ASSERT(s1.isInside(v011));
425 CPPUNIT_ASSERT(s1.isInside(v111));
426 CPPUNIT_ASSERT(s1.isInside(v211));
427 CPPUNIT_ASSERT(s1.isInside(v021));
428 CPPUNIT_ASSERT(s1.isInside(v121));
429 CPPUNIT_ASSERT(s1.isInside(v221));
430 CPPUNIT_ASSERT(s1.isInside(v002));
431 CPPUNIT_ASSERT(s1.isInside(v102));
432 CPPUNIT_ASSERT(s1.isInside(v202));
433 CPPUNIT_ASSERT(s1.isInside(v012));
434 CPPUNIT_ASSERT(s1.isInside(v112));
435 CPPUNIT_ASSERT(s1.isInside(v212));
436 CPPUNIT_ASSERT(s1.isInside(v022));
437 CPPUNIT_ASSERT(s1.isInside(v122));
438 CPPUNIT_ASSERT(s1.isInside(v222));
439
440 Shape s2 = Nowhere() && Everywhere();
441 CPPUNIT_ASSERT(!s2.isInside(v000));
442 CPPUNIT_ASSERT(!s2.isInside(v100));
443 CPPUNIT_ASSERT(!s2.isInside(v200));
444 CPPUNIT_ASSERT(!s2.isInside(v010));
445 CPPUNIT_ASSERT(!s2.isInside(v110));
446 CPPUNIT_ASSERT(!s2.isInside(v210));
447 CPPUNIT_ASSERT(!s2.isInside(v020));
448 CPPUNIT_ASSERT(!s2.isInside(v120));
449 CPPUNIT_ASSERT(!s2.isInside(v220));
450 CPPUNIT_ASSERT(!s2.isInside(v001));
451 CPPUNIT_ASSERT(!s2.isInside(v101));
452 CPPUNIT_ASSERT(!s2.isInside(v201));
453 CPPUNIT_ASSERT(!s2.isInside(v011));
454 CPPUNIT_ASSERT(!s2.isInside(v111));
455 CPPUNIT_ASSERT(!s2.isInside(v211));
456 CPPUNIT_ASSERT(!s2.isInside(v021));
457 CPPUNIT_ASSERT(!s2.isInside(v121));
458 CPPUNIT_ASSERT(!s2.isInside(v221));
459 CPPUNIT_ASSERT(!s2.isInside(v002));
460 CPPUNIT_ASSERT(!s2.isInside(v102));
461 CPPUNIT_ASSERT(!s2.isInside(v202));
462 CPPUNIT_ASSERT(!s2.isInside(v012));
463 CPPUNIT_ASSERT(!s2.isInside(v112));
464 CPPUNIT_ASSERT(!s2.isInside(v212));
465 CPPUNIT_ASSERT(!s2.isInside(v022));
466 CPPUNIT_ASSERT(!s2.isInside(v122));
467 CPPUNIT_ASSERT(!s2.isInside(v222));
468 }
469
470 {
471 Shape s1 = Everywhere() || Nowhere();
472 CPPUNIT_ASSERT(s1.isInside(v000));
473 CPPUNIT_ASSERT(s1.isInside(v100));
474 CPPUNIT_ASSERT(s1.isInside(v200));
475 CPPUNIT_ASSERT(s1.isInside(v010));
476 CPPUNIT_ASSERT(s1.isInside(v110));
477 CPPUNIT_ASSERT(s1.isInside(v210));
478 CPPUNIT_ASSERT(s1.isInside(v020));
479 CPPUNIT_ASSERT(s1.isInside(v120));
480 CPPUNIT_ASSERT(s1.isInside(v220));
481 CPPUNIT_ASSERT(s1.isInside(v001));
482 CPPUNIT_ASSERT(s1.isInside(v101));
483 CPPUNIT_ASSERT(s1.isInside(v201));
484 CPPUNIT_ASSERT(s1.isInside(v011));
485 CPPUNIT_ASSERT(s1.isInside(v111));
486 CPPUNIT_ASSERT(s1.isInside(v211));
487 CPPUNIT_ASSERT(s1.isInside(v021));
488 CPPUNIT_ASSERT(s1.isInside(v121));
489 CPPUNIT_ASSERT(s1.isInside(v221));
490 CPPUNIT_ASSERT(s1.isInside(v002));
491 CPPUNIT_ASSERT(s1.isInside(v102));
492 CPPUNIT_ASSERT(s1.isInside(v202));
493 CPPUNIT_ASSERT(s1.isInside(v012));
494 CPPUNIT_ASSERT(s1.isInside(v112));
495 CPPUNIT_ASSERT(s1.isInside(v212));
496 CPPUNIT_ASSERT(s1.isInside(v022));
497 CPPUNIT_ASSERT(s1.isInside(v122));
498 CPPUNIT_ASSERT(s1.isInside(v222));
499
500 Shape s2 = Everywhere() && Nowhere();
501 CPPUNIT_ASSERT(!s2.isInside(v000));
502 CPPUNIT_ASSERT(!s2.isInside(v100));
503 CPPUNIT_ASSERT(!s2.isInside(v200));
504 CPPUNIT_ASSERT(!s2.isInside(v010));
505 CPPUNIT_ASSERT(!s2.isInside(v110));
506 CPPUNIT_ASSERT(!s2.isInside(v210));
507 CPPUNIT_ASSERT(!s2.isInside(v020));
508 CPPUNIT_ASSERT(!s2.isInside(v120));
509 CPPUNIT_ASSERT(!s2.isInside(v220));
510 CPPUNIT_ASSERT(!s2.isInside(v001));
511 CPPUNIT_ASSERT(!s2.isInside(v101));
512 CPPUNIT_ASSERT(!s2.isInside(v201));
513 CPPUNIT_ASSERT(!s2.isInside(v011));
514 CPPUNIT_ASSERT(!s2.isInside(v111));
515 CPPUNIT_ASSERT(!s2.isInside(v211));
516 CPPUNIT_ASSERT(!s2.isInside(v021));
517 CPPUNIT_ASSERT(!s2.isInside(v121));
518 CPPUNIT_ASSERT(!s2.isInside(v221));
519 CPPUNIT_ASSERT(!s2.isInside(v002));
520 CPPUNIT_ASSERT(!s2.isInside(v102));
521 CPPUNIT_ASSERT(!s2.isInside(v202));
522 CPPUNIT_ASSERT(!s2.isInside(v012));
523 CPPUNIT_ASSERT(!s2.isInside(v112));
524 CPPUNIT_ASSERT(!s2.isInside(v212));
525 CPPUNIT_ASSERT(!s2.isInside(v022));
526 CPPUNIT_ASSERT(!s2.isInside(v122));
527 CPPUNIT_ASSERT(!s2.isInside(v222));
528 }
529
530 {
531 Shape s1 = Sphere() && Cuboid(); // Sphere in upper place
532
533 CPPUNIT_ASSERT(s1.isInside(v000));
534 CPPUNIT_ASSERT(s1.isInside(v100));
535 CPPUNIT_ASSERT(!s1.isInside(v200));
536 CPPUNIT_ASSERT(s1.isInside(v010));
537 CPPUNIT_ASSERT(!s1.isInside(v110));
538 CPPUNIT_ASSERT(!s1.isInside(v210));
539 CPPUNIT_ASSERT(!s1.isInside(v020));
540 CPPUNIT_ASSERT(!s1.isInside(v120));
541 CPPUNIT_ASSERT(!s1.isInside(v220));
542 CPPUNIT_ASSERT(s1.isInside(v001));
543 CPPUNIT_ASSERT(!s1.isInside(v101));
544 CPPUNIT_ASSERT(!s1.isInside(v201));
545 CPPUNIT_ASSERT(!s1.isInside(v011));
546 CPPUNIT_ASSERT(!s1.isInside(v111));
547 CPPUNIT_ASSERT(!s1.isInside(v211));
548 CPPUNIT_ASSERT(!s1.isInside(v021));
549 CPPUNIT_ASSERT(!s1.isInside(v121));
550 CPPUNIT_ASSERT(!s1.isInside(v221));
551 CPPUNIT_ASSERT(!s1.isInside(v002));
552 CPPUNIT_ASSERT(!s1.isInside(v102));
553 CPPUNIT_ASSERT(!s1.isInside(v202));
554 CPPUNIT_ASSERT(!s1.isInside(v012));
555 CPPUNIT_ASSERT(!s1.isInside(v112));
556 CPPUNIT_ASSERT(!s1.isInside(v212));
557 CPPUNIT_ASSERT(!s1.isInside(v022));
558 CPPUNIT_ASSERT(!s1.isInside(v122));
559 CPPUNIT_ASSERT(!s1.isInside(v222));
560
561 CPPUNIT_ASSERT(s1.isOnSurface(v000));
562 CPPUNIT_ASSERT(s1.isOnSurface(v100));
563 CPPUNIT_ASSERT(!s1.isOnSurface(v200));
564 CPPUNIT_ASSERT(s1.isOnSurface(v010));
565 CPPUNIT_ASSERT(!s1.isOnSurface(v110));
566 CPPUNIT_ASSERT(!s1.isOnSurface(v210));
567 CPPUNIT_ASSERT(!s1.isOnSurface(v020));
568 CPPUNIT_ASSERT(!s1.isOnSurface(v120));
569 CPPUNIT_ASSERT(!s1.isOnSurface(v220));
570 CPPUNIT_ASSERT(s1.isOnSurface(v001));
571 CPPUNIT_ASSERT(!s1.isOnSurface(v101));
572 CPPUNIT_ASSERT(!s1.isOnSurface(v201));
573 CPPUNIT_ASSERT(!s1.isOnSurface(v011));
574 CPPUNIT_ASSERT(!s1.isOnSurface(v111));
575 CPPUNIT_ASSERT(!s1.isOnSurface(v211));
576 CPPUNIT_ASSERT(!s1.isOnSurface(v021));
577 CPPUNIT_ASSERT(!s1.isOnSurface(v121));
578 CPPUNIT_ASSERT(!s1.isOnSurface(v221));
579 CPPUNIT_ASSERT(!s1.isOnSurface(v002));
580 CPPUNIT_ASSERT(!s1.isOnSurface(v102));
581 CPPUNIT_ASSERT(!s1.isOnSurface(v202));
582 CPPUNIT_ASSERT(!s1.isOnSurface(v012));
583 CPPUNIT_ASSERT(!s1.isOnSurface(v112));
584 CPPUNIT_ASSERT(!s1.isOnSurface(v212));
585 CPPUNIT_ASSERT(!s1.isOnSurface(v022));
586 CPPUNIT_ASSERT(!s1.isOnSurface(v122));
587 CPPUNIT_ASSERT(!s1.isOnSurface(v222));
588
589
590 Shape s2 = Sphere() || Cuboid(); // Should be same as Cuboid
591
592 CPPUNIT_ASSERT(s2.isInside(v000));
593 CPPUNIT_ASSERT(s2.isInside(v100));
594 CPPUNIT_ASSERT(s2.isInside(v200));
595 CPPUNIT_ASSERT(s2.isInside(v010));
596 CPPUNIT_ASSERT(s2.isInside(v110));
597 CPPUNIT_ASSERT(!s2.isInside(v210));
598 CPPUNIT_ASSERT(s2.isInside(v020));
599 CPPUNIT_ASSERT(!s2.isInside(v120));
600 CPPUNIT_ASSERT(!s2.isInside(v220));
601 CPPUNIT_ASSERT(s2.isInside(v001));
602 CPPUNIT_ASSERT(s2.isInside(v101));
603 CPPUNIT_ASSERT(!s2.isInside(v201));
604 CPPUNIT_ASSERT(s2.isInside(v011));
605 CPPUNIT_ASSERT(s2.isInside(v111));
606 CPPUNIT_ASSERT(!s2.isInside(v211));
607 CPPUNIT_ASSERT(!s2.isInside(v021));
608 CPPUNIT_ASSERT(!s2.isInside(v121));
609 CPPUNIT_ASSERT(!s2.isInside(v221));
610 CPPUNIT_ASSERT(s2.isInside(v002));
611 CPPUNIT_ASSERT(!s2.isInside(v102));
612 CPPUNIT_ASSERT(!s2.isInside(v202));
613 CPPUNIT_ASSERT(!s2.isInside(v012));
614 CPPUNIT_ASSERT(!s2.isInside(v112));
615 CPPUNIT_ASSERT(!s2.isInside(v212));
616 CPPUNIT_ASSERT(!s2.isInside(v022));
617 CPPUNIT_ASSERT(!s2.isInside(v122));
618 CPPUNIT_ASSERT(!s2.isInside(v222));
619
620 CPPUNIT_ASSERT(!s2.isOnSurface(v000));
621 CPPUNIT_ASSERT(s2.isOnSurface(v100));
622 CPPUNIT_ASSERT(s2.isOnSurface(v200));
623 CPPUNIT_ASSERT(s2.isOnSurface(v010));
624 CPPUNIT_ASSERT(s2.isOnSurface(v110));
625 CPPUNIT_ASSERT(!s2.isOnSurface(v210));
626 CPPUNIT_ASSERT(s2.isOnSurface(v020));
627 CPPUNIT_ASSERT(!s2.isOnSurface(v120));
628 CPPUNIT_ASSERT(!s2.isOnSurface(v220));
629 CPPUNIT_ASSERT(s2.isOnSurface(v001));
630 CPPUNIT_ASSERT(s2.isOnSurface(v101));
631 CPPUNIT_ASSERT(!s2.isOnSurface(v201));
632 CPPUNIT_ASSERT(s2.isOnSurface(v011));
633 CPPUNIT_ASSERT(s2.isOnSurface(v111));
634 CPPUNIT_ASSERT(!s2.isOnSurface(v211));
635 CPPUNIT_ASSERT(!s2.isOnSurface(v021));
636 CPPUNIT_ASSERT(!s2.isOnSurface(v121));
637 CPPUNIT_ASSERT(!s2.isOnSurface(v221));
638 CPPUNIT_ASSERT(s2.isOnSurface(v002));
639 CPPUNIT_ASSERT(!s2.isOnSurface(v102));
640 CPPUNIT_ASSERT(!s2.isOnSurface(v202));
641 CPPUNIT_ASSERT(!s2.isOnSurface(v012));
642 CPPUNIT_ASSERT(!s2.isOnSurface(v112));
643 CPPUNIT_ASSERT(!s2.isOnSurface(v212));
644 CPPUNIT_ASSERT(!s2.isOnSurface(v022));
645 CPPUNIT_ASSERT(!s2.isOnSurface(v122));
646 CPPUNIT_ASSERT(!s2.isOnSurface(v222));
647 }
648
649}
650
651void BaseShapesTest::PointsOnSurfaceTest(){
652 Shape s = Sphere();
653 const size_t N = 200;
654 std::vector<Vector> PointsOnSurface = s.getHomogeneousPointsOnSurface(N);
655 for (std::vector<Vector>::const_iterator iter = PointsOnSurface.begin(); iter != PointsOnSurface.end(); ++iter) {
656 CPPUNIT_ASSERT(fabs(1. - (*iter).NormSquared()) < MYEPSILON);
657 }
658 CPPUNIT_ASSERT_EQUAL((size_t)194, PointsOnSurface.size());
659}
660
Note: See TracBrowser for help on using the repository browser.