Changeset fe90ab for src/Fragmentation
- Timestamp:
- Sep 14, 2016, 7:02:33 AM (8 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, GeometryObjects, Gui_displays_atomic_force_velocity, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, Ubuntu_1604_changes, stable
- Children:
- 1af2ae
- Parents:
- 36bd59
- git-author:
- Frederik Heber <heber@…> (07/12/14 19:07:44)
- git-committer:
- Frederik Heber <heber@…> (09/14/16 07:02:33)
- Location:
- src/Fragmentation/Exporters
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Exporters/SphericalPointDistribution.cpp
r36bd59 rfe90ab 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; … … 781 812 } 782 813 814 void SphericalPointDistribution::initSelf(const int _NumberOfPoints) 815 { 816 switch (_NumberOfPoints) 817 { 818 case 0: 819 points = get<0>(); 820 adjacency = getConnections<0>(); 821 break; 822 case 1: 823 points = get<1>(); 824 adjacency = getConnections<1>(); 825 break; 826 case 2: 827 points = get<2>(); 828 adjacency = getConnections<2>(); 829 break; 830 case 3: 831 points = get<3>(); 832 adjacency = getConnections<3>(); 833 break; 834 case 4: 835 points = get<4>(); 836 adjacency = getConnections<4>(); 837 break; 838 case 5: 839 points = get<5>(); 840 adjacency = getConnections<5>(); 841 break; 842 case 6: 843 points = get<6>(); 844 adjacency = getConnections<6>(); 845 break; 846 case 7: 847 points = get<7>(); 848 adjacency = getConnections<7>(); 849 break; 850 case 8: 851 points = get<8>(); 852 adjacency = getConnections<8>(); 853 break; 854 case 9: 855 points = get<9>(); 856 adjacency = getConnections<9>(); 857 break; 858 case 10: 859 points = get<10>(); 860 adjacency = getConnections<10>(); 861 break; 862 case 11: 863 points = get<11>(); 864 adjacency = getConnections<11>(); 865 break; 866 case 12: 867 points = get<12>(); 868 adjacency = getConnections<12>(); 869 break; 870 case 14: 871 points = get<14>(); 872 adjacency = getConnections<14>(); 873 break; 874 default: 875 ASSERT(0, "SphericalPointDistribution::initSelf() - cannot deal with the case " 876 +toString(_NumberOfPoints)+"."); 877 } 878 LOG(3, "DEBUG: Ideal polygon is " << points); 879 } 783 880 784 881 SphericalPointDistribution::Polygon_t 785 SphericalPointDistribution::matchSphericalPointDistributions( 786 const SphericalPointDistribution::WeightedPolygon_t &_polygon, 787 SphericalPointDistribution::Polygon_t &_newpolygon 788 ) 882 SphericalPointDistribution::getRemainingPoints( 883 const WeightedPolygon_t &_polygon, 884 const int _N) 789 885 { 790 886 SphericalPointDistribution::Polygon_t remainingpoints; 791 887 888 // initialze to given number of points 889 initSelf(_N); 792 890 LOG(2, "INFO: Matching old polygon " << _polygon 793 << " with new polygon " << _newpolygon); 794 795 if (_polygon.size() == _newpolygon.size()) { 796 // same number of points desired as are present? Do nothing 797 LOG(2, "INFO: There are no vacant points to return."); 891 << " with new polygon " << points); 892 893 // check whether any points will remain vacant 894 int RemainingPoints = _N; 895 for (WeightedPolygon_t::const_iterator iter = _polygon.begin(); 896 iter != _polygon.end(); ++iter) 897 RemainingPoints -= iter->second; 898 if (RemainingPoints == 0) 798 899 return remainingpoints; 799 } 800 801 if (_polygon.size() > 0) { 802 IndexList_t bestmatching = findBestMatching(_polygon, _newpolygon); 900 901 if (_N > 0) { 902 IndexList_t bestmatching = findBestMatching(_polygon); 803 903 LOG(2, "INFO: Best matching is " << bestmatching); 804 904 … … 819 919 newSet.indices.resize(NumberIds, -1); 820 920 std::copy(beginiter, enditer, newSet.indices.begin()); 821 std::copy( _newpolygon.begin(),_newpolygon.end(), std::back_inserter(newSet.polygon));921 std::copy(points.begin(),points.end(), std::back_inserter(newSet.polygon)); 822 922 823 923 // determine rotation angles to align the two point distributions with … … 927 1027 return remainingpoints; 928 1028 } else 929 return _newpolygon;930 } 1029 return points; 1030 } -
src/Fragmentation/Exporters/SphericalPointDistribution.hpp
r36bd59 rfe90ab 74 74 } 75 75 76 /** Matches a given spherical distribution with another containing more77 * points.76 /** Returns vacant spots to fill to get a complete spherical point distribution from 77 * given points \a _polygon, containing then \a _N in total. 78 78 * 79 79 * This is a helper to determine points where to best insert saturation 80 80 * hydrogens. 81 81 * 82 * \param _polygon current occupied positions 83 * \param _newpolygon ideal distribution to match best with current occupied 84 * positions 85 * \return remaining vacant positions relative to \a _polygon 86 */ 87 static Polygon_t matchSphericalPointDistributions( 88 const WeightedPolygon_t &_polygon, 89 Polygon_t &_newpolygon 90 ); 82 * \param _polygon already filled places to match 83 * \param _N desired total number fo points 84 */ 85 Polygon_t getRemainingPoints(const WeightedPolygon_t &_polygon, const int _N); 91 86 92 87 //!> default radius of the spherical distribution … … 131 126 132 127 private: 128 //!> points for the ideal distribution 129 Polygon_t points; 130 //!> connection information between these ideal points 131 adjacency_t adjacency; 132 133 /** Initialize inner status (points and adjacency) to desired number of 134 * points. 135 * 136 * \param _N number of points 137 */ 138 void initSelf(const int _N); 139 140 private: 133 141 //!> grant unit tests access to private parts 134 142 friend class SphericalPointDistributionTest; … … 143 151 144 152 struct MatchingControlStructure { 153 MatchingControlStructure( 154 const adjacency_t &_adjacency, 155 const VectorArray_t &_oldpoints, 156 const VectorArray_t &_newpoints, 157 const WeightsArray_t &_weights 158 ); 145 159 bool foundflag; 146 160 double bestL2; 161 const adjacency_t &adjacency; 162 const VectorArray_t oldpoints; 163 const VectorArray_t newpoints; 164 const WeightsArray_t weights; 147 165 IndexTupleList_t bestmatching; 148 VectorArray_t oldpoints;149 VectorArray_t newpoints;150 WeightsArray_t weights;151 166 }; 152 167 … … 160 175 ); 161 176 162 static IndexList_t findBestMatching( 163 const WeightedPolygon_t &_polygon, 164 Polygon_t &_newpolygon 165 ); 177 IndexList_t findBestMatching(const WeightedPolygon_t &_polygon); 166 178 167 179 static IndexList_t joinPoints( -
src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.cpp
r36bd59 rfe90ab 736 736 } 737 737 738 /** UnitTest for matchSphericalPointDistributions() with two points739 */ 740 void SphericalPointDistributionTest:: matchSphericalPointDistributionsTest_2()738 /** UnitTest for getRemainingPoints() with two points 739 */ 740 void SphericalPointDistributionTest::getRemainingPointsTest_2() 741 741 { 742 742 SphericalPointDistribution SPD(1.); … … 745 745 SphericalPointDistribution::WeightedPolygon_t polygon; 746 746 polygon += std::make_pair(Vector(1.,0.,0.), 1); 747 SphericalPointDistribution::Polygon_t newpolygon =748 SPD.get<2>();749 747 SphericalPointDistribution::Polygon_t expected; 750 748 expected += Vector(-1.,0.,0.); 751 749 SphericalPointDistribution::Polygon_t remaining = 752 SphericalPointDistribution::matchSphericalPointDistributions( 753 polygon, 754 newpolygon); 750 SPD.getRemainingPoints(polygon, 2); 755 751 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 756 752 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 761 757 SphericalPointDistribution::WeightedPolygon_t polygon; 762 758 polygon += std::make_pair( Vector(0.,1.,0.), 1); 763 SphericalPointDistribution::Polygon_t newpolygon =764 SPD.get<2>();765 759 SphericalPointDistribution::Polygon_t expected; 766 760 expected += Vector(0.,-1.,0.); 767 761 SphericalPointDistribution::Polygon_t remaining = 768 SphericalPointDistribution::matchSphericalPointDistributions( 769 polygon, 770 newpolygon); 762 SPD.getRemainingPoints(polygon, 2); 771 763 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 772 764 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 777 769 SphericalPointDistribution::WeightedPolygon_t polygon; 778 770 polygon += std::make_pair( Vector(0.,0.,-1.), 1); 779 SphericalPointDistribution::Polygon_t newpolygon =780 SPD.get<2>();781 771 SphericalPointDistribution::Polygon_t expected; 782 772 expected += Vector(0.,0.,1.); 783 773 SphericalPointDistribution::Polygon_t remaining = 784 SphericalPointDistribution::matchSphericalPointDistributions( 785 polygon, 786 newpolygon); 774 SPD.getRemainingPoints(polygon, 2); 787 775 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 788 776 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 794 782 SphericalPointDistribution::WeightedPolygon_t polygon; 795 783 polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1); 796 SphericalPointDistribution::Polygon_t newpolygon =797 SPD.get<2>();798 784 SphericalPointDistribution::Polygon_t expected; 799 785 expected += RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI); 800 786 SphericalPointDistribution::Polygon_t remaining = 801 SphericalPointDistribution::matchSphericalPointDistributions( 802 polygon, 803 newpolygon); 804 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 805 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 806 } 807 } 808 809 /** UnitTest for matchSphericalPointDistributions() with three points 810 */ 811 void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_3() 787 SPD.getRemainingPoints(polygon, 2); 788 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 789 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 790 } 791 } 792 793 /** UnitTest for getRemainingPoints() with three points 794 */ 795 void SphericalPointDistributionTest::getRemainingPointsTest_3() 812 796 { 813 797 SphericalPointDistribution SPD(1.); … … 817 801 SphericalPointDistribution::WeightedPolygon_t polygon; 818 802 polygon += std::make_pair( Vector(1.,0.,0.), 1); 819 SphericalPointDistribution::Polygon_t newpolygon=803 SphericalPointDistribution::Polygon_t expected = 820 804 SPD.get<3>(); 821 SphericalPointDistribution::Polygon_t expected = newpolygon; 822 expected.pop_front(); // remove first point 823 SphericalPointDistribution::Polygon_t remaining = 824 SphericalPointDistribution::matchSphericalPointDistributions( 825 polygon, 826 newpolygon); 805 expected.pop_front(); // remove first point 806 SphericalPointDistribution::Polygon_t remaining = 807 SPD.getRemainingPoints(polygon, 3); 827 808 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 828 809 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 833 814 SphericalPointDistribution::WeightedPolygon_t polygon; 834 815 polygon += std::make_pair( Vector(0.,1.,0.), 1); 835 SphericalPointDistribution::Polygon_t newpolygon=816 SphericalPointDistribution::Polygon_t expected = 836 817 SPD.get<3>(); 837 SphericalPointDistribution::Polygon_t expected = newpolygon;838 818 expected.pop_front(); // remove first point 839 819 for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin(); … … 843 823 } 844 824 SphericalPointDistribution::Polygon_t remaining = 845 SphericalPointDistribution::matchSphericalPointDistributions( 846 polygon, 847 newpolygon); 825 SPD.getRemainingPoints(polygon, 3); 848 826 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 849 827 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 855 833 polygon += std::make_pair( Vector(1.,0.,0.), 1); 856 834 polygon += std::make_pair( Vector(-0.5, sqrt(3)*0.5,0.), 1); 857 SphericalPointDistribution::Polygon_t newpolygon=835 SphericalPointDistribution::Polygon_t expected = 858 836 SPD.get<3>(); 859 SphericalPointDistribution::Polygon_t expected = newpolygon; 860 expected.pop_front(); // remove first point 861 expected.pop_front(); // remove second point 862 SphericalPointDistribution::Polygon_t remaining = 863 SphericalPointDistribution::matchSphericalPointDistributions( 864 polygon, 865 newpolygon); 837 expected.pop_front(); // remove first point 838 expected.pop_front(); // remove second point 839 SphericalPointDistribution::Polygon_t remaining = 840 SPD.getRemainingPoints(polygon, 3); 866 841 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 867 842 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 878 853 polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1); 879 854 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-0.5, sqrt(3)*0.5,0.), 47.6/180*M_PI), 1); 880 SphericalPointDistribution::Polygon_t newpolygon=855 SphericalPointDistribution::Polygon_t expected = 881 856 SPD.get<3>(); 882 SphericalPointDistribution::Polygon_t expected = newpolygon;883 857 expected.pop_front(); // remove first point 884 858 expected.pop_front(); // remove second point … … 887 861 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 888 862 SphericalPointDistribution::Polygon_t remaining = 889 SphericalPointDistribution::matchSphericalPointDistributions( 890 polygon, 891 newpolygon); 863 SPD.getRemainingPoints(polygon, 3); 892 864 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 893 865 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 908 880 SphericalPointDistribution::Polygon_t expected; // empty cause none are vacant 909 881 SphericalPointDistribution::Polygon_t remaining = 910 SphericalPointDistribution::matchSphericalPointDistributions( 911 polygon, 912 newpolygon); 882 SPD.getRemainingPoints(polygon, 3); 913 883 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 914 884 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 931 901 SphericalPointDistribution::Polygon_t expected; // empty cause none are vacant 932 902 SphericalPointDistribution::Polygon_t remaining = 933 SphericalPointDistribution::matchSphericalPointDistributions( 934 polygon, 935 newpolygon); 936 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 937 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 938 // also slightly perturbed 939 const double amplitude = 0.05; 940 perturbPolygon(polygon, amplitude); 941 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) ); 942 } 943 } 944 945 /** UnitTest for matchSphericalPointDistributions() with four points 946 */ 947 void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_4() 903 SPD.getRemainingPoints(polygon, 3); 904 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 905 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 906 // also slightly perturbed 907 const double amplitude = 0.05; 908 perturbPolygon(polygon, amplitude); 909 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) ); 910 } 911 } 912 913 /** UnitTest for getRemainingPoints() with four points 914 */ 915 void SphericalPointDistributionTest::getRemainingPointsTest_4() 948 916 { 949 917 SphericalPointDistribution SPD(1.); … … 953 921 SphericalPointDistribution::WeightedPolygon_t polygon; 954 922 polygon += std::make_pair( Vector(1.,0.,0.), 1); 955 SphericalPointDistribution::Polygon_t newpolygon=923 SphericalPointDistribution::Polygon_t expected = 956 924 SPD.get<4>(); 957 SphericalPointDistribution::Polygon_t expected = newpolygon; 958 expected.pop_front(); // remove first point 959 SphericalPointDistribution::Polygon_t remaining = 960 SphericalPointDistribution::matchSphericalPointDistributions( 961 polygon, 962 newpolygon); 925 expected.pop_front(); // remove first point 926 SphericalPointDistribution::Polygon_t remaining = 927 SPD.getRemainingPoints(polygon, 4); 963 928 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 964 929 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 969 934 SphericalPointDistribution::WeightedPolygon_t polygon; 970 935 polygon += std::make_pair( Vector(0.,1.,0.), 1); 971 SphericalPointDistribution::Polygon_t newpolygon=936 SphericalPointDistribution::Polygon_t expected = 972 937 SPD.get<4>(); 973 SphericalPointDistribution::Polygon_t expected = newpolygon;974 938 expected.pop_front(); // remove first point 975 939 for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin(); … … 979 943 } 980 944 SphericalPointDistribution::Polygon_t remaining = 981 SphericalPointDistribution::matchSphericalPointDistributions( 982 polygon, 983 newpolygon); 945 SPD.getRemainingPoints(polygon, 4); 984 946 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 985 947 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 991 953 polygon += std::make_pair( Vector(1.,0.,0.), 1); 992 954 polygon += std::make_pair( Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 1); 993 SphericalPointDistribution::Polygon_t newpolygon=955 SphericalPointDistribution::Polygon_t expected = 994 956 SPD.get<4>(); 995 SphericalPointDistribution::Polygon_t expected = newpolygon; 996 expected.pop_front(); // remove first point 997 expected.pop_front(); // remove second point 998 SphericalPointDistribution::Polygon_t remaining = 999 SphericalPointDistribution::matchSphericalPointDistributions( 1000 polygon, 1001 newpolygon); 957 expected.pop_front(); // remove first point 958 expected.pop_front(); // remove second point 959 SphericalPointDistribution::Polygon_t remaining = 960 SPD.getRemainingPoints(polygon, 4); 1002 961 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1003 962 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1013 972 polygon += std::make_pair( Vector(1.,0.,0.), 1); 1014 973 polygon += std::make_pair( Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 1); 1015 SphericalPointDistribution::Polygon_t newpolygon=974 SphericalPointDistribution::Polygon_t expected = 1016 975 SPD.get<4>(); 1017 SphericalPointDistribution::Polygon_t expected = newpolygon; 1018 expected.pop_front(); // remove first point 1019 expected.pop_front(); // remove second point 1020 SphericalPointDistribution::Polygon_t remaining = 1021 SphericalPointDistribution::matchSphericalPointDistributions( 1022 polygon, 1023 newpolygon); 976 expected.pop_front(); // remove first point 977 expected.pop_front(); // remove second point 978 SphericalPointDistribution::Polygon_t remaining = 979 SPD.getRemainingPoints(polygon, 4); 1024 980 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1025 981 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1036 992 polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1); 1037 993 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 47.6/180*M_PI), 1); 1038 SphericalPointDistribution::Polygon_t newpolygon=994 SphericalPointDistribution::Polygon_t expected = 1039 995 SPD.get<4>(); 1040 SphericalPointDistribution::Polygon_t expected = newpolygon;1041 996 expected.pop_front(); // remove first point 1042 997 expected.pop_front(); // remove second point … … 1045 1000 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 1046 1001 SphericalPointDistribution::Polygon_t remaining = 1047 SphericalPointDistribution::matchSphericalPointDistributions( 1048 polygon, 1049 newpolygon); 1002 SPD.getRemainingPoints(polygon, 4); 1050 1003 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1051 1004 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1062 1015 polygon += std::make_pair( Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 1); 1063 1016 polygon += std::make_pair( Vector(-1./3.0, -M_SQRT2/3.0, M_SQRT2/sqrt(3)), 1); 1064 SphericalPointDistribution::Polygon_t newpolygon=1017 SphericalPointDistribution::Polygon_t expected = 1065 1018 SPD.get<4>(); 1066 SphericalPointDistribution::Polygon_t expected = newpolygon;1067 1019 expected.pop_front(); // remove first point 1068 1020 expected.pop_front(); // remove second point 1069 1021 expected.pop_front(); // remove third point 1070 1022 SphericalPointDistribution::Polygon_t remaining = 1071 SphericalPointDistribution::matchSphericalPointDistributions( 1072 polygon, 1073 newpolygon); 1023 SPD.getRemainingPoints(polygon, 4); 1074 1024 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1075 1025 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1087 1037 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 47.6/180*M_PI), 1); 1088 1038 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1./3.0, -M_SQRT2/3.0, M_SQRT2/sqrt(3)), 47.6/180*M_PI), 1); 1089 SphericalPointDistribution::Polygon_t newpolygon=1039 SphericalPointDistribution::Polygon_t expected = 1090 1040 SPD.get<4>(); 1091 SphericalPointDistribution::Polygon_t expected = newpolygon;1092 1041 expected.pop_front(); // remove first point 1093 1042 expected.pop_front(); // remove second point … … 1097 1046 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 1098 1047 SphericalPointDistribution::Polygon_t remaining = 1099 SphericalPointDistribution::matchSphericalPointDistributions( 1100 polygon, 1101 newpolygon); 1102 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1103 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 1104 // also slightly perturbed 1105 const double amplitude = 0.05; 1106 perturbPolygon(polygon, amplitude); 1107 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) ); 1108 } 1109 } 1110 1111 /** UnitTest for matchSphericalPointDistributions() with four points and weights 1048 SPD.getRemainingPoints(polygon, 4); 1049 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1050 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 1051 // also slightly perturbed 1052 const double amplitude = 0.05; 1053 perturbPolygon(polygon, amplitude); 1054 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) ); 1055 } 1056 } 1057 1058 /** UnitTest for getRemainingPoints() with four points and weights 1112 1059 * not all equal to one. 1113 1060 */ 1114 void SphericalPointDistributionTest:: matchSphericalPointDistributionsTest_multiple()1061 void SphericalPointDistributionTest::getRemainingPointsTest_multiple() 1115 1062 { 1116 1063 SphericalPointDistribution SPD(1.); … … 1126 1073 expected += Vector(-0.5773502691896,-5.551115123126e-17,-0.8164965809277); 1127 1074 SphericalPointDistribution::Polygon_t remaining = 1128 SphericalPointDistribution::matchSphericalPointDistributions( 1129 polygon, 1130 newpolygon); 1075 SPD.getRemainingPoints(polygon, 4); 1131 1076 // std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl; 1132 1077 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); … … 1145 1090 expected += Vector(-0.3535533905933,-0.3535533905933,-0.8660254037844); 1146 1091 SphericalPointDistribution::Polygon_t remaining = 1147 SphericalPointDistribution::matchSphericalPointDistributions( 1148 polygon, 1149 newpolygon); 1150 // std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl; 1092 SPD.getRemainingPoints(polygon, 5); 1093 std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl; 1151 1094 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1152 1095 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1165 1108 expected += Vector(0.3535534025157,-0.3535533856548,0.8660254009332); 1166 1109 SphericalPointDistribution::Polygon_t remaining = 1167 SphericalPointDistribution::matchSphericalPointDistributions( 1168 polygon, 1169 newpolygon); 1110 SPD.getRemainingPoints(polygon, 5); 1170 1111 // std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl; 1171 1112 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); … … 1181 1122 SPD.get<6>(); 1182 1123 SphericalPointDistribution::Polygon_t expected; 1124 expected += Vector(0.,0.,1.); 1183 1125 expected += Vector(0.,0.,-1.); 1184 expected += Vector(0.,0.,1.); 1185 SphericalPointDistribution::Polygon_t remaining = 1186 SphericalPointDistribution::matchSphericalPointDistributions( 1187 polygon, 1188 newpolygon); 1126 SphericalPointDistribution::Polygon_t remaining = 1127 SPD.getRemainingPoints(polygon, 6); 1189 1128 // std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl; 1190 1129 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); … … 1193 1132 } 1194 1133 1195 /** UnitTest for matchSphericalPointDistributions() with five points1196 */ 1197 void SphericalPointDistributionTest:: matchSphericalPointDistributionsTest_5()1134 /** UnitTest for getRemainingPoints() with five points 1135 */ 1136 void SphericalPointDistributionTest::getRemainingPointsTest_5() 1198 1137 { 1199 1138 SphericalPointDistribution SPD(1.); … … 1203 1142 SphericalPointDistribution::WeightedPolygon_t polygon; 1204 1143 polygon += std::make_pair( Vector(1.,0.,0.), 1); 1205 SphericalPointDistribution::Polygon_t newpolygon=1144 SphericalPointDistribution::Polygon_t expected = 1206 1145 SPD.get<5>(); 1207 SphericalPointDistribution::Polygon_t expected = newpolygon; 1208 expected.pop_front(); // remove first point 1209 SphericalPointDistribution::Polygon_t remaining = 1210 SphericalPointDistribution::matchSphericalPointDistributions( 1211 polygon, 1212 newpolygon); 1146 expected.pop_front(); // remove first point 1147 SphericalPointDistribution::Polygon_t remaining = 1148 SPD.getRemainingPoints(polygon, 5); 1213 1149 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1214 1150 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1219 1155 SphericalPointDistribution::WeightedPolygon_t polygon; 1220 1156 polygon += std::make_pair( Vector(0.,1.,0.), 1); 1221 SphericalPointDistribution::Polygon_t newpolygon=1157 SphericalPointDistribution::Polygon_t expected = 1222 1158 SPD.get<5>(); 1223 SphericalPointDistribution::Polygon_t expected = newpolygon;1224 1159 expected.pop_front(); // remove first point 1225 1160 for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin(); … … 1229 1164 } 1230 1165 SphericalPointDistribution::Polygon_t remaining = 1231 SphericalPointDistribution::matchSphericalPointDistributions( 1232 polygon, 1233 newpolygon); 1166 SPD.getRemainingPoints(polygon, 5); 1234 1167 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1235 1168 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1241 1174 polygon += std::make_pair( Vector(1.,0.,0.), 1); 1242 1175 polygon += std::make_pair( Vector(-1.,0.,0.), 1); 1243 SphericalPointDistribution::Polygon_t newpolygon=1176 SphericalPointDistribution::Polygon_t expected = 1244 1177 SPD.get<5>(); 1245 SphericalPointDistribution::Polygon_t expected = newpolygon; 1246 expected.pop_front(); // remove first point 1247 expected.pop_front(); // remove second point 1248 SphericalPointDistribution::Polygon_t remaining = 1249 SphericalPointDistribution::matchSphericalPointDistributions( 1250 polygon, 1251 newpolygon); 1178 expected.pop_front(); // remove first point 1179 expected.pop_front(); // remove second point 1180 SphericalPointDistribution::Polygon_t remaining = 1181 SPD.getRemainingPoints(polygon, 5); 1252 1182 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1253 1183 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1264 1194 polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180.*M_PI), 1); 1265 1195 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180.*M_PI), 1); 1266 SphericalPointDistribution::Polygon_t newpolygon=1196 SphericalPointDistribution::Polygon_t expected = 1267 1197 SPD.get<5>(); 1268 SphericalPointDistribution::Polygon_t expected = newpolygon;1269 1198 expected.pop_front(); // remove first point 1270 1199 expected.pop_front(); // remove second point … … 1273 1202 *iter = RotationAxis.rotateVector(*iter, 47.6/180.*M_PI); 1274 1203 SphericalPointDistribution::Polygon_t remaining = 1275 SphericalPointDistribution::matchSphericalPointDistributions( 1276 polygon, 1277 newpolygon); 1204 SPD.getRemainingPoints(polygon, 5); 1278 1205 // the three remaining points sit on a plane that may be rotated arbitrarily 1279 1206 // so we cannot simply check for equality between expected and remaining … … 1295 1222 polygon += std::make_pair( Vector(-1., 0.0, 0.0), 1); 1296 1223 polygon += std::make_pair( Vector(0.0, 1., 0.0), 1); 1297 SphericalPointDistribution::Polygon_t newpolygon=1224 SphericalPointDistribution::Polygon_t expected = 1298 1225 SPD.get<5>(); 1299 SphericalPointDistribution::Polygon_t expected = newpolygon;1300 1226 expected.pop_front(); // remove first point 1301 1227 expected.pop_front(); // remove second point 1302 1228 expected.pop_front(); // remove third point 1303 1229 SphericalPointDistribution::Polygon_t remaining = 1304 SphericalPointDistribution::matchSphericalPointDistributions( 1305 polygon, 1306 newpolygon); 1230 SPD.getRemainingPoints(polygon, 5); 1307 1231 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1308 1232 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1320 1244 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI), 1); 1321 1245 polygon += std::make_pair(RotationAxis.rotateVector(Vector(0.0, 1., 0.0), 47.6/180*M_PI), 1); 1322 SphericalPointDistribution::Polygon_t newpolygon=1246 SphericalPointDistribution::Polygon_t expected = 1323 1247 SPD.get<5>(); 1324 SphericalPointDistribution::Polygon_t expected = newpolygon;1325 1248 expected.pop_front(); // remove first point 1326 1249 expected.pop_front(); // remove second point … … 1330 1253 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 1331 1254 SphericalPointDistribution::Polygon_t remaining = 1332 SphericalPointDistribution::matchSphericalPointDistributions( 1333 polygon, 1334 newpolygon); 1335 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1336 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 1337 // also slightly perturbed 1338 const double amplitude = 0.05; 1339 perturbPolygon(polygon, amplitude); 1340 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) ); 1341 } 1342 } 1343 1344 /** UnitTest for matchSphericalPointDistributions() with six points 1345 */ 1346 void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_6() 1255 SPD.getRemainingPoints(polygon, 5); 1256 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1257 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 1258 // also slightly perturbed 1259 const double amplitude = 0.05; 1260 perturbPolygon(polygon, amplitude); 1261 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) ); 1262 } 1263 } 1264 1265 /** UnitTest for getRemainingPoints() with six points 1266 */ 1267 void SphericalPointDistributionTest::getRemainingPointsTest_6() 1347 1268 { 1348 1269 SphericalPointDistribution SPD(1.); … … 1352 1273 SphericalPointDistribution::WeightedPolygon_t polygon; 1353 1274 polygon += std::make_pair( Vector(1.,0.,0.), 1); 1354 SphericalPointDistribution::Polygon_t newpolygon=1275 SphericalPointDistribution::Polygon_t expected = 1355 1276 SPD.get<6>(); 1356 SphericalPointDistribution::Polygon_t expected = newpolygon; 1357 expected.pop_front(); // remove first point 1358 SphericalPointDistribution::Polygon_t remaining = 1359 SphericalPointDistribution::matchSphericalPointDistributions( 1360 polygon, 1361 newpolygon); 1277 expected.pop_front(); // remove first point 1278 SphericalPointDistribution::Polygon_t remaining = 1279 SPD.getRemainingPoints(polygon, 6); 1362 1280 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1363 1281 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1368 1286 SphericalPointDistribution::WeightedPolygon_t polygon; 1369 1287 polygon += std::make_pair( Vector(0.,1.,0.), 1); 1370 SphericalPointDistribution::Polygon_t newpolygon=1288 SphericalPointDistribution::Polygon_t expected = 1371 1289 SPD.get<6>(); 1372 SphericalPointDistribution::Polygon_t expected = newpolygon;1373 1290 expected.pop_front(); // remove first point 1374 1291 for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin(); … … 1378 1295 } 1379 1296 SphericalPointDistribution::Polygon_t remaining = 1380 SphericalPointDistribution::matchSphericalPointDistributions( 1381 polygon, 1382 newpolygon); 1297 SPD.getRemainingPoints(polygon, 6); 1383 1298 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1384 1299 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1390 1305 polygon += std::make_pair( Vector(1.,0.,0.), 1); 1391 1306 polygon += std::make_pair( Vector(-1.,0.,0.), 1); 1392 SphericalPointDistribution::Polygon_t newpolygon=1307 SphericalPointDistribution::Polygon_t expected = 1393 1308 SPD.get<6>(); 1394 SphericalPointDistribution::Polygon_t expected = newpolygon;1395 1309 expected.pop_front(); // remove first point 1396 1310 expected.pop_front(); // remove second spoint 1397 1311 SphericalPointDistribution::Polygon_t remaining = 1398 SphericalPointDistribution::matchSphericalPointDistributions( 1399 polygon, 1400 newpolygon); 1312 SPD.getRemainingPoints(polygon, 6); 1401 1313 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1402 1314 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1413 1325 polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1); 1414 1326 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI), 1); 1415 SphericalPointDistribution::Polygon_t newpolygon=1327 SphericalPointDistribution::Polygon_t expected = 1416 1328 SPD.get<6>(); 1417 SphericalPointDistribution::Polygon_t expected = newpolygon;1418 1329 expected.pop_front(); // remove first point 1419 1330 expected.pop_front(); // remove second spoint … … 1422 1333 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 1423 1334 SphericalPointDistribution::Polygon_t remaining = 1424 SphericalPointDistribution::matchSphericalPointDistributions( 1425 polygon, 1426 newpolygon); 1335 SPD.getRemainingPoints(polygon, 6); 1427 1336 // the four remaining points sit on a plane that may have been rotated arbitrarily 1428 1337 // so we cannot simply check for equality between expected and remaining … … 1444 1353 polygon += std::make_pair( Vector(-1., 0.0, 0.0), 1); 1445 1354 polygon += std::make_pair( Vector(0.0, 1., 0.0), 1); 1446 SphericalPointDistribution::Polygon_t newpolygon=1355 SphericalPointDistribution::Polygon_t expected = 1447 1356 SPD.get<6>(); 1448 SphericalPointDistribution::Polygon_t expected = newpolygon;1449 1357 expected.pop_front(); // remove first point 1450 1358 expected.pop_front(); // remove second point 1451 1359 expected.pop_front(); // remove third point 1452 1360 SphericalPointDistribution::Polygon_t remaining = 1453 SphericalPointDistribution::matchSphericalPointDistributions( 1454 polygon, 1455 newpolygon); 1361 SPD.getRemainingPoints(polygon, 6); 1456 1362 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1457 1363 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1469 1375 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI), 1); 1470 1376 polygon += std::make_pair(RotationAxis.rotateVector(Vector(0.0, 1., 0.0), 47.6/180*M_PI), 1); 1471 SphericalPointDistribution::Polygon_t newpolygon=1377 SphericalPointDistribution::Polygon_t expected = 1472 1378 SPD.get<6>(); 1473 SphericalPointDistribution::Polygon_t expected = newpolygon;1474 1379 expected.pop_front(); // remove first point 1475 1380 expected.pop_front(); // remove second point … … 1479 1384 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 1480 1385 SphericalPointDistribution::Polygon_t remaining = 1481 SphericalPointDistribution::matchSphericalPointDistributions( 1482 polygon, 1483 newpolygon); 1484 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1485 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 1486 // also slightly perturbed 1487 const double amplitude = 0.05; 1488 perturbPolygon(polygon, amplitude); 1489 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) ); 1490 } 1491 } 1492 1493 /** UnitTest for matchSphericalPointDistributions() with seven points 1494 */ 1495 void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_7() 1386 SPD.getRemainingPoints(polygon, 6); 1387 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1388 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 1389 // also slightly perturbed 1390 const double amplitude = 0.05; 1391 perturbPolygon(polygon, amplitude); 1392 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) ); 1393 } 1394 } 1395 1396 /** UnitTest for getRemainingPoints() with seven points 1397 */ 1398 void SphericalPointDistributionTest::getRemainingPointsTest_7() 1496 1399 { 1497 1400 SphericalPointDistribution SPD(1.); … … 1501 1404 SphericalPointDistribution::WeightedPolygon_t polygon; 1502 1405 polygon += std::make_pair( Vector(1.,0.,0.), 1); 1503 SphericalPointDistribution::Polygon_t newpolygon=1406 SphericalPointDistribution::Polygon_t expected = 1504 1407 SPD.get<7>(); 1505 SphericalPointDistribution::Polygon_t expected = newpolygon; 1506 expected.pop_front(); // remove first point 1507 SphericalPointDistribution::Polygon_t remaining = 1508 SphericalPointDistribution::matchSphericalPointDistributions( 1509 polygon, 1510 newpolygon); 1408 expected.pop_front(); // remove first point 1409 SphericalPointDistribution::Polygon_t remaining = 1410 SPD.getRemainingPoints(polygon, 7); 1511 1411 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1512 1412 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1517 1417 SphericalPointDistribution::WeightedPolygon_t polygon; 1518 1418 polygon += std::make_pair( Vector(0.,1.,0.), 1); 1519 SphericalPointDistribution::Polygon_t newpolygon=1419 SphericalPointDistribution::Polygon_t expected = 1520 1420 SPD.get<7>(); 1521 SphericalPointDistribution::Polygon_t expected = newpolygon;1522 1421 expected.pop_front(); // remove first point 1523 1422 for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin(); … … 1527 1426 } 1528 1427 SphericalPointDistribution::Polygon_t remaining = 1529 SphericalPointDistribution::matchSphericalPointDistributions( 1530 polygon, 1531 newpolygon); 1428 SPD.getRemainingPoints(polygon, 7); 1532 1429 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1533 1430 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1539 1436 polygon += std::make_pair( Vector(1.,0.,0.), 1); 1540 1437 polygon += std::make_pair( Vector(-1.,0.,0.), 1); 1541 SphericalPointDistribution::Polygon_t newpolygon=1438 SphericalPointDistribution::Polygon_t expected = 1542 1439 SPD.get<7>(); 1543 SphericalPointDistribution::Polygon_t expected = newpolygon; 1544 expected.pop_front(); // remove first point 1545 expected.pop_front(); // remove second point 1546 SphericalPointDistribution::Polygon_t remaining = 1547 SphericalPointDistribution::matchSphericalPointDistributions( 1548 polygon, 1549 newpolygon); 1440 expected.pop_front(); // remove first point 1441 expected.pop_front(); // remove second point 1442 SphericalPointDistribution::Polygon_t remaining = 1443 SPD.getRemainingPoints(polygon, 7); 1550 1444 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1551 1445 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1562 1456 polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1); 1563 1457 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI), 1); 1564 SphericalPointDistribution::Polygon_t newpolygon=1458 SphericalPointDistribution::Polygon_t expected = 1565 1459 SPD.get<7>(); 1566 SphericalPointDistribution::Polygon_t expected = newpolygon;1567 1460 expected.pop_front(); // remove first point 1568 1461 expected.pop_front(); // remove second point … … 1571 1464 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 1572 1465 SphericalPointDistribution::Polygon_t remaining = 1573 SphericalPointDistribution::matchSphericalPointDistributions( 1574 polygon, 1575 newpolygon); 1466 SPD.getRemainingPoints(polygon, 7); 1576 1467 // the five remaining points sit on a plane that may have been rotated arbitrarily 1577 1468 // so we cannot simply check for equality between expected and remaining … … 1593 1484 polygon += std::make_pair( Vector(-1., 0.0, 0.0), 1); 1594 1485 polygon += std::make_pair( Vector(0.0, 1., 0.0), 1); 1595 SphericalPointDistribution::Polygon_t newpolygon=1486 SphericalPointDistribution::Polygon_t expected = 1596 1487 SPD.get<7>(); 1597 SphericalPointDistribution::Polygon_t expected = newpolygon;1598 1488 expected.pop_front(); // remove first point 1599 1489 expected.pop_front(); // remove second point 1600 1490 expected.pop_front(); // remove third point 1601 1491 SphericalPointDistribution::Polygon_t remaining = 1602 SphericalPointDistribution::matchSphericalPointDistributions( 1603 polygon, 1604 newpolygon); 1492 SPD.getRemainingPoints(polygon, 7); 1605 1493 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1606 1494 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1618 1506 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI), 1); 1619 1507 polygon += std::make_pair(RotationAxis.rotateVector(Vector(0.0, 1., 0.0), 47.6/180*M_PI), 1); 1620 SphericalPointDistribution::Polygon_t newpolygon=1508 SphericalPointDistribution::Polygon_t expected = 1621 1509 SPD.get<7>(); 1622 SphericalPointDistribution::Polygon_t expected = newpolygon;1623 1510 expected.pop_front(); // remove first point 1624 1511 expected.pop_front(); // remove second point … … 1628 1515 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 1629 1516 SphericalPointDistribution::Polygon_t remaining = 1630 SphericalPointDistribution::matchSphericalPointDistributions( 1631 polygon, 1632 newpolygon); 1633 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1634 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 1635 // also slightly perturbed 1636 const double amplitude = 0.05; 1637 perturbPolygon(polygon, amplitude); 1638 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) ); 1639 } 1640 } 1641 1642 /** UnitTest for matchSphericalPointDistributions() with eight points 1643 */ 1644 void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_8() 1517 SPD.getRemainingPoints(polygon, 7); 1518 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1519 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 1520 // also slightly perturbed 1521 const double amplitude = 0.05; 1522 perturbPolygon(polygon, amplitude); 1523 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) ); 1524 } 1525 } 1526 1527 /** UnitTest for getRemainingPoints() with eight points 1528 */ 1529 void SphericalPointDistributionTest::getRemainingPointsTest_8() 1645 1530 { 1646 1531 SphericalPointDistribution SPD(1.); … … 1650 1535 SphericalPointDistribution::WeightedPolygon_t polygon; 1651 1536 polygon += std::make_pair( Vector(1.,0.,0.), 1); 1652 SphericalPointDistribution::Polygon_t newpolygon=1537 SphericalPointDistribution::Polygon_t expected = 1653 1538 SPD.get<8>(); 1654 SphericalPointDistribution::Polygon_t expected = newpolygon; 1655 expected.pop_front(); // remove first point 1656 SphericalPointDistribution::Polygon_t remaining = 1657 SphericalPointDistribution::matchSphericalPointDistributions( 1658 polygon, 1659 newpolygon); 1539 expected.pop_front(); // remove first point 1540 SphericalPointDistribution::Polygon_t remaining = 1541 SPD.getRemainingPoints(polygon, 8); 1660 1542 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1661 1543 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1666 1548 SphericalPointDistribution::WeightedPolygon_t polygon; 1667 1549 polygon += std::make_pair( Vector(0.,1.,0.), 1); 1668 SphericalPointDistribution::Polygon_t newpolygon=1550 SphericalPointDistribution::Polygon_t expected = 1669 1551 SPD.get<8>(); 1670 SphericalPointDistribution::Polygon_t expected = newpolygon;1671 1552 expected.pop_front(); // remove first point 1672 1553 for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin(); … … 1675 1556 (*iter)[0] *= -1.; 1676 1557 } 1677 SphericalPointDistribution::Polygon_t remaining = 1678 SphericalPointDistribution::matchSphericalPointDistributions( 1679 polygon, 1680 newpolygon); 1558 SphericalPointDistribution::Polygon_t remaining = 1559 SPD.getRemainingPoints(polygon, 8); 1681 1560 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1682 1561 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1688 1567 polygon += std::make_pair( Vector(1.,0.,0.), 1); 1689 1568 polygon += std::make_pair( Vector(-1.,0.,0.), 1); 1690 SphericalPointDistribution::Polygon_t newpolygon=1569 SphericalPointDistribution::Polygon_t expected = 1691 1570 SPD.get<8>(); 1692 SphericalPointDistribution::Polygon_t expected = newpolygon; 1693 expected.pop_front(); // remove first point 1694 expected.pop_front(); // remove second point 1695 SphericalPointDistribution::Polygon_t remaining = 1696 SphericalPointDistribution::matchSphericalPointDistributions( 1697 polygon, 1698 newpolygon); 1571 expected.pop_front(); // remove first point 1572 expected.pop_front(); // remove second point 1573 SphericalPointDistribution::Polygon_t remaining = 1574 SPD.getRemainingPoints(polygon, 8); 1699 1575 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1700 1576 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1711 1587 polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1); 1712 1588 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI), 1); 1713 SphericalPointDistribution::Polygon_t newpolygon=1589 SphericalPointDistribution::Polygon_t expected = 1714 1590 SPD.get<8>(); 1715 SphericalPointDistribution::Polygon_t expected = newpolygon;1716 1591 expected.pop_front(); // remove first point 1717 1592 expected.pop_front(); // remove second point … … 1720 1595 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 1721 1596 SphericalPointDistribution::Polygon_t remaining = 1722 SphericalPointDistribution::matchSphericalPointDistributions( 1723 polygon, 1724 newpolygon); 1597 SPD.getRemainingPoints(polygon, 8); 1725 1598 // the six remaining points sit on two planes that may have been rotated arbitrarily 1726 1599 // so we cannot simply check for equality between expected and remaining … … 1746 1619 polygon += std::make_pair( Vector(-1., 0.0, 0.0), 1); 1747 1620 polygon += std::make_pair( Vector(-1./3.0, 2.0*M_SQRT2/3.0, 0.0), 1); 1748 SphericalPointDistribution::Polygon_t newpolygon=1621 SphericalPointDistribution::Polygon_t expected = 1749 1622 SPD.get<8>(); 1750 SphericalPointDistribution::Polygon_t expected = newpolygon;1751 1623 expected.pop_front(); // remove first point 1752 1624 expected.pop_front(); // remove second point 1753 1625 expected.pop_front(); // remove third point 1754 1626 SphericalPointDistribution::Polygon_t remaining = 1755 SphericalPointDistribution::matchSphericalPointDistributions( 1756 polygon, 1757 newpolygon); 1627 SPD.getRemainingPoints(polygon, 8); 1758 1628 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1759 1629 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); … … 1771 1641 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI), 1); 1772 1642 polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1./3.0, 2.0*M_SQRT2/3.0, 0.0), 47.6/180*M_PI), 1); 1773 SphericalPointDistribution::Polygon_t newpolygon=1643 SphericalPointDistribution::Polygon_t expected = 1774 1644 SPD.get<8>(); 1775 SphericalPointDistribution::Polygon_t expected = newpolygon;1776 1645 expected.pop_front(); // remove first point 1777 1646 expected.pop_front(); // remove second point … … 1781 1650 *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI); 1782 1651 SphericalPointDistribution::Polygon_t remaining = 1783 SphericalPointDistribution::matchSphericalPointDistributions( 1784 polygon, 1785 newpolygon); 1786 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1787 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 1788 // also slightly perturbed 1789 const double amplitude = 0.05; 1790 perturbPolygon(polygon, amplitude); 1791 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) ); 1792 } 1793 } 1652 SPD.getRemainingPoints(polygon, 8); 1653 // CPPUNIT_ASSERT_EQUAL( expected, remaining ); 1654 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) ); 1655 // also slightly perturbed 1656 const double amplitude = 0.05; 1657 perturbPolygon(polygon, amplitude); 1658 CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) ); 1659 } 1660 } -
src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.hpp
r36bd59 rfe90ab 65 65 CPPUNIT_TEST ( getConnectionTest<12> ); 66 66 CPPUNIT_TEST ( getConnectionTest<14> ); 67 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_2 );68 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_3 );69 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_4 );70 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_5 );71 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_6 );72 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_7 );73 CPPUNIT_TEST ( matchSphericalPointDistributionsTest_8 );74 // CPPUNIT_TEST ( matchSphericalPointDistributionsTest_multiple );67 CPPUNIT_TEST ( getRemainingPointsTest_2 ); 68 CPPUNIT_TEST ( getRemainingPointsTest_3 ); 69 CPPUNIT_TEST ( getRemainingPointsTest_4 ); 70 CPPUNIT_TEST ( getRemainingPointsTest_5 ); 71 CPPUNIT_TEST ( getRemainingPointsTest_6 ); 72 CPPUNIT_TEST ( getRemainingPointsTest_7 ); 73 CPPUNIT_TEST ( getRemainingPointsTest_8 ); 74 CPPUNIT_TEST ( getRemainingPointsTest_multiple ); 75 75 CPPUNIT_TEST_SUITE_END(); 76 76 … … 81 81 void areEqualToWithinBoundsTest(); 82 82 void joinPointsTest(); 83 void matchSphericalPointDistributionsTest_2();84 void matchSphericalPointDistributionsTest_3();85 void matchSphericalPointDistributionsTest_4();86 void matchSphericalPointDistributionsTest_5();87 void matchSphericalPointDistributionsTest_6();88 void matchSphericalPointDistributionsTest_7();89 void matchSphericalPointDistributionsTest_8();90 void matchSphericalPointDistributionsTest_multiple();83 void getRemainingPointsTest_2(); 84 void getRemainingPointsTest_3(); 85 void getRemainingPointsTest_4(); 86 void getRemainingPointsTest_5(); 87 void getRemainingPointsTest_6(); 88 void getRemainingPointsTest_7(); 89 void getRemainingPointsTest_8(); 90 void getRemainingPointsTest_multiple(); 91 91 92 92 private:
Note:
See TracChangeset
for help on using the changeset viewer.