source: src/Shapes/unittests/BaseShapesUnitTest.cpp@ 52575c

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 52575c was 125841, checked in by Frederik Heber <heber@…>, 12 years ago

Made Sphere_impl::getHomogeneousPointsOnSurface() more accurate

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