Changeset fe90ab for src/Fragmentation


Ignore:
Timestamp:
Sep 14, 2016, 7:02:33 AM (8 years ago)
Author:
Frederik Heber <heber@…>
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)
Message:

recurseMatching() now takes connections into account.

  • matchSphericalPointDistribution() replaced by getRemainingPoints() as that describes what it does. match...() sounds symmetrical which the function is no longer as connection is associated with former _newpolygon.
  • SphericalPointDistribution now has internal points and adjacency, initialized by initSelf().
  • findBestMatching() and getRemainingPoints() are no longer static functions.
  • all unit tests are working again, including the .._multiple() that tests for joint points due to bond degree greater than 1.
  • the huge case switch in SaturatedFragment::saturateAtom() now resides in initSelf().
Location:
src/Fragmentation/Exporters
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Exporters/SphericalPointDistribution.cpp

    r36bd59 rfe90ab  
    480480      for (IndexList_t::iterator iter = _indices.begin();
    481481          (iter != _indices.end()) && (!_MCS.foundflag);) {
     482
    482483        // check whether we can stay in the current bin or have to move on to next one
    483484        if (*_remainiter == 0) {
     
    490491          }
    491492        }
    492         // advance in matching to same position
     493
     494        // advance in matching to current bin to fill in
    493495        const size_t OldIndex = std::distance(_remainingweights.begin(), _remainiter);
    494496        while (_matching.size() <= OldIndex) { // add empty lists of new bin is opened
     
    498500        IndexTupleList_t::iterator filliniter = _matching.begin();
    499501        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
    500517        // add index to matching
    501518        filliniter->push_back(*iter);
     
    532549}
    533550
     551SphericalPointDistribution::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
    534565/** Finds combinatorially the best matching between points in \a _polygon
    535566 * and \a _newpolygon.
     
    551582 */
    552583SphericalPointDistribution::IndexList_t SphericalPointDistribution::findBestMatching(
    553     const WeightedPolygon_t &_polygon,
    554     Polygon_t &_newpolygon
     584    const WeightedPolygon_t &_polygon
    555585    )
    556586{
    557   MatchingControlStructure MCS;
    558   MCS.foundflag = false;
    559   MCS.bestL2 = std::numeric_limits<double>::max();
    560587  // transform lists into arrays
     588  VectorArray_t oldpoints;
     589  VectorArray_t newpoints;
     590  WeightsArray_t weights;
    561591  for (WeightedPolygon_t::const_iterator iter = _polygon.begin();
    562592      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);
    567598
    568599  // search for bestmatching combinatorially
    569600  {
    570601    // translate polygon into vector to enable index addressing
    571     IndexList_t indices(_newpolygon.size());
     602    IndexList_t indices(points.size());
    572603    std::generate(indices.begin(), indices.end(), UniqueNumber);
    573604    IndexTupleList_t matching;
     
    594625  // combine multiple points and create simple IndexList from IndexTupleList
    595626  const SphericalPointDistribution::IndexList_t IndexList =
    596       joinPoints(_newpolygon, MCS.newpoints, MCS.bestmatching);
     627      joinPoints(points, MCS.newpoints, MCS.bestmatching);
    597628
    598629  return IndexList;
     
    781812}
    782813
     814void 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}
    783880
    784881SphericalPointDistribution::Polygon_t
    785 SphericalPointDistribution::matchSphericalPointDistributions(
    786     const SphericalPointDistribution::WeightedPolygon_t &_polygon,
    787     SphericalPointDistribution::Polygon_t &_newpolygon
    788     )
     882SphericalPointDistribution::getRemainingPoints(
     883    const WeightedPolygon_t &_polygon,
     884    const int _N)
    789885{
    790886  SphericalPointDistribution::Polygon_t remainingpoints;
    791887
     888  // initialze to given number of points
     889  initSelf(_N);
    792890  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)
    798899    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);
    803903    LOG(2, "INFO: Best matching is " << bestmatching);
    804904
     
    819919    newSet.indices.resize(NumberIds, -1);
    820920    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));
    822922
    823923    // determine rotation angles to align the two point distributions with
     
    9271027    return remainingpoints;
    9281028  } else
    929     return _newpolygon;
    930 }
     1029    return points;
     1030}
  • src/Fragmentation/Exporters/SphericalPointDistribution.hpp

    r36bd59 rfe90ab  
    7474  }
    7575
    76   /** Matches a given spherical distribution with another containing more
    77    * 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.
    7878   *
    7979   * This is a helper to determine points where to best insert saturation
    8080   * hydrogens.
    8181   *
    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);
    9186
    9287  //!> default radius of the spherical distribution
     
    131126
    132127private:
     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
     140private:
    133141  //!> grant unit tests access to private parts
    134142  friend class SphericalPointDistributionTest;
     
    143151
    144152  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        );
    145159    bool foundflag;
    146160    double bestL2;
     161    const adjacency_t &adjacency;
     162    const VectorArray_t oldpoints;
     163    const VectorArray_t newpoints;
     164    const WeightsArray_t weights;
    147165    IndexTupleList_t bestmatching;
    148     VectorArray_t oldpoints;
    149     VectorArray_t newpoints;
    150     WeightsArray_t weights;
    151166  };
    152167
     
    160175      );
    161176
    162   static IndexList_t findBestMatching(
    163       const WeightedPolygon_t &_polygon,
    164       Polygon_t &_newpolygon
    165       );
     177  IndexList_t findBestMatching(const WeightedPolygon_t &_polygon);
    166178
    167179  static IndexList_t joinPoints(
  • src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.cpp

    r36bd59 rfe90ab  
    736736}
    737737
    738 /** UnitTest for matchSphericalPointDistributions() with two points
    739  */
    740 void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_2()
     738/** UnitTest for getRemainingPoints() with two points
     739 */
     740void SphericalPointDistributionTest::getRemainingPointsTest_2()
    741741{
    742742  SphericalPointDistribution SPD(1.);
     
    745745    SphericalPointDistribution::WeightedPolygon_t polygon;
    746746    polygon += std::make_pair(Vector(1.,0.,0.), 1);
    747     SphericalPointDistribution::Polygon_t newpolygon =
    748         SPD.get<2>();
    749747    SphericalPointDistribution::Polygon_t expected;
    750748    expected += Vector(-1.,0.,0.);
    751749    SphericalPointDistribution::Polygon_t remaining =
    752         SphericalPointDistribution::matchSphericalPointDistributions(
    753             polygon,
    754             newpolygon);
     750        SPD.getRemainingPoints(polygon, 2);
    755751//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    756752    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    761757    SphericalPointDistribution::WeightedPolygon_t polygon;
    762758    polygon += std::make_pair( Vector(0.,1.,0.), 1);
    763     SphericalPointDistribution::Polygon_t newpolygon =
    764         SPD.get<2>();
    765759    SphericalPointDistribution::Polygon_t expected;
    766760    expected += Vector(0.,-1.,0.);
    767761    SphericalPointDistribution::Polygon_t remaining =
    768         SphericalPointDistribution::matchSphericalPointDistributions(
    769             polygon,
    770             newpolygon);
     762        SPD.getRemainingPoints(polygon, 2);
    771763//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    772764    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    777769    SphericalPointDistribution::WeightedPolygon_t polygon;
    778770    polygon += std::make_pair( Vector(0.,0.,-1.), 1);
    779     SphericalPointDistribution::Polygon_t newpolygon =
    780         SPD.get<2>();
    781771    SphericalPointDistribution::Polygon_t expected;
    782772    expected += Vector(0.,0.,1.);
    783773    SphericalPointDistribution::Polygon_t remaining =
    784         SphericalPointDistribution::matchSphericalPointDistributions(
    785             polygon,
    786             newpolygon);
     774        SPD.getRemainingPoints(polygon, 2);
    787775//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    788776    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    794782    SphericalPointDistribution::WeightedPolygon_t polygon;
    795783    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>();
    798784    SphericalPointDistribution::Polygon_t expected;
    799785    expected += RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI);
    800786    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 */
     795void SphericalPointDistributionTest::getRemainingPointsTest_3()
    812796{
    813797  SphericalPointDistribution SPD(1.);
     
    817801    SphericalPointDistribution::WeightedPolygon_t polygon;
    818802    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    819     SphericalPointDistribution::Polygon_t newpolygon =
     803    SphericalPointDistribution::Polygon_t expected =
    820804        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);
    827808//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    828809    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    833814    SphericalPointDistribution::WeightedPolygon_t polygon;
    834815    polygon += std::make_pair( Vector(0.,1.,0.), 1);
    835     SphericalPointDistribution::Polygon_t newpolygon =
     816    SphericalPointDistribution::Polygon_t expected =
    836817        SPD.get<3>();
    837     SphericalPointDistribution::Polygon_t expected = newpolygon;
    838818    expected.pop_front(); // remove first point
    839819    for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
     
    843823    }
    844824    SphericalPointDistribution::Polygon_t remaining =
    845         SphericalPointDistribution::matchSphericalPointDistributions(
    846             polygon,
    847             newpolygon);
     825        SPD.getRemainingPoints(polygon, 3);
    848826//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    849827    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    855833    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    856834    polygon += std::make_pair( Vector(-0.5, sqrt(3)*0.5,0.), 1);
    857     SphericalPointDistribution::Polygon_t newpolygon =
     835    SphericalPointDistribution::Polygon_t expected =
    858836        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);
    866841//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    867842    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    878853    polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1);
    879854    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 =
    881856        SPD.get<3>();
    882     SphericalPointDistribution::Polygon_t expected = newpolygon;
    883857    expected.pop_front(); // remove first point
    884858    expected.pop_front(); // remove second point
     
    887861      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    888862    SphericalPointDistribution::Polygon_t remaining =
    889         SphericalPointDistribution::matchSphericalPointDistributions(
    890             polygon,
    891             newpolygon);
     863        SPD.getRemainingPoints(polygon, 3);
    892864//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    893865    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    908880    SphericalPointDistribution::Polygon_t expected; // empty cause none are vacant
    909881    SphericalPointDistribution::Polygon_t remaining =
    910         SphericalPointDistribution::matchSphericalPointDistributions(
    911             polygon,
    912             newpolygon);
     882        SPD.getRemainingPoints(polygon, 3);
    913883//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    914884    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    931901    SphericalPointDistribution::Polygon_t expected; // empty cause none are vacant
    932902    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 */
     915void SphericalPointDistributionTest::getRemainingPointsTest_4()
    948916{
    949917  SphericalPointDistribution SPD(1.);
     
    953921    SphericalPointDistribution::WeightedPolygon_t polygon;
    954922    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    955     SphericalPointDistribution::Polygon_t newpolygon =
     923    SphericalPointDistribution::Polygon_t expected =
    956924        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);
    963928    //    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    964929        CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    969934    SphericalPointDistribution::WeightedPolygon_t polygon;
    970935    polygon += std::make_pair( Vector(0.,1.,0.), 1);
    971     SphericalPointDistribution::Polygon_t newpolygon =
     936    SphericalPointDistribution::Polygon_t expected =
    972937        SPD.get<4>();
    973     SphericalPointDistribution::Polygon_t expected = newpolygon;
    974938    expected.pop_front(); // remove first point
    975939    for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
     
    979943    }
    980944    SphericalPointDistribution::Polygon_t remaining =
    981         SphericalPointDistribution::matchSphericalPointDistributions(
    982             polygon,
    983             newpolygon);
     945        SPD.getRemainingPoints(polygon, 4);
    984946//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    985947    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    991953    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    992954    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 =
    994956        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);
    1002961//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    1003962    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    1013972    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    1014973    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 =
    1016975        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);
    1024980//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    1025981    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    1036992    polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1);
    1037993    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 =
    1039995        SPD.get<4>();
    1040     SphericalPointDistribution::Polygon_t expected = newpolygon;
    1041996    expected.pop_front(); // remove first point
    1042997    expected.pop_front(); // remove second point
     
    10451000      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    10461001    SphericalPointDistribution::Polygon_t remaining =
    1047         SphericalPointDistribution::matchSphericalPointDistributions(
    1048             polygon,
    1049             newpolygon);
     1002        SPD.getRemainingPoints(polygon, 4);
    10501003//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    10511004    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    10621015    polygon += std::make_pair( Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 1);
    10631016    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 =
    10651018        SPD.get<4>();
    1066     SphericalPointDistribution::Polygon_t expected = newpolygon;
    10671019    expected.pop_front(); // remove first point
    10681020    expected.pop_front(); // remove second point
    10691021    expected.pop_front(); // remove third point
    10701022    SphericalPointDistribution::Polygon_t remaining =
    1071         SphericalPointDistribution::matchSphericalPointDistributions(
    1072             polygon,
    1073             newpolygon);
     1023        SPD.getRemainingPoints(polygon, 4);
    10741024//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    10751025    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    10871037    polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 47.6/180*M_PI), 1);
    10881038    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 =
    10901040        SPD.get<4>();
    1091     SphericalPointDistribution::Polygon_t expected = newpolygon;
    10921041    expected.pop_front(); // remove first point
    10931042    expected.pop_front(); // remove second point
     
    10971046      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    10981047    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
    11121059 * not all equal to one.
    11131060 */
    1114 void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_multiple()
     1061void SphericalPointDistributionTest::getRemainingPointsTest_multiple()
    11151062{
    11161063  SphericalPointDistribution SPD(1.);
     
    11261073    expected += Vector(-0.5773502691896,-5.551115123126e-17,-0.8164965809277);
    11271074    SphericalPointDistribution::Polygon_t remaining =
    1128         SphericalPointDistribution::matchSphericalPointDistributions(
    1129             polygon,
    1130             newpolygon);
     1075        SPD.getRemainingPoints(polygon, 4);
    11311076//    std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl;
    11321077//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     
    11451090    expected += Vector(-0.3535533905933,-0.3535533905933,-0.8660254037844);
    11461091    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;
    11511094//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    11521095    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    11651108    expected += Vector(0.3535534025157,-0.3535533856548,0.8660254009332);
    11661109    SphericalPointDistribution::Polygon_t remaining =
    1167         SphericalPointDistribution::matchSphericalPointDistributions(
    1168             polygon,
    1169             newpolygon);
     1110        SPD.getRemainingPoints(polygon, 5);
    11701111//    std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl;
    11711112//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     
    11811122        SPD.get<6>();
    11821123    SphericalPointDistribution::Polygon_t expected;
     1124    expected += Vector(0.,0.,1.);
    11831125    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);
    11891128//    std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl;
    11901129//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     
    11931132}
    11941133
    1195 /** UnitTest for matchSphericalPointDistributions() with five points
    1196  */
    1197 void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_5()
     1134/** UnitTest for getRemainingPoints() with five points
     1135 */
     1136void SphericalPointDistributionTest::getRemainingPointsTest_5()
    11981137{
    11991138  SphericalPointDistribution SPD(1.);
     
    12031142    SphericalPointDistribution::WeightedPolygon_t polygon;
    12041143    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    1205     SphericalPointDistribution::Polygon_t newpolygon =
     1144    SphericalPointDistribution::Polygon_t expected =
    12061145        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);
    12131149//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    12141150    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    12191155    SphericalPointDistribution::WeightedPolygon_t polygon;
    12201156    polygon += std::make_pair( Vector(0.,1.,0.), 1);
    1221     SphericalPointDistribution::Polygon_t newpolygon =
     1157    SphericalPointDistribution::Polygon_t expected =
    12221158        SPD.get<5>();
    1223     SphericalPointDistribution::Polygon_t expected = newpolygon;
    12241159    expected.pop_front(); // remove first point
    12251160    for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
     
    12291164    }
    12301165    SphericalPointDistribution::Polygon_t remaining =
    1231         SphericalPointDistribution::matchSphericalPointDistributions(
    1232             polygon,
    1233             newpolygon);
     1166        SPD.getRemainingPoints(polygon, 5);
    12341167//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    12351168    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    12411174    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    12421175    polygon += std::make_pair( Vector(-1.,0.,0.), 1);
    1243     SphericalPointDistribution::Polygon_t newpolygon =
     1176    SphericalPointDistribution::Polygon_t expected =
    12441177        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);
    12521182//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    12531183    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    12641194    polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180.*M_PI), 1);
    12651195    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 =
    12671197        SPD.get<5>();
    1268     SphericalPointDistribution::Polygon_t expected = newpolygon;
    12691198    expected.pop_front(); // remove first point
    12701199    expected.pop_front(); // remove second point
     
    12731202      *iter = RotationAxis.rotateVector(*iter, 47.6/180.*M_PI);
    12741203    SphericalPointDistribution::Polygon_t remaining =
    1275         SphericalPointDistribution::matchSphericalPointDistributions(
    1276             polygon,
    1277             newpolygon);
     1204        SPD.getRemainingPoints(polygon, 5);
    12781205    // the three remaining points sit on a plane that may be rotated arbitrarily
    12791206    // so we cannot simply check for equality between expected and remaining
     
    12951222    polygon += std::make_pair( Vector(-1., 0.0, 0.0), 1);
    12961223    polygon += std::make_pair( Vector(0.0, 1., 0.0), 1);
    1297     SphericalPointDistribution::Polygon_t newpolygon =
     1224    SphericalPointDistribution::Polygon_t expected =
    12981225        SPD.get<5>();
    1299     SphericalPointDistribution::Polygon_t expected = newpolygon;
    13001226    expected.pop_front(); // remove first point
    13011227    expected.pop_front(); // remove second point
    13021228    expected.pop_front(); // remove third point
    13031229    SphericalPointDistribution::Polygon_t remaining =
    1304         SphericalPointDistribution::matchSphericalPointDistributions(
    1305             polygon,
    1306             newpolygon);
     1230        SPD.getRemainingPoints(polygon, 5);
    13071231//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    13081232    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    13201244    polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI), 1);
    13211245    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 =
    13231247        SPD.get<5>();
    1324     SphericalPointDistribution::Polygon_t expected = newpolygon;
    13251248    expected.pop_front(); // remove first point
    13261249    expected.pop_front(); // remove second point
     
    13301253      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    13311254    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 */
     1267void SphericalPointDistributionTest::getRemainingPointsTest_6()
    13471268{
    13481269  SphericalPointDistribution SPD(1.);
     
    13521273    SphericalPointDistribution::WeightedPolygon_t polygon;
    13531274    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    1354     SphericalPointDistribution::Polygon_t newpolygon =
     1275    SphericalPointDistribution::Polygon_t expected =
    13551276        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);
    13621280//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    13631281    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    13681286    SphericalPointDistribution::WeightedPolygon_t polygon;
    13691287    polygon += std::make_pair( Vector(0.,1.,0.), 1);
    1370     SphericalPointDistribution::Polygon_t newpolygon =
     1288    SphericalPointDistribution::Polygon_t expected =
    13711289        SPD.get<6>();
    1372     SphericalPointDistribution::Polygon_t expected = newpolygon;
    13731290    expected.pop_front(); // remove first point
    13741291    for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
     
    13781295    }
    13791296    SphericalPointDistribution::Polygon_t remaining =
    1380         SphericalPointDistribution::matchSphericalPointDistributions(
    1381             polygon,
    1382             newpolygon);
     1297        SPD.getRemainingPoints(polygon, 6);
    13831298//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    13841299    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    13901305    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    13911306    polygon += std::make_pair( Vector(-1.,0.,0.), 1);
    1392     SphericalPointDistribution::Polygon_t newpolygon =
     1307    SphericalPointDistribution::Polygon_t expected =
    13931308        SPD.get<6>();
    1394     SphericalPointDistribution::Polygon_t expected = newpolygon;
    13951309    expected.pop_front(); // remove first point
    13961310    expected.pop_front(); // remove second spoint
    13971311    SphericalPointDistribution::Polygon_t remaining =
    1398         SphericalPointDistribution::matchSphericalPointDistributions(
    1399             polygon,
    1400             newpolygon);
     1312        SPD.getRemainingPoints(polygon, 6);
    14011313//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    14021314    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    14131325    polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1);
    14141326    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 =
    14161328        SPD.get<6>();
    1417     SphericalPointDistribution::Polygon_t expected = newpolygon;
    14181329    expected.pop_front(); // remove first point
    14191330    expected.pop_front(); // remove second spoint
     
    14221333      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    14231334    SphericalPointDistribution::Polygon_t remaining =
    1424         SphericalPointDistribution::matchSphericalPointDistributions(
    1425             polygon,
    1426             newpolygon);
     1335        SPD.getRemainingPoints(polygon, 6);
    14271336    // the four remaining points sit on a plane that may have been rotated arbitrarily
    14281337    // so we cannot simply check for equality between expected and remaining
     
    14441353    polygon += std::make_pair( Vector(-1., 0.0, 0.0), 1);
    14451354    polygon += std::make_pair( Vector(0.0, 1., 0.0), 1);
    1446     SphericalPointDistribution::Polygon_t newpolygon =
     1355    SphericalPointDistribution::Polygon_t expected =
    14471356        SPD.get<6>();
    1448     SphericalPointDistribution::Polygon_t expected = newpolygon;
    14491357    expected.pop_front(); // remove first point
    14501358    expected.pop_front(); // remove second point
    14511359    expected.pop_front(); // remove third point
    14521360    SphericalPointDistribution::Polygon_t remaining =
    1453         SphericalPointDistribution::matchSphericalPointDistributions(
    1454             polygon,
    1455             newpolygon);
     1361        SPD.getRemainingPoints(polygon, 6);
    14561362//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    14571363    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    14691375    polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI), 1);
    14701376    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 =
    14721378        SPD.get<6>();
    1473     SphericalPointDistribution::Polygon_t expected = newpolygon;
    14741379    expected.pop_front(); // remove first point
    14751380    expected.pop_front(); // remove second point
     
    14791384      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    14801385    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 */
     1398void SphericalPointDistributionTest::getRemainingPointsTest_7()
    14961399{
    14971400  SphericalPointDistribution SPD(1.);
     
    15011404    SphericalPointDistribution::WeightedPolygon_t polygon;
    15021405    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    1503     SphericalPointDistribution::Polygon_t newpolygon =
     1406    SphericalPointDistribution::Polygon_t expected =
    15041407        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);
    15111411//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    15121412    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    15171417    SphericalPointDistribution::WeightedPolygon_t polygon;
    15181418    polygon += std::make_pair( Vector(0.,1.,0.), 1);
    1519     SphericalPointDistribution::Polygon_t newpolygon =
     1419    SphericalPointDistribution::Polygon_t expected =
    15201420        SPD.get<7>();
    1521     SphericalPointDistribution::Polygon_t expected = newpolygon;
    15221421    expected.pop_front(); // remove first point
    15231422    for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
     
    15271426    }
    15281427    SphericalPointDistribution::Polygon_t remaining =
    1529         SphericalPointDistribution::matchSphericalPointDistributions(
    1530             polygon,
    1531             newpolygon);
     1428        SPD.getRemainingPoints(polygon, 7);
    15321429//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    15331430    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    15391436    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    15401437    polygon += std::make_pair( Vector(-1.,0.,0.), 1);
    1541     SphericalPointDistribution::Polygon_t newpolygon =
     1438    SphericalPointDistribution::Polygon_t expected =
    15421439        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);
    15501444//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    15511445    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    15621456    polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1);
    15631457    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 =
    15651459        SPD.get<7>();
    1566     SphericalPointDistribution::Polygon_t expected = newpolygon;
    15671460    expected.pop_front(); // remove first point
    15681461    expected.pop_front(); // remove second point
     
    15711464      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    15721465    SphericalPointDistribution::Polygon_t remaining =
    1573         SphericalPointDistribution::matchSphericalPointDistributions(
    1574             polygon,
    1575             newpolygon);
     1466        SPD.getRemainingPoints(polygon, 7);
    15761467    // the five remaining points sit on a plane that may have been rotated arbitrarily
    15771468    // so we cannot simply check for equality between expected and remaining
     
    15931484    polygon += std::make_pair( Vector(-1., 0.0, 0.0), 1);
    15941485    polygon += std::make_pair( Vector(0.0, 1., 0.0), 1);
    1595     SphericalPointDistribution::Polygon_t newpolygon =
     1486    SphericalPointDistribution::Polygon_t expected =
    15961487        SPD.get<7>();
    1597     SphericalPointDistribution::Polygon_t expected = newpolygon;
    15981488    expected.pop_front(); // remove first point
    15991489    expected.pop_front(); // remove second point
    16001490    expected.pop_front(); // remove third point
    16011491    SphericalPointDistribution::Polygon_t remaining =
    1602         SphericalPointDistribution::matchSphericalPointDistributions(
    1603             polygon,
    1604             newpolygon);
     1492        SPD.getRemainingPoints(polygon, 7);
    16051493//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    16061494    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    16181506    polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI), 1);
    16191507    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 =
    16211509        SPD.get<7>();
    1622     SphericalPointDistribution::Polygon_t expected = newpolygon;
    16231510    expected.pop_front(); // remove first point
    16241511    expected.pop_front(); // remove second point
     
    16281515      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    16291516    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 */
     1529void SphericalPointDistributionTest::getRemainingPointsTest_8()
    16451530{
    16461531  SphericalPointDistribution SPD(1.);
     
    16501535    SphericalPointDistribution::WeightedPolygon_t polygon;
    16511536    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    1652     SphericalPointDistribution::Polygon_t newpolygon =
     1537    SphericalPointDistribution::Polygon_t expected =
    16531538        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);
    16601542//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    16611543    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    16661548    SphericalPointDistribution::WeightedPolygon_t polygon;
    16671549    polygon += std::make_pair( Vector(0.,1.,0.), 1);
    1668     SphericalPointDistribution::Polygon_t newpolygon =
     1550    SphericalPointDistribution::Polygon_t expected =
    16691551        SPD.get<8>();
    1670     SphericalPointDistribution::Polygon_t expected = newpolygon;
    16711552    expected.pop_front(); // remove first point
    16721553    for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
     
    16751556      (*iter)[0] *= -1.;
    16761557    }
    1677    SphericalPointDistribution::Polygon_t remaining =
    1678         SphericalPointDistribution::matchSphericalPointDistributions(
    1679             polygon,
    1680             newpolygon);
     1558    SphericalPointDistribution::Polygon_t remaining =
     1559        SPD.getRemainingPoints(polygon, 8);
    16811560//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    16821561    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    16881567    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    16891568    polygon += std::make_pair( Vector(-1.,0.,0.), 1);
    1690     SphericalPointDistribution::Polygon_t newpolygon =
     1569    SphericalPointDistribution::Polygon_t expected =
    16911570        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);
    16991575//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    17001576    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    17111587    polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1);
    17121588    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 =
    17141590        SPD.get<8>();
    1715     SphericalPointDistribution::Polygon_t expected = newpolygon;
    17161591    expected.pop_front(); // remove first point
    17171592    expected.pop_front(); // remove second point
     
    17201595      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    17211596    SphericalPointDistribution::Polygon_t remaining =
    1722         SphericalPointDistribution::matchSphericalPointDistributions(
    1723             polygon,
    1724             newpolygon);
     1597        SPD.getRemainingPoints(polygon, 8);
    17251598    // the six remaining points sit on two planes that may have been rotated arbitrarily
    17261599    // so we cannot simply check for equality between expected and remaining
     
    17461619    polygon += std::make_pair( Vector(-1., 0.0, 0.0), 1);
    17471620    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 =
    17491622        SPD.get<8>();
    1750     SphericalPointDistribution::Polygon_t expected = newpolygon;
    17511623    expected.pop_front(); // remove first point
    17521624    expected.pop_front(); // remove second point
    17531625    expected.pop_front(); // remove third point
    17541626    SphericalPointDistribution::Polygon_t remaining =
    1755         SphericalPointDistribution::matchSphericalPointDistributions(
    1756             polygon,
    1757             newpolygon);
     1627        SPD.getRemainingPoints(polygon, 8);
    17581628//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    17591629    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    17711641    polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI), 1);
    17721642    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 =
    17741644        SPD.get<8>();
    1775     SphericalPointDistribution::Polygon_t expected = newpolygon;
    17761645    expected.pop_front(); // remove first point
    17771646    expected.pop_front(); // remove second point
     
    17811650      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    17821651    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  
    6565    CPPUNIT_TEST ( getConnectionTest<12> );
    6666    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 );
    7575    CPPUNIT_TEST_SUITE_END();
    7676
     
    8181      void areEqualToWithinBoundsTest();
    8282      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();
    9191
    9292private:
Note: See TracChangeset for help on using the changeset viewer.