[vtkusers] Help writing a vtkStructurePointsSource subclass
Lisa S. Avila
lisa.avila at kitware.com
Tue Feb 26 23:23:35 EST 2002
Hello Kevin,
In the execute method you must set the extent of the output - that is how
big the data really is (whole extent is how big the whole thing is (but only
a piece may be in memory).
Also, why do you have a local ImageData - why not just use the output
directly?
Lisa
----- Original Message -----
From: "Kevin Teich" <kteich at cortechs.net>
To: <vtkusers at public.kitware.com>
Sent: Tuesday, February 26, 2002 3:10 PM
Subject: [vtkusers] Help writing a vtkStructurePointsSource subclass
> (I'm reposting this question with some added information.)
>
> I'm writing a subclass of vtkStructuredPointsSource that will copy an
> input SP and pass it along to output. It has a vtkImageData as member
> data to hold the image. It has one function to copy the input:
>
> void vtkMutableStructuredPointsSource::CopyInput(vtkImageData *input)
> {
> if (this->ImageData == NULL)
> {
> this->ImageData = vtkImageData::New();
> }
>
> this->ImageData->DeepCopy( input );
>
> // Make sure we got good data.
> int coords[3] = { 128, 128, 128 };
> void* scalarPtr = this->ImageData->GetScalarPointer( coords );
> if( scalarPtr == NULL )
> {
> vtkErrorMacro( << "Didn't get ptr" );
> }
> }
>
> That works fine.
>
> In Execute(), I do this:
>
> void vtkMutableStructuredPointsSource::Execute()
> {
> // Make sure we have good data.
> int coords[3] = { 128, 128, 128 };
> void* scalarPtr = this->ImageData->GetScalarPointer( coords );
> if( scalarPtr == NULL )
> {
> vtkErrorMacro( << "Didn't get ptr" );
> }
>
> output->SetWholeExtent(this->ImageData->GetWholeExtent());
> output->SetNumberOfScalarComponents
> (this->ImageData->GetNumberOfScalarComponents());
> output->SetSpacing(this->ImageData->GetSpacing());
> output->SetOrigin(this->ImageData->GetOrigin());
>
> output->GetPointData()->SetScalars
> (this->ImageData->GetPointData()->GetScalars() );
> }
>
> ExecuteInformation() does the same thing except it doesnt set the scalar
> data at the end. This is very similar to the code I use for a custom
> volume reader that works.
>
> This doesn't work. When I hook it up as the source to a
> VolumeRaycastMapper and then to a Volume, nothing gets rendered. When I
> hook it up to an ImageReslice, I get this error:
>
> vtkStructuredPoints (0x8137e58): GetScalarPointer: Pixel (0, 0, 0) not in
> memory.
> Current extent= (0, -1, 0, -1, 0, -1)
>
> I've added this check at the end of the Execute() function:
>
> // Make sure we have good data.
> scalarPtr = output->GetScalarPointer( coords );
> if( scalarPtr == NULL )
> {
> vtkErrorMacro( << "Didn't get ptr" );
> }
>
> And this gives me an error. So, somewhere along the line, the scalars
> are not being copied to the output.
>
> I know I'm missing something obvious. Any pointers? Thanks.
>
>
> --
> Kevin Teich
>
> _______________________________________________
> 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://public.kitware.com/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list