- Timestamp:
- Aug 20, 2014, 1:06:16 PM (11 years ago)
- Children:
- ff72fb
- Parents:
- 0b517b
- git-author:
- Frederik Heber <heber@…> (07/12/14 19:07:44)
- git-committer:
- Frederik Heber <heber@…> (08/20/14 13:06:16)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Exporters/SphericalPointDistribution.cpp
r0b517b re6ca85 479 479 for (IndexList_t::iterator iter = _indices.begin(); 480 480 (iter != _indices.end()) && (!_MCS.foundflag);) { 481 481 482 // check whether we can stay in the current bin or have to move on to next one 482 483 if (*_remainiter == 0) { … … 489 490 } 490 491 } 491 // advance in matching to same position 492 493 // advance in matching to current bin to fill in 492 494 const size_t OldIndex = std::distance(_remainingweights.begin(), _remainiter); 493 495 while (_matching.size() <= OldIndex) { // add empty lists of new bin is opened … … 497 499 IndexTupleList_t::iterator filliniter = _matching.begin(); 498 500 std::advance(filliniter, OldIndex); 501 502 // check whether connection between bins' indices and candidate is satisfied 503 { 504 adjacency_t::const_iterator finder = _MCS.adjacency.find(*iter); 505 ASSERT( finder != _MCS.adjacency.end(), 506 "recurseMatchings() - "+toString(*iter)+" is not in adjacency list."); 507 if ((!filliniter->empty()) 508 && (finder->second.find(*filliniter->begin()) == finder->second.end())) { 509 LOG(5, "DEBUG; Skipping index " << *iter 510 << " as is not connected to current set." << *filliniter << "."); 511 ++iter; // note that for loop does not contain incrementor 512 continue; 513 } 514 } 515 499 516 // add index to matching 500 517 filliniter->push_back(*iter); … … 531 548 } 532 549 550 SphericalPointDistribution::MatchingControlStructure::MatchingControlStructure( 551 const adjacency_t &_adjacency, 552 const VectorArray_t &_oldpoints, 553 const VectorArray_t &_newpoints, 554 const WeightsArray_t &_weights 555 ) : 556 foundflag(false), 557 bestL2(std::numeric_limits<double>::max()), 558 adjacency(_adjacency), 559 oldpoints(_oldpoints), 560 newpoints(_newpoints), 561 weights(_weights) 562 {} 563 533 564 /** Finds combinatorially the best matching between points in \a _polygon 534 565 * and \a _newpolygon. … … 550 581 */ 551 582 SphericalPointDistribution::IndexList_t SphericalPointDistribution::findBestMatching( 552 const WeightedPolygon_t &_polygon, 553 Polygon_t &_newpolygon 583 const WeightedPolygon_t &_polygon 554 584 ) 555 585 { 556 MatchingControlStructure MCS;557 MCS.foundflag = false;558 MCS.bestL2 = std::numeric_limits<double>::max();559 586 // transform lists into arrays 587 VectorArray_t oldpoints; 588 VectorArray_t newpoints; 589 WeightsArray_t weights; 560 590 for (WeightedPolygon_t::const_iterator iter = _polygon.begin(); 561 591 iter != _polygon.end(); ++iter) { 562 MCS.oldpoints.push_back(iter->first); 563 MCS.weights.push_back(iter->second); 564 } 565 MCS.newpoints.insert(MCS.newpoints.begin(), _newpolygon.begin(),_newpolygon.end() ); 592 oldpoints.push_back(iter->first); 593 weights.push_back(iter->second); 594 } 595 newpoints.insert(newpoints.begin(), points.begin(), points.end() ); 596 MatchingControlStructure MCS(adjacency, oldpoints, newpoints, weights); 566 597 567 598 // search for bestmatching combinatorially 568 599 { 569 600 // translate polygon into vector to enable index addressing 570 IndexList_t indices( _newpolygon.size());601 IndexList_t indices(points.size()); 571 602 std::generate(indices.begin(), indices.end(), UniqueNumber); 572 603 IndexTupleList_t matching; … … 593 624 // combine multiple points and create simple IndexList from IndexTupleList 594 625 const SphericalPointDistribution::IndexList_t IndexList = 595 joinPoints( _newpolygon, MCS.newpoints, MCS.bestmatching);626 joinPoints(points, MCS.newpoints, MCS.bestmatching); 596 627 597 628 return IndexList; … … 774 805 } 775 806 807 void SphericalPointDistribution::initSelf(const int _NumberOfPoints) 808 { 809 switch (_NumberOfPoints) 810 { 811 case 0: 812 points = get<0>(); 813 adjacency = getConnections<0>(); 814 break; 815 case 1: 816 points = get<1>(); 817 adjacency = getConnections<1>(); 818 break; 819 case 2: 820 points = get<2>(); 821 adjacency = getConnections<2>(); 822 break; 823 case 3: 824 points = get<3>(); 825 adjacency = getConnections<3>(); 826 break; 827 case 4: 828 points = get<4>(); 829 adjacency = getConnections<4>(); 830 break; 831 case 5: 832 points = get<5>(); 833 adjacency = getConnections<5>(); 834 break; 835 case 6: 836 points = get<6>(); 837 adjacency = getConnections<6>(); 838 break; 839 case 7: 840 points = get<7>(); 841 adjacency = getConnections<7>(); 842 break; 843 case 8: 844 points = get<8>(); 845 adjacency = getConnections<8>(); 846 break; 847 case 9: 848 points = get<9>(); 849 adjacency = getConnections<9>(); 850 break; 851 case 10: 852 points = get<10>(); 853 adjacency = getConnections<10>(); 854 break; 855 case 11: 856 points = get<11>(); 857 adjacency = getConnections<11>(); 858 break; 859 case 12: 860 points = get<12>(); 861 adjacency = getConnections<12>(); 862 break; 863 case 14: 864 points = get<14>(); 865 adjacency = getConnections<14>(); 866 break; 867 default: 868 ASSERT(0, "SphericalPointDistribution::initSelf() - cannot deal with the case " 869 +toString(_NumberOfPoints)+"."); 870 } 871 LOG(3, "DEBUG: Ideal polygon is " << points); 872 } 776 873 777 874 SphericalPointDistribution::Polygon_t 778 SphericalPointDistribution::matchSphericalPointDistributions( 779 const SphericalPointDistribution::WeightedPolygon_t &_polygon, 780 SphericalPointDistribution::Polygon_t &_newpolygon 781 ) 875 SphericalPointDistribution::getRemainingPoints( 876 const WeightedPolygon_t &_polygon, 877 const int _N) 782 878 { 783 879 SphericalPointDistribution::Polygon_t remainingpoints; 784 880 881 // initialze to given number of points 882 initSelf(_N); 785 883 LOG(2, "INFO: Matching old polygon " << _polygon 786 << " with new polygon " << _newpolygon); 787 788 if (_polygon.size() == _newpolygon.size()) { 789 // same number of points desired as are present? Do nothing 790 LOG(2, "INFO: There are no vacant points to return."); 884 << " with new polygon " << points); 885 886 // check whether any points will remain vacant 887 int RemainingPoints = _N; 888 for (WeightedPolygon_t::const_iterator iter = _polygon.begin(); 889 iter != _polygon.end(); ++iter) 890 RemainingPoints -= iter->second; 891 if (RemainingPoints == 0) 791 892 return remainingpoints; 792 } 793 794 if (_polygon.size() > 0) { 795 IndexList_t bestmatching = findBestMatching(_polygon, _newpolygon); 893 894 if (_N > 0) { 895 IndexList_t bestmatching = findBestMatching(_polygon); 796 896 LOG(2, "INFO: Best matching is " << bestmatching); 797 897 … … 812 912 newSet.indices.resize(NumberIds, -1); 813 913 std::copy(beginiter, enditer, newSet.indices.begin()); 814 std::copy( _newpolygon.begin(),_newpolygon.end(), std::back_inserter(newSet.polygon));914 std::copy(points.begin(),points.end(), std::back_inserter(newSet.polygon)); 815 915 816 916 // determine rotation angles to align the two point distributions with … … 920 1020 return remainingpoints; 921 1021 } else 922 return _newpolygon;923 } 924 925 1022 return points; 1023 } 1024 1025
Note:
See TracChangeset
for help on using the changeset viewer.
