The originally intended use of mapping nodes was to allow a layer of abstraction in the process of applying a transformation (or transfer function) to a vector of data. Thus the programmer creates a mapping node and gives it a logical name (e.g. "8-bit Quantized Temperature" if what it's doing is quantizing temperature to 8 bits.). Following this (or upon construction), s/he may assign a vector of data, and or a mapping function. Then comes time to actually do work with the mapping node.
There are three methods that actually perform work with the mapping node, only two of which have currently been implemented. The first is mapValue() which takes a double and converts it to an int by way of the assigned mapping transform. If no transformation has been assigned, the program exits with error 1 after printing a message that tells you that no mapping function has been assigned. The second is mapAllData() which takes a PackedGlyph array, the length of that array, and an integer indicating which "field" of the PackedGlyph this transforms into. This method iterates through the data vector pointed to by the mapping node and for each value, applies the mapping transform and places the value in the appropriate slot in the PackedGlyph.
// // MappingNode.H - The Mapping Node Class // // James M. Kukla, UMBC CSEE // // $Id: MappingNode.H,v 1.2 1998/02/26 18:42:15 panda Exp $ #ifndef SFA_MAPPING_NODE_H #define SFA_MAPPING_NODE_H 1 static char rcsid[] = "$Id: MappingNode.H,v 1.2 1998/02/26 18:42:15 panda Exp $"; #include#include #include "Defines.H" #include "String.H" #include "PackedGlyph.H" // Define a function type for a generic Mapping Operation typedef int (* MappingFunction)(double); // Note: The MappingNode's pointers point to data of which it is the SECONDARY owner. // By this I mean that we're a reference to someone else's data and we DO NOT UNDER ANY // CIRCUMSTANCES DELETE THEM! class MappingNode { public: MappingNode(String l, double *da=NULL, MappingFunction op=NULL) : label(l), data_array(da), mapping_function(op), data_location_index(-1) {}; // Mutators void setDataArray(double *d) ; void setDataArrayIndex(int i) { data_location_index = i; } void setMappingFunction(MappingFunction op) ; void setLabel(String s) ; // Accessors double * getDataArray(void) ; MappingFunction getMappingFunction(void) ; String getLabel(void) ; int getDataArrayIndex(void) { return data_location_index; } // Other operations int mapValue(double d); int mapAllData(PackedGlyph *pg, int num_glyphs, int byte_offset, int pack_size); int mapAllData(PackedGlyph *pg, int num_glyphs, int field); private: double *data_array; MappingFunction mapping_function; String label; int data_location_index; }; #endif
Note that because this is sharing this data array it should NOT be free()-ed after passing it to this function and should never be free()-ed in the MappingNode destructor.
There are no error conditions for this method.
Correctness here is up to the user: there is no guarantee from the software's point of view that the index and the array will actually correspond.
Note that this is not needed except for time sequence data sets. The purpose of this method is automate the process of jumping from time step to time step among "parallel" arrays of data.
There are no error conditions for this method.
There are no error conditions for this method.
Correctness is the burder of the user: There is no guarantee that the name give to the node is meaningful, useful, or corresponds in any way to the actual purpose of the node instance.
If no mapping_function is defined, a fatal error is given and the program exits printing an error message.
If successful, this function returns SFA_OK.
If there are no data assigned to this MappingNode (data_array == NULL) or if there is no mapping function (mapping_function == NULL) an error is printed. Since this is a non-fatal error, SFA_OK is returned.
NOTE: Currently this method`s body is commented out, thus this method does nothing. Please consult the latest version of the file MappingNode.H to see if this is still the case and update the documentation once this function is operational.