| [bcf653] | 1 | /*
 | 
|---|
 | 2 |  * Project: MoleCuilder
 | 
|---|
 | 3 |  * Description: creates and alters molecular systems
 | 
|---|
| [0aa122] | 4 |  * Copyright (C)  2010-2012 University of Bonn. All rights reserved.
 | 
|---|
| [bcf653] | 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] | 20 | using 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 | 
 | 
|---|
| [255829] | 29 | #include "CodePatterns/Log.hpp"
 | 
|---|
| [e4fe8d] | 30 | #include "Helpers/defs.hpp"
 | 
|---|
| [6f0841] | 31 | #include "Atom/TesselPoint.hpp"
 | 
|---|
| [471dec] | 32 | #include "LinearAlgebra/Plane.hpp"
 | 
|---|
| [6dc3fe] | 33 | #include "LinearAlgebra/RealSpaceMatrix.hpp"
 | 
|---|
| [471dec] | 34 | #include "LinearAlgebra/VectorSet.hpp"
 | 
|---|
| [d127c8] | 35 | #include "Tesselation/BoundaryPointSet.hpp"
 | 
|---|
 | 36 | #include "Tesselation/BoundaryLineSet.hpp"
 | 
|---|
 | 37 | #include "Tesselation/BoundaryTriangleSet.hpp"
 | 
|---|
 | 38 | #include "Tesselation/CandidateForTesselation.hpp"
 | 
|---|
| [f844ef] | 39 | 
 | 
|---|
 | 40 | #include "Tesselation_BoundaryTriangleUnitTest.hpp"
 | 
|---|
| [e9c677] | 41 | 
 | 
|---|
| [9b6b2f] | 42 | #ifdef HAVE_TESTRUNNER
 | 
|---|
 | 43 | #include "UnitTestMain.hpp"
 | 
|---|
 | 44 | #endif /*HAVE_TESTRUNNER*/
 | 
|---|
 | 45 | 
 | 
|---|
| [88b400] | 46 | const double TesselationBoundaryTriangleTest::SPHERERADIUS=2.;
 | 
|---|
| [e9c677] | 47 | 
 | 
|---|
 | 48 | /********************************************** Test classes **************************************/
 | 
|---|
 | 49 | 
 | 
|---|
 | 50 | // Registers the fixture into the 'registry'
 | 
|---|
 | 51 | CPPUNIT_TEST_SUITE_REGISTRATION( TesselationBoundaryTriangleTest );
 | 
|---|
 | 52 | 
 | 
|---|
 | 53 | 
 | 
|---|
| [471dec] | 54 | void TesselationBoundaryTriangleTest::createTriangle(const std::vector<Vector> &Vectors)
 | 
|---|
| [e9c677] | 55 | {
 | 
|---|
| [471dec] | 56 |   CPPUNIT_ASSERT_EQUAL( (size_t)3, Vectors.size() );
 | 
|---|
| [e9c677] | 57 | 
 | 
|---|
 | 58 |   // create nodes
 | 
|---|
| [471dec] | 59 |   for (size_t count = 0; count < NDIM; ++count) {
 | 
|---|
 | 60 |     tesselpoints[count] = new TesselPoint;
 | 
|---|
 | 61 |     tesselpoints[count]->setPosition( Vectors[count] );
 | 
|---|
 | 62 |     tesselpoints[count]->setName(toString(count));
 | 
|---|
 | 63 |     tesselpoints[count]->setNr(count);
 | 
|---|
 | 64 |     points[count] = new BoundaryPointSet(tesselpoints[count]);
 | 
|---|
 | 65 |   }
 | 
|---|
| [e9c677] | 66 | 
 | 
|---|
 | 67 |   // create line
 | 
|---|
 | 68 |   lines[0] = new BoundaryLineSet(points[0], points[1], 0);
 | 
|---|
 | 69 |   lines[1] = new BoundaryLineSet(points[1], points[2], 1);
 | 
|---|
 | 70 |   lines[2] = new BoundaryLineSet(points[0], points[2], 2);
 | 
|---|
 | 71 | 
 | 
|---|
 | 72 |   // create triangle
 | 
|---|
 | 73 |   triangle = new BoundaryTriangleSet(lines, 0);
 | 
|---|
| [471dec] | 74 |   Plane p(Vectors[0], Vectors[1], Vectors[2]);
 | 
|---|
 | 75 |   triangle->GetNormalVector(p.getNormal());
 | 
|---|
 | 76 | }
 | 
