Compress / uncompress user-chosen arrays in a field.
module Compress_Prim < libdeps = "FLD", hdr_dirs = "/usr/people/zzcgubh/Progs/Index-Zlib/include ../utils_xp", link_files = "-L/usr/local/lib -lz", src_file = "compress.cxx", cxx_hdr_files = "fld/Xfld.h array_fn.h field_fn.h om_fn.h", cxx_src_files = "../utils_xp/array_fn.cxx ../utils_xp/field_fn.cxx ../utils_xp/om_fn.cxx", c_hdr_files = "deflate.h zconf.h zlib.h", c_src_files = "deflate.c" > { int compress_all <NEportLevels={2,0}>; int uncompress_all <NEportLevels={2,0}>; int process_nth <NEportLevels={2,0}>; int nth <NEportLevels={2,0}>; group &data < NEportLevels={2,0},NEx=506.,NEy=253. > { int nnodes; int nspace; Data_Array coordinates { nvals => <-.nnodes; veclen => <-.nspace; float values[.nvals][.veclen]; float min => cache(min_array(magnitude(.values),0,0)); float max => cache(max_array(magnitude(.values),0,0)); float min_vec[.veclen] => cache(min_array(.values,0,0)); float max_vec[.veclen] => cache(max_array(.values,0,0)); }; int+opt ndim; int+opt dims[.ndim]; int+opt npoints; float+opt points[.npoints][.nspace]; int+opt grid_type; int+opt ncell_sets; Cell_Set+opt cell_set[.ncell_sets] { int ncell_data; Data_Array cell_data[.ncell_data] { nvals => <-.ncells; }; }; DefaultXform+opt xform; int+opt nnode_data; Data_Array+opt node_data[.nnode_data] { nvals => <-.nnodes; }; }; cxxmethod+req compress_all_arrays (data+req, compress_all+req+notify); cxxmethod+req uncompress_all_arrays (data+req, uncompress_all+req+notify); cxxmethod+req process_nth_array (data+req, process_nth+req+notify, nth+req); };
Compresses/uncompresses arrays within an AVS/Express field. Any array within the field may be compressed independently - the user chooses an array using an array number to identify which array is to be processed. The array is compressed if it is a normal (i.e. uncompressed) field array. It is uncompressed if it has been previously compressed. Alternatively, all arrays may be compressed, or all arrays may be uncompressed.
Thus, one variable in a large multi-variate data set may be visualised whilst keeping all other variables compressed, or all arrays may be compressed before being subsequently written out to file (e.g. using the write_netCDF module). Note that arrays are compressed at source - a compressed copy of the field is not produced, rather the original arrays within the field are altered to be integer arrays of smaller size. The original types are restored when arrays are uncompressed.
Arrays are numbered starting from 1, and in the following order : grid, node data, cell data and connectivity. Since this module accepts any field or valid field subset, some of these components may be missing in the input data (the only requirement is for the integers nnodes, and nspace to be present, and for the Data_Array coordinates to be present either as an array or a connection to a function). Ordering of arrays within each of these categories is as in the input field. A connectivity array is defined as being the poly_connect_list in a Cell_Set, if it exists, otherwise it is the node_connect_list. The module examine_field may be used to determine which arrays are present in a field, display their sizes and types, and their array numbers.
&data
A reference to the input data, which must be in the form of certain field sub-objects. The following objects must be present in the group : int nnodes, int nspace, Data_Array coordinates. All the other sub-objects of a field are optional. Thus, any valid field or sub-set of a field (e.g. Mesh+Node_Data) will be accepted.
compress_all
Invokes the method to compress all arrays when set to non-zero. Is reset to zero after the method has finished executing.
uncompress_all
Invokes the method to uncompress all arrays when set to non-zero. Is reset to zero after the method has finished executing.
process_nth
Invokes the method to compress or uncompress the nth array when set to non-zero. Is reset to zero after the method has finished executing.
nth
The array number of the array to process when the process_nth parameter is set to non-zero.
There are no outputs. The input field is altered directly at source.
The low-level Compress_Prim module is used in the functional-macro Compress, and in the user-macro compress. Additionally, these macros also use the Compress_Param parameter block group object, as does the Compress_UI macro.
An example application Compress_Eg is provided, which uses the AVS/Express sample data file bluntfin.fld. This data file contains six arrays (one grid plus five node data). Executing compression on any of the arrays can be seen to change the size and type of the array in the field.
iac_proj/compress/compmods.v
contains the V definitions for the Compress_Param group and the Compress_Prim module.
iac_proj/compress/compress.cxx
contains the source code for the primitive module.
iac_proj/compress/deflate.c and iac_proj/compress/deflate.h
contain the source code for functions that access the compression library.
iac_proj/compress/INSTALL
contains instructions on how to add Compress project modules and macros to the IAC library structure.
iac_proj/compress/README
contains instructions on how to compile and install Compress project modules and macros.
Additional files are required for the compression library, and for AVS/Express utility functions (see below).
This module uses the general-purpose compression library Zlib. The source for this library may be obtained from http://www.cdrom.com/pub/infozip/zlib. The instructions given with the source should be followed to produce a linkable library. The link_files
and hdr_dirs
lines in the file iac_proj/compress/compmods.v should be altered (if necessary) to give the position of the library, and of the Zlib header files zlib.h and zconf.h.
The Zlib public-domain compression library uses a combination of the Huffman and LZ77 compression algorithms. This algorithm is very similar to that used in the gzip compression tools.
The module also requires the xp_util AVS/Express utility code files. These may be obtained from http://www.iavsc.org/, and need to be installed in the iac_proj directory according to the instructions given with the package.
It is recommended to use this module together with the Examine_Field project examine_field user macro, which inspects a field and provides brief information on the number of arrays, their ordering, names, sizes etc. The Compress_Tool project provides a user macro which combines the compress and examine_field user macros, and produces a single user-interface. Both projects are available from the iavsc module repository.
If both the Examine_Field project and the Compress project are required, then the cxx_src_files
line in either the examine_field_mods.v file or the compmods.v file should be removed or commented out (these cxx_src_files are common to both projects, which causes errors/warnings when linking if they are specified twice).
Brief compression performance details are written to the AVS/Express VCP window. These messages may be disabled by commenting out / removing the #define VERBOSE
line in the iac_proj/compress/compress.cxx file before compilation of the module.
See the README and INSTALL files for full information about compiling and installing the Compress project modules and macros.
Amardeep S Bhattal. Manchester Visualisation Centre, Manchester Computing, University of Manchester, Oxford Road, Manchester, M13 9PL, UK.
utils_xp, compress, Examine_Field_Prim, examine_field, compress_tool.
This software/documentation was produced as part of the INDEX project (Intelligent Data Extraction) which is funded under contract ESPRIT EP22745 of the European Community. For further details see http://www.man.ac.uk/MVC/research/INDEX/Public/. Copyright (c) June 1998, Manchester Visualisation Centre, UK. All Rights Reserved. Permission to use, copy, modify and distribute this software and its documentation is hereby granted without fee, provided that the above copyright notice and this permission notice appear in all copies of this software / documentation. This software/documentation is provided with no warranty, express or implied, including, without limitation, warrant of merchantability or fitness for a particular purpose.