[vtkusers] (no subject)

Thompson, David C dcthomp at sandia.gov
Thu Oct 11 04:39:57 EDT 2007


Good very late night everyone,

    I've just checked in a change to the vtkAbstractArray class. Each array
you create now contains an (initially NULL) pointer to a vtkInformation
object. This doesn't significantly change the size of vtkAbstractArray
objects and provides a nice way to annotate arrays with additional
information. The SetInformation() member function is protected (you may not
assign an information object to an array). If a vtkInformation object does
not exist when you call GetInformation(), one will be created for you and
its address returned. Thus you should always use GetInformation(), even from
within vtkAbstractArray and its descendants.

    The vtkDataArray has had the member variables that stored per-component
range information removed; this information is now stored in the
vtkInformation object associated with the array. When ComputeRange( int c )
is called, the c-th component range is computed and stored in a
vtkInformationVector object associated with the vtkDataArray::PER_COMPONENT
key. The c-th entry of that vector is a double vector with two entries
(min/max) associated with the vtkDataArray::COMPONENT_RANGE key. If you
request the L2 norm (c == -1), then a two-entry double vector associated with
the vtkDataArray::L2_NORM_RANGE is stored in the array's Information object.
You should not have to worry about this in general, however if you plan to
use the array's Information object, you must be aware that the information
object's MTime is compared to the array's MTime to decide whether the
range needs to be recomputed. So, if you are about to modify the information
object, you should compare its MTime to the array's MTime and either
1. Mark the computed ranges as invalid (i.e., [VTK_MAX_DOUBLE,VTK_MIN_DOUBLE]),
2. Recompute the ranges, or
3. Remove the information keys holding the ranges.
Otherwise, the ranges may not be synchronized with the array values. While
this may sound like a bit of a hassle, it ends up reducing the size of 
vtkDataArray objects thusly:

  Before adding Information and removing ComponentRange cache in favor of
  PER_COMPONENT, COMPONENT_RANGE, and L2_NORM_RANGE:
      sizeof(AbstractArray)=72
      sizeof(vtkStringArray)=96
      sizeof(vtkDataArray)=360
      sizeof(vtkDoubleArray)=400
  After:
      sizeof(AbstractArray)=80
      sizeof(vtkStringArray)=104
      sizeof(vtkDataArray)=104
      sizeof(vtkDoubleArray)=144
  (These sizes are on a 64-bit system.)

When vtkAbstractArray::DeepCopy() is called, the vtkInformation object is
deep copied as well. One remaining issue is how filters deal with the
vtkInformation object when passing arrays from input to output. Currently
filters ignore the information object. In the future, this behavior may
change. A note has been added to the member documentation on the
appropriate members of vtkDataSetAttributes (CopyAllocate and CopyData).
If you have any good ideas on how information can be copied while
maintaining consistency and without modifying every filter in VTK, please
let me know. You should also let me know if you encounter any problems
with the change or have (constructive) criticism.

    Thanks,
    David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20071011/75c7e1aa/attachment.htm>


More information about the vtkusers mailing list