|---|
| [e9c677] | 77 | 
 | 
|---|
| [471dec] | 78 | void TesselationBoundaryTriangleTest::setUp()
 | 
|---|
 | 79 | {
 | 
|---|
 | 80 |   setVerbosity(5);
 | 
|---|
 | 81 | 
 | 
|---|
 | 82 |   // create nodes
 | 
|---|
 | 83 |   std::vector<Vector> Vectors;
 | 
|---|
 | 84 |   Vectors.push_back( Vector(0., 0., 0.) );
 | 
|---|
 | 85 |   Vectors.push_back( Vector(0., 1., 0.) );
 | 
|---|
 | 86 |   Vectors.push_back( Vector(1., 0., 0.) );
 | 
|---|
 | 87 | 
 | 
|---|
 | 88 |   // create triangle
 | 
|---|
 | 89 |   createTriangle(Vectors);
 | 
|---|
 | 90 | }
 | 
|---|
| [e9c677] | 91 | 
 | 
|---|
 | 92 | void TesselationBoundaryTriangleTest::tearDown()
 | 
|---|
 | 93 | {
 | 
|---|
 | 94 |   delete(triangle);
 | 
|---|
| [5c8592] | 95 |   for (int i=0;i<3;++i) {
 | 
|---|
 | 96 |     // TesselPoint does not delete its vector as it only got a reference
 | 
|---|
 | 97 |     delete tesselpoints[i];
 | 
|---|
 | 98 |   }
 | 
|---|
| [e9c677] | 99 |   logger::purgeInstance();
 | 
|---|
 | 100 |   errorLogger::purgeInstance();
 | 
|---|
| [6dc3fe] | 101 | }
 | 
|---|
| [e9c677] | 102 | 
 | 
|---|
| [471dec] | 103 | /** UnitTest for Tesselation::IsInsideTriangle()
 | 
|---|
 | 104 |  */
 | 
|---|
 | 105 | void TesselationBoundaryTriangleTest::IsInsideTriangleTest()
 | 
