[GRASS-SVN] r46712 - in grass-addons/raster: . r.colors.out_vtk
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jun 15 05:34:25 EDT 2011
Author: hamish
Date: 2011-06-15 02:34:25 -0700 (Wed, 15 Jun 2011)
New Revision: 46712
Added:
grass-addons/raster/r.colors.out_vtk/
grass-addons/raster/r.colors.out_vtk/Makefile
grass-addons/raster/r.colors.out_vtk/r.colors.out_vtk
Log:
new module: r.colors.out_vtk for VTK colormaps
Added: grass-addons/raster/r.colors.out_vtk/Makefile
===================================================================
--- grass-addons/raster/r.colors.out_vtk/Makefile (rev 0)
+++ grass-addons/raster/r.colors.out_vtk/Makefile 2011-06-15 09:34:25 UTC (rev 46712)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../..
+
+PGM = r.colors.out_vtk
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script
Property changes on: grass-addons/raster/r.colors.out_vtk/Makefile
___________________________________________________________________
Added: svn:mime-type
+ text/x-makefile
Added: svn:eol-style
+ native
Added: grass-addons/raster/r.colors.out_vtk/r.colors.out_vtk
===================================================================
--- grass-addons/raster/r.colors.out_vtk/r.colors.out_vtk (rev 0)
+++ grass-addons/raster/r.colors.out_vtk/r.colors.out_vtk 2011-06-15 09:34:25 UTC (rev 46712)
@@ -0,0 +1,124 @@
+#!/bin/sh
+
+############################################################################
+#
+# MODULE: r.colors.out_vtk
+# AUTHOR(S): Hamish Bowman
+# PURPOSE:
+# COPYRIGHT: (c) 2011 Hamish Bowman and Rhe GRASS Development Team
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+############################################################################
+#
+# instructions:
+# http://www.vtk.org/Wiki/Manually_Creating_a_Colormap
+#
+# examples:
+# normalized:
+# <ColorMap name="Black-Body Radiation" space="RGB">
+# <Point x="0" o="0" r="0" g="0" b="0"/>
+# <Point x="0.4" o="0.4" r="0.901961" g="0" b="0"/>
+# <Point x="0.8" o="0.8" r="0.901961" g="0.901961" b="0"/>
+# <Point x="1" o="1" r="1" g="1" b="1"/>
+# </ColorMap>
+#
+# absolute:
+# <ColorMap name="Consistency" space="RGB">
+# <Point x="-1.000" o="1" r="0.0" g="0.0" b="0.0"/>
+# <Point x="0.000" o="1" r="0.0" g="1.0" b="0.0"/>
+# <Point x="1.000" o="1" r="1.0" g="0.0" b="0.0"/>
+# </ColorMap>
+#
+
+#%Module
+#% description: Exports the color table associated with a raster map layer to a VTK XML file.
+#% keywords: raster, export, color table, VTK
+#%End
+#%Flag
+#% key: n
+#% description: Normalize range for generic use
+#%End
+#%Option
+#% key: map
+#% type: string
+#% required: yes
+#% multiple: no
+#% key_desc: name
+#% description: Name of input raster map
+#% gisprompt: old,cell,raster
+#%End
+#%Option
+#% key: output
+#% type: string
+#% required: yes
+#% multiple: no
+#% key_desc: name
+#% description: Name of output XML colormap file
+#% gisprompt: new_file,file,output
+#%End
+
+if [ -z "$GISBASE" ] ; then
+ echo "You must be in GRASS GIS to run this program." 1>&2
+ exit 1
+fi
+
+if [ "$1" != "@ARGS_PARSED@" ] ; then
+ exec g.parser "$0" "$@"
+fi
+
+if [ ! -x `which r.colors.out` ] ; then
+ g.message -e "You need a newer version of GRASS to use this."
+ exit 1
+fi
+
+
+# --overwrite test
+if [ -e "$GIS_OPT_OUTPUT" ] ; then
+ if [ -z "$GRASS_OVERWRITE" ] || [ "$GRASS_OVERWRITE" -ne 1 ] ; then
+ g.message -e "File <$GIS_OPT_OUTPUT> already exists"
+ exit 1
+ fi
+fi
+
+#
+# test here if input map actually exists?
+#
+
+
+echo "<ColorMap name=\"$GIS_OPT_MAP\" space=\"RGB\">" > "$GIS_OPT_OUTPUT"
+
+
+if [ $GIS_FLAG_N -eq 1 ] ; then
+
+ eval `r.info -r "$GIS_OPT_INPUT"`
+
+ r.colors.out -p map="$GIS_OPT_INPUT" rules=- | \
+ tr ':' ' ' | awk -v MIN="$min" -v MAX="$max" \
+ '{ VALUE = ($1 - MIN)/(MAX - MIN)
+ printf("<Point x=\"%g\" o=\"%g\" r=\"%.3f\" g=\"%.3f\" b=\"%.3f\"/>\n", \
+ VALUE, VALUE, $2/255., $3/255., $4/255.)}' \
+ >> "$GIS_OPT_OUTPUT"
+
+ RCO_EXITCODE=$?
+else
+ r.colors.out map="$GIS_OPT_INPUT" rules=- | \
+ tr ':' ' ' | awk '{printf("<Point x=\"%g\" o=\"1\" r=\"%.3f\" g=\"%.3f\" b=\"%.3f\"/>\n", \
+ $1, $2/255., $3/255., $4/255.)}' >> "$GIS_OPT_OUTPUT"
+
+ RCO_EXITCODE=$?
+fi
+
+echo "</ColorMap>" >> "$GIS_OPT_OUTPUT"
+
+
+#done!
+exit $RCO_EXITCODE
Property changes on: grass-addons/raster/r.colors.out_vtk/r.colors.out_vtk
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ text/x-sh
Added: svn:eol-style
+ native
More information about the grass-commit
mailing list