source: src/unittests/BaseShapesUnittest.cpp@ c66537

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 c66537 was bcf653, checked in by Frederik Heber <heber@…>, 15 years ago

Added copyright note to each .cpp file and an extensive one to builder.cpp.

  • Property mode set to 100644
File size: 4.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 * BaseShapesUnittest.cpp
10 *
11 * Created on: Jun 18, 2010
12 * Author: crueger
13 */
14
15#include "BaseShapesUnittest.hpp"
16
17#include <cppunit/CompilerOutputter.h>
18#include <cppunit/extensions/TestFactoryRegistry.h>
19#include <cppunit/ui/text/TestRunner.h>
20
21#include <cmath>
22
23#ifdef HAVE_TESTRUNNER
24#include "UnitTestMain.hpp"
25#endif /*HAVE_TESTRUNNER*/
26
27#include "LinearAlgebra/Vector.hpp"
28#include "Shapes/Shape.hpp"
29
30#include "Shapes/BaseShapes.hpp"
31
32// Registers the fixture into the 'registry'
33CPPUNIT_TEST_SUITE_REGISTRATION( BaseShapesUnittest );
34
35void BaseShapesUnittest::setUp()
36{
37 v000 = 0*e1+0*e2+0*e3;
38 v100 = 1*e1+0*e2+0*e3;
39 v200 = -1*e1+0*e2+0*e3;
40 v010 = 0*e1+1*e2+0*e3;
41 v110 = 1*e1+1*e2+0*e3;
42 v210 = -1*e1+1*e2+0*e3;
43 v020 = 0*e1-1*e2+0*e3;
44 v120 = 1*e1-1*e2+0*e3;
45 v220 = -1*e1-1*e2+0*e3;
46 v001 = 0*e1+0*e2+1*e3;
47 v101 = 1*e1+0*e2+1*e3;
48 v201 = -1*e1+0*e2+1*e3;
49 v011 = 0*e1+1*e2+1*e3;
50 v111 = 1*e1+1*e2+1*e3;
51 v211 = -1*e1+1*e2+1*e3;
52 v021 = 0*e1-1*e2+1*e3;
53 v121 = 1*e1-1*e2+1*e3;
54 v221 = -1*e1-1*e2+1*e3;
55 v002 = 0*e1+0*e2-1*e3;
56 v102 = 1*e1+0*e2-1*e3;
57 v202 = -1*e1+0*e2-1*e3;
58 v012 = 0*e1+1*e2-1*e3;
59 v112 = 1*e1+1*e2-1*e3;
60 v212 = -1*e1+1*e2-1*e3;
61 v022 = 0*e1-1*e2-1*e3;
62 v122 = 1*e1-1*e2-1*e3;
63 v222 = -1*e1-1*e2-1*e3;
64}
65
66void BaseShapesUnittest::tearDown()
67{}
68
69
70void BaseShapesUnittest::isInsideTest(){
71 Shape s1 = Sphere();
72
73 CPPUNIT_ASSERT(s1.isInside(v000));
74 CPPUNIT_ASSERT(s1.isInside(v100));
75 CPPUNIT_ASSERT(s1.isInside(v200));
76 CPPUNIT_ASSERT(s1.isInside(v010));
77 CPPUNIT_ASSERT(!s1.isInside(v110));
78 CPPUNIT_ASSERT(!s1.isInside(v210));
79 CPPUNIT_ASSERT(s1.isInside(v020));
80 CPPUNIT_ASSERT(!s1.isInside(v120));
81 CPPUNIT_ASSERT(!s1.isInside(v220));
82 CPPUNIT_ASSERT(s1.isInside(v001));
83 CPPUNIT_ASSERT(!s1.isInside(v101));
84 CPPUNIT_ASSERT(!s1.isInside(v201));
85 CPPUNIT_ASSERT(!s1.isInside(v011));
86 CPPUNIT_ASSERT(!s1.isInside(v111));
87 CPPUNIT_ASSERT(!s1.isInside(v211));
88 CPPUNIT_ASSERT(!s1.isInside(v021));
89 CPPUNIT_ASSERT(!s1.isInside(v121));
90 CPPUNIT_ASSERT(!s1.isInside(v221));
91 CPPUNIT_ASSERT(s1.isInside(v002));
92 CPPUNIT_ASSERT(!s1.isInside(v102));
93 CPPUNIT_ASSERT(!s1.isInside(v202));
94 CPPUNIT_ASSERT(!s1.isInside(v012));
95 CPPUNIT_ASSERT(!s1.isInside(v112));
96 CPPUNIT_ASSERT(!s1.isInside(v212));
97 CPPUNIT_ASSERT(!s1.isInside(v022));
98 CPPUNIT_ASSERT(!s1.isInside(v122));
99 CPPUNIT_ASSERT(!s1.isInside(v222));
100
101 Shape s2 = Cuboid();
102
103 CPPUNIT_ASSERT(s2.isInside(v000));
104 CPPUNIT_ASSERT(s2.isInside(v100));
105 CPPUNIT_ASSERT(!s2.isInside(v200));
106 CPPUNIT_ASSERT(s2.isInside(v010));
107 CPPUNIT_ASSERT(s2.isInside(v110));
108 CPPUNIT_ASSERT(!s2.isInside(v210));
109 CPPUNIT_ASSERT(!s2.isInside(v020));
110 CPPUNIT_ASSERT(!s2.isInside(v120));
111 CPPUNIT_ASSERT(!s2.isInside(v220));
112 CPPUNIT_ASSERT(s2.isInside(v001));
113 CPPUNIT_ASSERT(s2.isInside(v101));
114 CPPUNIT_ASSERT(!s2.isInside(v201));
115 CPPUNIT_ASSERT(s2.isInside(v011));
116 CPPUNIT_ASSERT(s2.isInside(v111));
117 CPPUNIT_ASSERT(!s2.isInside(v211));
118 CPPUNIT_ASSERT(!s2.isInside(v021));
119 CPPUNIT_ASSERT(!s2.isInside(v121));
120 CPPUNIT_ASSERT(!s2.isInside(v221));
121 CPPUNIT_ASSERT(!s2.isInside(v002));
122 CPPUNIT_ASSERT(!s2.isInside(v102));
123 CPPUNIT_ASSERT(!s2.isInside(v202));
124 CPPUNIT_ASSERT(!s2.isInside(v012));
125 CPPUNIT_ASSERT(!s2.isInside(v112));
126 CPPUNIT_ASSERT(!s2.isInside(v212));
127 CPPUNIT_ASSERT(!s2.isInside(v022));
128 CPPUNIT_ASSERT(!s2.isInside(v122));
129 CPPUNIT_ASSERT(!s2.isInside(v222));
130
131}
132
133void BaseShapesUnittest::PointsOnSurfaceTest(){
134 Shape s = Sphere();
135 const size_t N = 200;
136 std::vector<Vector> PointsOnSurface = s.getHomogeneousPointsOnSurface(N);
137 for (std::vector<Vector>::const_iterator iter = PointsOnSurface.begin(); iter != PointsOnSurface.end(); ++iter) {
138 CPPUNIT_ASSERT(fabs(1. - (*iter).NormSquared()) < MYEPSILON);
139 }
140 CPPUNIT_ASSERT_EQUAL(N, PointsOnSurface.size());
141}
142
Note: See TracBrowser for help on using the repository browser.