|---|
 | 106 | {
 | 
|---|
 | 107 |   // inside points
 | 
|---|
 | 108 |   {
 | 
|---|
 | 109 |     // check each endnode
 | 
|---|
 | 110 |     for (size_t i=0; i< NDIM; ++i) {
 | 
|---|
 | 111 |       const Vector testPoint(triangle->endpoints[i]->node->getPosition());
 | 
|---|
 | 112 |       LOG(1, "INFO: Testing whether " << testPoint << " is an inner point.");
 | 
|---|
 | 113 |       CPPUNIT_ASSERT( triangle->IsInsideTriangle( testPoint ) );
 | 
|---|
 | 114 |     }
 | 
|---|
 | 115 |   }
 | 
|---|
 | 116 | 
 | 
|---|
 | 117 |   {
 | 
|---|
 | 118 |     // check points along each BoundaryLine
 | 
|---|
 | 119 |     for (size_t i=0; i< NDIM; ++i) {
 | 
|---|
 | 120 |       Vector offset = triangle->endpoints[i%3]->node->getPosition();
 | 
|---|
 | 121 |       Vector direction = triangle->endpoints[(i+1)%3]->node->getPosition() - offset;
 | 
|---|
 | 122 |       for (double s = 0.1; s < 1.; s+= 0.1) {
 | 
|---|
 | 123 |         Vector testPoint = offset + s*direction;
 | 
|---|
 | 124 |         LOG(1, "INFO: Testing whether " << testPoint << " is an inner point.");
 | 
|---|
 | 125 |         CPPUNIT_ASSERT( triangle->IsInsideTriangle( testPoint ) );
 | 
|---|
 | 126 |       }
 | 
|---|
 | 127 |     }
 | 
|---|
 | 128 |   }
 | 
|---|
 | 129 | 
 | 
|---|
 | 130 |   {
 | 
|---|
 | 131 |     // check central point
 | 
|---|
 | 132 |     Vector center;
 | 
|---|
 | 133 |     triangle->GetCenter(center);
 | 
|---|
 | 134 |     LOG(1, "INFO: Testing whether " << center << " is an inner point.");
 | 
|---|
 | 135 |     CPPUNIT_ASSERT( triangle->IsInsideTriangle( center ) );
 | 
|---|
 | 136 |   }
 | 
|---|
 | 137 | 
 | 
|---|
 | 138 |   // outside points
 | 
|---|
 | 139 |   {
 | 
|---|
 | 140 |     // check points outside (i.e. those not in xy-plane through origin)
 | 
|---|
 | 141 |     double n[3];
 | 
|---|
 | 142 |     const double boundary = 4.;
 | 
|---|
 | 143 |     const double step = 1.;
 | 
|---|
 | 144 |     // go through the cube and check each point
 | 
|---|
 | 145 |     for (n[0] = -boundary; n[0] <= boundary; n[0]+=step)
 | 
|---|
 | 146 |       for (n[1] = -boundary; n[1] <= boundary; n[1]+=step)
 | 
|---|
 | 147 |         for (n[2] = -boundary; n[2] <= boundary; n[2]+=step) {
 | 
|---|
 | 148 |           const Vector testPoint(n[0], n[1], n[2]);
 | 
|---|
 | 149 |           if (n[2] != 0) {
 | 
|---|
 | 150 |             LOG(1, "INFO: Testing whether " << testPoint << " is not an inner point.");
 | 
|---|
 | 151 |             CPPUNIT_ASSERT( !triangle->IsInsideTriangle( testPoint ) );
 | 
|---|
 | 152 |           }
 | 
|---|
 | 153 |         }
 | 
|---|
 | 154 |   }
 | 
|---|
 | 155 | 
 | 
|---|
 | 156 |   {
 | 
|---|
 | 157 |     // check points within the plane but outside of triangle
 | 
|---|
 | 158 |     double n[3];
 | 
|---|
 | 159 |     const double boundary = 4.;
 | 
|---|
 | 160 |     const double step = 1.;
 | 
|---|
 | 161 |     n[2] = 0;
 | 
|---|
 | 162 |     for (n[0] = -boundary; n[0] <= boundary; n[0]+=step)
 | 
|---|
 | 163 |       for (n[1] = -boundary; n[1] <= boundary; n[1]+=step) {
 | 
|---|
 | 164 |         const Vector testPoint(n[0], n[1], n[2]);
 | 
|---|
 | 165 |         if ((n[0] >=0) && (n[1] >=0) && (n[0]<=1) && (n[1]<=1)) {
 | 
|---|
 | 166 |           if (n[0]+n[1] <= 1) {
 | 
|---|
 | 167 |             LOG(1, "INFO: Testing whether " << testPoint << " is an inner point.");
 | 
|---|
 | 168 |             CPPUNIT_ASSERT( triangle->IsInsideTriangle( testPoint) );
 | 
|---|
 | 169 |           } else {
 | 
|---|
 | 170 |             LOG(1, "INFO: Testing whether " << testPoint << " is not an inner point.");
 | 
|---|
 | 171 |             CPPUNIT_ASSERT( !triangle->IsInsideTriangle( testPoint) );
 | 
|---|
 | 172 |           }
 | 
|---|
 | 173 |         } else {
 | 
|---|
 | 174 |           LOG(1, "INFO: Testing whether " << testPoint << " is not an inner point.");
 | 
|---|
 | 175 |           CPPUNIT_ASSERT( !triangle->IsInsideTriangle( testPoint) );
 | 
|---|
 | 176 |         }
 | 
|---|
 | 177 |       }
 | 
|---|
 | 178 |   }
 | 
|---|
 | 179 | }
 | 
