Changeset 9cf90e for src/Fragmentation
- Timestamp:
- May 25, 2016, 7:13:59 AM (9 years ago)
- Children:
- ec9bd2
- Parents:
- a52369
- git-author:
- Frederik Heber <heber@…> (07/12/14 19:07:44)
- git-committer:
- Frederik Heber <heber@…> (05/25/16 07:13:59)
- Location:
- src/Fragmentation/Exporters
- Files:
-
- 4 edited
-
SphericalPointDistribution.cpp (modified) (9 diffs)
-
SphericalPointDistribution.hpp (modified) (4 diffs)
-
unittests/SphericalPointDistributionUnitTest.cpp (modified) (64 diffs)
-
unittests/SphericalPointDistributionUnitTest.hpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Exporters/SphericalPointDistribution.cpp
ra52369 r9cf90e 480 480 for (IndexList_t::iterator iter = _indices.begin(); 481 481 (iter != _indices.end()) && (!_MCS.foundflag);) { 482 482 483 // check whether we can stay in the current bin or have to move on to next one 483 484 if (*_remainiter == 0) { … … 490 491 } 491 492 } 492 // advance in matching to same position 493 494 // advance in matching to current bin to fill in 493 495 const size_t OldIndex = std::distance(_remainingweights.begin(), _remainiter); 494 496 while (_matching.size() <= OldIndex) { // add empty lists of new bin is opened … … 498 500 IndexTupleList_t::iterator filliniter = _matching.begin(); 499 501 std::advance(filliniter, OldIndex); 502 503 // check whether connection between bins' indices and candidate is satisfied 504 { 505 adjacency_t::const_iterator finder = _MCS.adjacency.find(*iter); 506 ASSERT( finder != _MCS.adjacency.end(), 507 "recurseMatchings() - "+toString(*iter)+" is not in adjacency list."); 508 if ((!filliniter->empty()) 509 && (finder->second.find(*filliniter->begin()) == finder->second.end())) { 510 LOG(5, "DEBUG; Skipping index " << *iter 511 << " as is not connected to current set." << *filliniter << "."); 512 ++iter; // note that for loop does not contain incrementor 513 continue; 514 } 515 } 516 500 517 // add index to matching 501 518 filliniter->push_back(*iter); … … 532 549 } 533 550 551 SphericalPointDistribution::MatchingControlStructure::MatchingControlStructure( 552 const adjacency_t &_adjacency, 553 const VectorArray_t &_oldpoints, 554 const VectorArray_t &_newpoints, 555 const WeightsArray_t &_weights 556 ) : 557 foundflag(false), 558 bestL2(std::numeric_limits<double>::max()), 559 adjacency(_adjacency), 560 oldpoints(_oldpoints), 561 newpoints(_newpoints), 562 weights(_weights) 563 {} 564 534 565 /** Finds combinatorially the best matching between points in \a _polygon 535 566 * and \a _newpolygon. … … 551 582 */ 552 583 SphericalPointDistribution::IndexList_t SphericalPointDistribution::findBestMatching( 553 const WeightedPolygon_t &_polygon, 554 Polygon_t &_newpolygon 584 const WeightedPolygon_t &_polygon 555 585 ) 556 586 { 557 MatchingControlStructure MCS;558 MCS.foundflag = false;559 MCS.bestL2 = std::numeric_limits<double>::max();560 587 // transform lists into arrays 588 VectorArray_t oldpoints; 589 VectorArray_t newpoints; 590 WeightsArray_t weights; 561 591 for (WeightedPolygon_t::const_iterator iter = _polygon.begin(); 562 592 iter != _polygon.end(); ++iter) { 563 MCS.oldpoints.push_back(iter->first); 564 MCS.weights.push_back(iter->second); 565 } 566 MCS.newpoints.insert(MCS.newpoints.begin(), _newpolygon.begin(),_newpolygon.end() ); 593 oldpoints.push_back(iter->first); 594 weights.push_back(iter->second); 595 } 596 newpoints.insert(newpoints.begin(), points.begin(), points.end() ); 597 MatchingControlStructure MCS(adjacency, oldpoints, newpoints, weights); 567 598 568 599 // search for bestmatching combinatorially 569 600 { 570 601 // translate polygon into vector to enable index addressing 571 IndexList_t indices( _newpolygon.size());602 IndexList_t indices(points.size()); 572 603 std::generate(indices.begin(), indices.end(), UniqueNumber); 573 604 IndexTupleList_t matching; … … 594 625 // combine multiple points and create simple IndexList from IndexTupleList 595 626 const SphericalPointDistribution::IndexList_t IndexList = 596 joinPoints( _newpolygon, MCS.newpoints, MCS.bestmatching);627 joinPoints(points, MCS.newpoints, MCS.bestmatching); 597 628 598 629 return IndexList; … … 779 810 } 780 811 812 void SphericalPointDistribution::initSelf(const int _NumberOfPoints) 813 { 814 switch (_NumberOfPoints) 815 { 816 case 0: 817 points = get<0>(); 818 adjacency = getConnections<0>(); 819 break; 820 case 1: 821 points = get<1>(); 822 adjacency = getConnections<1>(); 823 break; 824 case 2: 825 points = get<2>(); 826 adjacency = getConnections<2>(); 827 break; 828 case 3: 829 points = get<3>(); 830 adjacency = getConnections<3>(); 831 break; 832 case 4: 833 points = get<4>(); 834 adjacency = getConnections<4>(); 835 break; 836 case 5: 837 points = get<5>(); 838 adjacency = getConnections<5>(); 839 break; 840 case 6: 841 points = get<6>(); 842 adjacency = getConnections<6>(); 843 break; 844 case 7: 845 points = get<7>(); 846 adjacency = getConnections<7>(); 847 break; 848 case 8: 849 points = get<8>(); 850 adjacency = getConnections<8>(); 851 break; 852 case 9: 853 points = get<9>(); 854 adjacency = getConnections<9>(); 855 break; 856 case 10: 857 points = get<10>(); 858 adjacency = getConnections<10>(); 859 break; 860 case 11: 861 points = get<11>(); 862 adjacency = getConnections<11>(); 863 break; 864 case 12: 865 points = get<12>(); 866 adjacency = getConnections<12>(); 867 break; 868 case 14: 869 points = get<14>(); 870 adjacency = getConnections<14>(); 871 break; 872 default: 873 ASSERT(0, "SphericalPointDistribution::initSelf() - cannot deal with the case " 874 +toString(_NumberOfPoints)+"."); 875 } 876 LOG(3, "DEBUG: Ideal polygon is " << points); 877 } 781 878 782 879 SphericalPointDistribution::Polygon_t 783 SphericalPointDistribution::matchSphericalPointDistributions( 784 const SphericalPointDistribution::WeightedPolygon_t &_polygon, 785 SphericalPointDistribution::Polygon_t &_newpolygon 786 ) 880 SphericalPointDistribution::getRemainingPoints( 881 const WeightedPolygon_t &_polygon, 882 const int _N) 787 883 { 788 884 SphericalPointDistribution::Polygon_t remainingpoints; 789 885 886 // initialze to given number of points 887 initSelf(_N); 790 888 LOG(2, "INFO: Matching old polygon " << _polygon 791 << " with new polygon " << _newpolygon); 792 793 if (_polygon.size() == _newpolygon.size()) { 794 // same number of points desired as are present? Do nothing 795 LOG(2, "INFO: There are no vacant points to return."); 889 << " with new polygon " << points); 890 891 // check whether any points will remain vacant 892 int RemainingPoints = _N; 893 for (WeightedPolygon_t::const_iterator iter = _polygon.begin(); 894 iter != _polygon.end(); ++iter) 895 RemainingPoints -= iter->second; 896 if (RemainingPoints == 0) 796 897 return remainingpoints; 797 } 798 799 if (_polygon.size() > 0) { 800 IndexList_t bestmatching = findBestMatching(_polygon, _newpolygon); 898 899 if (_N > 0) { 900 IndexList_t bestmatching = findBestMatching(_polygon); 801 901 LOG(2, "INFO: Best matching is " << bestmatching); 802 902 … … 817 917 newSet.indices.resize(NumberIds, -1); 818 918 std::copy(beginiter, enditer, newSet.indices.begin()); 819 std::copy( _newpolygon.begin(),_newpolygon.end(), std::back_inserter(newSet.polygon));919 std::copy(points.begin(),points.end(), std::back_inserter(newSet.polygon)); 820 920 821 921 // determine rotation angles to align the two point distributions with … … 925 1025 return remainingpoints; 926 1026 } else 927 return _newpolygon;928 } 1027 return points; 1028 } -
src/Fragmentation/Exporters/SphericalPointDistribution.hpp
ra52369 r9cf90e 72 72 } 73 73 74 /** Matches a given spherical distribution with another containing more75 * points.74 /** Returns vacant spots to fill to get a complete spherical point distribution from 75 * given points \a _polygon, containing then \a _N in total. 76 76 * 77 77 * This is a helper to determine points where to best insert saturation 78 78 * hydrogens. 79 79 * 80 * \param _polygon current occupied positions 81 * \param _newpolygon ideal distribution to match best with current occupied 82 * positions 83 * \return remaining vacant positions relative to \a _polygon 84 */ 85 static Polygon_t matchSphericalPointDistributions( 86 const WeightedPolygon_t &_polygon, 87 Polygon_t &_newpolygon 88 ); 80 * \param _polygon already filled places to match 81 * \param _N desired total number fo points 82 */ 83 Polygon_t getRemainingPoints(const WeightedPolygon_t &_polygon, const int _N); 89 84 90 85 //!> default radius of the spherical distribution … … 129 124 130 125 private: 126 //!> points for the ideal distribution 127 Polygon_t points; 128 //!> connection information between these ideal points 129 adjacency_t adjacency; 130 131 /** Initialize inner status (points and adjacency) to desired number of 132 * points. 133 * 134 * \param _N number of points 135 */ 136 void initSelf(const int _N); 137 138 private: 131 139 //!> grant unit tests access to private parts 132 140 friend class SphericalPointDistributionTest; … … 141 149 142 150 struct MatchingControlStructure { 151 MatchingControlStructure( 152 const adjacency_t &_adjacency, 153 const VectorArray_t &_oldpoints, 154 const VectorArray_t &_newpoints, 155 const WeightsArray_t &_weights 156 ); 143 157 bool foundflag; 144 158 double bestL2; 159 const adjacency_t &adjacency; 160 const VectorArray_t oldpoints; 161 const VectorArray_t newpoints; 162 const WeightsArray_t weights; 145 163 IndexTupleList_t bestmatching; 146 VectorArray_t oldpoints;147 VectorArray_t newpoints;148 WeightsArray_t weights;149 164 }; 150 165 … … 158 173 ); 159 174 160 static IndexList_t findBestMatching( 161 const WeightedPolygon_t &_polygon, 162 Polygon_t &_newpolygon 163 ); 175 IndexList_t findBestMatching(const WeightedPolygon_t &_polygon); 164 176 165 177 static IndexList_t joinPoints( -
src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.cpp
ra52369 r9cf90e 612 612 } 613 613 614 /** UnitTest for matchSphericalPointDistributions() with two points615 */ 616 void SphericalPointDistributionTest:: matchSphericalPointDistributionsTest_2()614 /** UnitTest for getRemainingPoints() with two points 615 */ 616 void SphericalPointDistributionTest::getRemainingPointsTest_2() 617 617 { 618 618 SphericalPointDistribution SPD(1.); … … 621 621 SphericalPointDistribution::WeightedPolygon_t polygon; 622 622 polygon += std::make_pair(Vector(1.,0.,0.), 1); 623 SphericalPointDistribution::Polygon_t newpolygon =624 SPD.get<2>();625 623 SphericalPointDistribution::Polygon_t expected; 626 624 expected += Vector(-1.,0.,0.); 627 625 SphericalPointDistribution::Polygon_t remaining = 628 SphericalPointDistribution::matchSphericalPointDistributions( 629 polygon, 630 newpolygon); 626 SPD.getRemainingPoints(polygon, 2); 631 627 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 632 628 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 637 633 SphericalPointDistribution::WeightedPolygon_t polygon; 638 634 polygon += std::make_pair( Vector(0.,1.,0.), 1); 639 SphericalPointDistribution::Polygon_t newpolygon =640 SPD.get<2>();641 635 SphericalPointDistribution::Polygon_t expected; 642 636 expected += Vector(0.,-1.,0.); 643 637 SphericalPointDistribution::Polygon_t remaining = 644 SphericalPointDistribution::matchSphericalPointDistributions( 645 polygon, 646 newpolygon); 638 SPD.getRemainingPoints(polygon, 2); 647 639 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 648 640 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 653 645 SphericalPointDistribution::WeightedPolygon_t polygon; 654 646 polygon += std::make_pair( Vector(0.,0.,-1.), 1); 655 SphericalPointDistribution::Polygon_t newpolygon =656 SPD.get<2>();657 647 SphericalPointDistribution::Polygon_t expected; 658 648 expected += Vector(0.,0.,1.); 659 649 SphericalPointDistribution::Polygon_t remaining = 660 SphericalPointDistribution::matchSphericalPointDistributions( 661 polygon, 662 newpolygon); 650 SPD.getRemainingPoints(polygon, 2); 663 651 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 664 652 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 670 658 SphericalPointDistribution::WeightedPolygon_t polygon; 671 659 polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1); 672 SphericalPointDistribution::Polygon_t newpolygon =673 SPD.get<2>();674 660 SphericalPointDistribution::Polygon_t expected; 675 661 expected += RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI); 676 662 SphericalPointDistribution::Polygon_t remaining = 677 SphericalPointDistribution::matchSphericalPointDistributions( 678 polygon, 679 newpolygon); 680 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 681 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 682 } 683 } 684 685 /** UnitTest for matchSphericalPointDistributions() with three points 686 */ 687 void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_3() 663 SPD.getRemainingPoints(polygon, 2); 664 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 665 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 666 } 667 } 668 669 /** UnitTest for getRemainingPoints() with three points 670 */ 671 void SphericalPointDistributionTest::getRemainingPointsTest_3() 688 672 { 689 673 SphericalPointDistribution SPD(1.); … … 693 677 SphericalPointDistribution::WeightedPolygon_t polygon; 694 678 polygon += std::make_pair( Vector(1.,0.,0.), 1); 695 SphericalPointDistribution::Polygon_t newpolygon=679 SphericalPointDistribution::Polygon_t expected = 696 680 SPD.get<3>(); 697 SphericalPointDistribution::Polygon_t expected = newpolygon; 698 expected.pop_front(); // remove first point 699 SphericalPointDistribution::Polygon_t remaining = 700 SphericalPointDistribution::matchSphericalPointDistributions( 701 polygon, 702 newpolygon); 681 expected.pop_front(); // remove first point 682 SphericalPointDistribution::Polygon_t remaining = 683 SPD.getRemainingPoints(polygon, 3); 703 684 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 704 685 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 709 690 SphericalPointDistribution::WeightedPolygon_t polygon; 710 691 polygon += std::make_pair( Vector(0.,1.,0.), 1); 711 SphericalPointDistribution::Polygon_t newpolygon=692 SphericalPointDistribution::Polygon_t expected = 712 693 SPD.get<3>(); 713 SphericalPointDistribution::Polygon_t expected = newpolygon;714 694 expected.pop_front(); // remove first point 715 695 for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin(); … … 719 699 } 720 700 SphericalPointDistribution::Polygon_t remaining = 721 SphericalPointDistribution::matchSphericalPointDistributions( 722 polygon, 723 newpolygon); 701 SPD.getRemainingPoints(polygon, 3); 724 702 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 725 703 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 731 709 polygon += std::make_pair( Vector(1.,0.,0.), 1); 732 710 polygon += std::make_pair( Vector(-0.5, sqrt(3)*0.5,0.), 1); 733 SphericalPointDistribution::Polygon_t newpolygon=711 SphericalPointDistribution::Polygon_t expected = 734 712 SPD.get<3>(); 735 SphericalPointDistribution::Polygon_t expected = newpolygon; 736 expected.pop_front(); // remove first point 737 expected.pop_front(); // remove second point 738 SphericalPointDistribution::Polygon_t remaining = 739 SphericalPointDistribution::matchSphericalPointDistributions( 740 polygon, 741 newpolygon); 713 expected.pop_front(); // remove first point 714 expected.pop_front(); // remove second point 715 SphericalPointDistribution::Polygon_t remaining = 716 SPD.getRemainingPoints(polygon, 3); 742 717 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 743 718 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 754 729 polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1); 755 730 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-0.5, sqrt(3)*0.5,0.), 47.6/180*M_PI), 1); 756 SphericalPointDistribution::Polygon_t newpolygon=731 SphericalPointDistribution::Polygon_t expected = 757 732 SPD.get<3>(); 758 SphericalPointDistribution::Polygon_t expected = newpolygon;759 733 expected.pop_front(); // remove first point 760 734 expected.pop_front(); // remove second point … … 763 737 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 764 738 SphericalPointDistribution::Polygon_t remaining = 765 SphericalPointDistribution::matchSphericalPointDistributions( 766 polygon, 767 newpolygon); 739 SPD.getRemainingPoints(polygon, 3); 768 740 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 769 741 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 784 756 SphericalPointDistribution::Polygon_t expected; // empty cause none are vacant 785 757 SphericalPointDistribution::Polygon_t remaining = 786 SphericalPointDistribution::matchSphericalPointDistributions( 787 polygon, 788 newpolygon); 758 SPD.getRemainingPoints(polygon, 3); 789 759 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 790 760 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 807 777 SphericalPointDistribution::Polygon_t expected; // empty cause none are vacant 808 778 SphericalPointDistribution::Polygon_t remaining = 809 SphericalPointDistribution::matchSphericalPointDistributions( 810 polygon, 811 newpolygon); 812 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 813 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 814 // also slightly perturbed 815 const double amplitude = 0.05; 816 perturbPolygon(polygon, amplitude); 817 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) ); 818 } 819 } 820 821 /** UnitTest for matchSphericalPointDistributions() with four points 822 */ 823 void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_4() 779 SPD.getRemainingPoints(polygon, 3); 780 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 781 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 782 // also slightly perturbed 783 const double amplitude = 0.05; 784 perturbPolygon(polygon, amplitude); 785 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) ); 786 } 787 } 788 789 /** UnitTest for getRemainingPoints() with four points 790 */ 791 void SphericalPointDistributionTest::getRemainingPointsTest_4() 824 792 { 825 793 SphericalPointDistribution SPD(1.); … … 829 797 SphericalPointDistribution::WeightedPolygon_t polygon; 830 798 polygon += std::make_pair( Vector(1.,0.,0.), 1); 831 SphericalPointDistribution::Polygon_t newpolygon=799 SphericalPointDistribution::Polygon_t expected = 832 800 SPD.get<4>(); 833 SphericalPointDistribution::Polygon_t expected = newpolygon; 834 expected.pop_front(); // remove first point 835 SphericalPointDistribution::Polygon_t remaining = 836 SphericalPointDistribution::matchSphericalPointDistributions( 837 polygon, 838 newpolygon); 801 expected.pop_front(); // remove first point 802 SphericalPointDistribution::Polygon_t remaining = 803 SPD.getRemainingPoints(polygon, 4); 839 804 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 840 805 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 845 810 SphericalPointDistribution::WeightedPolygon_t polygon; 846 811 polygon += std::make_pair( Vector(0.,1.,0.), 1); 847 SphericalPointDistribution::Polygon_t newpolygon=812 SphericalPointDistribution::Polygon_t expected = 848 813 SPD.get<4>(); 849 SphericalPointDistribution::Polygon_t expected = newpolygon;850 814 expected.pop_front(); // remove first point 851 815 for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin(); … … 855 819 } 856 820 SphericalPointDistribution::Polygon_t remaining = 857 SphericalPointDistribution::matchSphericalPointDistributions( 858 polygon, 859 newpolygon); 821 SPD.getRemainingPoints(polygon, 4); 860 822 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 861 823 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 867 829 polygon += std::make_pair( Vector(1.,0.,0.), 1); 868 830 polygon += std::make_pair( Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 1); 869 SphericalPointDistribution::Polygon_t newpolygon=831 SphericalPointDistribution::Polygon_t expected = 870 832 SPD.get<4>(); 871 SphericalPointDistribution::Polygon_t expected = newpolygon; 872 expected.pop_front(); // remove first point 873 expected.pop_front(); // remove second point 874 SphericalPointDistribution::Polygon_t remaining = 875 SphericalPointDistribution::matchSphericalPointDistributions( 876 polygon, 877 newpolygon); 833 expected.pop_front(); // remove first point 834 expected.pop_front(); // remove second point 835 SphericalPointDistribution::Polygon_t remaining = 836 SPD.getRemainingPoints(polygon, 4); 878 837 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 879 838 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 889 848 polygon += std::make_pair( Vector(1.,0.,0.), 1); 890 849 polygon += std::make_pair( Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 1); 891 SphericalPointDistribution::Polygon_t newpolygon=850 SphericalPointDistribution::Polygon_t expected = 892 851 SPD.get<4>(); 893 SphericalPointDistribution::Polygon_t expected = newpolygon; 894 expected.pop_front(); // remove first point 895 expected.pop_front(); // remove second point 896 SphericalPointDistribution::Polygon_t remaining = 897 SphericalPointDistribution::matchSphericalPointDistributions( 898 polygon, 899 newpolygon); 852 expected.pop_front(); // remove first point 853 expected.pop_front(); // remove second point 854 SphericalPointDistribution::Polygon_t remaining = 855 SPD.getRemainingPoints(polygon, 4); 900 856 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 901 857 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 912 868 polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1); 913 869 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 47.6/180*M_PI), 1); 914 SphericalPointDistribution::Polygon_t newpolygon=870 SphericalPointDistribution::Polygon_t expected = 915 871 SPD.get<4>(); 916 SphericalPointDistribution::Polygon_t expected = newpolygon;917 872 expected.pop_front(); // remove first point 918 873 expected.pop_front(); // remove second point … … 921 876 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 922 877 SphericalPointDistribution::Polygon_t remaining = 923 SphericalPointDistribution::matchSphericalPointDistributions( 924 polygon, 925 newpolygon); 878 SPD.getRemainingPoints(polygon, 4); 926 879 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 927 880 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 938 891 polygon += std::make_pair( Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 1); 939 892 polygon += std::make_pair( Vector(-1./3.0, -M_SQRT2/3.0, M_SQRT2/sqrt(3)), 1); 940 SphericalPointDistribution::Polygon_t newpolygon=893 SphericalPointDistribution::Polygon_t expected = 941 894 SPD.get<4>(); 942 SphericalPointDistribution::Polygon_t expected = newpolygon;943 895 expected.pop_front(); // remove first point 944 896 expected.pop_front(); // remove second point 945 897 expected.pop_front(); // remove third point 946 898 SphericalPointDistribution::Polygon_t remaining = 947 SphericalPointDistribution::matchSphericalPointDistributions( 948 polygon, 949 newpolygon); 899 SPD.getRemainingPoints(polygon, 4); 950 900 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 951 901 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 963 913 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 47.6/180*M_PI), 1); 964 914 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1./3.0, -M_SQRT2/3.0, M_SQRT2/sqrt(3)), 47.6/180*M_PI), 1); 965 SphericalPointDistribution::Polygon_t newpolygon=915 SphericalPointDistribution::Polygon_t expected = 966 916 SPD.get<4>(); 967 SphericalPointDistribution::Polygon_t expected = newpolygon;968 917 expected.pop_front(); // remove first point 969 918 expected.pop_front(); // remove second point … … 973 922 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 974 923 SphericalPointDistribution::Polygon_t remaining = 975 SphericalPointDistribution::matchSphericalPointDistributions( 976 polygon, 977 newpolygon); 978 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 979 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 980 // also slightly perturbed 981 const double amplitude = 0.05; 982 perturbPolygon(polygon, amplitude); 983 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) ); 984 } 985 } 986 987 /** UnitTest for matchSphericalPointDistributions() with four points and weights 924 SPD.getRemainingPoints(polygon, 4); 925 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 926 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 927 // also slightly perturbed 928 const double amplitude = 0.05; 929 perturbPolygon(polygon, amplitude); 930 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) ); 931 } 932 } 933 934 /** UnitTest for getRemainingPoints() with four points and weights 988 935 * not all equal to one. 989 936 */ 990 void SphericalPointDistributionTest:: matchSphericalPointDistributionsTest_multiple()937 void SphericalPointDistributionTest::getRemainingPointsTest_multiple() 991 938 { 992 939 SphericalPointDistribution SPD(1.); … … 1002 949 expected += Vector(-0.5773502691896,-5.551115123126e-17,-0.8164965809277); 1003 950 SphericalPointDistribution::Polygon_t remaining = 1004 SphericalPointDistribution::matchSphericalPointDistributions( 1005 polygon, 1006 newpolygon); 951 SPD.getRemainingPoints(polygon, 4); 1007 952 // std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl; 1008 953 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); … … 1021 966 expected += Vector(-0.3535533905933,-0.3535533905933,-0.8660254037844); 1022 967 SphericalPointDistribution::Polygon_t remaining = 1023 SphericalPointDistribution::matchSphericalPointDistributions( 1024 polygon, 1025 newpolygon); 1026 // std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl; 968 SPD.getRemainingPoints(polygon, 5); 969 std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl; 1027 970 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1028 971 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1041 984 expected += Vector(0.3535534025157,-0.3535533856548,0.8660254009332); 1042 985 SphericalPointDistribution::Polygon_t remaining = 1043 SphericalPointDistribution::matchSphericalPointDistributions( 1044 polygon, 1045 newpolygon); 986 SPD.getRemainingPoints(polygon, 5); 1046 987 // std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl; 1047 988 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); … … 1057 998 SPD.get<6>(); 1058 999 SphericalPointDistribution::Polygon_t expected; 1000 expected += Vector(0.,0.,1.); 1059 1001 expected += Vector(0.,0.,-1.); 1060 expected += Vector(0.,0.,1.); 1061 SphericalPointDistribution::Polygon_t remaining = 1062 SphericalPointDistribution::matchSphericalPointDistributions( 1063 polygon, 1064 newpolygon); 1002 SphericalPointDistribution::Polygon_t remaining = 1003 SPD.getRemainingPoints(polygon, 6); 1065 1004 // std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl; 1066 1005 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); … … 1069 1008 } 1070 1009 1071 /** UnitTest for matchSphericalPointDistributions() with five points1072 */ 1073 void SphericalPointDistributionTest:: matchSphericalPointDistributionsTest_5()1010 /** UnitTest for getRemainingPoints() with five points 1011 */ 1012 void SphericalPointDistributionTest::getRemainingPointsTest_5() 1074 1013 { 1075 1014 SphericalPointDistribution SPD(1.); … … 1079 1018 SphericalPointDistribution::WeightedPolygon_t polygon; 1080 1019 polygon += std::make_pair( Vector(1.,0.,0.), 1); 1081 SphericalPointDistribution::Polygon_t newpolygon=1020 SphericalPointDistribution::Polygon_t expected = 1082 1021 SPD.get<5>(); 1083 SphericalPointDistribution::Polygon_t expected = newpolygon; 1084 expected.pop_front(); // remove first point 1085 SphericalPointDistribution::Polygon_t remaining = 1086 SphericalPointDistribution::matchSphericalPointDistributions( 1087 polygon, 1088 newpolygon); 1022 expected.pop_front(); // remove first point 1023 SphericalPointDistribution::Polygon_t remaining = 1024 SPD.getRemainingPoints(polygon, 5); 1089 1025 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1090 1026 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1095 1031 SphericalPointDistribution::WeightedPolygon_t polygon; 1096 1032 polygon += std::make_pair( Vector(0.,1.,0.), 1); 1097 SphericalPointDistribution::Polygon_t newpolygon=1033 SphericalPointDistribution::Polygon_t expected = 1098 1034 SPD.get<5>(); 1099 SphericalPointDistribution::Polygon_t expected = newpolygon;1100 1035 expected.pop_front(); // remove first point 1101 1036 for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin(); … … 1105 1040 } 1106 1041 SphericalPointDistribution::Polygon_t remaining = 1107 SphericalPointDistribution::matchSphericalPointDistributions( 1108 polygon, 1109 newpolygon); 1042 SPD.getRemainingPoints(polygon, 5); 1110 1043 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1111 1044 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1117 1050 polygon += std::make_pair( Vector(1.,0.,0.), 1); 1118 1051 polygon += std::make_pair( Vector(-1.,0.,0.), 1); 1119 SphericalPointDistribution::Polygon_t newpolygon=1052 SphericalPointDistribution::Polygon_t expected = 1120 1053 SPD.get<5>(); 1121 SphericalPointDistribution::Polygon_t expected = newpolygon; 1122 expected.pop_front(); // remove first point 1123 expected.pop_front(); // remove second point 1124 SphericalPointDistribution::Polygon_t remaining = 1125 SphericalPointDistribution::matchSphericalPointDistributions( 1126 polygon, 1127 newpolygon); 1054 expected.pop_front(); // remove first point 1055 expected.pop_front(); // remove second point 1056 SphericalPointDistribution::Polygon_t remaining = 1057 SPD.getRemainingPoints(polygon, 5); 1128 1058 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1129 1059 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1140 1070 polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180.*M_PI), 1); 1141 1071 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180.*M_PI), 1); 1142 SphericalPointDistribution::Polygon_t newpolygon=1072 SphericalPointDistribution::Polygon_t expected = 1143 1073 SPD.get<5>(); 1144 SphericalPointDistribution::Polygon_t expected = newpolygon;1145 1074 expected.pop_front(); // remove first point 1146 1075 expected.pop_front(); // remove second point … … 1149 1078 *iter = RotationAxis.rotateVector(*iter, 47.6/180.*M_PI); 1150 1079 SphericalPointDistribution::Polygon_t remaining = 1151 SphericalPointDistribution::matchSphericalPointDistributions( 1152 polygon, 1153 newpolygon); 1080 SPD.getRemainingPoints(polygon, 5); 1154 1081 // the three remaining points sit on a plane that may be rotated arbitrarily 1155 1082 // so we cannot simply check for equality between expected and remaining … … 1171 1098 polygon += std::make_pair( Vector(-1., 0.0, 0.0), 1); 1172 1099 polygon += std::make_pair( Vector(0.0, 1., 0.0), 1); 1173 SphericalPointDistribution::Polygon_t newpolygon=1100 SphericalPointDistribution::Polygon_t expected = 1174 1101 SPD.get<5>(); 1175 SphericalPointDistribution::Polygon_t expected = newpolygon;1176 1102 expected.pop_front(); // remove first point 1177 1103 expected.pop_front(); // remove second point 1178 1104 expected.pop_front(); // remove third point 1179 1105 SphericalPointDistribution::Polygon_t remaining = 1180 SphericalPointDistribution::matchSphericalPointDistributions( 1181 polygon, 1182 newpolygon); 1106 SPD.getRemainingPoints(polygon, 5); 1183 1107 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1184 1108 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1196 1120 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI), 1); 1197 1121 polygon += std::make_pair(RotationAxis.rotateVector(Vector(0.0, 1., 0.0), 47.6/180*M_PI), 1); 1198 SphericalPointDistribution::Polygon_t newpolygon=1122 SphericalPointDistribution::Polygon_t expected = 1199 1123 SPD.get<5>(); 1200 SphericalPointDistribution::Polygon_t expected = newpolygon;1201 1124 expected.pop_front(); // remove first point 1202 1125 expected.pop_front(); // remove second point … … 1206 1129 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 1207 1130 SphericalPointDistribution::Polygon_t remaining = 1208 SphericalPointDistribution::matchSphericalPointDistributions( 1209 polygon, 1210 newpolygon); 1211 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1212 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 1213 // also slightly perturbed 1214 const double amplitude = 0.05; 1215 perturbPolygon(polygon, amplitude); 1216 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) ); 1217 } 1218 } 1219 1220 /** UnitTest for matchSphericalPointDistributions() with six points 1221 */ 1222 void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_6() 1131 SPD.getRemainingPoints(polygon, 5); 1132 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1133 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 1134 // also slightly perturbed 1135 const double amplitude = 0.05; 1136 perturbPolygon(polygon, amplitude); 1137 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) ); 1138 } 1139 } 1140 1141 /** UnitTest for getRemainingPoints() with six points 1142 */ 1143 void SphericalPointDistributionTest::getRemainingPointsTest_6() 1223 1144 { 1224 1145 SphericalPointDistribution SPD(1.); … … 1228 1149 SphericalPointDistribution::WeightedPolygon_t polygon; 1229 1150 polygon += std::make_pair( Vector(1.,0.,0.), 1); 1230 SphericalPointDistribution::Polygon_t newpolygon=1151 SphericalPointDistribution::Polygon_t expected = 1231 1152 SPD.get<6>(); 1232 SphericalPointDistribution::Polygon_t expected = newpolygon; 1233 expected.pop_front(); // remove first point 1234 SphericalPointDistribution::Polygon_t remaining = 1235 SphericalPointDistribution::matchSphericalPointDistributions( 1236 polygon, 1237 newpolygon); 1153 expected.pop_front(); // remove first point 1154 SphericalPointDistribution::Polygon_t remaining = 1155 SPD.getRemainingPoints(polygon, 6); 1238 1156 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1239 1157 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1244 1162 SphericalPointDistribution::WeightedPolygon_t polygon; 1245 1163 polygon += std::make_pair( Vector(0.,1.,0.), 1); 1246 SphericalPointDistribution::Polygon_t newpolygon=1164 SphericalPointDistribution::Polygon_t expected = 1247 1165 SPD.get<6>(); 1248 SphericalPointDistribution::Polygon_t expected = newpolygon;1249 1166 expected.pop_front(); // remove first point 1250 1167 for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin(); … … 1254 1171 } 1255 1172 SphericalPointDistribution::Polygon_t remaining = 1256 SphericalPointDistribution::matchSphericalPointDistributions( 1257 polygon, 1258 newpolygon); 1173 SPD.getRemainingPoints(polygon, 6); 1259 1174 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1260 1175 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1266 1181 polygon += std::make_pair( Vector(1.,0.,0.), 1); 1267 1182 polygon += std::make_pair( Vector(-1.,0.,0.), 1); 1268 SphericalPointDistribution::Polygon_t newpolygon=1183 SphericalPointDistribution::Polygon_t expected = 1269 1184 SPD.get<6>(); 1270 SphericalPointDistribution::Polygon_t expected = newpolygon;1271 1185 expected.pop_front(); // remove first point 1272 1186 expected.pop_front(); // remove second spoint 1273 1187 SphericalPointDistribution::Polygon_t remaining = 1274 SphericalPointDistribution::matchSphericalPointDistributions( 1275 polygon, 1276 newpolygon); 1188 SPD.getRemainingPoints(polygon, 6); 1277 1189 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1278 1190 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1289 1201 polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1); 1290 1202 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI), 1); 1291 SphericalPointDistribution::Polygon_t newpolygon=1203 SphericalPointDistribution::Polygon_t expected = 1292 1204 SPD.get<6>(); 1293 SphericalPointDistribution::Polygon_t expected = newpolygon;1294 1205 expected.pop_front(); // remove first point 1295 1206 expected.pop_front(); // remove second spoint … … 1298 1209 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 1299 1210 SphericalPointDistribution::Polygon_t remaining = 1300 SphericalPointDistribution::matchSphericalPointDistributions( 1301 polygon, 1302 newpolygon); 1211 SPD.getRemainingPoints(polygon, 6); 1303 1212 // the four remaining points sit on a plane that may have been rotated arbitrarily 1304 1213 // so we cannot simply check for equality between expected and remaining … … 1320 1229 polygon += std::make_pair( Vector(-1., 0.0, 0.0), 1); 1321 1230 polygon += std::make_pair( Vector(0.0, 1., 0.0), 1); 1322 SphericalPointDistribution::Polygon_t newpolygon=1231 SphericalPointDistribution::Polygon_t expected = 1323 1232 SPD.get<6>(); 1324 SphericalPointDistribution::Polygon_t expected = newpolygon;1325 1233 expected.pop_front(); // remove first point 1326 1234 expected.pop_front(); // remove second point 1327 1235 expected.pop_front(); // remove third point 1328 1236 SphericalPointDistribution::Polygon_t remaining = 1329 SphericalPointDistribution::matchSphericalPointDistributions( 1330 polygon, 1331 newpolygon); 1237 SPD.getRemainingPoints(polygon, 6); 1332 1238 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1333 1239 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1345 1251 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI), 1); 1346 1252 polygon += std::make_pair(RotationAxis.rotateVector(Vector(0.0, 1., 0.0), 47.6/180*M_PI), 1); 1347 SphericalPointDistribution::Polygon_t newpolygon=1253 SphericalPointDistribution::Polygon_t expected = 1348 1254 SPD.get<6>(); 1349 SphericalPointDistribution::Polygon_t expected = newpolygon;1350 1255 expected.pop_front(); // remove first point 1351 1256 expected.pop_front(); // remove second point … … 1355 1260 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 1356 1261 SphericalPointDistribution::Polygon_t remaining = 1357 SphericalPointDistribution::matchSphericalPointDistributions( 1358 polygon, 1359 newpolygon); 1360 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1361 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 1362 // also slightly perturbed 1363 const double amplitude = 0.05; 1364 perturbPolygon(polygon, amplitude); 1365 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) ); 1366 } 1367 } 1368 1369 /** UnitTest for matchSphericalPointDistributions() with seven points 1370 */ 1371 void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_7() 1262 SPD.getRemainingPoints(polygon, 6); 1263 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1264 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 1265 // also slightly perturbed 1266 const double amplitude = 0.05; 1267 perturbPolygon(polygon, amplitude); 1268 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) ); 1269 } 1270 } 1271 1272 /** UnitTest for getRemainingPoints() with seven points 1273 */ 1274 void SphericalPointDistributionTest::getRemainingPointsTest_7() 1372 1275 { 1373 1276 SphericalPointDistribution SPD(1.); … … 1377 1280 SphericalPointDistribution::WeightedPolygon_t polygon; 1378 1281 polygon += std::make_pair( Vector(1.,0.,0.), 1); 1379 SphericalPointDistribution::Polygon_t newpolygon=1282 SphericalPointDistribution::Polygon_t expected = 1380 1283 SPD.get<7>(); 1381 SphericalPointDistribution::Polygon_t expected = newpolygon; 1382 expected.pop_front(); // remove first point 1383 SphericalPointDistribution::Polygon_t remaining = 1384 SphericalPointDistribution::matchSphericalPointDistributions( 1385 polygon, 1386 newpolygon); 1284 expected.pop_front(); // remove first point 1285 SphericalPointDistribution::Polygon_t remaining = 1286 SPD.getRemainingPoints(polygon, 7); 1387 1287 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1388 1288 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1393 1293 SphericalPointDistribution::WeightedPolygon_t polygon; 1394 1294 polygon += std::make_pair( Vector(0.,1.,0.), 1); 1395 SphericalPointDistribution::Polygon_t newpolygon=1295 SphericalPointDistribution::Polygon_t expected = 1396 1296 SPD.get<7>(); 1397 SphericalPointDistribution::Polygon_t expected = newpolygon;1398 1297 expected.pop_front(); // remove first point 1399 1298 for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin(); … … 1403 1302 } 1404 1303 SphericalPointDistribution::Polygon_t remaining = 1405 SphericalPointDistribution::matchSphericalPointDistributions( 1406 polygon, 1407 newpolygon); 1304 SPD.getRemainingPoints(polygon, 7); 1408 1305 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1409 1306 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1415 1312 polygon += std::make_pair( Vector(1.,0.,0.), 1); 1416 1313 polygon += std::make_pair( Vector(-1.,0.,0.), 1); 1417 SphericalPointDistribution::Polygon_t newpolygon=1314 SphericalPointDistribution::Polygon_t expected = 1418 1315 SPD.get<7>(); 1419 SphericalPointDistribution::Polygon_t expected = newpolygon; 1420 expected.pop_front(); // remove first point 1421 expected.pop_front(); // remove second point 1422 SphericalPointDistribution::Polygon_t remaining = 1423 SphericalPointDistribution::matchSphericalPointDistributions( 1424 polygon, 1425 newpolygon); 1316 expected.pop_front(); // remove first point 1317 expected.pop_front(); // remove second point 1318 SphericalPointDistribution::Polygon_t remaining = 1319 SPD.getRemainingPoints(polygon, 7); 1426 1320 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1427 1321 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1438 1332 polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1); 1439 1333 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI), 1); 1440 SphericalPointDistribution::Polygon_t newpolygon=1334 SphericalPointDistribution::Polygon_t expected = 1441 1335 SPD.get<7>(); 1442 SphericalPointDistribution::Polygon_t expected = newpolygon;1443 1336 expected.pop_front(); // remove first point 1444 1337 expected.pop_front(); // remove second point … … 1447 1340 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 1448 1341 SphericalPointDistribution::Polygon_t remaining = 1449 SphericalPointDistribution::matchSphericalPointDistributions( 1450 polygon, 1451 newpolygon); 1342 SPD.getRemainingPoints(polygon, 7); 1452 1343 // the five remaining points sit on a plane that may have been rotated arbitrarily 1453 1344 // so we cannot simply check for equality between expected and remaining … … 1469 1360 polygon += std::make_pair( Vector(-1., 0.0, 0.0), 1); 1470 1361 polygon += std::make_pair( Vector(0.0, 1., 0.0), 1); 1471 SphericalPointDistribution::Polygon_t newpolygon=1362 SphericalPointDistribution::Polygon_t expected = 1472 1363 SPD.get<7>(); 1473 SphericalPointDistribution::Polygon_t expected = newpolygon;1474 1364 expected.pop_front(); // remove first point 1475 1365 expected.pop_front(); // remove second point 1476 1366 expected.pop_front(); // remove third point 1477 1367 SphericalPointDistribution::Polygon_t remaining = 1478 SphericalPointDistribution::matchSphericalPointDistributions( 1479 polygon, 1480 newpolygon); 1368 SPD.getRemainingPoints(polygon, 7); 1481 1369 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1482 1370 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1494 1382 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI), 1); 1495 1383 polygon += std::make_pair(RotationAxis.rotateVector(Vector(0.0, 1., 0.0), 47.6/180*M_PI), 1); 1496 SphericalPointDistribution::Polygon_t newpolygon=1384 SphericalPointDistribution::Polygon_t expected = 1497 1385 SPD.get<7>(); 1498 SphericalPointDistribution::Polygon_t expected = newpolygon;1499 1386 expected.pop_front(); // remove first point 1500 1387 expected.pop_front(); // remove second point … … 1504 1391 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 1505 1392 SphericalPointDistribution::Polygon_t remaining = 1506 SphericalPointDistribution::matchSphericalPointDistributions( 1507 polygon, 1508 newpolygon); 1509 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1510 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 1511 // also slightly perturbed 1512 const double amplitude = 0.05; 1513 perturbPolygon(polygon, amplitude); 1514 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) ); 1515 } 1516 } 1517 1518 /** UnitTest for matchSphericalPointDistributions() with eight points 1519 */ 1520 void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_8() 1393 SPD.getRemainingPoints(polygon, 7); 1394 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1395 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 1396 // also slightly perturbed 1397 const double amplitude = 0.05; 1398 perturbPolygon(polygon, amplitude); 1399 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) ); 1400 } 1401 } 1402 1403 /** UnitTest for getRemainingPoints() with eight points 1404 */ 1405 void SphericalPointDistributionTest::getRemainingPointsTest_8() 1521 1406 { 1522 1407 SphericalPointDistribution SPD(1.); … … 1526 1411 SphericalPointDistribution::WeightedPolygon_t polygon; 1527 1412 polygon += std::make_pair( Vector(1.,0.,0.), 1); 1528 SphericalPointDistribution::Polygon_t newpolygon=1413 SphericalPointDistribution::Polygon_t expected = 1529 1414 SPD.get<8>(); 1530 SphericalPointDistribution::Polygon_t expected = newpolygon; 1531 expected.pop_front(); // remove first point 1532 SphericalPointDistribution::Polygon_t remaining = 1533 SphericalPointDistribution::matchSphericalPointDistributions( 1534 polygon, 1535 newpolygon); 1415 expected.pop_front(); // remove first point 1416 SphericalPointDistribution::Polygon_t remaining = 1417 SPD.getRemainingPoints(polygon, 8); 1536 1418 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1537 1419 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1542 1424 SphericalPointDistribution::WeightedPolygon_t polygon; 1543 1425 polygon += std::make_pair( Vector(0.,1.,0.), 1); 1544 SphericalPointDistribution::Polygon_t newpolygon=1426 SphericalPointDistribution::Polygon_t expected = 1545 1427 SPD.get<8>(); 1546 SphericalPointDistribution::Polygon_t expected = newpolygon;1547 1428 expected.pop_front(); // remove first point 1548 1429 for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin(); … … 1551 1432 (*iter)[0] *= -1.; 1552 1433 } 1553 SphericalPointDistribution::Polygon_t remaining = 1554 SphericalPointDistribution::matchSphericalPointDistributions( 1555 polygon, 1556 newpolygon); 1434 SphericalPointDistribution::Polygon_t remaining = 1435 SPD.getRemainingPoints(polygon, 8); 1557 1436 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1558 1437 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1564 1443 polygon += std::make_pair( Vector(1.,0.,0.), 1); 1565 1444 polygon += std::make_pair( Vector(-1.,0.,0.), 1); 1566 SphericalPointDistribution::Polygon_t newpolygon=1445 SphericalPointDistribution::Polygon_t expected = 1567 1446 SPD.get<8>(); 1568 SphericalPointDistribution::Polygon_t expected = newpolygon; 1569 expected.pop_front(); // remove first point 1570 expected.pop_front(); // remove second point 1571 SphericalPointDistribution::Polygon_t remaining = 1572 SphericalPointDistribution::matchSphericalPointDistributions( 1573 polygon, 1574 newpolygon); 1447 expected.pop_front(); // remove first point 1448 expected.pop_front(); // remove second point 1449 SphericalPointDistribution::Polygon_t remaining = 1450 SPD.getRemainingPoints(polygon, 8); 1575 1451 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1576 1452 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1587 1463 polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1); 1588 1464 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI), 1); 1589 SphericalPointDistribution::Polygon_t newpolygon=1465 SphericalPointDistribution::Polygon_t expected = 1590 1466 SPD.get<8>(); 1591 SphericalPointDistribution::Polygon_t expected = newpolygon;1592 1467 expected.pop_front(); // remove first point 1593 1468 expected.pop_front(); // remove second point … … 1596 1471 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 1597 1472 SphericalPointDistribution::Polygon_t remaining = 1598 SphericalPointDistribution::matchSphericalPointDistributions( 1599 polygon, 1600 newpolygon); 1473 SPD.getRemainingPoints(polygon, 8); 1601 1474 // the six remaining points sit on two planes that may have been rotated arbitrarily 1602 1475 // so we cannot simply check for equality between expected and remaining … … 1622 1495 polygon += std::make_pair( Vector(-1., 0.0, 0.0), 1); 1623 1496 polygon += std::make_pair( Vector(-1./3.0, 2.0*M_SQRT2/3.0, 0.0), 1); 1624 SphericalPointDistribution::Polygon_t newpolygon=1497 SphericalPointDistribution::Polygon_t expected = 1625 1498 SPD.get<8>(); 1626 SphericalPointDistribution::Polygon_t expected = newpolygon;1627 1499 expected.pop_front(); // remove first point 1628 1500 expected.pop_front(); // remove second point 1629 1501 expected.pop_front(); // remove third point 1630 1502 SphericalPointDistribution::Polygon_t remaining = 1631 SphericalPointDistribution::matchSphericalPointDistributions( 1632 polygon, 1633 newpolygon); 1503 SPD.getRemainingPoints(polygon, 8); 1634 1504 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1635 1505 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1647 1517 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI), 1); 1648 1518 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1./3.0, 2.0*M_SQRT2/3.0, 0.0), 47.6/180*M_PI), 1); 1649 SphericalPointDistribution::Polygon_t newpolygon=1519 SphericalPointDistribution::Polygon_t expected = 1650 1520 SPD.get<8>(); 1651 SphericalPointDistribution::Polygon_t expected = newpolygon;1652 1521 expected.pop_front(); // remove first point 1653 1522 expected.pop_front(); // remove second point … … 1657 1526 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 1658 1527 SphericalPointDistribution::Polygon_t remaining = 1659 SphericalPointDistribution::matchSphericalPointDistributions( 1660 polygon, 1661 newpolygon); 1662 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1663 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 1664 // also slightly perturbed 1665 const double amplitude = 0.05; 1666 perturbPolygon(polygon, amplitude); 1667 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) ); 1668 } 1669 } 1528 SPD.getRemainingPoints(polygon, 8); 1529 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1530 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 1531 // also slightly perturbed 1532 const double amplitude = 0.05; 1533 perturbPolygon(polygon, amplitude); 1534 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) ); 1535 } 1536 } -
src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.hpp
ra52369 r9cf90e 61 61 CPPUNIT_TEST ( getConnectionTest<12> ); 62 62 CPPUNIT_TEST ( getConnectionTest<14> ); 63 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_2 );64 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_3 );65 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_4 );66 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_5 );67 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_6 );68 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_7 );69 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_8 );70 // CPPUNIT_TEST ( matchSphericalPointDistributionsTest_multiple );63 CPPUNIT_TEST ( getRemainingPointsTest_2 ); 64 CPPUNIT_TEST ( getRemainingPointsTest_3 ); 65 CPPUNIT_TEST ( getRemainingPointsTest_4 ); 66 CPPUNIT_TEST ( getRemainingPointsTest_5 ); 67 CPPUNIT_TEST ( getRemainingPointsTest_6 ); 68 CPPUNIT_TEST ( getRemainingPointsTest_7 ); 69 CPPUNIT_TEST ( getRemainingPointsTest_8 ); 70 CPPUNIT_TEST ( getRemainingPointsTest_multiple ); 71 71 CPPUNIT_TEST_SUITE_END(); 72 72 … … 77 77 void areEqualToWithinBoundsTest(); 78 78 void joinPointsTest(); 79 void matchSphericalPointDistributionsTest_2();80 void matchSphericalPointDistributionsTest_3();81 void matchSphericalPointDistributionsTest_4();82 void matchSphericalPointDistributionsTest_5();83 void matchSphericalPointDistributionsTest_6();84 void matchSphericalPointDistributionsTest_7();85 void matchSphericalPointDistributionsTest_8();86 void matchSphericalPointDistributionsTest_multiple();79 void getRemainingPointsTest_2(); 80 void getRemainingPointsTest_3(); 81 void getRemainingPointsTest_4(); 82 void getRemainingPointsTest_5(); 83 void getRemainingPointsTest_6(); 84 void getRemainingPointsTest_7(); 85 void getRemainingPointsTest_8(); 86 void getRemainingPointsTest_multiple(); 87 87 88 88 private:
Note:
See TracChangeset
for help on using the changeset viewer.
