Index: /issm/trunk/src/m/classes/public/modelextract2.m
===================================================================
--- /issm/trunk/src/m/classes/public/modelextract2.m	(revision 1367)
+++ /issm/trunk/src/m/classes/public/modelextract2.m	(revision 1368)
@@ -1,3 +1,3 @@
-function md2=modelextract2(md1,area,varargin)
+function md2=modelextract2(md1,area)
 %modelextract2 - extract a model according to an Argus contour or flag list
 %
@@ -12,9 +12,8 @@
 %
 %   Usage:
-%      md2=modelextract2(md1,area,varargin);
+%      md2=modelextract2(md1,area);
 %
 %   Examples:
 %      md2=modelextract2(md,'Domain.exp');
-%      md2=modelextract2(md,'Domain.exp',1);
 %      md2=modelextract2(md,md.elementoniceshelf);
 %
@@ -22,10 +21,7 @@
 
 %some checks
-if ((nargin~=2 & nargin~=3) | (nargout~=1)),
+if ((nargin~=2) | (nargout~=1)),
 	help modelextract2
 	error('modelextract2 error message: bad usage');
-end
-if strcmpi(md1.type,'3d'),
-	error('modelextract2 error message: only 2d model supported yet. Use BasinConstrain instead');
 end
 
@@ -87,4 +83,6 @@
 numberofgrids2=length(pos_grid);
 numberofelements2=length(pos_elem);
+flag_grid=zeros(numberofgrids1,1);
+flag_grid(pos_grid)=1;
 
 %Create Pelem and Pgrid (transform old grids in new grids and same thing for the elements)
@@ -138,4 +136,15 @@
 	md2.elements=elements_2;
 
+	%uppernodes lowernodes
+	if strcmpi(md1.type,'3d')
+		md2.uppergrids=md1.uppergrids(pos_grid);
+		pos=find(~isnan(md2.uppergrids));
+		md2.uppergrids(pos)=Pgrid(md2.uppergrids(pos));
+
+		md2.lowergrids=md1.lowergrids(pos_grid);
+		pos=find(~isnan(md2.lowergrids));
+		md2.lowergrids(pos)=Pgrid(md2.lowergrids(pos));
+	end
+
 	%Initial 2d mesh 
 	if strcmpi(md1.type,'3d')
@@ -167,8 +176,8 @@
 
 	%recreate segments
-	md2.segments=findsegments(md2);
-	md2.gridonboundary=zeros(numberofgrids2,1); md1.gridonboundary(md2.segments(:,1:2))=1;
-
-	if ~isnan(md2.elements_type), md2.elements_type=md1.elements_type(pos_elem,:);end
+	if strcmpi(md1.type,'2d')
+		md2.segments=findsegments(md2);
+		md2.gridonboundary=zeros(numberofgrids2,1); md1.gridonboundary(md2.segments(:,1:2))=1;
+	end
 
 	%Boundary conditions: Dirichlets on new boundary