|---|
 | 180 | 
 | 
|---|
 | 181 | /** UnitTest for Tesselation::IsInsideTriangle()
 | 
|---|
 | 182 |  *
 | 
|---|
 | 183 |  * We test for some specific points that occured in larger examples of the code.
 | 
|---|
 | 184 |  *
 | 
|---|
 | 185 |  */
 | 
|---|
 | 186 | void TesselationBoundaryTriangleTest::IsInsideTriangle_specificTest()
 | 
|---|
 | 187 | {
 | 
|---|
 | 188 |   {
 | 
|---|
| [03a713] | 189 |     delete triangle;
 | 
|---|
| [471dec] | 190 |     // test is from --create-micelle 200 --radius 30. --position "0,0,0" of sles.data
 | 
|---|
 | 191 |     // failure is: Intersection (23.1644,24.1867,65.1272) is not inside triangle [659|Na2451,O3652,Na3762].
 | 
|---|
 | 192 |     const Vector testPoint(1.57318,1.57612,10.9874);
 | 
|---|
 | 193 |     const Vector testIntersection(23.1644,24.1867,65.1272);
 | 
|---|
 | 194 |     std::vector<Vector> vectors;
 | 
|---|
 | 195 |     vectors.push_back( Vector(23.0563,30.4673,73.7555) );
 | 
|---|
 | 196 |     vectors.push_back( Vector(25.473,25.1512,68.5467) );
 | 
|---|
 | 197 |     vectors.push_back( Vector(23.1644,24.1867,65.1272) );
 | 
|---|
 | 198 |     createTriangle(vectors);
 | 
|---|
 | 199 |     CPPUNIT_ASSERT( triangle->IsInsideTriangle( testIntersection ) );
 | 
|---|
| [03a713] | 200 |   }
 | 
|---|
 | 201 |   {
 | 
|---|
 | 202 |     delete triangle;
 | 
|---|
 | 203 |     // test is from --create-micelle 200 --radius 30. --position "0,0,0" of sles.data
 | 
|---|
 | 204 |     // failure is: Intersection (20.6787,70.655,71.5657) is not inside triangle [622|Na1197,Na2166,O3366].
 | 
|---|
 | 205 |     // fix is lower LINALG_MYEPSILON (not std::numeric_limits<doubble>*100 but *1e-4)
 | 
|---|
 | 206 |     const Vector testPoint(1.57318,14.185,61.2155);
 | 
|---|
 | 207 |     const Vector testIntersection(20.67867516517798,70.65496977054023,71.56572984946152);
 | 
|---|
 | 208 |     std::vector<Vector> vectors;
 | 
|---|
 | 209 |     vectors.push_back( Vector(22.9592,68.7791,77.5907) );
 | 
|---|
 | 210 |     vectors.push_back( Vector(18.4729,72.0386,68.08839999999999) );
 | 
|---|
 | 211 |     vectors.push_back( Vector(20.3834,71.0154,70.1443) );
 | 
|---|
 | 212 |     createTriangle(vectors);
 | 
|---|
 | 213 |     CPPUNIT_ASSERT( triangle->IsInsideTriangle( testIntersection ) );
 | 
|---|
| [471dec] | 214 |   }
 | 
|---|
| [c27ce7] | 215 |   {
 | 
|---|
 | 216 |     delete triangle;
 | 
|---|
 | 217 |     // test is from --create-micelle 200 --radius 30. --position "0,0,0" of sles.data
 | 
|---|
 | 218 |     // failure is:Intersection (27.56537519896,13.40256646925,6.672946688134) is not inside triangle [702|Na5016,O6388,Na6498].
 | 
|---|
 | 219 |     // note that the Intersection cannot possibly lie be within the triangle!
 | 
|---|
| [6a7fcbb] | 220 |     // we test now against correct intersection
 | 
|---|
 | 221 |     const Vector testIntersection(14.6872,36.204,39.8043);
 | 
|---|
| [c27ce7] | 222 |     std::vector<Vector> vectors;
 | 
|---|
 | 223 |     vectors.push_back( Vector(10.7513,43.4247,48.4127) );
 | 
|---|
 | 224 |     vectors.push_back( Vector(13.7119,37.0827,47.4203) );
 | 
|---|
 | 225 |     vectors.push_back( Vector(14.6872,36.204,39.8043) );
 | 
|---|
 | 226 |     createTriangle(vectors);
 | 
|---|
 | 227 |     CPPUNIT_ASSERT( triangle->IsInsideTriangle( testIntersection ) );
 | 
|---|
 | 228 |   }
 | 
|---|
| [471dec] | 229 | }
 | 
