source: src/Filling/unittests/IsInsideSurface_FillPredicateUnitTest.cpp

Candidate_v1.6.1
Last change on this file was 94d5ac6, checked in by Frederik Heber <heber@…>, 12 years ago

FIX: As we use GSL internally, we are as of now required to use GPL v2 license.

  • GNU Scientific Library is used at every place in the code, especially the sub-package LinearAlgebra is based on it which in turn is used really everywhere in the remainder of MoleCuilder. Hence, we have to use the GPL license for the whole of MoleCuilder. In effect, GPL's COPYING was present all along and stated the terms of the GPL v2 license.
  • Hence, I added the default GPL v2 disclaimer to every source file and removed the note about a (actually missing) LICENSE file.
  • also, I added a help-redistribute action which again gives the disclaimer of the GPL v2.
  • also, I changed in the disclaimer that is printed at every program start in builder_init.cpp.
  • TEST: Added check on GPL statement present in every module to test CodeChecks project-disclaimer.
  • Property mode set to 100644
File size: 3.8 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 *
6 *
7 * This file is part of MoleCuilder.
8 *
9 * MoleCuilder is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * MoleCuilder is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23/*
24 * IsInsideSurface_FillPredicateUnitTest.cpp
25 *
26 * Created on: Jan 18, 2012
27 * Author: heber
28 */
29
30// include config.h
31#ifdef HAVE_CONFIG_H
32#include <config.h>
33#endif
34
35#include <cppunit/CompilerOutputter.h>
36#include <cppunit/extensions/TestFactoryRegistry.h>
37#include <cppunit/ui/text/TestRunner.h>
38
39#include "CodePatterns/Assert.hpp"
40#include "CodePatterns/Log.hpp"
41
42#include "Atom/TesselPoint.hpp"
43#include "LinkedCell/PointCloudAdaptor.hpp"
44#include "Filling/Predicates/IsInsideSurface_FillPredicate.hpp"
45#include "Filling/NodeTypes.hpp"
46#include "LinearAlgebra/Vector.hpp"
47#include "Tesselation/BoundaryLineSet.hpp"
48#include "Tesselation/BoundaryTriangleSet.hpp"
49#include "Tesselation/CandidateForTesselation.hpp"
50#include "Tesselation/tesselation.hpp"
51
52#include "IsInsideSurface_FillPredicateUnitTest.hpp"
53
54#ifdef HAVE_TESTRUNNER
55#include "UnitTestMain.hpp"
56#endif /*HAVE_TESTRUNNER*/
57
58const double IsInsideSurface_FillPredicateTest::SPHERERADIUS=2.;
59
60/********************************************** Test classes **************************************/
61
62// Registers the fixture into the 'registry'
63CPPUNIT_TEST_SUITE_REGISTRATION( IsInsideSurface_FillPredicateTest );
64
65
66void IsInsideSurface_FillPredicateTest::setUp()
67{
68 // failing asserts should be thrown
69 ASSERT_DO(Assert::Throw);
70
71 // create corners
72 class TesselPoint *Walker;
73 Walker = new TesselPoint;
74 Walker->setPosition(Vector(1., 0., -1.));
75 Walker->setName("1");
76 Walker->setNr(1);
77 Corners.push_back(Walker);
78 Walker = new TesselPoint;
79 Walker->setPosition(Vector(-1., 1., -1.));
80 Walker->setName("2");
81 Walker->setNr(2);
82 Corners.push_back(Walker);
83 Walker = new TesselPoint;
84 Walker->setPosition(Vector(-1., -1., -1.));
85 Walker->setName("3");
86 Walker->setNr(3);
87 Corners.push_back(Walker);
88 Walker = new TesselPoint;
89 Walker->setPosition(Vector(-1., 0., 1.));
90 Walker->setName("4");
91 Walker->setNr(4);
92 Corners.push_back(Walker);
93
94 // create linkedcell
95 PointCloudAdaptor<TesselPointSTLList> cloud(&Corners, "TesselPointSTLList");
96 LinkedList = new LinkedCell_deprecated(cloud, 2.*SPHERERADIUS);
97
98 // create tesselation
99 TesselStruct = new Tesselation;
100 (*TesselStruct)(cloud, SPHERERADIUS);
101
102 // create predicate
103 predicate = new FillPredicate(IsInsideSurface_FillPredicate(*TesselStruct, *LinkedList));
104}
105
106
107void IsInsideSurface_FillPredicateTest::tearDown()
108{
109 delete predicate;
110
111 delete(LinkedList);
112 delete(TesselStruct);
113 for (TesselPointSTLList::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++)
114 delete(*Runner);
115 Corners.clear();
116 logger::purgeInstance();
117 errorLogger::purgeInstance();
118
119}
120
121/** Test whether operator() returns as desired
122 *
123 */
124void IsInsideSurface_FillPredicateTest::operatorTest()
125{
126 Node center(0.,0.,0.);
127 Node corner(1.,0.,-1.);
128 Node outside(2.,0.,0.);
129
130 {
131 // center is inside
132 CPPUNIT_ASSERT( (*predicate)(center) );
133 }
134
135 {
136 // corner is inside
137 CPPUNIT_ASSERT( (*predicate)(corner) );
138 }
139
140 {
141 // outside is outside
142 CPPUNIT_ASSERT( !(*predicate)(outside) );
143 }
144}
Note: See TracBrowser for help on using the repository browser.