Changeset 9cf90e for src/Fragmentation


Ignore:
Timestamp:
May 25, 2016, 7:13:59 AM (9 years ago)
Author:
Frederik Heber <heber@…>
Children:
ec9bd2
Parents:
a52369
git-author:
Frederik Heber <heber@…> (07/12/14 19:07:44)
git-committer:
Frederik Heber <heber@…> (05/25/16 07:13:59)
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

    ra52369 r9cf90e  
    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;
     
    779810}
    780811
     812void SphericalPointDistribution::initSelf(const int _NumberOfPoints)
     813{
     814  switch (_NumberOfPoints)
     815  {
     816    case 0:
     817      points = get<0>();
     818      adjacency = getConnections<0>();
     819      break;
     820    case 1:
     821      points = get<1>();
     822      adjacency = getConnections<1>();
     823      break;
     824    case 2:
     825      points = get<2>();
     826      adjacency = getConnections<2>();
     827      break;
     828    case 3:
     829      points = get<3>();
     830      adjacency = getConnections<3>();
     831      break;
     832    case 4:
     833      points = get<4>();
     834      adjacency = getConnections<4>();
     835      break;
     836    case 5:
     837      points = get<5>();
     838      adjacency = getConnections<5>();
     839      break;
     840    case 6:
     841      points = get<6>();
     842      adjacency = getConnections<6>();
     843      break;
     844    case 7:
     845      points = get<7>();
     846      adjacency = getConnections<7>();
     847      break;
     848    case 8:
     849      points = get<8>();
     850      adjacency = getConnections<8>();
     851      break;
     852    case 9:
     853      points = get<9>();
     854      adjacency = getConnections<9>();
     855      break;
     856    case 10:
     857      points = get<10>();
     858      adjacency = getConnections<10>();
     859      break;
     860    case 11:
     861      points = get<11>();
     862      adjacency = getConnections<11>();
     863      break;
     864    case 12:
     865      points = get<12>();
     866      adjacency = getConnections<12>();
     867      break;
     868    case 14:
     869      points = get<14>();
     870      adjacency = getConnections<14>();
     871      break;
     872    default:
     873      ASSERT(0, "SphericalPointDistribution::initSelf() - cannot deal with the case "
     874          +toString(_NumberOfPoints)+".");
     875  }
     876  LOG(3, "DEBUG: Ideal polygon is " << points);
     877}
    781878
    782879SphericalPointDistribution::Polygon_t
    783 SphericalPointDistribution::matchSphericalPointDistributions(
    784     const SphericalPointDistribution::WeightedPolygon_t &_polygon,
    785     SphericalPointDistribution::Polygon_t &_newpolygon
    786     )
     880SphericalPointDistribution::getRemainingPoints(
     881    const WeightedPolygon_t &_polygon,
     882    const int _N)
    787883{
    788884  SphericalPointDistribution::Polygon_t remainingpoints;
    789885
     886  // initialze to given number of points
     887  initSelf(_N);
    790888  LOG(2, "INFO: Matching old polygon " << _polygon
    791       << " with new polygon " << _newpolygon);
    792 
    793   if (_polygon.size() == _newpolygon.size()) {
    794     // same number of points desired as are present? Do nothing
    795     LOG(2, "INFO: There are no vacant points to return.");
     889      << " with new polygon " << points);
     890
     891  // check whether any points will remain vacant
     892  int RemainingPoints = _N;
     893  for (WeightedPolygon_t::const_iterator iter = _polygon.begin();
     894      iter != _polygon.end(); ++iter)
     895    RemainingPoints -= iter->second;
     896  if (RemainingPoints == 0)
    796897    return remainingpoints;
    797   }
    798 
    799   if (_polygon.size() > 0) {
    800     IndexList_t bestmatching = findBestMatching(_polygon, _newpolygon);
     898
     899  if (_N > 0) {
     900    IndexList_t bestmatching = findBestMatching(_polygon);
    801901    LOG(2, "INFO: Best matching is " << bestmatching);
    802902
     
    817917    newSet.indices.resize(NumberIds, -1);
    818918    std::copy(beginiter, enditer, newSet.indices.begin());
    819     std::copy(_newpolygon.begin(),_newpolygon.end(), std::back_inserter(newSet.polygon));
     919    std::copy(points.begin(),points.end(), std::back_inserter(newSet.polygon));
    820920
    821921    // determine rotation angles to align the two point distributions with
     
    9251025    return remainingpoints;
    9261026  } else
    927     return _newpolygon;
    928 }
     1027    return points;
     1028}
  • src/Fragmentation/Exporters/SphericalPointDistribution.hpp

    ra52369 r9cf90e  
    7272  }
    7373
    74   /** Matches a given spherical distribution with another containing more
    75    * points.
     74  /** Returns vacant spots to fill to get a complete spherical point distribution from
     75   * given points \a _polygon, containing then \a _N in total.
    7676   *
    7777   * This is a helper to determine points where to best insert saturation
    7878   * hydrogens.
    7979   *
    80    * \param _polygon current occupied positions
    81    * \param _newpolygon ideal distribution to match best with current occupied
    82    *        positions
    83    * \return remaining vacant positions relative to \a _polygon
    84    */
    85   static Polygon_t matchSphericalPointDistributions(
    86       const WeightedPolygon_t &_polygon,
    87       Polygon_t &_newpolygon
    88       );
     80   * \param _polygon already filled places to match
     81   * \param _N desired total number fo points
     82   */
     83  Polygon_t getRemainingPoints(const WeightedPolygon_t &_polygon, const int _N);
    8984
    9085  //!> default radius of the spherical distribution
     
    129124
    130125private:
     126  //!> points for the ideal distribution
     127  Polygon_t points;
     128  //!> connection information between these ideal points
     129  adjacency_t adjacency;
     130
     131  /** Initialize inner status (points and adjacency) to desired number of
     132   * points.
     133   *
     134   * \param _N number of points
     135   */
     136  void initSelf(const int _N);
     137
     138private:
    131139  //!> grant unit tests access to private parts
    132140  friend class SphericalPointDistributionTest;
     
    141149
    142150  struct MatchingControlStructure {
     151    MatchingControlStructure(
     152        const adjacency_t &_adjacency,
     153        const VectorArray_t &_oldpoints,
     154        const VectorArray_t &_newpoints,
     155        const WeightsArray_t &_weights
     156        );
    143157    bool foundflag;
    144158    double bestL2;
     159    const adjacency_t &adjacency;
     160    const VectorArray_t oldpoints;
     161    const VectorArray_t newpoints;
     162    const WeightsArray_t weights;
    145163    IndexTupleList_t bestmatching;
    146     VectorArray_t oldpoints;
    147     VectorArray_t newpoints;
    148     WeightsArray_t weights;
    149164  };
    150165
     
    158173      );
    159174
    160   static IndexList_t findBestMatching(
    161       const WeightedPolygon_t &_polygon,
    162       Polygon_t &_newpolygon
    163       );
     175  IndexList_t findBestMatching(const WeightedPolygon_t &_polygon);
    164176
    165177  static IndexList_t joinPoints(
  • src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.cpp

    ra52369 r9cf90e  
    612612}
    613613
    614 /** UnitTest for matchSphericalPointDistributions() with two points
    615  */
    616 void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_2()
     614/** UnitTest for getRemainingPoints() with two points
     615 */
     616void SphericalPointDistributionTest::getRemainingPointsTest_2()
    617617{
    618618  SphericalPointDistribution SPD(1.);
     
    621621    SphericalPointDistribution::WeightedPolygon_t polygon;
    622622    polygon += std::make_pair(Vector(1.,0.,0.), 1);
    623     SphericalPointDistribution::Polygon_t newpolygon =
    624         SPD.get<2>();
    625623    SphericalPointDistribution::Polygon_t expected;
    626624    expected += Vector(-1.,0.,0.);
    627625    SphericalPointDistribution::Polygon_t remaining =
    628         SphericalPointDistribution::matchSphericalPointDistributions(
    629             polygon,
    630             newpolygon);
     626        SPD.getRemainingPoints(polygon, 2);
    631627//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    632628    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    637633    SphericalPointDistribution::WeightedPolygon_t polygon;
    638634    polygon += std::make_pair( Vector(0.,1.,0.), 1);
    639     SphericalPointDistribution::Polygon_t newpolygon =
    640         SPD.get<2>();
    641635    SphericalPointDistribution::Polygon_t expected;
    642636    expected += Vector(0.,-1.,0.);
    643637    SphericalPointDistribution::Polygon_t remaining =
    644         SphericalPointDistribution::matchSphericalPointDistributions(
    645             polygon,
    646             newpolygon);
     638        SPD.getRemainingPoints(polygon, 2);
    647639//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    648640    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    653645    SphericalPointDistribution::WeightedPolygon_t polygon;
    654646    polygon += std::make_pair( Vector(0.,0.,-1.), 1);
    655     SphericalPointDistribution::Polygon_t newpolygon =
    656         SPD.get<2>();
    657647    SphericalPointDistribution::Polygon_t expected;
    658648    expected += Vector(0.,0.,1.);
    659649    SphericalPointDistribution::Polygon_t remaining =
    660         SphericalPointDistribution::matchSphericalPointDistributions(
    661             polygon,
    662             newpolygon);
     650        SPD.getRemainingPoints(polygon, 2);
    663651//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    664652    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    670658    SphericalPointDistribution::WeightedPolygon_t polygon;
    671659    polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1);
    672     SphericalPointDistribution::Polygon_t newpolygon =
    673         SPD.get<2>();
    674660    SphericalPointDistribution::Polygon_t expected;
    675661    expected += RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI);
    676662    SphericalPointDistribution::Polygon_t remaining =
    677         SphericalPointDistribution::matchSphericalPointDistributions(
    678             polygon,
    679             newpolygon);
    680 //    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    681     CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
    682   }
    683 }
    684 
    685 /** UnitTest for matchSphericalPointDistributions() with three points
    686  */
    687 void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_3()
     663        SPD.getRemainingPoints(polygon, 2);
     664//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     665    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     666  }
     667}
     668
     669/** UnitTest for getRemainingPoints() with three points
     670 */
     671void SphericalPointDistributionTest::getRemainingPointsTest_3()
    688672{
    689673  SphericalPointDistribution SPD(1.);
     
    693677    SphericalPointDistribution::WeightedPolygon_t polygon;
    694678    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    695     SphericalPointDistribution::Polygon_t newpolygon =
     679    SphericalPointDistribution::Polygon_t expected =
    696680        SPD.get<3>();
    697     SphericalPointDistribution::Polygon_t expected = newpolygon;
    698     expected.pop_front(); // remove first point
    699     SphericalPointDistribution::Polygon_t remaining =
    700         SphericalPointDistribution::matchSphericalPointDistributions(
    701             polygon,
    702             newpolygon);
     681    expected.pop_front(); // remove first point
     682    SphericalPointDistribution::Polygon_t remaining =
     683        SPD.getRemainingPoints(polygon, 3);
    703684//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    704685    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    709690    SphericalPointDistribution::WeightedPolygon_t polygon;
    710691    polygon += std::make_pair( Vector(0.,1.,0.), 1);
    711     SphericalPointDistribution::Polygon_t newpolygon =
     692    SphericalPointDistribution::Polygon_t expected =
    712693        SPD.get<3>();
    713     SphericalPointDistribution::Polygon_t expected = newpolygon;
    714694    expected.pop_front(); // remove first point
    715695    for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
     
    719699    }
    720700    SphericalPointDistribution::Polygon_t remaining =
    721         SphericalPointDistribution::matchSphericalPointDistributions(
    722             polygon,
    723             newpolygon);
     701        SPD.getRemainingPoints(polygon, 3);
    724702//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    725703    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    731709    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    732710    polygon += std::make_pair( Vector(-0.5, sqrt(3)*0.5,0.), 1);
    733     SphericalPointDistribution::Polygon_t newpolygon =
     711    SphericalPointDistribution::Polygon_t expected =
    734712        SPD.get<3>();
    735     SphericalPointDistribution::Polygon_t expected = newpolygon;
    736     expected.pop_front(); // remove first point
    737     expected.pop_front(); // remove second point
    738     SphericalPointDistribution::Polygon_t remaining =
    739         SphericalPointDistribution::matchSphericalPointDistributions(
    740             polygon,
    741             newpolygon);
     713    expected.pop_front(); // remove first point
     714    expected.pop_front(); // remove second point
     715    SphericalPointDistribution::Polygon_t remaining =
     716        SPD.getRemainingPoints(polygon, 3);
    742717//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    743718    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    754729    polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1);
    755730    polygon += std::make_pair(RotationAxis.rotateVector(Vector(-0.5, sqrt(3)*0.5,0.), 47.6/180*M_PI), 1);
    756     SphericalPointDistribution::Polygon_t newpolygon =
     731    SphericalPointDistribution::Polygon_t expected =
    757732        SPD.get<3>();
    758     SphericalPointDistribution::Polygon_t expected = newpolygon;
    759733    expected.pop_front(); // remove first point
    760734    expected.pop_front(); // remove second point
     
    763737      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    764738    SphericalPointDistribution::Polygon_t remaining =
    765         SphericalPointDistribution::matchSphericalPointDistributions(
    766             polygon,
    767             newpolygon);
     739        SPD.getRemainingPoints(polygon, 3);
    768740//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    769741    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    784756    SphericalPointDistribution::Polygon_t expected; // empty cause none are vacant
    785757    SphericalPointDistribution::Polygon_t remaining =
    786         SphericalPointDistribution::matchSphericalPointDistributions(
    787             polygon,
    788             newpolygon);
     758        SPD.getRemainingPoints(polygon, 3);
    789759//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    790760    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    807777    SphericalPointDistribution::Polygon_t expected; // empty cause none are vacant
    808778    SphericalPointDistribution::Polygon_t remaining =
    809         SphericalPointDistribution::matchSphericalPointDistributions(
    810             polygon,
    811             newpolygon);
    812 //    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    813     CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
    814     // also slightly perturbed
    815     const double amplitude = 0.05;
    816     perturbPolygon(polygon, amplitude);
    817     CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
    818   }
    819 }
    820 
    821 /** UnitTest for matchSphericalPointDistributions() with four points
    822  */
    823 void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_4()
     779        SPD.getRemainingPoints(polygon, 3);
     780//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     781    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     782    // also slightly perturbed
     783    const double amplitude = 0.05;
     784    perturbPolygon(polygon, amplitude);
     785    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
     786  }
     787}
     788
     789/** UnitTest for getRemainingPoints() with four points
     790 */
     791void SphericalPointDistributionTest::getRemainingPointsTest_4()
    824792{
    825793  SphericalPointDistribution SPD(1.);
     
    829797    SphericalPointDistribution::WeightedPolygon_t polygon;
    830798    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    831     SphericalPointDistribution::Polygon_t newpolygon =
     799    SphericalPointDistribution::Polygon_t expected =
    832800        SPD.get<4>();
    833     SphericalPointDistribution::Polygon_t expected = newpolygon;
    834     expected.pop_front(); // remove first point
    835     SphericalPointDistribution::Polygon_t remaining =
    836         SphericalPointDistribution::matchSphericalPointDistributions(
    837             polygon,
    838             newpolygon);
     801    expected.pop_front(); // remove first point
     802    SphericalPointDistribution::Polygon_t remaining =
     803        SPD.getRemainingPoints(polygon, 4);
    839804    //    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    840805        CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    845810    SphericalPointDistribution::WeightedPolygon_t polygon;
    846811    polygon += std::make_pair( Vector(0.,1.,0.), 1);
    847     SphericalPointDistribution::Polygon_t newpolygon =
     812    SphericalPointDistribution::Polygon_t expected =
    848813        SPD.get<4>();
    849     SphericalPointDistribution::Polygon_t expected = newpolygon;
    850814    expected.pop_front(); // remove first point
    851815    for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
     
    855819    }
    856820    SphericalPointDistribution::Polygon_t remaining =
    857         SphericalPointDistribution::matchSphericalPointDistributions(
    858             polygon,
    859             newpolygon);
     821        SPD.getRemainingPoints(polygon, 4);
    860822//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    861823    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    867829    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    868830    polygon += std::make_pair( Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 1);
    869     SphericalPointDistribution::Polygon_t newpolygon =
     831    SphericalPointDistribution::Polygon_t expected =
    870832        SPD.get<4>();
    871     SphericalPointDistribution::Polygon_t expected = newpolygon;
    872     expected.pop_front(); // remove first point
    873     expected.pop_front(); // remove second point
    874     SphericalPointDistribution::Polygon_t remaining =
    875         SphericalPointDistribution::matchSphericalPointDistributions(
    876             polygon,
    877             newpolygon);
     833    expected.pop_front(); // remove first point
     834    expected.pop_front(); // remove second point
     835    SphericalPointDistribution::Polygon_t remaining =
     836        SPD.getRemainingPoints(polygon, 4);
    878837//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    879838    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    889848    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    890849    polygon += std::make_pair( Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 1);
    891     SphericalPointDistribution::Polygon_t newpolygon =
     850    SphericalPointDistribution::Polygon_t expected =
    892851        SPD.get<4>();
    893     SphericalPointDistribution::Polygon_t expected = newpolygon;
    894     expected.pop_front(); // remove first point
    895     expected.pop_front(); // remove second point
    896     SphericalPointDistribution::Polygon_t remaining =
    897         SphericalPointDistribution::matchSphericalPointDistributions(
    898             polygon,
    899             newpolygon);
     852    expected.pop_front(); // remove first point
     853    expected.pop_front(); // remove second point
     854    SphericalPointDistribution::Polygon_t remaining =
     855        SPD.getRemainingPoints(polygon, 4);
    900856//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    901857    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    912868    polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1);
    913869    polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 47.6/180*M_PI), 1);
    914     SphericalPointDistribution::Polygon_t newpolygon =
     870    SphericalPointDistribution::Polygon_t expected =
    915871        SPD.get<4>();
    916     SphericalPointDistribution::Polygon_t expected = newpolygon;
    917872    expected.pop_front(); // remove first point
    918873    expected.pop_front(); // remove second point
     
    921876      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    922877    SphericalPointDistribution::Polygon_t remaining =
    923         SphericalPointDistribution::matchSphericalPointDistributions(
    924             polygon,
    925             newpolygon);
     878        SPD.getRemainingPoints(polygon, 4);
    926879//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    927880    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    938891    polygon += std::make_pair( Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 1);
    939892    polygon += std::make_pair( Vector(-1./3.0, -M_SQRT2/3.0, M_SQRT2/sqrt(3)), 1);
    940     SphericalPointDistribution::Polygon_t newpolygon =
     893    SphericalPointDistribution::Polygon_t expected =
    941894        SPD.get<4>();
    942     SphericalPointDistribution::Polygon_t expected = newpolygon;
    943895    expected.pop_front(); // remove first point
    944896    expected.pop_front(); // remove second point
    945897    expected.pop_front(); // remove third point
    946898    SphericalPointDistribution::Polygon_t remaining =
    947         SphericalPointDistribution::matchSphericalPointDistributions(
    948             polygon,
    949             newpolygon);
     899        SPD.getRemainingPoints(polygon, 4);
    950900//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    951901    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    963913    polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1./3.0, 2.0*M_SQRT2/3.0,0.), 47.6/180*M_PI), 1);
    964914    polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1./3.0, -M_SQRT2/3.0, M_SQRT2/sqrt(3)), 47.6/180*M_PI), 1);
    965     SphericalPointDistribution::Polygon_t newpolygon =
     915    SphericalPointDistribution::Polygon_t expected =
    966916        SPD.get<4>();
    967     SphericalPointDistribution::Polygon_t expected = newpolygon;
    968917    expected.pop_front(); // remove first point
    969918    expected.pop_front(); // remove second point
     
    973922      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    974923    SphericalPointDistribution::Polygon_t remaining =
    975         SphericalPointDistribution::matchSphericalPointDistributions(
    976             polygon,
    977             newpolygon);
    978 //    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    979     CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
    980     // also slightly perturbed
    981     const double amplitude = 0.05;
    982     perturbPolygon(polygon, amplitude);
    983     CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
    984   }
    985 }
    986 
    987 /** UnitTest for matchSphericalPointDistributions() with four points and weights
     924        SPD.getRemainingPoints(polygon, 4);
     925//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     926    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     927    // also slightly perturbed
     928    const double amplitude = 0.05;
     929    perturbPolygon(polygon, amplitude);
     930    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
     931  }
     932}
     933
     934/** UnitTest for getRemainingPoints() with four points and weights
    988935 * not all equal to one.
    989936 */
    990 void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_multiple()
     937void SphericalPointDistributionTest::getRemainingPointsTest_multiple()
    991938{
    992939  SphericalPointDistribution SPD(1.);
     
    1002949    expected += Vector(-0.5773502691896,-5.551115123126e-17,-0.8164965809277);
    1003950    SphericalPointDistribution::Polygon_t remaining =
    1004         SphericalPointDistribution::matchSphericalPointDistributions(
    1005             polygon,
    1006             newpolygon);
     951        SPD.getRemainingPoints(polygon, 4);
    1007952//    std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl;
    1008953//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     
    1021966    expected += Vector(-0.3535533905933,-0.3535533905933,-0.8660254037844);
    1022967    SphericalPointDistribution::Polygon_t remaining =
    1023         SphericalPointDistribution::matchSphericalPointDistributions(
    1024             polygon,
    1025             newpolygon);
    1026 //    std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl;
     968        SPD.getRemainingPoints(polygon, 5);
     969    std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl;
    1027970//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    1028971    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    1041984    expected += Vector(0.3535534025157,-0.3535533856548,0.8660254009332);
    1042985    SphericalPointDistribution::Polygon_t remaining =
    1043         SphericalPointDistribution::matchSphericalPointDistributions(
    1044             polygon,
    1045             newpolygon);
     986        SPD.getRemainingPoints(polygon, 5);
    1046987//    std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl;
    1047988//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     
    1057998        SPD.get<6>();
    1058999    SphericalPointDistribution::Polygon_t expected;
     1000    expected += Vector(0.,0.,1.);
    10591001    expected += Vector(0.,0.,-1.);
    1060     expected += Vector(0.,0.,1.);
    1061     SphericalPointDistribution::Polygon_t remaining =
    1062         SphericalPointDistribution::matchSphericalPointDistributions(
    1063             polygon,
    1064             newpolygon);
     1002    SphericalPointDistribution::Polygon_t remaining =
     1003        SPD.getRemainingPoints(polygon, 6);
    10651004//    std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl;
    10661005//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     
    10691008}
    10701009
    1071 /** UnitTest for matchSphericalPointDistributions() with five points
    1072  */
    1073 void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_5()
     1010/** UnitTest for getRemainingPoints() with five points
     1011 */
     1012void SphericalPointDistributionTest::getRemainingPointsTest_5()
    10741013{
    10751014  SphericalPointDistribution SPD(1.);
     
    10791018    SphericalPointDistribution::WeightedPolygon_t polygon;
    10801019    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    1081     SphericalPointDistribution::Polygon_t newpolygon =
     1020    SphericalPointDistribution::Polygon_t expected =
    10821021        SPD.get<5>();
    1083     SphericalPointDistribution::Polygon_t expected = newpolygon;
    1084     expected.pop_front(); // remove first point
    1085     SphericalPointDistribution::Polygon_t remaining =
    1086         SphericalPointDistribution::matchSphericalPointDistributions(
    1087             polygon,
    1088             newpolygon);
     1022    expected.pop_front(); // remove first point
     1023    SphericalPointDistribution::Polygon_t remaining =
     1024        SPD.getRemainingPoints(polygon, 5);
    10891025//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    10901026    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    10951031    SphericalPointDistribution::WeightedPolygon_t polygon;
    10961032    polygon += std::make_pair( Vector(0.,1.,0.), 1);
    1097     SphericalPointDistribution::Polygon_t newpolygon =
     1033    SphericalPointDistribution::Polygon_t expected =
    10981034        SPD.get<5>();
    1099     SphericalPointDistribution::Polygon_t expected = newpolygon;
    11001035    expected.pop_front(); // remove first point
    11011036    for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
     
    11051040    }
    11061041    SphericalPointDistribution::Polygon_t remaining =
    1107         SphericalPointDistribution::matchSphericalPointDistributions(
    1108             polygon,
    1109             newpolygon);
     1042        SPD.getRemainingPoints(polygon, 5);
    11101043//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    11111044    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    11171050    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    11181051    polygon += std::make_pair( Vector(-1.,0.,0.), 1);
    1119     SphericalPointDistribution::Polygon_t newpolygon =
     1052    SphericalPointDistribution::Polygon_t expected =
    11201053        SPD.get<5>();
    1121     SphericalPointDistribution::Polygon_t expected = newpolygon;
    1122     expected.pop_front(); // remove first point
    1123     expected.pop_front(); // remove second point
    1124     SphericalPointDistribution::Polygon_t remaining =
    1125         SphericalPointDistribution::matchSphericalPointDistributions(
    1126             polygon,
    1127             newpolygon);
     1054    expected.pop_front(); // remove first point
     1055    expected.pop_front(); // remove second point
     1056    SphericalPointDistribution::Polygon_t remaining =
     1057        SPD.getRemainingPoints(polygon, 5);
    11281058//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    11291059    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    11401070    polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180.*M_PI), 1);
    11411071    polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180.*M_PI), 1);
    1142     SphericalPointDistribution::Polygon_t newpolygon =
     1072    SphericalPointDistribution::Polygon_t expected =
    11431073        SPD.get<5>();
    1144     SphericalPointDistribution::Polygon_t expected = newpolygon;
    11451074    expected.pop_front(); // remove first point
    11461075    expected.pop_front(); // remove second point
     
    11491078      *iter = RotationAxis.rotateVector(*iter, 47.6/180.*M_PI);
    11501079    SphericalPointDistribution::Polygon_t remaining =
    1151         SphericalPointDistribution::matchSphericalPointDistributions(
    1152             polygon,
    1153             newpolygon);
     1080        SPD.getRemainingPoints(polygon, 5);
    11541081    // the three remaining points sit on a plane that may be rotated arbitrarily
    11551082    // so we cannot simply check for equality between expected and remaining
     
    11711098    polygon += std::make_pair( Vector(-1., 0.0, 0.0), 1);
    11721099    polygon += std::make_pair( Vector(0.0, 1., 0.0), 1);
    1173     SphericalPointDistribution::Polygon_t newpolygon =
     1100    SphericalPointDistribution::Polygon_t expected =
    11741101        SPD.get<5>();
    1175     SphericalPointDistribution::Polygon_t expected = newpolygon;
    11761102    expected.pop_front(); // remove first point
    11771103    expected.pop_front(); // remove second point
    11781104    expected.pop_front(); // remove third point
    11791105    SphericalPointDistribution::Polygon_t remaining =
    1180         SphericalPointDistribution::matchSphericalPointDistributions(
    1181             polygon,
    1182             newpolygon);
     1106        SPD.getRemainingPoints(polygon, 5);
    11831107//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    11841108    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    11961120    polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI), 1);
    11971121    polygon += std::make_pair(RotationAxis.rotateVector(Vector(0.0, 1., 0.0), 47.6/180*M_PI), 1);
    1198     SphericalPointDistribution::Polygon_t newpolygon =
     1122    SphericalPointDistribution::Polygon_t expected =
    11991123        SPD.get<5>();
    1200     SphericalPointDistribution::Polygon_t expected = newpolygon;
    12011124    expected.pop_front(); // remove first point
    12021125    expected.pop_front(); // remove second point
     
    12061129      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    12071130    SphericalPointDistribution::Polygon_t remaining =
    1208         SphericalPointDistribution::matchSphericalPointDistributions(
    1209             polygon,
    1210             newpolygon);
    1211 //    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    1212     CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
    1213     // also slightly perturbed
    1214     const double amplitude = 0.05;
    1215     perturbPolygon(polygon, amplitude);
    1216     CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
    1217   }
    1218 }
    1219 
    1220 /** UnitTest for matchSphericalPointDistributions() with six points
    1221  */
    1222 void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_6()
     1131        SPD.getRemainingPoints(polygon, 5);
     1132//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     1133    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     1134    // also slightly perturbed
     1135    const double amplitude = 0.05;
     1136    perturbPolygon(polygon, amplitude);
     1137    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
     1138  }
     1139}
     1140
     1141/** UnitTest for getRemainingPoints() with six points
     1142 */
     1143void SphericalPointDistributionTest::getRemainingPointsTest_6()
    12231144{
    12241145  SphericalPointDistribution SPD(1.);
     
    12281149    SphericalPointDistribution::WeightedPolygon_t polygon;
    12291150    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    1230     SphericalPointDistribution::Polygon_t newpolygon =
     1151    SphericalPointDistribution::Polygon_t expected =
    12311152        SPD.get<6>();
    1232     SphericalPointDistribution::Polygon_t expected = newpolygon;
    1233     expected.pop_front(); // remove first point
    1234     SphericalPointDistribution::Polygon_t remaining =
    1235         SphericalPointDistribution::matchSphericalPointDistributions(
    1236             polygon,
    1237             newpolygon);
     1153    expected.pop_front(); // remove first point
     1154    SphericalPointDistribution::Polygon_t remaining =
     1155        SPD.getRemainingPoints(polygon, 6);
    12381156//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    12391157    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    12441162    SphericalPointDistribution::WeightedPolygon_t polygon;
    12451163    polygon += std::make_pair( Vector(0.,1.,0.), 1);
    1246     SphericalPointDistribution::Polygon_t newpolygon =
     1164    SphericalPointDistribution::Polygon_t expected =
    12471165        SPD.get<6>();
    1248     SphericalPointDistribution::Polygon_t expected = newpolygon;
    12491166    expected.pop_front(); // remove first point
    12501167    for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
     
    12541171    }
    12551172    SphericalPointDistribution::Polygon_t remaining =
    1256         SphericalPointDistribution::matchSphericalPointDistributions(
    1257             polygon,
    1258             newpolygon);
     1173        SPD.getRemainingPoints(polygon, 6);
    12591174//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    12601175    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    12661181    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    12671182    polygon += std::make_pair( Vector(-1.,0.,0.), 1);
    1268     SphericalPointDistribution::Polygon_t newpolygon =
     1183    SphericalPointDistribution::Polygon_t expected =
    12691184        SPD.get<6>();
    1270     SphericalPointDistribution::Polygon_t expected = newpolygon;
    12711185    expected.pop_front(); // remove first point
    12721186    expected.pop_front(); // remove second spoint
    12731187    SphericalPointDistribution::Polygon_t remaining =
    1274         SphericalPointDistribution::matchSphericalPointDistributions(
    1275             polygon,
    1276             newpolygon);
     1188        SPD.getRemainingPoints(polygon, 6);
    12771189//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    12781190    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    12891201    polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1);
    12901202    polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI), 1);
    1291     SphericalPointDistribution::Polygon_t newpolygon =
     1203    SphericalPointDistribution::Polygon_t expected =
    12921204        SPD.get<6>();
    1293     SphericalPointDistribution::Polygon_t expected = newpolygon;
    12941205    expected.pop_front(); // remove first point
    12951206    expected.pop_front(); // remove second spoint
     
    12981209      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    12991210    SphericalPointDistribution::Polygon_t remaining =
    1300         SphericalPointDistribution::matchSphericalPointDistributions(
    1301             polygon,
    1302             newpolygon);
     1211        SPD.getRemainingPoints(polygon, 6);
    13031212    // the four remaining points sit on a plane that may have been rotated arbitrarily
    13041213    // so we cannot simply check for equality between expected and remaining
     
    13201229    polygon += std::make_pair( Vector(-1., 0.0, 0.0), 1);
    13211230    polygon += std::make_pair( Vector(0.0, 1., 0.0), 1);
    1322     SphericalPointDistribution::Polygon_t newpolygon =
     1231    SphericalPointDistribution::Polygon_t expected =
    13231232        SPD.get<6>();
    1324     SphericalPointDistribution::Polygon_t expected = newpolygon;
    13251233    expected.pop_front(); // remove first point
    13261234    expected.pop_front(); // remove second point
    13271235    expected.pop_front(); // remove third point
    13281236    SphericalPointDistribution::Polygon_t remaining =
    1329         SphericalPointDistribution::matchSphericalPointDistributions(
    1330             polygon,
    1331             newpolygon);
     1237        SPD.getRemainingPoints(polygon, 6);
    13321238//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    13331239    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    13451251    polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI), 1);
    13461252    polygon += std::make_pair(RotationAxis.rotateVector(Vector(0.0, 1., 0.0), 47.6/180*M_PI), 1);
    1347     SphericalPointDistribution::Polygon_t newpolygon =
     1253    SphericalPointDistribution::Polygon_t expected =
    13481254        SPD.get<6>();
    1349     SphericalPointDistribution::Polygon_t expected = newpolygon;
    13501255    expected.pop_front(); // remove first point
    13511256    expected.pop_front(); // remove second point
     
    13551260      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    13561261    SphericalPointDistribution::Polygon_t remaining =
    1357         SphericalPointDistribution::matchSphericalPointDistributions(
    1358             polygon,
    1359             newpolygon);
    1360 //    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    1361     CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
    1362     // also slightly perturbed
    1363     const double amplitude = 0.05;
    1364     perturbPolygon(polygon, amplitude);
    1365     CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
    1366   }
    1367 }
    1368 
    1369 /** UnitTest for matchSphericalPointDistributions() with seven points
    1370  */
    1371 void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_7()
     1262        SPD.getRemainingPoints(polygon, 6);
     1263//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     1264    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     1265    // also slightly perturbed
     1266    const double amplitude = 0.05;
     1267    perturbPolygon(polygon, amplitude);
     1268    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
     1269  }
     1270}
     1271
     1272/** UnitTest for getRemainingPoints() with seven points
     1273 */
     1274void SphericalPointDistributionTest::getRemainingPointsTest_7()
    13721275{
    13731276  SphericalPointDistribution SPD(1.);
     
    13771280    SphericalPointDistribution::WeightedPolygon_t polygon;
    13781281    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    1379     SphericalPointDistribution::Polygon_t newpolygon =
     1282    SphericalPointDistribution::Polygon_t expected =
    13801283        SPD.get<7>();
    1381     SphericalPointDistribution::Polygon_t expected = newpolygon;
    1382     expected.pop_front(); // remove first point
    1383     SphericalPointDistribution::Polygon_t remaining =
    1384         SphericalPointDistribution::matchSphericalPointDistributions(
    1385             polygon,
    1386             newpolygon);
     1284    expected.pop_front(); // remove first point
     1285    SphericalPointDistribution::Polygon_t remaining =
     1286        SPD.getRemainingPoints(polygon, 7);
    13871287//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    13881288    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    13931293    SphericalPointDistribution::WeightedPolygon_t polygon;
    13941294    polygon += std::make_pair( Vector(0.,1.,0.), 1);
    1395     SphericalPointDistribution::Polygon_t newpolygon =
     1295    SphericalPointDistribution::Polygon_t expected =
    13961296        SPD.get<7>();
    1397     SphericalPointDistribution::Polygon_t expected = newpolygon;
    13981297    expected.pop_front(); // remove first point
    13991298    for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
     
    14031302    }
    14041303    SphericalPointDistribution::Polygon_t remaining =
    1405         SphericalPointDistribution::matchSphericalPointDistributions(
    1406             polygon,
    1407             newpolygon);
     1304        SPD.getRemainingPoints(polygon, 7);
    14081305//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    14091306    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    14151312    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    14161313    polygon += std::make_pair( Vector(-1.,0.,0.), 1);
    1417     SphericalPointDistribution::Polygon_t newpolygon =
     1314    SphericalPointDistribution::Polygon_t expected =
    14181315        SPD.get<7>();
    1419     SphericalPointDistribution::Polygon_t expected = newpolygon;
    1420     expected.pop_front(); // remove first point
    1421     expected.pop_front(); // remove second point
    1422     SphericalPointDistribution::Polygon_t remaining =
    1423         SphericalPointDistribution::matchSphericalPointDistributions(
    1424             polygon,
    1425             newpolygon);
     1316    expected.pop_front(); // remove first point
     1317    expected.pop_front(); // remove second point
     1318    SphericalPointDistribution::Polygon_t remaining =
     1319        SPD.getRemainingPoints(polygon, 7);
    14261320//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    14271321    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    14381332    polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1);
    14391333    polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI), 1);
    1440     SphericalPointDistribution::Polygon_t newpolygon =
     1334    SphericalPointDistribution::Polygon_t expected =
    14411335        SPD.get<7>();
    1442     SphericalPointDistribution::Polygon_t expected = newpolygon;
    14431336    expected.pop_front(); // remove first point
    14441337    expected.pop_front(); // remove second point
     
    14471340      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    14481341    SphericalPointDistribution::Polygon_t remaining =
    1449         SphericalPointDistribution::matchSphericalPointDistributions(
    1450             polygon,
    1451             newpolygon);
     1342        SPD.getRemainingPoints(polygon, 7);
    14521343    // the five remaining points sit on a plane that may have been rotated arbitrarily
    14531344    // so we cannot simply check for equality between expected and remaining
     
    14691360    polygon += std::make_pair( Vector(-1., 0.0, 0.0), 1);
    14701361    polygon += std::make_pair( Vector(0.0, 1., 0.0), 1);
    1471     SphericalPointDistribution::Polygon_t newpolygon =
     1362    SphericalPointDistribution::Polygon_t expected =
    14721363        SPD.get<7>();
    1473     SphericalPointDistribution::Polygon_t expected = newpolygon;
    14741364    expected.pop_front(); // remove first point
    14751365    expected.pop_front(); // remove second point
    14761366    expected.pop_front(); // remove third point
    14771367    SphericalPointDistribution::Polygon_t remaining =
    1478         SphericalPointDistribution::matchSphericalPointDistributions(
    1479             polygon,
    1480             newpolygon);
     1368        SPD.getRemainingPoints(polygon, 7);
    14811369//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    14821370    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    14941382    polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI), 1);
    14951383    polygon += std::make_pair(RotationAxis.rotateVector(Vector(0.0, 1., 0.0), 47.6/180*M_PI), 1);
    1496     SphericalPointDistribution::Polygon_t newpolygon =
     1384    SphericalPointDistribution::Polygon_t expected =
    14971385        SPD.get<7>();
    1498     SphericalPointDistribution::Polygon_t expected = newpolygon;
    14991386    expected.pop_front(); // remove first point
    15001387    expected.pop_front(); // remove second point
     
    15041391      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    15051392    SphericalPointDistribution::Polygon_t remaining =
    1506         SphericalPointDistribution::matchSphericalPointDistributions(
    1507             polygon,
    1508             newpolygon);
    1509 //    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    1510     CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
    1511     // also slightly perturbed
    1512     const double amplitude = 0.05;
    1513     perturbPolygon(polygon, amplitude);
    1514     CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
    1515   }
    1516 }
    1517 
    1518 /** UnitTest for matchSphericalPointDistributions() with eight points
    1519  */
    1520 void SphericalPointDistributionTest::matchSphericalPointDistributionsTest_8()
     1393        SPD.getRemainingPoints(polygon, 7);
     1394//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     1395    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     1396    // also slightly perturbed
     1397    const double amplitude = 0.05;
     1398    perturbPolygon(polygon, amplitude);
     1399    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
     1400  }
     1401}
     1402
     1403/** UnitTest for getRemainingPoints() with eight points
     1404 */
     1405void SphericalPointDistributionTest::getRemainingPointsTest_8()
    15211406{
    15221407  SphericalPointDistribution SPD(1.);
     
    15261411    SphericalPointDistribution::WeightedPolygon_t polygon;
    15271412    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    1528     SphericalPointDistribution::Polygon_t newpolygon =
     1413    SphericalPointDistribution::Polygon_t expected =
    15291414        SPD.get<8>();
    1530     SphericalPointDistribution::Polygon_t expected = newpolygon;
    1531     expected.pop_front(); // remove first point
    1532     SphericalPointDistribution::Polygon_t remaining =
    1533         SphericalPointDistribution::matchSphericalPointDistributions(
    1534             polygon,
    1535             newpolygon);
     1415    expected.pop_front(); // remove first point
     1416    SphericalPointDistribution::Polygon_t remaining =
     1417        SPD.getRemainingPoints(polygon, 8);
    15361418//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    15371419    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    15421424    SphericalPointDistribution::WeightedPolygon_t polygon;
    15431425    polygon += std::make_pair( Vector(0.,1.,0.), 1);
    1544     SphericalPointDistribution::Polygon_t newpolygon =
     1426    SphericalPointDistribution::Polygon_t expected =
    15451427        SPD.get<8>();
    1546     SphericalPointDistribution::Polygon_t expected = newpolygon;
    15471428    expected.pop_front(); // remove first point
    15481429    for (SphericalPointDistribution::Polygon_t::iterator iter = expected.begin();
     
    15511432      (*iter)[0] *= -1.;
    15521433    }
    1553    SphericalPointDistribution::Polygon_t remaining =
    1554         SphericalPointDistribution::matchSphericalPointDistributions(
    1555             polygon,
    1556             newpolygon);
     1434    SphericalPointDistribution::Polygon_t remaining =
     1435        SPD.getRemainingPoints(polygon, 8);
    15571436//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    15581437    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    15641443    polygon += std::make_pair( Vector(1.,0.,0.), 1);
    15651444    polygon += std::make_pair( Vector(-1.,0.,0.), 1);
    1566     SphericalPointDistribution::Polygon_t newpolygon =
     1445    SphericalPointDistribution::Polygon_t expected =
    15671446        SPD.get<8>();
    1568     SphericalPointDistribution::Polygon_t expected = newpolygon;
    1569     expected.pop_front(); // remove first point
    1570     expected.pop_front(); // remove second point
    1571     SphericalPointDistribution::Polygon_t remaining =
    1572         SphericalPointDistribution::matchSphericalPointDistributions(
    1573             polygon,
    1574             newpolygon);
     1447    expected.pop_front(); // remove first point
     1448    expected.pop_front(); // remove second point
     1449    SphericalPointDistribution::Polygon_t remaining =
     1450        SPD.getRemainingPoints(polygon, 8);
    15751451//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    15761452    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    15871463    polygon += std::make_pair(RotationAxis.rotateVector(Vector(1.,0.,0.), 47.6/180*M_PI), 1);
    15881464    polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI), 1);
    1589     SphericalPointDistribution::Polygon_t newpolygon =
     1465    SphericalPointDistribution::Polygon_t expected =
    15901466        SPD.get<8>();
    1591     SphericalPointDistribution::Polygon_t expected = newpolygon;
    15921467    expected.pop_front(); // remove first point
    15931468    expected.pop_front(); // remove second point
     
    15961471      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    15971472    SphericalPointDistribution::Polygon_t remaining =
    1598         SphericalPointDistribution::matchSphericalPointDistributions(
    1599             polygon,
    1600             newpolygon);
     1473        SPD.getRemainingPoints(polygon, 8);
    16011474    // the six remaining points sit on two planes that may have been rotated arbitrarily
    16021475    // so we cannot simply check for equality between expected and remaining
     
    16221495    polygon += std::make_pair( Vector(-1., 0.0, 0.0), 1);
    16231496    polygon += std::make_pair( Vector(-1./3.0, 2.0*M_SQRT2/3.0, 0.0), 1);
    1624     SphericalPointDistribution::Polygon_t newpolygon =
     1497    SphericalPointDistribution::Polygon_t expected =
    16251498        SPD.get<8>();
    1626     SphericalPointDistribution::Polygon_t expected = newpolygon;
    16271499    expected.pop_front(); // remove first point
    16281500    expected.pop_front(); // remove second point
    16291501    expected.pop_front(); // remove third point
    16301502    SphericalPointDistribution::Polygon_t remaining =
    1631         SphericalPointDistribution::matchSphericalPointDistributions(
    1632             polygon,
    1633             newpolygon);
     1503        SPD.getRemainingPoints(polygon, 8);
    16341504//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    16351505    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    16471517    polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1., 0.0, 0.0), 47.6/180*M_PI), 1);
    16481518    polygon += std::make_pair(RotationAxis.rotateVector(Vector(-1./3.0, 2.0*M_SQRT2/3.0, 0.0), 47.6/180*M_PI), 1);
    1649     SphericalPointDistribution::Polygon_t newpolygon =
     1519    SphericalPointDistribution::Polygon_t expected =
    16501520        SPD.get<8>();
    1651     SphericalPointDistribution::Polygon_t expected = newpolygon;
    16521521    expected.pop_front(); // remove first point
    16531522    expected.pop_front(); // remove second point
     
    16571526      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    16581527    SphericalPointDistribution::Polygon_t remaining =
    1659         SphericalPointDistribution::matchSphericalPointDistributions(
    1660             polygon,
    1661             newpolygon);
    1662 //    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    1663     CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
    1664     // also slightly perturbed
    1665     const double amplitude = 0.05;
    1666     perturbPolygon(polygon, amplitude);
    1667     CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
    1668   }
    1669 }
     1528        SPD.getRemainingPoints(polygon, 8);
     1529//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     1530    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     1531    // also slightly perturbed
     1532    const double amplitude = 0.05;
     1533    perturbPolygon(polygon, amplitude);
     1534    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
     1535  }
     1536}
  • src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.hpp

    ra52369 r9cf90e  
    6161    CPPUNIT_TEST ( getConnectionTest<12> );
    6262    CPPUNIT_TEST ( getConnectionTest<14> );
    63     CPPUNIT_TEST ( matchSphericalPointDistributionsTest_2 );
    64     CPPUNIT_TEST ( matchSphericalPointDistributionsTest_3 );
    65     CPPUNIT_TEST ( matchSphericalPointDistributionsTest_4 );
    66     CPPUNIT_TEST ( matchSphericalPointDistributionsTest_5 );
    67     CPPUNIT_TEST ( matchSphericalPointDistributionsTest_6 );
    68     CPPUNIT_TEST ( matchSphericalPointDistributionsTest_7 );
    69     CPPUNIT_TEST ( matchSphericalPointDistributionsTest_8 );
    70 //    CPPUNIT_TEST ( matchSphericalPointDistributionsTest_multiple );
     63    CPPUNIT_TEST ( getRemainingPointsTest_2 );
     64    CPPUNIT_TEST ( getRemainingPointsTest_3 );
     65    CPPUNIT_TEST ( getRemainingPointsTest_4 );
     66    CPPUNIT_TEST ( getRemainingPointsTest_5 );
     67    CPPUNIT_TEST ( getRemainingPointsTest_6 );
     68    CPPUNIT_TEST ( getRemainingPointsTest_7 );
     69    CPPUNIT_TEST ( getRemainingPointsTest_8 );
     70    CPPUNIT_TEST ( getRemainingPointsTest_multiple );
    7171    CPPUNIT_TEST_SUITE_END();
    7272
     
    7777      void areEqualToWithinBoundsTest();
    7878      void joinPointsTest();
    79       void matchSphericalPointDistributionsTest_2();
    80       void matchSphericalPointDistributionsTest_3();
    81       void matchSphericalPointDistributionsTest_4();
    82       void matchSphericalPointDistributionsTest_5();
    83       void matchSphericalPointDistributionsTest_6();
    84       void matchSphericalPointDistributionsTest_7();
    85       void matchSphericalPointDistributionsTest_8();
    86       void matchSphericalPointDistributionsTest_multiple();
     79      void getRemainingPointsTest_2();
     80      void getRemainingPointsTest_3();
     81      void getRemainingPointsTest_4();
     82      void getRemainingPointsTest_5();
     83      void getRemainingPointsTest_6();
     84      void getRemainingPointsTest_7();
     85      void getRemainingPointsTest_8();
     86      void getRemainingPointsTest_multiple();
    8787
    8888private:
Note: See TracChangeset for help on using the changeset viewer.