|---|
 | 230 | 
 | 
|---|
| [6dc3fe] | 231 | /** UnitTest for Tesselation::GetClosestPointInsideTriangle()
 | 
|---|
 | 232 |  *
 | 
|---|
 | 233 |  * We check whether this function always returns a intersection inside the
 | 
|---|
 | 234 |  * triangle.
 | 
|---|
 | 235 |  *
 | 
|---|
 | 236 |  */
 | 
|---|
 | 237 | void TesselationBoundaryTriangleTest::GetClosestPointInsideTriangleTest()
 | 
|---|
 | 238 | {
 | 
|---|
 | 239 |   Vector TestIntersection;
 | 
|---|
 | 240 | 
 | 
|---|
 | 241 |   {
 | 
|---|
 | 242 |     // march through a cube mesh on triangle in xy plane
 | 
|---|
 | 243 |     double n[3];
 | 
|---|
 | 244 |     const double boundary = 4.;
 | 
|---|
 | 245 |     const double step = 1.;
 | 
|---|
 | 246 |     // go through the cube and check each point
 | 
|---|
 | 247 |     for (n[0] = -boundary; n[0] <= boundary; n[0]+=step)
 | 
|---|
 | 248 |       for (n[1] = -boundary; n[1] <= boundary; n[1]+=step)
 | 
|---|
 | 249 |         for (n[2] = -boundary; n[2] <= boundary; n[2]+=step) {
 | 
|---|
 | 250 |           const Vector testPoint(n[0], n[1], n[2]);
 | 
|---|
 | 251 |           triangle->GetClosestPointInsideTriangle(testPoint, TestIntersection);
 | 
|---|
 | 252 |           CPPUNIT_ASSERT( triangle->IsInsideTriangle( TestIntersection ));
 | 
|---|
 | 253 |         }
 | 
|---|
 | 254 |   }
 | 
|---|
 | 255 | 
 | 
|---|
 | 256 |   delete triangle;
 | 
|---|
 | 257 |   // create better triangle;
 | 
|---|
 | 258 |   VECTORSET(std::vector) Vectors;
 | 
|---|
 | 259 |   Vectors.push_back( Vector(0., 0., 0.) );
 | 
|---|
 | 260 |   Vectors.push_back( Vector(0., 1., 0.) );
 | 
|---|
 | 261 |   Vectors.push_back( Vector(1., 0., 0.) );
 | 
|---|
 | 262 |   RealSpaceMatrix M;
 | 
|---|
 | 263 |   M.setRotation(M_PI/3., M_PI/4., 2.*M_PI/3.);
 | 
|---|
 | 264 |   Vectors.transform(M);
 | 
|---|
 | 265 |   createTriangle(Vectors);
 | 
|---|
 | 266 | 
 | 
|---|
 | 267 |   {
 | 
|---|
 | 268 |     // march through a cube mesh on rotated triangle
 | 
|---|
 | 269 |     double n[3];
 | 
|---|
 | 270 |     const double boundary = 4.;
 | 
|---|
 | 271 |     const double step = 1.;
 | 
|---|
 | 272 |     // go through the cube and check each point
 | 
|---|
 | 273 |     for (n[0] = -boundary; n[0] <= boundary; n[0]+=step)
 | 
|---|
 | 274 |       for (n[1] = -boundary; n[1] <= boundary; n[1]+=step)
 | 
|---|
 | 275 |         for (n[2] = -boundary; n[2] <= boundary; n[2]+=step) {
 | 
|---|
 | 276 |           const Vector testPoint(n[0], n[1], n[2]);
 | 
|---|
 | 277 |           triangle->GetClosestPointInsideTriangle(testPoint, TestIntersection);
 | 
|---|
 | 278 |           CPPUNIT_ASSERT( triangle->IsInsideTriangle( TestIntersection ));
 | 
|---|
 | 279 |         }
 | 
|---|
 | 280 |   }
 | 
|---|
 | 281 | }
 | 
