source: src/unittests/Tesselation_BoundaryTriangleUnitTest.cpp@ 8766e72

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 8766e72 was a479fa, checked in by Frederik Heber <heber@…>, 14 years ago

Renamed ParticleInfo::nr to ParticleInfo::ParticleInfo_nr for easier privatization.

  • Property mode set to 100644
File size: 7.4 KB
RevLine 
[bcf653]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
[e9c677]8/*
[f844ef]9 * Tesselation_BoundaryTriangleUnitTest.cpp
[e9c677]10 *
11 * Created on: Jan 13, 2010
12 * Author: heber
13 */
14
[bf3817]15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
[e9c677]20using namespace std;
21
22#include <cppunit/CompilerOutputter.h>
23#include <cppunit/extensions/TestFactoryRegistry.h>
24#include <cppunit/ui/text/TestRunner.h>
25
26#include <cstring>
[d74077]27#include <iostream>
[e9c677]28
[e4fe8d]29#include "Helpers/defs.hpp"
[d74077]30#include "TesselPoint.hpp"
31#include "BoundaryPointSet.hpp"
32#include "BoundaryLineSet.hpp"
33#include "BoundaryTriangleSet.hpp"
34#include "CandidateForTesselation.hpp"
[f844ef]35
36#include "Tesselation_BoundaryTriangleUnitTest.hpp"
[e9c677]37
[9b6b2f]38#ifdef HAVE_TESTRUNNER
39#include "UnitTestMain.hpp"
40#endif /*HAVE_TESTRUNNER*/
41
[88b400]42const double TesselationBoundaryTriangleTest::SPHERERADIUS=2.;
[e9c677]43
44/********************************************** Test classes **************************************/
45
46// Registers the fixture into the 'registry'
47CPPUNIT_TEST_SUITE_REGISTRATION( TesselationBoundaryTriangleTest );
48
49
50void TesselationBoundaryTriangleTest::setUp()
51{
52 setVerbosity(5);
53
54 // create nodes
[5c8592]55 tesselpoints[0] = new TesselPoint;
[d74077]56 tesselpoints[0]->setPosition(Vector(0., 0., 0.));
[68f03d]57 tesselpoints[0]->setName("1");
[a479fa]58 tesselpoints[0]->setNr(1);
[5c8592]59 points[0] = new BoundaryPointSet(tesselpoints[0]);
60 tesselpoints[1] = new TesselPoint;
[d74077]61 tesselpoints[1]->setPosition(Vector(0., 1., 0.));
[68f03d]62 tesselpoints[1]->setName("2");
[a479fa]63 tesselpoints[1]->setNr(2);
[5c8592]64 points[1] = new BoundaryPointSet(tesselpoints[1]);
65 tesselpoints[2] = new TesselPoint;
[d74077]66 tesselpoints[2]->setPosition(Vector(1., 0., 0.));
[68f03d]67 tesselpoints[2]->setName("3");
[a479fa]68 tesselpoints[2]->setNr(3);
[5c8592]69 points[2] = new BoundaryPointSet(tesselpoints[2] );
[e9c677]70
71 // create line
72 lines[0] = new BoundaryLineSet(points[0], points[1], 0);
73 lines[1] = new BoundaryLineSet(points[1], points[2], 1);
74 lines[2] = new BoundaryLineSet(points[0], points[2], 2);
75
76 // create triangle
77 triangle = new BoundaryTriangleSet(lines, 0);
78 triangle->GetNormalVector(Vector(0.,0.,1.));
79};
80
81
82void TesselationBoundaryTriangleTest::tearDown()
83{
84 delete(triangle);
[5c8592]85 for (int i=0;i<3;++i) {
86 // TesselPoint does not delete its vector as it only got a reference
87 delete tesselpoints[i];
88 }
[e9c677]89 logger::purgeInstance();
90 errorLogger::purgeInstance();
91};
92
93/** UnitTest for Tesselation::IsInnerPoint()
94 */
95void TesselationBoundaryTriangleTest::GetClosestPointOnPlaneTest()
96{
97 Vector TestIntersection;
98 Vector Point;
99
100 // simple test on y line
[1bd79e]101 Point = Vector(-1.,0.5,0.);
[d74077]102 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
[1bd79e]103 Point = Vector(0.,0.5,0.);
[e9c677]104 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
[1bd79e]105 Point = Vector(-4.,0.5,0.);
[d74077]106 CPPUNIT_ASSERT_EQUAL( 16., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
[1bd79e]107 Point = Vector(0.,0.5,0.);
[e9c677]108 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
109
110 // simple test on x line
[1bd79e]111 Point = Vector(0.5,-1.,0.);
[d74077]112 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
[1bd79e]113 Point = Vector(0.5,0.,0.);
[e9c677]114 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
[1bd79e]115 Point = Vector(0.5,-6.,0.);
[d74077]116 CPPUNIT_ASSERT_EQUAL( 36., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
[1bd79e]117 Point = Vector(0.5,0.,0.);
[e9c677]118 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
119
120 // simple test on slanted line
[1bd79e]121 Point = Vector(1.,1.,0.);
[d74077]122 CPPUNIT_ASSERT_EQUAL( 0.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
[1bd79e]123 Point = Vector(0.5,0.5,0.);
[e9c677]124 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
[1bd79e]125 Point = Vector(5.,5.,0.);
[d74077]126 CPPUNIT_ASSERT_EQUAL( 40.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
[1bd79e]127 Point = Vector(0.5,0.5,0.);
[e9c677]128 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
129
130 // simple test on first node
[1bd79e]131 Point = Vector(-1.,-1.,0.);
[d74077]132 CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
[1bd79e]133 Point = Vector(0.,0.,0.);
[e9c677]134 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
135
136 // simple test on second node
[1bd79e]137 Point = Vector(0.,2.,0.);
[d74077]138 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
[1bd79e]139 Point = Vector(0.,1.,0.);
[e9c677]140 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
141
142 // simple test on third node
[1bd79e]143 Point = Vector(2.,0.,0.);
[d74077]144 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
[1bd79e]145 Point = Vector(1.,0.,0.);
[e9c677]146 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
147};
148
149/** UnitTest for Tesselation::IsInnerPoint()
150 */
151void TesselationBoundaryTriangleTest::GetClosestPointOffPlaneTest()
152{
153 Vector TestIntersection;
154 Vector Point;
155
156 // straight down/up
[1bd79e]157 Point = Vector(1./3.,1./3.,+5.);
[d74077]158 CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
[1bd79e]159 Point = Vector(1./3.,1./3.,0.);
[e9c677]160 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
[1bd79e]161 Point = Vector(1./3.,1./3.,-5.);
[d74077]162 CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
[1bd79e]163 Point = Vector(1./3.,1./3.,0.);
[e9c677]164 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
165
166 // simple test on y line
[1bd79e]167 Point = Vector(-1.,0.5,+2.);
[d74077]168 CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
[1bd79e]169 Point = Vector(0.,0.5,0.);
[e9c677]170 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
[1bd79e]171 Point = Vector(-1.,0.5,-3.);
[d74077]172 CPPUNIT_ASSERT_EQUAL( 10., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
[1bd79e]173 Point = Vector(0.,0.5,0.);
[e9c677]174 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
175
176 // simple test on x line
[1bd79e]177 Point = Vector(0.5,-1.,+1.);
[d74077]178 CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
[1bd79e]179 Point = Vector(0.5,0.,0.);
[e9c677]180 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
[1bd79e]181 Point = Vector(0.5,-1.,-2.);
[d74077]182 CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
[1bd79e]183 Point = Vector(0.5,0.,0.);
[e9c677]184 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
185
186 // simple test on slanted line
[1bd79e]187 Point = Vector(1.,1.,+3.);
[d74077]188 CPPUNIT_ASSERT_EQUAL( 9.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
[1bd79e]189 Point = Vector(0.5,0.5,0.);
[e9c677]190 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
[1bd79e]191 Point = Vector(1.,1.,-4.);
[d74077]192 CPPUNIT_ASSERT_EQUAL( 16.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
[1bd79e]193 Point = Vector(0.5,0.5,0.);
[e9c677]194 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
195
196 // simple test on first node
[1bd79e]197 Point = Vector(-1.,-1.,5.);
[d74077]198 CPPUNIT_ASSERT_EQUAL( 27., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
[1bd79e]199 Point = Vector(0.,0.,0.);
[e9c677]200 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
201
202 // simple test on second node
[1bd79e]203 Point = Vector(0.,2.,5.);
[d74077]204 CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
[1bd79e]205 Point = Vector(0.,1.,0.);
[e9c677]206 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
207
208 // simple test on third node
[1bd79e]209 Point = Vector(2.,0.,5.);
[d74077]210 CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
[1bd79e]211 Point = Vector(1.,0.,0.);
[e9c677]212 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
213};
Note: See TracBrowser for help on using the repository browser.