Index: /issm/branches/trunk-jpl-ad2/src/m/plot/plot_gl.m
===================================================================
--- /issm/branches/trunk-jpl-ad2/src/m/plot/plot_gl.m	(revision 18306)
+++ /issm/branches/trunk-jpl-ad2/src/m/plot/plot_gl.m	(revision 18307)
@@ -14,5 +14,5 @@
 
 %Setup unique directory in present dir: 
-directory=['.webgl'];
+directory=getfieldvalue(options,'webpagename','.webgl');
 database=['./generic/'];
 cd(directory);
@@ -32,4 +32,7 @@
 replacestringinfile('./generic/editables.js','var height_scaling = 60.0;',['var height_scaling = ' num2str(getfieldvalue(options,'height_scaling',60)) ';']);
 
+%size of frame: 
+replacestringinfile('./css/mystyle.css','height: 55%; /*editable*/',['height: ' num2str(getfieldvalue(options,'frame_height',55)) '%; /*editable*/']);
+
 %high resolution: 
 if ~getfieldvalue(options,'highres',0);
@@ -39,4 +42,7 @@
 %ocean zero threshold: 
 replacestringinfile('./generic/editables.js','var ocean_threshold = .001;',['var ocean_threshold = ' num2str(getfieldvalue(options,'ocean_threshold',.001)) ';']);
