source: src/Shapes/unittests/ShapeUnitTest.cpp@ 6d2207

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 6d2207 was 0b3cbdf, checked in by Frederik Heber <heber@…>, 14 years ago

Moved ShapeUnittest to Shapes/unittests/ShapeUnitTest.

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