|---|
 | 282 | 
 | 
|---|
| [c27ce7] | 283 | /** UnitTest for Tesselation::GetClosestPointInsideTriangle()
 | 
|---|
 | 284 |  *
 | 
|---|
 | 285 |  * We test for some specific points that occured in larger examples of the code.
 | 
|---|
 | 286 |  *
 | 
|---|
 | 287 |  */
 | 
|---|
 | 288 | void TesselationBoundaryTriangleTest::GetClosestPointInsideTriangle_specificTest()
 | 
|---|
 | 289 | {
 | 
|---|
 | 290 |   {
 | 
|---|
 | 291 |     delete triangle;
 | 
|---|
 | 292 |     // test is from --create-micelle 200 --radius 30. --position "0,0,0" of sles.data
 | 
|---|
 | 293 |     // failure is:Intersection (27.56537519896,13.40256646925,6.672946688134) is not inside triangle [702|Na5016,O6388,Na6498].
 | 
|---|
 | 294 |     // note that the Intersection cannot possibly lie be within the triangle
 | 
|---|
 | 295 |     // however, it is on its plane (off only by 2.7e-12)
 | 
|---|
| [6a7fcbb] | 296 |     // testPoint2 is corrected version
 | 
|---|
| [c27ce7] | 297 |     const Vector testPoint(27.56537519896,13.40256646925,6.672946688134);
 | 
|---|
| [6a7fcbb] | 298 |     const Vector testPoint2(14.6872,36.204,39.8043);
 | 
|---|
| [c27ce7] | 299 |     Vector testIntersection;
 | 
|---|
 | 300 |     std::vector<Vector> vectors;
 | 
|---|
 | 301 |     vectors.push_back( Vector(10.7513,43.4247,48.4127) );
 | 
|---|
 | 302 |     vectors.push_back( Vector(13.7119,37.0827,47.4203) );
 | 
|---|
 | 303 |     vectors.push_back( Vector(14.6872,36.204,39.8043) );
 | 
|---|
 | 304 |     createTriangle(vectors);
 | 
|---|
 | 305 |     triangle->GetClosestPointInsideTriangle(testPoint, testIntersection);
 | 
|---|
| [6a7fcbb] | 306 |     CPPUNIT_ASSERT ( testPoint != testIntersection );
 | 
|---|
 | 307 |     CPPUNIT_ASSERT ( testPoint2 == testIntersection );
 | 
|---|
| [c27ce7] | 308 |   }
 | 
|---|
 | 309 | }
 | 
|---|
| [6dc3fe] | 310 | 
 | 
|---|
| [e9c677] | 311 | /** UnitTest for Tesselation::IsInnerPoint()
 | 
|---|
 | 312 |  */
 | 
|---|
 | 313 | void TesselationBoundaryTriangleTest::GetClosestPointOnPlaneTest()
 | 