+
+%intial view angle: 
+replacestringinfile('./generic/editables.js','var view_number_default = 3;',['var view_number_default = ' num2str(getfieldvalue(options,'view_number_default',3)) ';']);
 
 %Deal with mesh and results {{{
Index: /issm/branches/trunk-jpl-ad2/src/m/plot/prepare_gl.m
===================================================================
--- /issm/branches/trunk-jpl-ad2/src/m/plot/prepare_gl.m	(revision 18306)
+++ /issm/branches/trunk-jpl-ad2/src/m/plot/prepare_gl.m	(revision 18307)
@@ -4,9 +4,12 @@
 scriptsdir=['~/issm-projects/visl/externalicelab/fem'];
 if strcmpi(md.mesh.hemisphere','s'),
-	triangulation='/Users/larour/ModelData/BamberDEMAntarctica1km/triangulated/triangulation_15.mat';
+	triangulation='/Users/larour/ModelData/BamberDEMAntarctica1km/triangulated/triangulation_2.mat';
 	radar_image='/Users/larour/ModelData/BamberDEMAntarctica1km/triangulated/radar.png';
+	triangulation_hd='/Users/larour/ModelData/BamberDEMAntarctica1km/triangulated/triangulation_2.mat';
+	geotiff_name_hd=['/u/astrid-r1b/ModelData/MosaicTiffRsat/amm125m_v2_200m.tif'];
 elseif strcmpi(md.mesh.hemisphere','n'),
 	triangulation='/u/astrid-r1b/ModelData/HowatDEMGreenland2012/triangulated/triangulation_15.mat';
 	radar_image='/u/astrid-r1b/ModelData/HowatDEMGreenland2012/triangulated/radar.png';
+	triangulation_hd='/u/astrid-r1b/ModelData/HowatDEMGreenland2012/triangulated/triangulation_2.mat';
 else
 	error('prepare_gl error usage: ''hemisphere'' should be set to ''s'' or ''n''');
@@ -17,5 +20,5 @@
 
 %Setup unique directory in present dir: 
-directory='.webgl';
+directory=getfieldvalue(options,'webpagename','.webgl');
 mkdir(directory);
 cd(directory);
@@ -88,6 +91,7 @@
 fclose(fid);
 %}}}
-%Write high-res Greenland triangulation to disk  {{{
+%Write high-res triangulation to disk  {{{
 if getfieldvalue(options,'highres',0);
+	
 	x0=min(md.mesh.x);
 	x1=max(md.mesh.x);
@@ -124,5 +128,5 @@
 	[status,height]=system(['convert radar_hd.png -format %h info:']); height=str2num(height);
 
-	%get these a powers of 2: 
+	%get these a power of 2: 
 	width=2^(nextpow2(width));
 	height=2^(nextpow2(height));
@@ -133,18 +137,36 @@
 	system(['mv radar_hd.png ' database '/radar_hd.png']);
 
-	%create square mesh initially: 
-	md_temp=squaremesh(model,1,1,100,100);
-
-	%scale:
-	md_temp.mesh.x=x0+md_temp.mesh.x*(x1-x0);
-	md_temp.mesh.y=y0+md_temp.mesh.y*(y1-y0);
-
-	%now refine to better capture surface:
-	hmax=500000;
-	hmin=500;
-	err=2;
-	sobs=InterpFromGridToMesh(x_m,y_m,surface,md_temp.mesh.x,md_temp.mesh.y,0);
-	md_temp=bamg(md_temp,'hmax',hmax,'hmin',hmin,'gradation',10,'field',sobs,'err',err,'splitcorner',1,'KeepVertices',0);
-	sobs=InterpFromGridToMesh(x_m,y_m,surface,md_temp.mesh.x,md_temp.mesh.y,0);
+	%now, extract higher resolution triangulation:
+	trhd=load(triangulation_hd); a=trhd;
+	trhd.xelem=trhd.x(trhd.index)*[1;1;1]/3;
+	trhd.yelem=trhd.y(trhd.index)*[1;1;1]/3;
+	
+	pos_elem=find(x0<=trhd.xelem & trhd.xelem<=x1 & y0<=trhd.yelem & trhd.yelem<=y1);
+	pos_node=sort(unique(trhd.index(pos_elem,:)));
+
+	%keep track of some fields
+	numberofvertices1=length(trhd.x);
+	numberofelements1=length(trhd.index);
+	numberofvertices2=length(pos_node);
+	numberofelements2=length(pos_elem);
+	flag_node=zeros(numberofvertices1,1);
+	flag_node(pos_node)=1;
+
+	%Create Pelem and Pnode (transform old nodes in new nodes and same thing for the elements)
+	Pelem=zeros(numberofelements1,1);
+	Pelem(pos_elem)=[1:numberofelements2]';
+	Pnode=zeros(numberofvertices1,1);
+	Pnode(pos_node)=[1:numberofvertices2]';
+
+	%renumber the elements (some nodes won't exist anymore)
+	index2=trhd.index(pos_elem,:);
+	index2(:,1)=Pnode(index2(:,1));
+	index2(:,2)=Pnode(index2(:,2));
+	index2(:,3)=Pnode(index2(:,3));
+
+	trhd.index=index2;
+	trhd.x=trhd.x(pos_node);
+	trhd.y=trhd.y(pos_node);
+	trhd.surface=trhd.surface(pos_node);
 
 	%write triangulation and surface to disk: 
@@ -154,16 +176,16 @@
 	fprintf(fid,'<!-- index_surface_hd{{{-->\n');
 	fprintf(fid,'var index_surface_hd=[');
-	for i=1:md_temp.mesh.numberofelements-1,
-		fprintf(fid,'[%i, %i, %i],',md_temp.mesh.elements(i,1),md_temp.mesh.elements(i,2),md_temp.mesh.elements(i,3));
-	end
-	fprintf(fid,'[%i, %i, %i]];\n',md_temp.mesh.elements(end,1),md_temp.mesh.elements(end,2),md_temp.mesh.elements(end,3));
+	for i=1:length(trhd.index)-1,
+		fprintf(fid,'[%i, %i, %i],',trhd.index(i,1),trhd.index(i,2),trhd.index(i,3));
+	end
+	fprintf(fid,'[%i, %i, %i]];\n',trhd.index(end,1),trhd.index(end,2),trhd.index(end,3));
 	fprintf(fid,'<!--}}}-->\n');
 	%write x:
 	fprintf(fid,'<!-- x_surface_hd{{{-->\n');
 	fprintf(fid,'var x_surface_hd=[');
-	for i=1:md_temp.mesh.numberofvertices-1,
-		fprintf(fid,'%g,',md_temp.mesh.x(i,1));
-	end
-	fprintf(fid,'%g];\n',md_temp.mesh.x(end,1));
+	for i=1:length(trhd.x)-1,
+		fprintf(fid,'%g,',trhd.x(i,1));
+	end
+	fprintf(fid,'%g];\n',trhd.x(end,1));
 	fprintf(fid,'<!--}}}-->\n');
 
@@ -171,8 +193,8 @@
 	fprintf(fid,'<!-- y_surface_hd{{{-->\n');
 	fprintf(fid,'var y_surface_hd=[');
-	for i=1:md_temp.mesh.numberofvertices-1,
-		fprintf(fid,'%g,',md_temp.mesh.y(i,1));
-	end
-	fprintf(fid,'%g];\n',md_temp.mesh.y(end,1));
+	for i=1:length(trhd.y)-1,
+		fprintf(fid,'%g,',trhd.y(i,1));
+	end
+	fprintf(fid,'%g];\n',trhd.y(end,1));
 	fprintf(fid,'<!--}}}-->\n');
 
@@ -180,11 +202,13 @@
 	fprintf(fid,'<!-- surface_surface_hd{{{-->\n');
 	fprintf(fid,'var surface_surface_hd=[');
-	for i=1:md_temp.mesh.numberofvertices-1,
-		fprintf(fid,'%g,',sobs(i));
-	end
-	fprintf(fid,'%g];\n',sobs(end));
+	for i=1:length(trhd.surface)-1,
+		fprintf(fid,'%g,',trhd.surface(i));
+	end
+	fprintf(fid,'%g];\n',trhd.surface(end));
 	fprintf(fid,'<!--}}}-->\n');
 
 	fclose(fid);
+	a2=trhd;
+	save temp2 a2 a
 else
 	delete([database '/radar_hd.png']);
