source: src/Shapes/unittests/ShapeUnitTest.cpp@ 30c753

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 30c753 was d103d3, checked in by Frederik Heber <heber@…>, 13 years ago

Added additional check in CodeCheck's project disclaimer for current year in copyright.

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