|---|
 | 314 | {
 | 
|---|
 | 315 |   Vector TestIntersection;
 | 
|---|
 | 316 |   Vector Point;
 | 
|---|
 | 317 | 
 | 
|---|
 | 318 |   // simple test on y line
 | 
|---|
| [1bd79e] | 319 |   Point = Vector(-1.,0.5,0.);
 | 
|---|
| [d74077] | 320 |   CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
 | 
|---|
| [1bd79e] | 321 |   Point = Vector(0.,0.5,0.);
 | 
|---|
| [e9c677] | 322 |   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
 | 
|---|
| [1bd79e] | 323 |   Point = Vector(-4.,0.5,0.);
 | 
|---|
| [d74077] | 324 |   CPPUNIT_ASSERT_EQUAL( 16., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
 | 
|---|
| [1bd79e] | 325 |   Point = Vector(0.,0.5,0.);
 | 
|---|
| [e9c677] | 326 |   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
 | 
|---|
 | 327 | 
 | 
|---|
 | 328 |   // simple test on x line
 | 
|---|
| [1bd79e] | 329 |   Point = Vector(0.5,-1.,0.);
 | 
|---|
| [d74077] | 330 |   CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
 | 
|---|
| [1bd79e] | 331 |   Point = Vector(0.5,0.,0.);
 | 
|---|
| [e9c677] | 332 |   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
 | 
|---|
| [1bd79e] | 333 |   Point = Vector(0.5,-6.,0.);
 | 
|---|
| [d74077] | 334 |   CPPUNIT_ASSERT_EQUAL( 36., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
 | 
|---|
| [1bd79e] | 335 |   Point = Vector(0.5,0.,0.);
 | 
|---|
| [e9c677] | 336 |   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
 | 
|---|
 | 337 | 
 | 
|---|
 | 338 |   // simple test on slanted line
 | 
|---|
| [1bd79e] | 339 |   Point = Vector(1.,1.,0.);
 | 
|---|
| [d74077] | 340 |   CPPUNIT_ASSERT_EQUAL( 0.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
 | 
|---|
| [1bd79e] | 341 |   Point = Vector(0.5,0.5,0.);
 | 
|---|
| [e9c677] | 342 |   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
 | 
|---|
| [1bd79e] | 343 |   Point = Vector(5.,5.,0.);
 | 
|---|
| [d74077] | 344 |   CPPUNIT_ASSERT_EQUAL( 40.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
 | 
|---|
| [1bd79e] | 345 |   Point = Vector(0.5,0.5,0.);
 | 
|---|
| [e9c677] | 346 |   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
 | 
|---|
 | 347 | 
 | 
|---|
 | 348 |   // simple test on first node
 | 
|---|
| [1bd79e] | 349 |   Point = Vector(-1.,-1.,0.);
 | 
|---|
| [d74077] | 350 |   CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
 | 
|---|
| [1bd79e] | 351 |   Point = Vector(0.,0.,0.);
 | 
|---|
| [e9c677] | 352 |   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
 | 
|---|
 | 353 | 
 | 
|---|
 | 354 |   // simple test on second node
 | 
|---|
| [1bd79e] | 355 |   Point = Vector(0.,2.,0.);
 | 
|---|
| [d74077] | 356 |   CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
 | 
|---|
| [1bd79e] | 357 |   Point = Vector(0.,1.,0.);
 | 
|---|
| [e9c677] | 358 |   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
 | 
|---|
 | 359 | 
 | 
|---|
 | 360 |   // simple test on third node
 | 
|---|
| [1bd79e] | 361 |   Point = Vector(2.,0.,0.);
 | 
|---|
| [d74077] | 362 |   CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
 | 
|---|
| [1bd79e] | 363 |   Point = Vector(1.,0.,0.);
 | 
|---|
| [e9c677] | 364 |   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
 | 
|---|
 | 365 | };
 | 
|---|
 | 366 | 
 | 
|---|
 | 367 | /** UnitTest for Tesselation::IsInnerPoint()
 | 
|---|
 | 368 |  */
 | 
|---|
 | 369 | void TesselationBoundaryTriangleTest::GetClosestPointOffPlaneTest()
 | 
|---|
 | 370 | {
 | 
|---|
 | 371 |   Vector TestIntersection;
 | 
|---|
 | 372 |   Vector Point;
 | 
|---|
 | 373 | 
 | 
|---|
 | 374 |   // straight down/up
 | 
|---|
| [1bd79e] | 375 |   Point = Vector(1./3.,1./3.,+5.);
 | 
|---|
| [d74077] | 376 |   CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
 | 
|---|
| [1bd79e] | 377 |   Point = Vector(1./3.,1./3.,0.);
 | 
|---|
| [e9c677] | 378 |   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
 | 
|---|
| [1bd79e] | 379 |   Point = Vector(1./3.,1./3.,-5.);
 | 
|---|
| [d74077] | 380 |   CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
 | 
|---|
| [1bd79e] | 381 |   Point = Vector(1./3.,1./3.,0.);
 | 
|---|
| [e9c677] | 382 |   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
 | 
|---|
 | 383 | 
 | 
|---|
 | 384 |   // simple test on y line
 | 
|---|
| [1bd79e] | 385 |   Point = Vector(-1.,0.5,+2.);
 | 
|---|
| [d74077] | 386 |   CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
 | 
|---|
| [1bd79e] | 387 |   Point = Vector(0.,0.5,0.);
 | 
|---|
| [e9c677] | 388 |   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
 | 
|---|
| [1bd79e] | 389 |   Point = Vector(-1.,0.5,-3.);
 | 
|---|
| [d74077] | 390 |   CPPUNIT_ASSERT_EQUAL( 10., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
 | 
|---|
| [1bd79e] | 391 |   Point = Vector(0.,0.5,0.);
 | 
|---|
| [e9c677] | 392 |   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
 | 
|---|
 | 393 | 
 | 
|---|
 | 394 |   // simple test on x line
 | 
|---|
| [1bd79e] | 395 |   Point = Vector(0.5,-1.,+1.);
 | 
|---|
| [d74077] | 396 |   CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
 | 
|---|
| [1bd79e] | 397 |   Point = Vector(0.5,0.,0.);
 | 
|---|
| [e9c677] | 398 |   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
 | 
|---|
| [1bd79e] | 399 |   Point = Vector(0.5,-1.,-2.);
 | 
|---|
| [d74077] | 400 |   CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
 | 
|---|
| [1bd79e] | 401 |   Point = Vector(0.5,0.,0.);
 | 
|---|
| [e9c677] | 402 |   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
 | 
|---|
 | 403 | 
 | 
|---|
 | 404 |   // simple test on slanted line
 | 
|---|
| [1bd79e] | 405 |   Point = Vector(1.,1.,+3.);
 | 
|---|
| [d74077] | 406 |   CPPUNIT_ASSERT_EQUAL( 9.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
 | 
|---|
| [1bd79e] | 407 |   Point = Vector(0.5,0.5,0.);
 | 
|---|
| [e9c677] | 408 |   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
 | 
|---|
| [1bd79e] | 409 |   Point = Vector(1.,1.,-4.);
 | 
|---|
| [d74077] | 410 |   CPPUNIT_ASSERT_EQUAL( 16.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
 | 
|---|
| [1bd79e] | 411 |   Point = Vector(0.5,0.5,0.);
 | 
|---|
| [e9c677] | 412 |   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
 | 
|---|
 | 413 | 
 | 
|---|
 | 414 |   // simple test on first node
 | 
|---|
| [1bd79e] | 415 |   Point = Vector(-1.,-1.,5.);
 | 
|---|
| [d74077] | 416 |   CPPUNIT_ASSERT_EQUAL( 27., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
 | 
|---|
| [1bd79e] | 417 |   Point = Vector(0.,0.,0.);
 | 
|---|
| [e9c677] | 418 |   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
 | 
|---|
 | 419 | 
 | 
|---|
 | 420 |   // simple test on second node
 | 
|---|
| [1bd79e] | 421 |   Point = Vector(0.,2.,5.);
 | 
|---|
| [d74077] | 422 |   CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
 | 
|---|
| [1bd79e] | 423 |   Point = Vector(0.,1.,0.);
 | 
|---|
| [e9c677] | 424 |   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
 | 
|---|
 | 425 | 
 | 
|---|
 | 426 |   // simple test on third node
 | 
|---|
| [1bd79e] | 427 |   Point = Vector(2.,0.,5.);
 | 
|---|
| [d74077] | 428 |   CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
 | 
|---|
| [1bd79e] | 429 |   Point = Vector(1.,0.,0.);
 | 
|---|
| [e9c677] | 430 |   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
 | 
|---|
 | 431 | };
 | 
|---|