[cig-commits] commit: improve flt2vtk.sh to read from standard input; update the sampling and extent of vtk files.

Mercurial hg at geodynamics.org
Wed Jul 4 02:39:12 PDT 2012


changeset:   134:4b4b129d1b47
tag:         tip
user:        Sylvain Barbot <sbarbot at caltech.edu>
date:        Wed Jul 04 02:39:05 2012 -0700
files:       src/relax.f90 util/flt2vtk.sh
description:
improve flt2vtk.sh to read from standard input; update the sampling and extent of vtk files.


diff -r 78e39e657aca -r 4b4b129d1b47 src/relax.f90
--- a/src/relax.f90	Mon Jul 02 20:29:30 2012 -0700
+++ b/src/relax.f90	Wed Jul 04 02:39:05 2012 -0700
@@ -407,16 +407,16 @@ PROGRAM relax
      filename=trim(in%wdir)//"/disp-000.vtk"//char(0)
      title="coseismic displacement vector field"//char(0)
      name="displacement"//char(0)
-     CALL exportvtk_vectors_legacy(u1,u2,u3,in%sx1,in%sx2,in%sx3/8,in%dx1,in%dx2,in%dx3, &
-                                   4,4,8,filename,title,name)
+     CALL exportvtk_vectors_legacy(u1,u2,u3,in%sx1,in%sx2,in%sx3/2,in%dx1,in%dx2,in%dx3, &
+                                   4,4,4,filename,title,name)
      !CALL exportvtk_vectors_slice(u1,u2,u3,in%sx1,in%sx2,in%sx3/2,in%dx1,in%dx2,in%dx3,in%oz,8,8,filename)
   END IF
   IF (in%isoutputvtkrelax) THEN
      filename=trim(in%wdir)//"/disp-relax-0000.vtk"//char(0)
      title="postseismic displacement vector field"//char(0)
      name="displacement"//char(0)
-     CALL exportvtk_vectors_legacy(u1r,u2r,u3r,in%sx1,in%sx2,in%sx3/4,in%dx1,in%dx2,in%dx3, &
-                                   4,4,8,filename,title,name)
+     CALL exportvtk_vectors_legacy(u1r,u2r,u3r,in%sx1,in%sx2,in%sx3/2,in%dx1,in%dx2,in%dx3, &
+                                   4,4,4,filename,title,name)
   END IF
 #endif
   IF (ALLOCATED(in%ptsname)) THEN
diff -r 78e39e657aca -r 4b4b129d1b47 util/flt2vtk.sh
--- a/util/flt2vtk.sh	Mon Jul 02 20:29:30 2012 -0700
+++ b/util/flt2vtk.sh	Wed Jul 04 02:39:05 2012 -0700
@@ -4,36 +4,9 @@ self=$(basename $0)
 self=$(basename $0)
 trap 'echo $self: Some errors occurred. Exiting.; exit' ERR
 
-if [ $# -eq 0 ]; then
-        echo "$self converts an .flt file to a vtp polygon"
-	echo "file in xml format for visualization in Paraview"
-	echo ""
-	echo "usage: $self file.flt"
-	echo "       $self file1.flt file2.flt file3.flt "
-	echo ""
-	echo "file foo.flt is converted to foo.vtp"
-	echo "files foo.ext are converted to foo.ext.vtp"
-	echo ""
+flt2vtk(){
 
-	exit
-fi
-
-# loop over list of files to convert
-while [ $# -ne 0 ];do
-
-FLTFILE=$1
-
-if [ ! -e $FLTFILE ]; then
-	echo $self: could not find $FLTFILE. exiting.
-	exit 2
-fi
-
-# define output file name (file.flt is converted to file.vtp, file.ext to file.ext.vtp)
-VTKFILE=$(dirname $1)/$(basename $1 .flt).vtp
-
-echo $self: converting $1 to $VTKFILE
-
-grep -v "#" $FLTFILE | awk '
+	grep -v "#" $FLTFILE | awk '
 	BEGIN{
 		pi=atan2(1,0)*2;
 		printf("<?xml version=\"1.0\"?>\n");
@@ -100,6 +73,46 @@ grep -v "#" $FLTFILE | awk '
 		printf("  </PolyData>\n");
 		printf("</VTKFile>\n");
 	}' > $VTKFILE
+}
 
-	shift
-done
+usage(){
+        echo "$self converts an .flt file to a vtp polygon"
+	echo "file in xml format for visualization in Paraview"
+	echo ""
+	echo "usage: $self file.flt"
+	echo "       $self file1.flt file2.flt file3.flt "
+	echo ""
+	echo "or from the standard input"
+	echo ""
+	echo "       cat file.flt | $self > file.vtp"
+	echo ""
+	echo "file foo.flt is converted to foo.vtp"
+	echo "files foo.ext are converted to foo.ext.vtp"
+	echo ""
+}
+
+if [ -t 0 ] && [ $# -eq 0 ]; then
+	usage
+	exit
+fi
+
+if [ ! -t 0 ]; then
+	FLTFILE=$1
+	VTKFILE=/dev/stdout
+	flt2vtk
+else
+	# loop over list of files to convert
+	while [ $# -ne 0 ];do
+		# define output file name (file.flt is converted to file.vtp, file.ext to file.ext.vtp)
+		VTKFILE=$(dirname $1)/$(basename $1 .flt).vtp
+		FLTFILE=$1
+		if [ ! -e $FLTFILE ]; then
+			echo $self: could not find $FLTFILE. exiting.
+			exit 2
+		fi
+		echo $self: converting $1 to $VTKFILE
+		flt2vtk
+		shift
+	done
+fi
+



More information about the CIG-COMMITS mailing list