Index: /issm/trunk/src/m/kml/edgeadjacency.m
===================================================================
--- /issm/trunk/src/m/kml/edgeadjacency.m	(revision 6299)
+++ /issm/trunk/src/m/kml/edgeadjacency.m	(revision 6299)
@@ -0,0 +1,71 @@
+%
+%  create an edge adjacency table for the elements in the model.
+%
+%  [edgeadj,edgeuns,elemuns]=edgeadjacency(elem,nodecon)
+%
+%  where the required input is:
+%    elem          (numeric, element connectivity array (elems x nodes))
+%    nodecon       (numeric, node connectivity array (nodes x elems+1))
+%
+%  and the required output is:
+%    edgeadj       (numeric, edge adjacency array (elems x edges))
+%
+%  the optional output is:
+%    edgeuns       (numeric, unshared edge list (edgeuns x 2))
+%    elemuns       (numeric, unshared edge element list (edgeuns x 1))
+%
+function [edgeadj,edgeuns,elemuns]=edgeadjacency(elem,nodecon)
+
+if ~nargin
+    help edgeadjacency
+    return
+end
+
+%%  create the edge adjacency array
+
+edgeadj=zeros(size(elem));
+
+%  loop over the elements
+
+for i=1:size(elem,1)
+
+%  loop over the edges for each element (trias only for now)
+
+    for j=1:size(elem,2)
+        inode1=elem(i,j);
+        inode2=elem(i,mod(j,size(elem,2))+1);
+        
+%  loop over the elements containing the first node of the edge to see
+%  if they contain the second node of the edge
+
+        for k=1:nodecon(inode1,end)
+            if (nodecon(inode1,k) ~= i) && ...
+               ~isempty(find(elem(nodecon(inode1,k),:)==inode2,1))
+                edgeadj(i,j)=nodecon(inode1,k);
+                break;
+            end
+        end
+    end
+end
+
+%%  create the unshared edge list
+
+if (nargout >= 2)
+    [icol,irow]=find(edgeadj'==0);
+    edgeuns=zeros(length(irow),2);
+    if (nargout >= 3)
+        elemuns=zeros(length(irow),1);
+    end
+
+%  loop over the edges
+
+    for i=1:length(irow)
+        edgeuns(i,1)=elem(irow(i),icol(i));
+        edgeuns(i,2)=elem(irow(i),mod(icol(i),size(elem,2))+1);
+        if (nargout >= 3)
+            elemuns(i)=irow(i);
+        end
+    end
+end
+
+end
Index: /issm/trunk/src/m/kml/kml_mesh_write.m
===================================================================
--- /issm/trunk/src/m/kml/kml_mesh_write.m	(revision 6298)
+++ /issm/trunk/src/m/kml/kml_mesh_write.m	(revision 6299)
@@ -12,11 +12,12 @@
 %
 %  and the optional input is:
-%    data          (numeric, results data)
+%    data          (numeric, element or nodal results data)
 %    alt           (numeric, altitude for polygons, default 10000)
 %    lwidth        (numeric, line width in pixels, default 1)
 %    popac         (numeric, polygon opacity, default 0.50)
-%    cmin          (numeric, minimum of color scale)
-%    cmax          (numeric, maximum of color scale)
+%    cmin          (numeric, minimum of color map)
+%    cmax          (numeric, maximum of color map)
 %    cmap          (char or numeric, colormap definition)
+%    prtplt        (char, 'off'/'no' for partition segment plot)
 %
 function []=kml_mesh_write(varargin)
@@ -256,5 +257,6 @@
 %  write folder for partition segments
 
-if md.npart
+if (~exist('prtplt','var') || strncmpi(prtplt,'on' ,2) || strncmpi(prtplt,'y',1)) && ...
+    md.npart
     [xseg,yseg]=flagedges(md.elements,md.x,md.y,md.part);
     fprintf(fid,'    <Folder>\n');
@@ -264,5 +266,5 @@
         md.npart,size(xseg,1));
 
-%  write each element as a polygon
+%  write each segment as a linestring
 
     disp(['Writing ' num2str(size(xseg,1)) ' partition segments as KML linestrings.']);
@@ -289,4 +291,40 @@
 end
 
+%  write folder for partition edges
+
+if (~exist('prtplt','var') || strncmpi(prtplt,'on' ,2) || strncmpi(prtplt,'y',1)) && ...
+    md.npart
+    [edgeadj,edgeuns,elemuns]=edgeadjacency(md.elements,md.nodeconnectivity);
+    fprintf(fid,'    <Folder>\n');
+    fprintf(fid,'      <name>Partition Edges</name>\n');
+    fprintf(fid,'      <visibility>1</visibility>\n');
+    fprintf(fid,'      <description>Partitions=%d, Edges=%d</description>\n',...
+        md.npart,size(edgeuns,1));
+
+%  write each partition edge as a linestring
+
+    disp(['Writing ' num2str(size(edgeuns,1)) ' partition edges as KML linestrings.']);
+    for i=1:size(edgeuns,1)
+        fprintf(fid,'      <Placemark>\n');
+        fprintf(fid,'        <name>Edge %d</name>\n',i);
+        fprintf(fid,'        <visibility>1</visibility>\n');
+        fprintf(fid,'        <styleUrl>#RedLineRedPoly</styleUrl>\n');
+        fprintf(fid,'        <LineString>\n');
+        fprintf(fid,'          <extrude>1</extrude>\n');
+        fprintf(fid,'          <tessellate>1</tessellate>\n');
+        fprintf(fid,'          <altitudeMode>relativeToGround</altitudeMode>\n');
+        fprintf(fid,'          <coordinates>\n');
+        for j=1:2
+            [lat(j),long(j)]=mapxy(md.x(edgeuns(i,j)),md.y(edgeuns(i,j)),'s');
+            fprintf(fid,'            %0.16g,%0.16g,%0.16g\n',long(j),lat(j),alt);
+        end
+
+        fprintf(fid,'          </coordinates>\n');
+        fprintf(fid,'        </LineString>\n');
+        fprintf(fid,'      </Placemark>\n');
+    end
+    fprintf(fid,'    </Folder>\n');
+end
+
 %  write trailer data
 
