Package: libvtk5
Version: 5.0.1-4
Severity: normal

Hi!

I found a bug in VTK library: it fails to correctly read two-dimensional
PLOT3D solution (Q) files.


Steps to reproduce the bug (using MayaVi, version 1.5-4):

  Extract the attached gzipped tar archive (which includes a test PLOT3D
  geometry+solution pair of files, along with a Fortran77 program that
  generates it)

  $ tar xvzf VTK_PLOT3D_testcase.tar.gz
  fakehurr_merid.q
  fakehurr_merid.xyz
  gen_fakehurr.f
  $ mayavi

  Using menus, select File -> Open -> PLOT3D file -> Multi-block file.
  As XYZ Co-ordinate file, select `fakehurr_merid.xyz'; as Q Solution
  file, select `fakehurr_merid.q'.
  In the configuration dialog window, select, say, density and momentum,
  and then click on the More Options button.  In the detailed dialog
  window, check BinaryFileOn, DebugOn, DoNotReduceNumberOfOutputsOn,
  HasByteCountOn, MultiGridOn, TwoDimensionalGeometryOn; *un*check
  the other checkboxes (that is to say: AbortExecuteOn, ForceReadOn,
  IBlankingOn, ReleaseDataFlagOn).  Select SetByteOrderToLittleEndian
  and click on the Ok button.
  Back in the configuration dialog window, click on the Re-read data
  file button.
  On stderr, various vtkPLOT3DReader debug messages appear, among which:

  : setting ErrorCode to 0
  : Geometry number of grids: 1
  : Geometry, block 0 dimensions: 31 41 1
  : Q number of grids: 1
  : Q, block 0 dimensions: 31 41 8
  : setting ErrorCode to 20005
  : Geometry and data dimensions do not match. Data file may be corrupt.

  VTK wrongly thinks that the Q block has 31x41x8 nodes, while
  it actually has 31x41x1 nodes (being two-dimensional).
  Hence the dimension mismatch between geometry and data.

  Trying to visualize data fails.  For instance, using menus, select
  Visualize -> Modules -> ContourGridPlane: selecting Z-axis and
  checking Show Contours in the configuration dialog window fails
  to show any contours.


Now the good news: I studied the vtkPLOT3DReader source code and
detected the cause of this bug.
A patch against VTK version 5.0.1 is attached: it fixes this bug for
both vtkPLOT3DReader and vtkMultiBlockPLOT3DReader classes.  While I
was at it, I also discarded some useless variable loading in some
PLOT3D functions, fixed a misleading debug message, fixed a macro
definition in order to make it correct from a fluid dynamics point of
view (even though this has currently no practical effect, since
the extraneous multiplying factor is 1.0), and fixed some comments.


OK, I hope this patch can be applied to vtk Debian package and also
incorporated into the official VTK development branch.


Finally the legal details.
I'm not sure that my contribution to VTK is creative enough to grant
copyright protection.  Anyway, should it be found to be copyrighted,
I hereby release it under the same terms as the rest of VTK, that is
to say:

| Copyright (c) 1993-2003 Ken Martin, Will Schroeder, Bill Lorensen 
| Copyright (c) 2006 Francesco Poli
| All rights reserved.
| 
| Redistribution and use in source and binary forms, with or without
| modification, are permitted provided that the following conditions are met:
| 
|  * Redistributions of source code must retain the above copyright notice,
|    this list of conditions and the following disclaimer.
| 
|  * Redistributions in binary form must reproduce the above copyright notice,
|    this list of conditions and the following disclaimer in the documentation
|    and/or other materials provided with the distribution.
| 
|  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
|    of any contributors may be used to endorse or promote products derived
|    from this software without specific prior written permission.
| 
|  * Modified source versions must be plainly marked as such, and must not be
|    misrepresented as being the original software.
| 
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
| AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
| ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
| ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
| DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
| CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
| OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Moreover, in order to comply with the license of the rest of VTK, I must
explicitly mark as modified the source version of VTK which can be
obtained by applying my patch to the original VTK source version 5.0.1.
Changes to VTK source code done by Francesco Poli in order to fix bugs:

 * IO/vtkPLOT3DReader.cxx
    -> fixed a bug in ReadQHeader() that prevented 2D files to be read
    -> discarded useless StagnationEnergy loading in some PLOT3D function
       computation methods
    -> fixed a debug message
    -> fixed VTK_PINF macro definition (irrelevant as long as
       VTK_RHOINF is 1.0, but anyway...)
    -> fixed some wrong comments

 * IO/vtkMultiBlockPLOT3DReader.cxx
    -> fixed a bug in ReadQHeader() that prevented 2D files to be read
    -> discarded useless StagnationEnergy loading in some PLOT3D function
       computation methods
    -> fixed a debug message
    -> fixed VTK_PINF macro definition (irrelevant as long as
       VTK_RHOINF is 1.0, but anyway...)
    -> fixed some wrong comments




-- System Information:
Debian Release: 3.1
Architecture: i386 (i686)
Kernel: Linux 2.4.33.3
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1)

Versions of packages libvtk5 depends on:
ii  libc6              2.3.2.ds1-22sarge4    GNU C Library: Shared libraries an
ii  libexpat1          1.95.8-3              XML parsing C library - runtime li
ii  libfreetype6       2.1.7-6               FreeType 2 font engine, shared lib
ii  libgcc1            1:3.4.3-13sarge1      GCC support library
ii  libice6            4.3.0.dfsg.1-14sarge2 Inter-Client Exchange library
ii  libjpeg62          6b-10                 The Independent JPEG Group's JPEG 
ii  libpng12-0         1.2.8rel-1            PNG library - runtime
ii  libsm6             4.3.0.dfsg.1-14sarge2 X Window System Session Management
ii  libstdc++5         1:3.3.5-13            The GNU Standard C++ Library v3
ii  libtiff4           3.7.2-7               Tag Image File Format (TIFF) libra
ii  libx11-6           4.3.0.dfsg.1-14sarge2 X Window System protocol client li
ii  libxext6           4.3.0.dfsg.1-14sarge2 X Window System miscellaneous exte
ii  libxt6             4.3.0.dfsg.1-14sarge2 X Toolkit Intrinsics
ii  xlibmesa-gl [libgl 4.3.0.dfsg.1-14sarge2 Mesa 3D graphics library [XFree86]
ii  xlibs              4.3.0.dfsg.1-14sarge2 X Keyboard Extension (XKB) configu
ii  zlib1g             1:1.2.2-4.sarge.2     compression library - runtime

-- no debconf information

Attachment: VTK_PLOT3D_testcase.tar.gz
Description: Binary data

Attachment: VTK_version_5.0.1_PLOT3Dbugfixes.diff.gz
Description: Binary data

Reply via email to