Ignore:
Timestamp:
Aug 20, 2014, 1:07:11 PM (11 years ago)
Author:
Frederik Heber <heber@…>
Children:
2971aa
Parents:
7e45c4
git-author:
Frederik Heber <heber@…> (07/21/14 08:21:53)
git-committer:
Frederik Heber <heber@…> (08/20/14 13:07:11)
Message:

tempcommit: Modified jointPoints() to just combine points and switch to trivial matching.

File:
1 edited

Legend:

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

    r7e45c4 r907198  
    753753    )
    754754{
     755  // generate trivial index list
     756  IndexList_t IndexList(_bestmatching.size(), (size_t)-1);
     757  std::generate(IndexList.begin(), IndexList.end(), UniqueNumber);
     758  LOG(4, "DEBUG: Our new trivial IndexList reads as " << IndexList);
     759
    755760  // combine all multiple points
    756   IndexList_t IndexList;
    757   IndexArray_t removalpoints;
    758   unsigned int UniqueIndex = _newpolygon.size(); // all indices up to size are used right now
    759761  VectorArray_t newCenters;
    760   newCenters.reserve(_bestmatching.size());
     762  newCenters.resize(_bestmatching.size());
     763  VectorArray_t::iterator centeriter = newCenters.begin();
    761764  for (IndexTupleList_t::const_iterator tupleiter = _bestmatching.begin();
    762       tupleiter != _bestmatching.end(); ++tupleiter) {
     765      tupleiter != _bestmatching.end(); ++tupleiter, ++centeriter) {
    763766    ASSERT (tupleiter->size() > 0,
    764767        "findBestMatching() - encountered tuple in bestmatching with size 0.");
    765768    if (tupleiter->size() == 1) {
    766769      // add point and index
    767       IndexList.push_back(*tupleiter->begin());
     770      *centeriter = _newpoints[*tupleiter->begin()];
    768771    } else {
    769772      // combine into weighted and normalized center
    770       Vector Center = calculateCenter(_newpoints, *tupleiter);
    771       Center.Normalize();
    772       _newpolygon.push_back(Center);
     773      *centeriter = calculateCenter(_newpoints, *tupleiter);
     774      (*centeriter).Normalize();
    773775      LOG(5, "DEBUG: Combining " << tupleiter->size() << " points to weighted center "
    774           << Center << " with new index " << UniqueIndex);
    775       // mark for removal
    776       removalpoints.insert(removalpoints.end(), tupleiter->begin(), tupleiter->end());
    777       // add new index
    778       IndexList.push_back(UniqueIndex++);
     776          << *centeriter << ".");
    779777    }
    780778  }
    781   // IndexList is now our new bestmatching (that is bijective)
    782   LOG(4, "DEBUG: Our new bijective IndexList reads as " << IndexList);
    783 
    784   // modifying _newpolygon: remove all points in removalpoints, add those in newCenters
    785   Polygon_t allnewpoints = _newpolygon;
    786   {
    787     _newpolygon.clear();
    788     std::sort(removalpoints.begin(), removalpoints.end());
    789     size_t i = 0;
    790     IndexArray_t::const_iterator removeiter = removalpoints.begin();
    791     for (Polygon_t::iterator iter = allnewpoints.begin();
    792         iter != allnewpoints.end(); ++iter, ++i) {
    793       if ((removeiter != removalpoints.end()) && (i == *removeiter)) {
    794         // don't add, go to next remove index
    795         ++removeiter;
    796       } else {
    797         // otherwise add points
    798         _newpolygon.push_back(*iter);
    799       }
    800     }
    801   }
    802   LOG(4, "DEBUG: The polygon with recentered points removed is " << _newpolygon);
    803 
    804   // map IndexList to new shrinked _newpolygon
    805   typedef std::set<unsigned int> IndexSet_t;
    806   IndexSet_t SortedIndexList(IndexList.begin(), IndexList.end());
    807   IndexList.clear();
    808   {
    809     size_t offset = 0;
    810     IndexSet_t::const_iterator listiter = SortedIndexList.begin();
    811     IndexArray_t::const_iterator removeiter = removalpoints.begin();
    812     for (size_t i = 0; i < allnewpoints.size(); ++i) {
    813       if ((removeiter != removalpoints.end()) && (i == *removeiter)) {
    814         ++offset;
    815         ++removeiter;
    816       } else if ((listiter != SortedIndexList.end()) && (i == *listiter)) {
    817         IndexList.push_back(*listiter - offset);
    818         ++listiter;
    819       }
    820     }
    821   }
    822   LOG(4, "DEBUG: Our new bijective IndexList corrected for removed points reads as "
    823       << IndexList);
     779  _newpolygon.insert(_newpolygon.begin(), newCenters.begin(), newCenters.end());
     780  LOG(4, "DEBUG: The polygon with centered points is " << _newpolygon);
    824781
    825782  return IndexList;
     
    11831140    // combine multiple points and create simple IndexList from IndexTupleList
    11841141    MatchingControlStructure MCS = findBestMatching(_polygon);
     1142    points.clear();
    11851143    IndexList_t bestmatching = joinPoints(points, MCS.newpoints, MCS.bestmatching);
    11861144    LOG(2, "INFO: Best matching is " << bestmatching);
Note: See TracChangeset for help on using the changeset viewer.