<html>
<body>
I doubt that this will fix the seg fault, but shouldn't your DataExtent
be set to <b>0</b>, xdim-1, <b>0</b>, ydim-1, <b>0</b>, zdim-1?<br>
- Amy<br><br>
At 11:41 AM 5/31/2005, Randall Hand wrote:<br>
<blockquote type=cite class=cite cite="">Well, I modified my code to do
the following:<br><br>
xdim = 2191;<br>
ydim = 2191;<br>
zdim = 800;<br>
vtkImageReader *file = vtkImageReader::New();<br>
file->SetFileName(argv[1]);<br>
file->SetDataExtent(1, xdim-1,<br>
1, ydim-1,<br>
1, zdim-1);<br>
file->SetHeaderSize(4);<br>
file->SetDataScalarTypeToUnsignedChar();<br>
file->SetScalarArrayName("data");<br>
file->Update();<br>
PrintStatistics(file->GetOutput());<br><br>
and, sadly, it still segfaults:<br>
[10:39:48am]% dbx imageimport<br>
dbx version 7.3.4 (86441_Nov11 MR) Nov 11 2002 11:31:55<br>
Core from signal SIGSEGV: Segmentation violation<br>
(dbx) where<br>
Thread 0x10000<br>
> 0
::vtkImageReaderUpdate2(vtkImageReader*,vtkImageData*,unsigned
char*,unsigned char*)(self = 0x100375a0, data = 0x100380d0, inPtr =
0x1003adce = "", outPtr = (nil))
["/viz/home/rhand/src/ezViz/Utilities/VTK/IO/vtkImageReader.cxx":333,
0x7b58fb4]<br>
(dbx) quit<br><br>
The data file:<br>
[10:39:58am]% ls -la bytes.CY00000<br>
-rwxr----- 1 rhand erdcvsta
3840384808 May 27 09:01 bytes.CY00000<br><br>
3,840,384,808 bytes. 2191 * 2191 * 800 = 3,840,384,800 .. 4 bytes
header at both the beginning and the end.<br>
<br><br>
On 5/31/05, <b>Amy Squillacote</b>
<<a href="mailto:amy.squillacote@kitware.com">
amy.squillacote@kitware.com</a>> wrote:<br>
<dl>
<dd>Did you try using the SetHeaderSize method in vtkImageReader2 (the
superclass of vtkImageReader)? I know it isn't just specifying a
number of bytes to read, but using that and the SetDataExtent method
(also in vtkImageReader) should do the right thing.<br><br>
<dd>- Amy<br><br>
<br>
<dd>At 10:15 AM 5/31/2005, Randall Hand wrote:<br>
<blockquote type=cite class=cite cite="">
<dd>Ok, I'm looking at this now (computers are finally back online :) ),
and I can't figure out how to set the raw number of bytes to read.
I see SetDataVOI, but nothing to "bypass" that and specify a
number of bytes.<br><br>
<dd>On 5/27/05, Mathieu Malaterre</b>
<<a href="mailto:mathieu.malaterre@kitware.com">
mathieu.malaterre@kitware.com</a>> wrote:
<dl>
<dd>Randall,<br>
<dd> Hum I believe you can read
those bytes but never use it... Could you
<dd>try to read 3,840,384,800 bytes + 4 but set properly the dimension.
If
<dd>you are lucky enough no test is done to check consistency of
datasize
<dd>and dimension of data.<br>
<dd>My 2 cents,
<dd>Mathieu<br>
<dd>Randall Hand wrote:
<dd>> Well, I have an addition 4 bytes at the end of the file to skip
as
<dd>> well.. I suppose I could postprocess & write a new file
without these
<dd>> final 4 bytes, but that's gonna be pretty wasteful of disk
space. Is
<dd>> there a way to skip them?
<dd>>
<dd>>
<dd>>
<dd>> On 5/27/05, *Mathieu Malaterre*
<<a href="mailto:mathieu.malaterre@kitware.com">
mathieu.malaterre@kitware.com</a>
<dd>> <<a href="mailto:%20mathieu.malaterre@kitware.com"> mailto:
mathieu.malaterre@kitware.com</a>>> wrote:
<dd>>
<dd>> Randall,
<dd>>
<dd>
>
Could you instead give vtkImageReader a try. Just specify
<dd>> the lenght of
<dd>> data you want to read: 3,840,384,800
bytes. By default vtkImageReader
<dd>> start reading from the end. Thefore you
are garantee to skip a
<dd>> header if
<dd>> any (4 bytes in your case apparently).
<dd>>
<dd>> HTH
<dd>> Mathieu
<dd>>
<dd>> Randall Hand wrote:
<dd>> > I'm attempting to load a
simple "Brick of Bytes (BoB)" format
<dd>> file into
<dd>> > VTK. It is
2191x2191x800 unsigned chars (3,840,384,800 bytes).
<dd>> With 4
<dd>> > bytes at the beginning that I
have to skip (Gotta love fortran). My
<dd>> > code is like the following:
<dd>> >
<dd>> > if
(stat(argv[1], &file_info) == -1) {
<dd>>
> perror("Unable
to stat file!\n\t");
<dd>>
> return -1;
<dd>> > }
<dd>> > fptr
= fopen(argv[1], "r");
<dd>> > if
((data = (char*)malloc(file_info.st_size)) == NULL) {
<dd>>
> perror("Unable
to allocate memory!\n\t");
<dd>>
> return -1;
<dd>> > }
<dd>> >
dataptr = data;
<dd>> >
fread(dataptr, 1, 4, fptr);
<dd>> >
dataptr += 4;
<dd>> >
printf("\n\n");
<dd>> >
for(int i=0; i<xdim; i++) {
<dd>>
> fread(dataptr,
ydim,zdim, fptr);
<dd>>
> dataptr += (ydim *
zdim);
<dd>> > }
<dd>> >
<dd>> >
vtkImageImport *import = vtkImageImport::New();
<dd>> >
import->AddObserver(vtkCommand::ProgressEvent, progress);
<dd>> >
import->SetDataScalarTypeToUnsignedChar();
<dd>> >
import->SetNumberOfScalarComponents(1);
<dd>> >
import->SetWholeExtent(1, xdim-1,
<dd>>
>
1, ydim-1,
<dd>>
>
1, zdim-1);
<dd>> >
import->SetDataExtentToWholeExtent();
<dd>> >
import->SetImportVoidPointer(data + skip);
<dd>> >
<dd>> >
vtkDataSetWriter *writer = vtkDataSetWriter::New();
<dd>> >
writer->SetInput(import->GetOutput());
<dd>> >
writer->SetFileName("resulting.vtk");
<dd>> >
writer->Write();
<dd>> >
<dd>> >
<dd>> > When I run this, however, the
output VTK file only contains the
<dd>> following:
<dd>> > # vtk DataFile Version 3.0
<dd>> > vtk output
<dd>> > ASCII
<dd>> > DATASET STRUCTURED_POINTS
<dd>> > DIMENSIONS 2191 2191 800
<dd>> > SPACING 1 1 1
<dd>> > ORIGIN 1 1 1
<dd>> >
<dd>> > No data is actually written
to the file. When I try to connect
<dd>> this to
<dd>> > a rendering pipeline or start
querying the resulting vtkDataSet for
<dd>> > properties (Scalar ranges,
number of points, etc) I get strange
<dd>> results
<dd>> > and eventually I get
Segfault/Core dumps. Often times the number of
<dd>> > points listed comes out as a
large negative number, instead of the
<dd>> > 3.8bil that it should be.
<dd>> >
<dd>> > A stack trace of the core
dumps only reveals this:
<dd>> >
<dd>> > [8:50:48am]% dbx imageimport
<dd>> > dbx version 7.3.4
(86441_Nov11 MR) Nov 11 2002 11:31:55
<dd>> > Core from signal SIGSEGV:
Segmentation violation
<dd>> > (dbx) where
<dd>> >
<dd>> > Thread 0x10000
<dd>> > > 0
vtkDataArrayTemplate<unsigned
<dd>> char>::ComputeScalarRange(int)(this
<dd>> > = 0xf4eb83c0, comp = 0)
<dd>> >
<dd>>
["/viz/home/rhand/src/ezViz/Utilities/VTK/Common/vtkDataArrayTemplate.txx":644,
<dd>> > 0x85f2758]
<dd>> > (dbx)
<dd>> > (dbx) quit
<dd>> >
<dd>> >
<dd>> >
<dd>> > --
<dd>> > Randall Hand
<dd>> >
<a href="http://www.yeraze.com">http://www.yeraze.com</a>
<dd>> >
<dd>> >
<dd>> >
<dd>>
------------------------------------------------------------------------
<dd>> >
<dd>> >
_______________________________________________
<dd>> > This is the private VTK
discussion list.
<dd>> > Please keep messages
on-topic. Check the FAQ at:
<dd>>
<a href="http://www.vtk.org/Wiki/VTK_FAQ">
http://www.vtk.org/Wiki/VTK_FAQ</a>
<dd>> > Follow this link to
subscribe/unsubscribe:
<dd>> >
<a href="http://www.vtk.org/mailman/listinfo/vtkusers">
http://www.vtk.org/mailman/listinfo/vtkusers </a>
<dd>>
<dd>>
<dd>>
<dd>>
<dd>> --
<dd>> Randall Hand
<dd>> <a href="http://www.yeraze.com">http://www.yeraze.com</a>
<<a href="http://www.yeraze.com/" eudora="autourl">
</a><a href="http://www.yeraze.com/" eudora="autourl">
http://www.yeraze.com</a>><br><br>
</dl><br><br>
<br>
<dd>-- <br>
<dd>Randall Hand<br>
<dd><a href="http://www.yeraze.com">http://www.yeraze.com</a> <br>
<dd>_______________________________________________<br>
<dd>This is the private VTK discussion list. <br>
<dd>Please keep messages on-topic. Check the FAQ at:
<a href="http://www.vtk.org/Wiki/VTK_FAQ">
http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<dd>Follow this link to subscribe/unsubscribe:<br>
<dd><a href="http://www.vtk.org/mailman/listinfo/vtkusers">
http://www.vtk.org/mailman/listinfo/vtkusers</a></blockquote><br>
</dl><br><br>
<br>
-- <br>
Randall Hand<br>
<a href="http://www.yeraze.com">http://www.yeraze.com</a>
</blockquote></body>
</html>