Index: /issm/trunk/src/m/classes/public/modelextract.m
===================================================================
--- /issm/trunk/src/m/classes/public/modelextract.m	(revision 3582)
+++ /issm/trunk/src/m/classes/public/modelextract.m	(revision 3583)
@@ -136,4 +136,20 @@
 		md2.z2d=md1.z(pos_grid_2d);
 	end
+
+	%Edges
+	if size(md2.edges,2)>1, %do not use ~isnan because there are some NaNs...
+		%renumber first two columns
+		md2.edges(:,1)=Pgrid(md2.edges(:,1)); 
+		md2.edges(:,2)=Pgrid(md2.edges(:,2)); 
+		md2.edges(:,3)=Pelem(md2.edges(:,3));
+		%remove column where the first element is not in the domain
+		md2.edges=md2.edges(find(md2.edges(:,1) & md2.edges(:,2) & md2.edges(:,3)),:);
+		%now we must renumber the second column and put NaN if the element is not in the domain
+		A=md2.edges(:,4);
+		A(find(~isnan(A)))=Pelem(A(find(~isnan(A))));
+		A(find(A==0))=NaN;
+		md2.edges(:,4)=A; clear A;
+	end
+
 
 	%Penalties
