test.r3.out.vtk.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # This script tests the export of voxel data
  2. # into the VTK format. Almost all options of
  3. # r3.out.vtk are tested. Validation data for each test
  4. # is located in the module source directory
  5. # We need to set a specific region in the
  6. # @preprocess step of this test. We generate
  7. # raster and voxel data with r.mapcalc and r3.mapcalc
  8. # The region setting should work for UTM and LL test locations
  9. g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3
  10. # Now generate two elevation maps, we have 8 rows and use
  11. # them for elevation computation. The rows are counted from north
  12. # to south. So in the south the elevation must have a maximum.
  13. r.mapcalc --o expr="elev_bottom = row()"
  14. r.mapcalc --o expr="elev_top = row() + 50"
  15. # Now create a voxel map with value = col + row + depth.
  16. r3.mapcalc --o expr="volume = col() + row() + depth()"
  17. # Add null value information
  18. r3.mapcalc --o expr="volume_null = if(row() == 2 || row() == 7, null(), volume)"
  19. # Create the rgb maps
  20. r3.mapcalc --o expr="volume_rgb = volume_null * 5"
  21. # The first @test just exports the volume map as cell and point data
  22. # using alow precision and replaces the default null value with 0
  23. # the created @files should be compared with the reference data.
  24. r3.out.vtk --o input=volume_null output=test_volume_null_1_cells.vtk dp=3 null=0
  25. r3.out.vtk -p --o input=volume_null output=test_volume_null_1_points.vtk dp=3 null=0
  26. # The second @test adds rgb and vector maps. We re-use the created volume map
  27. # for vector creation. The rgb value must range fom 0 - 255. The generated @files
  28. # should be compared with the reference data.
  29. r3.out.vtk --o rgbmaps=volume_rgb,volume_rgb,volume_rgb vectormaps=volume_null,volume_null,volume_null input=volume_null output=test_volume_null_1_cells_rgb_vect.vtk dp=3 null=-1.0
  30. r3.out.vtk -p --o rgbmaps=volume_rgb,volume_rgb,volume_rgb vectormaps=volume_null,volume_null,volume_null input=volume_null output=test_volume_null_1_points_rgb_vect.vtk dp=3 null=-1.0
  31. # The third @test uses raster maps to create volume data with an elevation surface
  32. # The maximum elevation should be in the south. Reference @files are present for validation.
  33. r3.out.vtk -s --o top=elev_top bottom=elev_bottom input=volume_null output=test_volume_null_1_cells_elevation.vtk dp=3 null=0
  34. r3.out.vtk -sp --o top=elev_top bottom=elev_bottom input=volume_null output=test_volume_null_1_points_elevation.vtk dp=3 null=0
  35. # Comparison of references and vtk files
  36. for i in `ls *.ref` ; do
  37. diff $i "`basename $i .ref`.vtk" ;
  38. done
  39. rm *.vtk