Skip to content

Commit

Permalink
modules: Always use current major version in VTK outputs (r.out.vtk, …
Browse files Browse the repository at this point in the history
…r3.out.vtk, v.out.vtk) (#2343)

r.out.vtk, r3.out.vtk, and v.out.vtk include software name in the VTK header line for the 'exported from' description text. This removes the hard-coded major version from the string and uses the current major version instead.
  • Loading branch information
wenzeslaus authored Feb 15, 2023
1 parent 8b6cd94 commit b59a047
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 19 deletions.
7 changes: 4 additions & 3 deletions raster/r.out.vtk/writeascii.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ void write_vtk_normal_header(FILE *fp, struct Cell_head region,

/*Simple vtk ASCII header */
fprintf(fp, "# vtk DataFile Version 3.0\n");
fprintf(fp, "GRASS GIS 7 Export\n");
/* The header line describes the data. */
fprintf(fp, "GRASS GIS %i Export\n", GRASS_VERSION_MAJOR);
fprintf(fp, "ASCII\n");
fprintf(fp, "DATASET STRUCTURED_POINTS\n"); /*We are using the structured
point dataset. */
Expand Down Expand Up @@ -104,7 +105,7 @@ void write_vtk_structured_elevation_header(FILE *fp, struct Cell_head region)

/*Simple vtk ASCII header */
fprintf(fp, "# vtk DataFile Version 3.0\n");
fprintf(fp, "GRASS GIS 7 Export\n");
fprintf(fp, "GRASS GIS %i Export\n", GRASS_VERSION_MAJOR);
fprintf(fp, "ASCII\n");
fprintf(fp, "DATASET STRUCTURED_GRID\n"); /*We are using the structured grid
dataset. */
Expand All @@ -122,7 +123,7 @@ void write_vtk_polygonal_elevation_header(FILE *fp, struct Cell_head region)

/*Simple vtk ASCII header */
fprintf(fp, "# vtk DataFile Version 3.0\n");
fprintf(fp, "GRASS GIS 7 Export\n");
fprintf(fp, "GRASS GIS %i Export\n", GRASS_VERSION_MAJOR);
fprintf(fp, "ASCII\n");
fprintf(fp, "DATASET POLYDATA\n"); /*We are using polydataset. */
fprintf(fp, "POINTS %i float\n", region.cols * region.rows);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ r3.mapcalc --o expr="volume_rgb = volume_null * 5"
# The first @test just exports the volume map as cell and point data
# using alow precision and replaces the default null value with 0
# the created @files should be compared with the reference data.
r3.out.vtk --o input=volume_null output=test_volume_null_1_cells.vtk dp=3 null=0
r3.out.vtk -p --o input=volume_null output=test_volume_null_1_points.vtk dp=3 null=0
r3.out.vtk --o input=volume_null output=test_volume_null_1_cells.vtk precision=3 null=0
r3.out.vtk -p --o input=volume_null output=test_volume_null_1_points.vtk precision=3 null=0

# The second @test adds rgb and vector maps. We re-use the created volume map
# for vector creation. The rgb value must range fom 0 - 255. The generated @files
# should be compared with the reference data.
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
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
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 precision=3 null=-1.0
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 precision=3 null=-1.0

# The third @test uses raster maps to create volume data with an elevation surface
# The maximum elevation should be in the south. Reference @files are present for validation.
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
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
r3.out.vtk -s --o top=elev_top bottom=elev_bottom input=volume_null output=test_volume_null_1_cells_elevation.vtk precision=3 null=0
r3.out.vtk -sp --o top=elev_top bottom=elev_bottom input=volume_null output=test_volume_null_1_points_elevation.vtk precision=3 null=0

# Comparison of references and vtk files
for i in `ls *.ref` ; do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# vtk DataFile Version 3.0
GRASS GIS 7 Export
GRASS GIS 8 Export
ASCII
DATASET STRUCTURED_POINTS
DIMENSIONS 13 9 6
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# vtk DataFile Version 3.0
GRASS GIS 7 Export
GRASS GIS 8 Export
ASCII
DATASET UNSTRUCTURED_GRID
POINTS 3840 float
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# vtk DataFile Version 3.0
GRASS GIS 7 Export
GRASS GIS 8 Export
ASCII
DATASET STRUCTURED_POINTS
DIMENSIONS 13 9 6
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# vtk DataFile Version 3.0
GRASS GIS 7 Export
GRASS GIS 8 Export
ASCII
DATASET STRUCTURED_POINTS
DIMENSIONS 12 8 5
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# vtk DataFile Version 3.0
GRASS GIS 7 Export
GRASS GIS 8 Export
ASCII
DATASET STRUCTURED_GRID
DIMENSIONS 12 8 5
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# vtk DataFile Version 3.0
GRASS GIS 7 Export
GRASS GIS 8 Export
ASCII
DATASET STRUCTURED_POINTS
DIMENSIONS 12 8 5
Expand Down
7 changes: 4 additions & 3 deletions raster3d/r3.out.vtk/writeVTKHead.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ void write_vtk_structured_point_header(FILE *fp, char *vtkFile UNUSED,
/*Simple vtk ASCII header */

fprintf(fp, "# vtk DataFile Version 3.0\n");
fprintf(fp, "GRASS GIS 7 Export\n");
/* The header line describes the data. */
fprintf(fp, "GRASS GIS %i Export\n", GRASS_VERSION_MAJOR);
fprintf(fp, "ASCII\n");
fprintf(fp, "DATASET STRUCTURED_POINTS\n"); /*We are using the structured
point dataset. */
Expand Down Expand Up @@ -100,7 +101,7 @@ void write_vtk_structured_grid_header(FILE *fp, char *vtkFile UNUSED,
3,
"write_vtk_structured_grid_header: Writing VTKStructuredGrid-Header");
fprintf(fp, "# vtk DataFile Version 3.0\n");
fprintf(fp, "GRASS GIS 7 Export\n");
fprintf(fp, "GRASS GIS %i Export\n", GRASS_VERSION_MAJOR);
fprintf(fp, "ASCII\n");
fprintf(fp, "DATASET STRUCTURED_GRID\n"); /*We are using the structured grid
dataset. */
Expand All @@ -122,7 +123,7 @@ void write_vtk_unstructured_grid_header(FILE *fp, char *vtkFile UNUSED,
G_debug(3, "write_vtk_unstructured_grid_header: Writing "
"VTKUnstructuredGrid-Header");
fprintf(fp, "# vtk DataFile Version 3.0\n");
fprintf(fp, "GRASS GIS 7 Export\n");
fprintf(fp, "GRASS GIS %i Export\n", GRASS_VERSION_MAJOR);
fprintf(fp, "ASCII\n");
fprintf(fp, "DATASET UNSTRUCTURED_GRID\n"); /*We are using the unstructured
grid dataset. */
Expand Down
4 changes: 3 additions & 1 deletion vector/v.out.vtk/head.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ int write_vtk_head(FILE *fp, struct Map_info *Map)
{
G_debug(3, _("writeVTKHeader: Writing VTK-Header"));
fprintf(fp, "# vtk DataFile Version 3.0\n");
fprintf(fp, "GRASS GIS 7 vector map: %s\n", Map->name);
/* The header line describes the data. */
fprintf(fp, "GRASS GIS %d vector map: %s\n", GRASS_VERSION_MAJOR,
Map->name);
fprintf(fp, "ASCII\n");
fprintf(fp, "DATASET POLYDATA\n"); /*We are using polydata. If Volume data
is supported, uGrid should be used */
Expand Down

0 comments on commit b59a047

Please sign in to comment.