source: src/unittests/BaseShapesUnittest.cpp@ 13e3c3

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 13e3c3 was c5186e, checked in by Frederik Heber <heber@…>, 14 years ago

Added getHomogenousPointsOnSurface() function to Shapes.

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