- Timestamp:
 - Aug 20, 2014, 1:07:11 PM (11 years ago)
 - 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)
 - File:
 - 
      
- 1 edited
 
 
Legend:
- Unmodified
 - Added
 - Removed
 
- 
      
src/Fragmentation/Exporters/SphericalPointDistribution.cpp
r7e45c4 r907198 753 753 ) 754 754 { 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 755 760 // 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 now759 761 VectorArray_t newCenters; 760 newCenters.reserve(_bestmatching.size()); 762 newCenters.resize(_bestmatching.size()); 763 VectorArray_t::iterator centeriter = newCenters.begin(); 761 764 for (IndexTupleList_t::const_iterator tupleiter = _bestmatching.begin(); 762 tupleiter != _bestmatching.end(); ++tupleiter ) {765 tupleiter != _bestmatching.end(); ++tupleiter, ++centeriter) { 763 766 ASSERT (tupleiter->size() > 0, 764 767 "findBestMatching() - encountered tuple in bestmatching with size 0."); 765 768 if (tupleiter->size() == 1) { 766 769 // add point and index 767 IndexList.push_back(*tupleiter->begin());770 *centeriter = _newpoints[*tupleiter->begin()]; 768 771 } else { 769 772 // 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(); 773 775 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 << "."); 779 777 } 780 778 } 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); 824 781 825 782 return IndexList; … … 1183 1140 // combine multiple points and create simple IndexList from IndexTupleList 1184 1141 MatchingControlStructure MCS = findBestMatching(_polygon); 1142 points.clear(); 1185 1143 IndexList_t bestmatching = joinPoints(points, MCS.newpoints, MCS.bestmatching); 1186 1144 LOG(2, "INFO: Best matching is " << bestmatching);  
  Note:
 See   TracChangeset
 for help on using the changeset viewer.
  