Changeset 6312


Ignore:
Timestamp:
10/15/10 09:32:48 (15 years ago)
Author:
jschierm
Message:

Intermediate version of kml_mesh_write.m with overlapping partitions.

Location:
issm/trunk/src/m/kml
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/m/kml/edgeadjacency.m

    r6299 r6312  
    22%  create an edge adjacency table for the elements in the model.
    33%
    4 %  [edgeadj,edgeuns,elemuns]=edgeadjacency(elem,nodecon)
     4%  [edgeadj]=edgeadjacency(elem,nodecon)
    55%
    66%  where the required input is:
     
    1111%    edgeadj       (numeric, edge adjacency array (elems x edges))
    1212%
    13 %  the optional output is:
    14 %    edgeuns       (numeric, unshared edge list (edgeuns x 2))
    15 %    elemuns       (numeric, unshared edge element list (edgeuns x 1))
    16 %
    17 function [edgeadj,edgeuns,elemuns]=edgeadjacency(elem,nodecon)
     13function [edgeadj]=edgeadjacency(elem,nodecon)
    1814
    1915if ~nargin
     
    4945end
    5046
    51 %%  create the unshared edge list
    52 
    53 if (nargout >= 2)
    54     [icol,irow]=find(edgeadj'==0);
    55     edgeuns=zeros(length(irow),2);
    56     if (nargout >= 3)
    57         elemuns=zeros(length(irow),1);
    58     end
    59 
    60 %  loop over the edges
    61 
    62     for i=1:length(irow)
    63         edgeuns(i,1)=elem(irow(i),icol(i));
    64         edgeuns(i,2)=elem(irow(i),mod(icol(i),size(elem,2))+1);
    65         if (nargout >= 3)
    66             elemuns(i)=irow(i);
    67         end
    68     end
    6947end
    70 
    71 end
  • issm/trunk/src/m/kml/kml_mesh_write.m

    r6302 r6312  
    295295if (~exist('prtplt','var') || strncmpi(prtplt,'on' ,2) || strncmpi(prtplt,'y',1)) && ...
    296296    md.npart
    297     [edgeadj,edgeuns,elemuns]=edgeadjacency(md.elements,md.nodeconnectivity);
     297    [edgeadj]=edgeadjacency(md.elements,md.nodeconnectivity);
     298    [icol,irow]=find(edgeadj'==0);
     299    edgeuns=zeros(length(irow),2);
     300    for i=1:length(irow)
     301        edgeuns(i,1)=md.elements(irow(i),icol(i));
     302        edgeuns(i,2)=md.elements(irow(i),mod(icol(i),size(md.elements,2))+1);
     303    end
    298304    fprintf(fid,'    <Folder>\n');
    299305    fprintf(fid,'      <name>Unshared Edges</name>\n');
     
    327333end
    328334
     335%  write folder for partitions
     336
     337fprintf(fid,'    <Folder>\n');
     338fprintf(fid,'      <name>Partitions</name>\n');
     339fprintf(fid,'      <visibility>1</visibility>\n');
     340fprintf(fid,'      <description>Partitions=%d, Nodes=%d</description>\n',...
     341    md.npart,md.numberofgrids);
     342
     343%  write each partition loop as a polygon
     344
     345disp(['Writing ' num2str(md.npart) ' partitions as KML polygons.']);
     346epart=md.part(md.elements)+1;
     347for k=1:md.npart
     348    [icol,irow]=find(epart'==k);
     349    irow=unique(irow);
     350    elem=md.elements(irow,:);
     351    nodecon=NodeConnectivity(elem,md.numberofgrids);
     352    [edgeper,elemper,iloop]=edgeperimeter(elem,nodecon);
     353    iloop(end+1)=size(edgeper,1)+1;
     354    for i=1:length(iloop)-1
     355        fprintf(fid,'      <Placemark>\n');
     356        if (length(iloop)-1 > 1)
     357            fprintf(fid,'        <name>Partition %d, Loop %d</name>\n',k,i);
     358        else
     359            fprintf(fid,'        <name>Partition %d</name>\n',k);
     360        end
     361        fprintf(fid,'        <visibility>1</visibility>\n');
     362    %     if exist('edata','var')
     363    %         fprintf(fid,'        <description>Element data: %g</description>\n',edata(i));
     364    %         imap = fix((edata(i)-cmin)/(cmax-cmin)*size(cmap,1))+1;
     365    %         if     (imap >= 1) && (imap <= size(cmap,1))
     366    %             fprintf(fid,'        <styleUrl>#MatlabColor%d</styleUrl>\n',imap);
     367    %         elseif (edata(i) == cmax)
     368    %             fprintf(fid,'        <styleUrl>#MatlabColor%d</styleUrl>\n',size(cmap,1));
     369    %         else
     370    %             fprintf(fid,'        <styleUrl>#BlackLineEmptyPoly</styleUrl>\n');
     371    %         end
     372    %     else
     373            fprintf(fid,'        <styleUrl>#BlackLineRandomPoly</styleUrl>\n');
     374    %     end
     375        fprintf(fid,'        <Polygon>\n');
     376        fprintf(fid,'          <extrude>1</extrude>\n');
     377        fprintf(fid,'          <altitudeMode>relativeToGround</altitudeMode>\n');
     378        fprintf(fid,'          <outerBoundaryIs>\n');
     379        fprintf(fid,'            <LinearRing>\n');
     380        fprintf(fid,'              <coordinates>\n');
     381        for j=iloop(i):iloop(i+1)-1
     382            [lat(j),long(j)]=mapxy(md.x(edgeper(j,1)),md.y(edgeper(j,1)),'s');
     383            fprintf(fid,'                %0.16g,%0.16g,%0.16g\n',long(j),lat(j),alt);
     384        end
     385        fprintf(fid,'                %0.16g,%0.16g,%0.16g\n',long(iloop(i)),lat(iloop(i)),alt);
     386
     387        fprintf(fid,'              </coordinates>\n');
     388        fprintf(fid,'            </LinearRing>\n');
     389        fprintf(fid,'          </outerBoundaryIs>\n');
     390        fprintf(fid,'        </Polygon>\n');
     391        fprintf(fid,'      </Placemark>\n');
     392    end
     393end
     394fprintf(fid,'    </Folder>\n');
     395
    329396%  write trailer data
    330397
Note: See TracChangeset for help on using the changeset viewer.