Changeset 42c742
- 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)
 - Location:
 - src/Fragmentation
 - Files:
 - 
      
- 2 added
 - 5 edited
 
- 
          
  Exporters/SphericalPointDistribution.hpp (modified) (4 diffs)
 - 
          
  Exporters/SphericalPointDistribution_getConnections.cpp (added)
 - 
          
  Exporters/unittests/Makefile.am (modified) (2 diffs)
 - 
          
  Exporters/unittests/SphericalPointDistributionUnitTest.cpp (modified) (5 diffs)
 - 
          
  Exporters/unittests/SphericalPointDistributionUnitTest.hpp (modified) (2 diffs)
 - 
          
  Exporters/unittests/SphericalPointDistributionUnitTest_assistant.hpp (added)
 - 
          
  Makefile.am (modified) (1 diff)
 
 
Legend:
- Unmodified
 - Added
 - Removed
 
- 
      
src/Fragmentation/Exporters/SphericalPointDistribution.hpp
ref3885 r42c742 19 19 #include <cmath> 20 20 #include <list> 21 #include <map> 22 #include <set> 23 #include <vector> 21 24 22 25 #include "LinearAlgebra/Vector.hpp" … … 49 52 //!> typedef for the list of points with integral weights 50 53 typedef std::list<std::pair<Vector, int> > WeightedPolygon_t; 54 //!> typedef for a sorted list of indices 55 typedef std::set<unsigned int> IndexSet_t; 56 //!> typedef for the adjacency list of a polygon 57 typedef std::map<unsigned int, IndexSet_t > adjacency_t; 51 58 52 59 /** General getter function for the distribution of points on the surface. … … 61 68 } 62 69 70 template <int N> adjacency_t getConnections() 71 { 72 ASSERT(0, "SphericalPointDistribution::getConnections() - not specialized for "+toString(N)+"."); 73 } 63 74 64 75 /** Matches a given spherical distribution with another containing more … … 193 204 template <> SphericalPointDistribution::Polygon_t SphericalPointDistribution::get<14>(); 194 205 206 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<0>(); 207 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<1>(); 208 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<2>(); 209 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<3>(); 210 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<4>(); 211 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<5>(); 212 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<6>(); 213 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<7>(); 214 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<8>(); 215 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<9>(); 216 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<10>(); 217 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<11>(); 218 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<12>(); 219 template <> SphericalPointDistribution::adjacency_t SphericalPointDistribution::getConnections<14>(); 220 195 221 #endif /* SPHERICALPOINTDISTRIBUTION_HPP_ */  - 
      
src/Fragmentation/Exporters/unittests/Makefile.am
ref3885 r42c742 10 10 ../Fragmentation/Exporters/unittests/HydrogenPoolUnitTest.hpp \ 11 11 ../Fragmentation/Exporters/unittests/SaturatedFragmentUnitTest.hpp \ 12 ../Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.hpp 12 ../Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.hpp \ 13 ../Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest_assistant.hpp 13 14 14 15 FRAGMENTATIONEXPORTERSTESTS = \ … … 17 18 SphericalPointDistributionUnitTest 18 19 19 XFAIL_TESTS += SphericalPointDistributionUnitTest20 20 TESTS += $(FRAGMENTATIONEXPORTERSTESTS) 21 21 check_PROGRAMS += $(FRAGMENTATIONEXPORTERSTESTS)  - 
      
src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.cpp
ref3885 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 */  - 
      
src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.hpp
ref3885 r42c742 19 19 /********************************************** Test classes **************************************/ 20 20 21 class SphericalPointDistributionTest : public CppUnit::TestFixture 21 /** Template specialization needs to be in front of adding the test via CPPUNIT_TEST 22 * Hence,we put it in an extra class and inherit the functions. 23 */ 24 struct SphericalPointDistributionTest_assistant 22 25 { 26 public: 27 template <int N> 28 void getConnectionTest(); 29 }; 30 31 template <> void SphericalPointDistributionTest_assistant::getConnectionTest<0>(); 32 template <> void SphericalPointDistributionTest_assistant::getConnectionTest<1>(); 33 template <> void SphericalPointDistributionTest_assistant::getConnectionTest<2>(); 34 35 #include "SphericalPointDistributionUnitTest_assistant.hpp" 36 37 class SphericalPointDistributionTest : 38 public CppUnit::TestFixture, 39 public SphericalPointDistributionTest_assistant 40 { 41 42 private: 23 43 CPPUNIT_TEST_SUITE( SphericalPointDistributionTest) ; 24 44 CPPUNIT_TEST( calculateCenterOfMinimumDistanceTest ); 25 45 CPPUNIT_TEST ( areEqualToWithinBoundsTest ); 26 46 CPPUNIT_TEST ( joinPointsTest ); 47 CPPUNIT_TEST ( getConnectionTest<0> ); 48 CPPUNIT_TEST ( getConnectionTest<1> ); 49 CPPUNIT_TEST ( getConnectionTest<2> ); 50 CPPUNIT_TEST ( getConnectionTest<3> ); 51 CPPUNIT_TEST ( getConnectionTest<4> ); 52 CPPUNIT_TEST ( getConnectionTest<5> ); 53 CPPUNIT_TEST ( getConnectionTest<6> ); 54 CPPUNIT_TEST ( getConnectionTest<7> ); 55 CPPUNIT_TEST ( getConnectionTest<8> ); 56 CPPUNIT_TEST ( getConnectionTest<9> ); 57 CPPUNIT_TEST ( getConnectionTest<10> ); 58 CPPUNIT_TEST ( getConnectionTest<11> ); 59 CPPUNIT_TEST ( getConnectionTest<12> ); 60 CPPUNIT_TEST ( getConnectionTest<14> ); 27 61 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_2 ); 28 62 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_3 ); … … 32 66 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_7 ); 33 67 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_8 ); 34 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_multiple );68 // CPPUNIT_TEST ( matchSphericalPointDistributionsTest_multiple ); 35 69 CPPUNIT_TEST_SUITE_END(); 36 70  - 
      
src/Fragmentation/Makefile.am
ref3885 r42c742 9 9 Fragmentation/Exporters/SaturatedFragment.cpp \ 10 10 Fragmentation/Exporters/SphericalPointDistribution.cpp \ 11 Fragmentation/Exporters/SphericalPointDistribution_getConnections.cpp \ 11 12 Fragmentation/Exporters/SphericalPointDistribution_getPoints.cpp \ 12 13 Fragmentation/Homology/FragmentEdge.cpp \  
  Note:
 See   TracChangeset
 for help on using the changeset viewer.
  