Created
          October 17, 2013 12:29 
        
      - 
      
 - 
        
Save pratikmallya/7024039 to your computer and use it in GitHub Desktop.  
    Atlas merge code
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function [atlas] = merge_manifold() | |
| % merge atlas2 into atlas, return a new atlas | |
| % this code performs a "Brute force" merge where all the charts of the second | |
| % atlas are checked for nearness to the first atlas, and then merged in | |
| atlas1 = coco_bd_read('cylinder1', 'atlas'); | |
| atlas2 = coco_bd_read('cylinder2', 'atlas'); | |
| atlas2charts = atlas2.charts{1:5}; | |
| atlas = atlas1; | |
| for i = 1:numel(atlas2charts) | |
| chart = atlas2.charts{i}; | |
| nbfunc = @(x) atlas.isclose(chart, x); | |
| bd_charts = atlas.charts(atlas.boundary); | |
| idx = cellfun(nbfunc, bd_charts); | |
| close_charts = atlas.boundary(idx); | |
| checked = [0, chart.id]; | |
| while ~isempty(close_charts) | |
| [atlas chart checked] = ... | |
| atlas.merge_recursive(chart, close_charts(1), checked); | |
| close_charts = setdiff(close_charts, checked); | |
| end | |
| atlas.charts = [atlas.charts, {chart}]; | |
| atlas.boundary = [atlas.boundary, chart.id]; | |
| bd_charts = atlas.charts(atlas.boundary); | |
| idx = cellfun(@(x) ~isempty(x.bv), bd_charts); | |
| atlas.boundary = atlas.boundary(idx); | |
| end | |
| % plot the results | |
| plot_charts(atlas.charts, 1, 2, 3); | |
| axis equal | |
| axis tight | |
| view(60,30) | |
| drawnow | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment