- Timestamp:
- May 25, 2016, 7:13:59 AM (9 years ago)
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Exporters/SphericalPointDistribution.cpp
ra52369 r9cf90e 480 480 for (IndexList_t::iterator iter = _indices.begin(); 481 481 (iter != _indices.end()) && (!_MCS.foundflag);) { 482 482 483 // check whether we can stay in the current bin or have to move on to next one 483 484 if (*_remainiter == 0) { … … 490 491 } 491 492 } 492 // advance in matching to same position 493 494 // advance in matching to current bin to fill in 493 495 const size_t OldIndex = std::distance(_remainingweights.begin(), _remainiter); 494 496 while (_matching.size() <= OldIndex) { // add empty lists of new bin is opened … … 498 500 IndexTupleList_t::iterator filliniter = _matching.begin(); 499 501 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 500 517 // add index to matching 501 518 filliniter->push_back(*iter); … … 532 549 } 533 550 551 SphericalPointDistribution::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 534 565 /** Finds combinatorially the best matching between points in \a _polygon 535 566 * and \a _newpolygon. … … 551 582 */ 552 583 SphericalPointDistribution::IndexList_t SphericalPointDistribution::findBestMatching( 553 const WeightedPolygon_t &_polygon, 554 Polygon_t &_newpolygon 584 const WeightedPolygon_t &_polygon 555 585 ) 556 586 { 557 MatchingControlStructure MCS;558 MCS.foundflag = false;559 MCS.bestL2 = std::numeric_limits<double>::max();560 587 // transform lists into arrays 588 VectorArray_t oldpoints; 589 VectorArray_t newpoints; 590 WeightsArray_t weights; 561 591 for (WeightedPolygon_t::const_iterator iter = _polygon.begin(); 562 592 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); 567 598 568 599 // search for bestmatching combinatorially 569 600 { 570 601 // translate polygon into vector to enable index addressing 571 IndexList_t indices( _newpolygon.size());602 IndexList_t indices(points.size()); 572 603 std::generate(indices.begin(), indices.end(), UniqueNumber); 573 604 IndexTupleList_t matching; … … 594 625 // combine multiple points and create simple IndexList from IndexTupleList 595 626 const SphericalPointDistribution::IndexList_t IndexList = 596 joinPoints( _newpolygon, MCS.newpoints, MCS.bestmatching);627 joinPoints(points, MCS.newpoints, MCS.bestmatching); 597 628 598 629 return IndexList; … … 779 810 } 780 811 812 void 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 } 781 878 782 879 SphericalPointDistribution::Polygon_t 783 SphericalPointDistribution::matchSphericalPointDistributions( 784 const SphericalPointDistribution::WeightedPolygon_t &_polygon, 785 SphericalPointDistribution::Polygon_t &_newpolygon 786 ) 880 SphericalPointDistribution::getRemainingPoints( 881 const WeightedPolygon_t &_polygon, 882 const int _N) 787 883 { 788 884 SphericalPointDistribution::Polygon_t remainingpoints; 789 885 886 // initialze to given number of points 887 initSelf(_N); 790 888 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) 796 897 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); 801 901 LOG(2, "INFO: Best matching is " << bestmatching); 802 902 … … 817 917 newSet.indices.resize(NumberIds, -1); 818 918 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)); 820 920 821 921 // determine rotation angles to align the two point distributions with … … 925 1025 return remainingpoints; 926 1026 } else 927 return _newpolygon;928 } 1027 return points; 1028 }
Note:
See TracChangeset
for help on using the changeset viewer.
