- Timestamp:
- Aug 20, 2014, 1:06:16 PM (11 years ago)
- Children:
- 0b517b
- Parents:
- ef3885
- git-author:
- Frederik Heber <heber@…> (07/12/14 11:57:54)
- git-committer:
- Frederik Heber <heber@…> (08/20/14 13:06:16)
- File:
- 
      - 1 edited
 
 
Legend:
- Unmodified
- Added
- Removed
- 
      src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.cppref3885 r42c742 45 45 #include "SphericalPointDistributionUnitTest.hpp" 46 46 47 #include <algorithm> 47 48 #include <boost/assign.hpp> 48 49 #include <boost/math/quaternion.hpp> … … 53 54 #include "LinearAlgebra/Line.hpp" 54 55 56 #include "Atom/TesselPoint.hpp" 55 57 #include "Fragmentation/Exporters/SphericalPointDistribution.hpp" 56 57 #include "LinearAlgebra/Line.hpp" 58 #include "LinkedCell/linkedcell.hpp" 59 #include "LinkedCell/PointCloudAdaptor.hpp" 60 #include "Tesselation/BoundaryLineSet.hpp" 61 #include "Tesselation/tesselation.hpp" 58 62 59 63 #ifdef HAVE_TESTRUNNER … … 78 82 ASSERT_DO(Assert::Throw); 79 83 80 setVerbosity( 6);84 setVerbosity(2); 81 85 } 82 86 … … 270 274 } 271 275 272 /** UnitTest for matchSphericalPointDistributions() with two points 273 */ 274 void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_2() 275 { 276 /** UnitTest for getConnections() 277 */ 278 template <> 279 void SphericalPointDistributionTest_assistant::getConnectionTest<0>() 280 { 281 const int N=0; 276 282 SphericalPointDistribution SPD(1.); 277 // test with one point, matching trivially 278 { 279 SphericalPointDistribution::WeightedPolygon_t polygon; 280 polygon += std::make_pair(Vector(1.,0.,0.), 1); 281 SphericalPointDistribution::Polygon_t newpolygon = 282 SPD.get<2>(); 283 SphericalPointDistribution::Polygon_t expected; 284 expected += Vector(-1.,0.,0.); 285 SphericalPointDistribution::Polygon_t remaining = 286 SphericalPointDistribution::matchSphericalPointDistributions( 287 polygon, 288 newpolygon); 289 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 290 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 291 } 292 293 // test with one point, just a flip of axis 294 { 295 SphericalPointDistribution::WeightedPolygon_t polygon; 296 polygon += std::make_pair( Vector(0.,1.,0.), 1); 297 SphericalPointDistribution::Polygon_t newpolygon = 298 SPD.get<2>(); 299 SphericalPointDistribution::Polygon_t expected; 300 expected += Vector(0.,-1.,0.); 301 SphericalPointDistribution::Polygon_t remaining = 302 SphericalPointDistribution::matchSphericalPointDistributions( 303 polygon, 304 newpolygon); 305 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 306 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 307 } 308 309 // test with one point, just a flip to another axis 310 { 311 SphericalPointDistribution::WeightedPolygon_t polygon; 312 polygon += std::make_pair( Vector(0.,0.,-1.), 1); 313 SphericalPointDistribution::Polygon_t newpolygon = 314 SPD.get<2>(); 315 SphericalPointDistribution::Polygon_t expected; 316 expected += Vector(0.,0.,1.); 317 SphericalPointDistribution::Polygon_t remaining = 318 SphericalPointDistribution::matchSphericalPointDistributions( 319 polygon, 320 newpolygon); 321 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 322 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 323 } 324 325 // test with one point, full rotation 326 { 327 Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248)); 328 SphericalPointDistribution::WeightedPolygon_t polygon; 329 polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1); 330 SphericalPointDistribution::Polygon_t newpolygon = 331 SPD.get<2>(); 332 SphericalPointDistribution::Polygon_t expected; 333 expected += RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI); 334 SphericalPointDistribution::Polygon_t remaining = 335 SphericalPointDistribution::matchSphericalPointDistributions( 336 polygon, 337 newpolygon); 338 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 339 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 340 } 283 284 // create empty adjacency 285 SphericalPointDistribution::adjacency_t adjacency; 286 287 // get the implemented connections 288 SphericalPointDistribution::adjacency_t expected = 289 SPD.getConnections<N>(); 290 291 // and compare the two 292 CPPUNIT_ASSERT_EQUAL( expected, adjacency ); 293 } 294 295 /** UnitTest for getConnections() 296 */ 297 template <> 298 void SphericalPointDistributionTest_assistant::getConnectionTest<1>() 299 { 300 const int N=1; 301 SphericalPointDistribution SPD(1.); 302 303 // create empty adjacency 304 SphericalPointDistribution::adjacency_t adjacency; 305 306 // get the implemented connections 307 SphericalPointDistribution::adjacency_t expected = 308 SPD.getConnections<N>(); 309 310 // and compare the two 311 CPPUNIT_ASSERT_EQUAL( expected, adjacency ); 312 } 313 314 /** UnitTest for getConnections() 315 */ 316 template <> 317 void SphericalPointDistributionTest_assistant::getConnectionTest<2>() 318 { 319 const int N=2; 320 SphericalPointDistribution SPD(1.); 321 322 // create empty adjacency 323 SphericalPointDistribution::adjacency_t adjacency; 324 adjacency += 325 make_pair< 326 unsigned int, 327 SphericalPointDistribution::IndexSet_t > 328 (0, list_of<unsigned int>(1)); 329 adjacency += 330 make_pair< 331 unsigned int, 332 SphericalPointDistribution::IndexSet_t > 333 (1, list_of<unsigned int>(0)); 334 335 // get the implemented connections 336 SphericalPointDistribution::adjacency_t expected = 337 SPD.getConnections<N>(); 338 339 // and compare the two 340 CPPUNIT_ASSERT_EQUAL( expected, adjacency ); 341 341 } 342 342 … … 460 460 } 461 461 462 /** UnitTest for matchSphericalPointDistributions() with two points 463 */ 464 void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_2() 465 { 466 SphericalPointDistribution SPD(1.); 467 // test with one point, matching trivially 468 { 469 SphericalPointDistribution::WeightedPolygon_t polygon; 470 polygon += std::make_pair(Vector(1.,0.,0.), 1); 471 SphericalPointDistribution::Polygon_t newpolygon = 472 SPD.get<2>(); 473 SphericalPointDistribution::Polygon_t expected; 474 expected += Vector(-1.,0.,0.); 475 SphericalPointDistribution::Polygon_t remaining = 476 SphericalPointDistribution::matchSphericalPointDistributions( 477 polygon, 478 newpolygon); 479 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 480 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 481 } 482 483 // test with one point, just a flip of axis 484 { 485 SphericalPointDistribution::WeightedPolygon_t polygon; 486 polygon += std::make_pair( Vector(0.,1.,0.), 1); 487 SphericalPointDistribution::Polygon_t newpolygon = 488 SPD.get<2>(); 489 SphericalPointDistribution::Polygon_t expected; 490 expected += Vector(0.,-1.,0.); 491 SphericalPointDistribution::Polygon_t remaining = 492 SphericalPointDistribution::matchSphericalPointDistributions( 493 polygon, 494 newpolygon); 495 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 496 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 497 } 498 499 // test with one point, just a flip to another axis 500 { 501 SphericalPointDistribution::WeightedPolygon_t polygon; 502 polygon += std::make_pair( Vector(0.,0.,-1.), 1); 503 SphericalPointDistribution::Polygon_t newpolygon = 504 SPD.get<2>(); 505 SphericalPointDistribution::Polygon_t expected; 506 expected += Vector(0.,0.,1.); 507 SphericalPointDistribution::Polygon_t remaining = 508 SphericalPointDistribution::matchSphericalPointDistributions( 509 polygon, 510 newpolygon); 511 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 512 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 513 } 514 515 // test with one point, full rotation 516 { 517 Line RotationAxis(zeroVec, Vector(0.2, 0.43, 0.6893248)); 518 SphericalPointDistribution::WeightedPolygon_t polygon; 519 polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1); 520 SphericalPointDistribution::Polygon_t newpolygon = 521 SPD.get<2>(); 522 SphericalPointDistribution::Polygon_t expected; 523 expected += RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI); 524 SphericalPointDistribution::Polygon_t remaining = 525 SphericalPointDistribution::matchSphericalPointDistributions( 526 polygon, 527 newpolygon); 528 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 529 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 530 } 531 } 532 462 533 /** UnitTest for matchSphericalPointDistributions() with three points 463 534 */ 
  Note:
 See   TracChangeset
 for help on using the changeset viewer.
  
