You're right.. i've been messing with those numbers thinking I was
violating my extents or an array boundary.. it hasn't helped tho.<br><br><div><span class="gmail_quote">On 5/31/05, <b class="gmail_sendername">Amy Squillacote</b> <<a href="mailto:amy.squillacote@kitware.com">amy.squillacote@kitware.com
</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
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><span class="sg">
- Amy</span><div><span class="e" id="q_104337304330bb04_2"><br><br>
At 11:41 AM 5/31/2005, Randall Hand wrote:<br>
<blockquote type="cite" cite="http://">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" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
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><dd>- Amy<br><br>
<br>
</dd><dd>At 10:15 AM 5/31/2005, Randall Hand wrote:<br>
<blockquote type="cite" cite="http://">
<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><dd>On 5/27/05, Mathieu Malaterre
<<a href="mailto:mathieu.malaterre@kitware.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
mathieu.malaterre@kitware.com</a>> wrote: 
<dl>
<dd>Randall,<br>
</dd><dd>        Hum I believe you can read
those bytes but never use it... Could you 
</dd><dd>try to read 3,840,384,800 bytes + 4 but set properly the dimension.
If
</dd><dd>you are lucky enough no test is done to check consistency of
datasize
</dd><dd>and dimension of data.<br>
</dd><dd>My 2 cents,
</dd><dd>Mathieu<br>
</dd><dd>Randall Hand wrote: 
</dd><dd>> Well, I have an addition 4 bytes at the end of the file to skip
as
</dd><dd>> well.. I suppose I could postprocess & write a new file
without these
</dd><dd>> final 4 bytes, but that's gonna be pretty wasteful of disk
space.  Is 
</dd><dd>> there a way to skip them?
</dd><dd>>
</dd><dd>>
</dd><dd>>
</dd><dd>> On 5/27/05, *Mathieu Malaterre*
<<a href="mailto:mathieu.malaterre@kitware.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
mathieu.malaterre@kitware.com</a>
</dd><dd>> <<a href="mailto:%20mathieu.malaterre@kitware.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"> mailto:
mathieu.malaterre@kitware.com</a>>> wrote:
</dd><dd>>
</dd><dd>>     Randall,
</dd><dd>>
</dd><dd>
>            
Could you instead give vtkImageReader a try. Just specify
</dd><dd>>     the lenght of
</dd><dd>>     data you want to read: 3,840,384,800
bytes. By default vtkImageReader
</dd><dd>>     start reading from the end. Thefore you
are garantee to skip a 
</dd><dd>>     header if
</dd><dd>>     any (4 bytes in your case apparently).
</dd><dd>>
</dd><dd>>     HTH
</dd><dd>>     Mathieu
</dd><dd>>
</dd><dd>>     Randall Hand wrote:
</dd><dd>>      > I'm attempting to load a
simple "Brick of Bytes (BoB)" format 
</dd><dd>>     file into
</dd><dd>>      > VTK.  It is
2191x2191x800 unsigned chars (3,840,384,800 bytes).
</dd><dd>>     With 4
</dd><dd>>      > bytes at the beginning that I
have to skip (Gotta love fortran).  My
</dd><dd>>      > code is like the following: 
</dd><dd>>      >
</dd><dd>>      >     if
(stat(argv[1], &file_info) == -1) {
</dd><dd>>     
>         perror("Unable
to stat file!\n\t");
</dd><dd>>     
>         return -1;
</dd><dd>>      >     }
</dd><dd>>      >     fptr
= fopen(argv[1], "r"); 
</dd><dd>>      >     if
((data = (char*)malloc(file_info.st_size)) == NULL) {
</dd><dd>>     
>         perror("Unable
to allocate memory!\n\t");
</dd><dd>>     
>         return -1;
</dd><dd>>      >     }
</dd><dd>>      >    
dataptr = data;
</dd><dd>>      >    
fread(dataptr, 1, 4, fptr);
</dd><dd>>      >    
dataptr += 4; 
</dd><dd>>      >    
printf("\n\n");
</dd><dd>>      >    
for(int i=0; i<xdim; i++) {
</dd><dd>>     
>         fread(dataptr,
ydim,zdim,  fptr);
</dd><dd>>     
>         dataptr += (ydim *
zdim);
</dd><dd>>      >     }
</dd><dd>>      >
</dd><dd>>      >    
vtkImageImport *import = vtkImageImport::New();
</dd><dd>>      >    
import->AddObserver(vtkCommand::ProgressEvent, progress); 
</dd><dd>>      >    
import->SetDataScalarTypeToUnsignedChar();
</dd><dd>>      >    
import->SetNumberOfScalarComponents(1);
</dd><dd>>      >    
import->SetWholeExtent(1, xdim-1,
</dd><dd>>     
>                           
1, ydim-1,
</dd><dd>>     
>                           
1, zdim-1);
</dd><dd>>      >    
import->SetDataExtentToWholeExtent();
</dd><dd>>      >    
import->SetImportVoidPointer(data + skip);
</dd><dd>>      >
</dd><dd>>      >    
vtkDataSetWriter *writer = vtkDataSetWriter::New(); 
</dd><dd>>      >    
writer->SetInput(import->GetOutput());
</dd><dd>>      >    
writer->SetFileName("resulting.vtk");
</dd><dd>>      >    
writer->Write();
</dd><dd>>      >
</dd><dd>>      >
</dd><dd>>      > When I run this, however, the
output VTK file only contains the
</dd><dd>>     following:
</dd><dd>>      > # vtk DataFile Version 3.0
</dd><dd>>      > vtk output
</dd><dd>>      > ASCII
</dd><dd>>      > DATASET STRUCTURED_POINTS 
</dd><dd>>      > DIMENSIONS 2191 2191 800
</dd><dd>>      > SPACING 1 1 1
</dd><dd>>      > ORIGIN 1 1 1
</dd><dd>>      >
</dd><dd>>      > No data is actually written
to the file.  When I try to connect
</dd><dd>>     this to 
</dd><dd>>      > a rendering pipeline or start
querying the resulting vtkDataSet for
</dd><dd>>      > properties (Scalar ranges,
number of points, etc) I get strange
</dd><dd>>     results
</dd><dd>>      > and eventually I get
Segfault/Core dumps.  Often times the number of 
</dd><dd>>      > points listed comes out as a
large negative number, instead of the
</dd><dd>>      > 3.8bil that it should be.
</dd><dd>>      >
</dd><dd>>      > A stack trace of the core
dumps only reveals this:
</dd><dd>>      > 
</dd><dd>>      > [8:50:48am]% dbx imageimport
</dd><dd>>      > dbx version 7.3.4
(86441_Nov11 MR) Nov 11 2002 11:31:55
</dd><dd>>      > Core from signal SIGSEGV:
Segmentation violation
</dd><dd>>      > (dbx) where
</dd><dd>>      >
</dd><dd>>      > Thread 0x10000
</dd><dd>>      >  >  0
vtkDataArrayTemplate<unsigned
</dd><dd>>     char>::ComputeScalarRange(int)(this
</dd><dd>>      > = 0xf4eb83c0, comp = 0)
</dd><dd>>      >
</dd><dd>>    
["/viz/home/rhand/src/ezViz/Utilities/VTK/Common/vtkDataArrayTemplate.txx":644,
</dd><dd>>      > 0x85f2758]
</dd><dd>>      > (dbx)
</dd><dd>>      > (dbx) quit
</dd><dd>>      >
</dd><dd>>      >
</dd><dd>>      > 
</dd><dd>>      > --
</dd><dd>>      > Randall Hand
</dd><dd>>      >
<a href="http://www.yeraze.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.yeraze.com</a>
</dd><dd>>      >
</dd><dd>>      >
</dd><dd>>      >
</dd><dd>>    
------------------------------------------------------------------------ 
</dd><dd>>      >
</dd><dd>>      >
_______________________________________________
</dd><dd>>      > This is the private VTK
discussion list.
</dd><dd>>      > Please keep messages
on-topic. Check the FAQ at:
</dd><dd>>    
<a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://www.vtk.org/Wiki/VTK_FAQ</a>
</dd><dd>>      > Follow this link to
subscribe/unsubscribe:
</dd><dd>>      >
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://www.vtk.org/mailman/listinfo/vtkusers </a>
</dd><dd>>
</dd><dd>>
</dd><dd>>
</dd><dd>>
</dd><dd>> --
</dd><dd>> Randall Hand
</dd><dd>> <a href="http://www.yeraze.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.yeraze.com</a>
<<a href="http://www.yeraze.com/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
</a><a href="http://www.yeraze.com/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://www.yeraze.com</a>><br><br>
</dd></dl><br><br>
<br>
</dd><dd>-- <br>
</dd><dd>Randall Hand<br>
</dd><dd><a href="http://www.yeraze.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.yeraze.com</a> <br>
</dd><dd>_______________________________________________<br>
</dd><dd>This is the private VTK discussion list. <br>
</dd><dd>Please keep messages on-topic. Check the FAQ at:
<a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://www.vtk.org/Wiki/VTK_FAQ</a><br>
</dd><dd>Follow this link to subscribe/unsubscribe:<br>
</dd><dd><a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://www.vtk.org/mailman/listinfo/vtkusers</a></dd></blockquote><br>
</dd></dl><br><br>
<br>
-- <br>
Randall Hand<br>
<a href="http://www.yeraze.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.yeraze.com</a>
</blockquote>
</span></div></blockquote></div><br><br><br>-- <br>Randall Hand<br><a href="http://www.yeraze.com">http://www.yeraze.com</a>