- Timestamp:
- Aug 20, 2014, 1:06:47 PM (11 years ago)
- Parents:
- 693036
- git-author:
- Frederik Heber <heber@…> (07/21/14 08:21:53)
- git-committer:
- Frederik Heber <heber@…> (08/20/14 13:06:47)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Exporters/SphericalPointDistribution.cpp
r693036 r87491e 632 632 ) 633 633 { 634 // generate trivial index list 635 IndexList_t IndexList(_bestmatching.size(), (size_t)-1); 636 std::generate(IndexList.begin(), IndexList.end(), UniqueNumber); 637 LOG(4, "DEBUG: Our new trivial IndexList reads as " << IndexList); 638 634 639 // combine all multiple points 635 IndexList_t IndexList;636 IndexArray_t removalpoints;637 unsigned int UniqueIndex = _newpolygon.size(); // all indices up to size are used right now638 640 VectorArray_t newCenters; 639 newCenters.reserve(_bestmatching.size()); 641 newCenters.resize(_bestmatching.size()); 642 VectorArray_t::iterator centeriter = newCenters.begin(); 640 643 for (IndexTupleList_t::const_iterator tupleiter = _bestmatching.begin(); 641 tupleiter != _bestmatching.end(); ++tupleiter ) {644 tupleiter != _bestmatching.end(); ++tupleiter, ++centeriter) { 642 645 ASSERT (tupleiter->size() > 0, 643 646 "findBestMatching() - encountered tuple in bestmatching with size 0."); 644 647 if (tupleiter->size() == 1) { 645 648 // add point and index 646 IndexList.push_back(*tupleiter->begin());649 *centeriter = _newpoints[*tupleiter->begin()]; 647 650 } else { 648 651 // combine into weighted and normalized center 649 Vector Center = calculateCenter(_newpoints, *tupleiter); 650 Center.Normalize(); 651 _newpolygon.push_back(Center); 652 *centeriter = calculateCenter(_newpoints, *tupleiter); 653 (*centeriter).Normalize(); 652 654 LOG(5, "DEBUG: Combining " << tupleiter->size() << " points to weighted center " 653 << Center << " with new index " << UniqueIndex); 654 // mark for removal 655 removalpoints.insert(removalpoints.end(), tupleiter->begin(), tupleiter->end()); 656 // add new index 657 IndexList.push_back(UniqueIndex++); 658 } 659 } 660 // IndexList is now our new bestmatching (that is bijective) 661 LOG(4, "DEBUG: Our new bijective IndexList reads as " << IndexList); 662 663 // modifying _newpolygon: remove all points in removalpoints, add those in newCenters 664 Polygon_t allnewpoints = _newpolygon; 665 { 666 _newpolygon.clear(); 667 std::sort(removalpoints.begin(), removalpoints.end()); 668 size_t i = 0; 669 IndexArray_t::const_iterator removeiter = removalpoints.begin(); 670 for (Polygon_t::iterator iter = allnewpoints.begin(); 671 iter != allnewpoints.end(); ++iter, ++i) { 672 if ((removeiter != removalpoints.end()) && (i == *removeiter)) { 673 // don't add, go to next remove index 674 ++removeiter; 675 } else { 676 // otherwise add points 677 _newpolygon.push_back(*iter); 678 } 679 } 680 } 681 LOG(4, "DEBUG: The polygon with recentered points removed is " << _newpolygon); 682 683 // map IndexList to new shrinked _newpolygon 684 typedef std::set<unsigned int> IndexSet_t; 685 IndexSet_t SortedIndexList(IndexList.begin(), IndexList.end()); 686 IndexList.clear(); 687 { 688 size_t offset = 0; 689 IndexSet_t::const_iterator listiter = SortedIndexList.begin(); 690 IndexArray_t::const_iterator removeiter = removalpoints.begin(); 691 for (size_t i = 0; i < allnewpoints.size(); ++i) { 692 if ((removeiter != removalpoints.end()) && (i == *removeiter)) { 693 ++offset; 694 ++removeiter; 695 } else if ((listiter != SortedIndexList.end()) && (i == *listiter)) { 696 IndexList.push_back(*listiter - offset); 697 ++listiter; 698 } 699 } 700 } 701 LOG(4, "DEBUG: Our new bijective IndexList corrected for removed points reads as " 702 << IndexList); 655 << *centeriter << "."); 656 } 657 } 658 _newpolygon.insert(_newpolygon.begin(), newCenters.begin(), newCenters.end()); 659 LOG(4, "DEBUG: The polygon with centered points is " << _newpolygon); 703 660 704 661 return IndexList; … … 1045 1002 // combine multiple points and create simple IndexList from IndexTupleList 1046 1003 MatchingControlStructure MCS = findBestMatching(_polygon); 1004 points.clear(); 1047 1005 IndexList_t bestmatching = joinPoints(points, MCS.newpoints, MCS.bestmatching); 1048 1006 LOG(2, "INFO: Best matching is " << bestmatching);
Note:
See TracChangeset
for help on using the changeset viewer.
