[vtkusers] visualizing a vtkRectilinearGrid
tom fogal
tfogal at apollo.sr.unh.edu
Fri Jun 4 15:19:05 EDT 2004
Sorry for more of this thread... hopefully it will help someone trying
to write their own Reader object in the future. It seems I've run in
to a technical C++ issue.
Well, I figured out that I need to allocate a new vtkRectilinearGrid
within my object and then call this->SetOutput() with an argument of
the Grid that I created.
This fixes the DataDescription problem, but brings me back to my
earlier problem!
The [letter]Coordinates arrays are becoming NULL somehow. I think I'm
running into some sort of issue with vtkRectilinearGridGeometryFilter
when I try to SetInput() on it. SetInput actually ends up calling
vtkProcessObject::SetNthInput(0,my_vtkRectilinearGrid) and it all
works out because vtkRectilinearGrid is a descendant of vtkDataObject,
which is what SetNthInput wants for a second argument.
gdb doesn't seem to know the true identity of this vtkDataObject is a
vtkRectilinearGrid. If I try to print
vtkRectilinearGridGeometryFilter::Inputs[0] it tells me that it is a
pointer to a vtkDataObject. If i try to cast it into a
vtkRectilinearGrid, I get "whatever's in memory" for the extra slots
that vtkRectilinearGrids add to vtkDataObjects - including XCoordinates,
YCoordinates, ZCoordinates.
So because of this I'm thinking that somehow during the input-insertion
procedure the vtkRectilinearGrid is losing the full scope of its type.
I'm not exactly sure why though... it seems like a perfectly valid model
for what needs to be done (storing derived objects via an array of
pointers to a parent objects).
Whew. Any C++/VTK guru's are more than welcome to comment...
-tom
<200406041557.i54FvrFY030554 at apollo.sr.unh.edu>tom fogal writes:
>Well, that fixed one of the problems =)
>
>If I add in the allocation for the vtkRectilinearGrid it gets rid of my
>segfault, but I get a new error:
>
>ERROR: In /my/source/dir/vtkRectilinearGrid.cxx, line 416
>vtkRectilinearGrid (0x516910): Requesting a point from an empty data set.
>
>So it appears as if my data set is empty. One would get this message
>when vtkRectilinearGrid::DataDescription = VTK_EMPTY, according to the
>source, and DataDescription is set in SetExtent(), for example. So I called
>SetExtent with the dimensions of my array and then set a breakpoint there -
>the DataDescription is getting set to 8, which is VTK_XYZ_GRID according to
>vtkStructuredData.h
>Yet when it gets time to render the data, DataDescription is suddenly
>VTK_EMPTY? There must be some intermediate call that is changing it...
>
>My code is now like this:
>
> vtkRectilinearGrid *output = (vtkRectilinearGrid*) this->GetOutput();
> output = vtkRectilinearGrid::New();
> output->SetDimensions(dim[IND_X],dim[IND_Y],dim[IND_Z]);
> output->UpdateInformation();
> output->SetWholeExtent(0,391,0,111,0,111);
> output->SetExtent(0,391,0,111,0,111);
> output->SetXCoordinates(rdata[IND_X]);
> output->SetYCoordinates(rdata[IND_Y]);
> output->SetZCoordinates(rdata[IND_Z]);
>
>where dim = {392, 112, 112}.
>I think calling SetWholeExtent() and SetExtent() is redundant, but it doesn't
>seem to matter whether or not I call both, one or the other, or none at all -
>I still get the 'empty data set' error.
>
>Any ideas?
>
>-tom
>
> <4EB6E1738CC2E940BAD2EFBFBF5A38F101C3B208 at OREADE.ipsn.fr>ALIZIER Julien AUSY writes:
>>Hi Tom, hi all,
>>
>>I had a similar problem few months ago when I was testing rectilinear grids.
>>I had to call these lines (//***) in my constructor (without them I was
>>getting a segmentation fault ):
>>
>>vtkRectilinearGrid * myoutput = vtkRectilinearGrid::New();
>>myoutput->SetDimensions(4,5,6);
>>//myoutput->UpdateInformation(); //*** I can't remember if that one is
>>really needed
>>myoutput->SetWholeExtent(0, 1, 0, 2, 0, 3); //*** This one is IMPORTANT
>>
>>
>>Hope this helps
>>
>>-- Julien
>>
>>
>>-----Message d'origine-----
>>De : tom fogal [mailto:tfogal at apollo.sr.unh.edu]
>>Envoyé : jeudi 3 juin 2004 18:42
>>À : vtkusers at vtk.org
>>Objet : [vtkusers] visualizing a vtkRectilinearGrid
>>
>>
>>Hi all, I've managed to create a vtk object for loading a new data
>>format that my group uses. It's derived from vtkRectilinearGridSource,
>>and I can't seem to find a good way to visualize the output so that
>>I can see if I actually got things loaded correctly =)
>>
>>I set the output within the object with code like the following:
>>
>>---
>>vtkRectilinearGrid *output = (vtkRectilinearGrid*) this->GetOutput()
>>output->SetDimensions(x,y,z);
>>output->SetXCoordinates(data[0]);
>>output->SetYCoordinates(data[1]);
>>output->SetZCoordinates(data[2]);
>>---
>>
>>where data is declared like 'vtkFloatArray *data[3]'. I can print out
>>the data within the array and they seem to be good; for example,
>>'print data[0]->Array[0]' works fine (and has the correct data) in
>>gdb.
>>
>>In an attempt to visualize , I create a vtkRectilinearGridGeometryFilter
>>and SetInput() from my Reader's GetOutput(). A PolyDataMapper gets its
>>input from the GeometryFilter's output, and that gets passed to an
>>actor, to a renderer and then displayed.
>>
>>Only I get a segmentation fault when trying to Execute() the filter.
>>It eventually ends up that down in vtkRectilinearGrid::GetPoint I have
>>'XCoordinates' as a NULL pointer and it is dereferenced.
>>
>>Am I doing something wrong here, or forgetting to set some component
>>of my rectilinear grid? I was hoping to get some sort of IsoSurface
>>but I'd settle for just about anything showing up on my screen at this
>>point.
>>
>>Any ideas would be greatly appreciated.
>>
>>-tom
>>_______________________________________________
>>This is the private VTK discussion list.
>>Please keep messages on-topic. Check the FAQ at:
>><http://public.kitware.com/cgi-bin/vtkfaq>
>>Follow this link to subscribe/unsubscribe:
>>http://www.vtk.org/mailman/listinfo/vtkusers
>>_______________________________________________
>>This is the private VTK discussion list.
>>Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
>>Follow this link to subscribe/unsubscribe:
>>http://www.vtk.org/mailman/listinfo/vtkusers
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list