Commit ffadd122 authored by Charles Law's avatar Charles Law
Browse files

Data was not getting region extent

parent 5f85d2df
......@@ -288,19 +288,8 @@ void vtkImageCache::GenerateUnCachedRegionData(vtkImageRegion *region)
// Create the data object for this region, to fix its size.
// Memory allocation is delayed as long as possible.
if ( ! region->GetData())
{
int saveAxes[VTK_IMAGE_DIMENSIONS];
vtkImageData *data = new vtkImageData;
region->GetAxes(VTK_IMAGE_DIMENSIONS, saveAxes);
region->SetAxes(VTK_IMAGE_DIMENSIONS, data->GetAxes());
data->SetExtent(VTK_IMAGE_DIMENSIONS, region->GetExtent());
data->SetScalarType(this->ScalarType);
region->SetAxes(saveAxes);
region->SetData(data);
// Since region has registered data, we mst delete our reference
data->Delete();
}
region->GetData();
// Tell the filter to generate the data for this region
// IMPORTANT: Region is just to communicate extent, and does not
......
......@@ -650,6 +650,13 @@ void *vtkImageData::GetScalarPointer(int coordinates[VTK_IMAGE_DIMENSIONS])
{
this->AllocateScalars();
scalars = this->PointData.GetScalars();
if (scalars == NULL)
{
vtkErrorMacro("Can't allocate scalars");
// for debugging
this->AllocateScalars();
scalars = this->PointData.GetScalars();
}
}
// error checking: since most acceses will be from pointer arithmetic.
......
......@@ -123,6 +123,10 @@ void vtkImageRegion::PrintSelf(ostream& os, vtkIndent indent)
}
}
//----------------------------------------------------------------------------
// Description:
// Convert 4d vector (not extent!) from one coordinate system into another
......@@ -422,6 +426,29 @@ void vtkImageRegion::SetData(vtkImageData *data)
}
//----------------------------------------------------------------------------
// Description:
// Returns the data. If one does not exist, the a data object is created.
vtkImageData *vtkImageRegion::GetData()
{
if ( ! this->Data)
{
int extent[VTK_IMAGE_EXTENT_DIMENSIONS];
this->Data = new vtkImageData;
this->Data->SetScalarType(this->ScalarType);
this->GetExtent(extent);
this->ChangeExtentCoordinateSystem(this->Extent, this->Axes,
extent, this->Data->GetAxes());
this->Data->SetExtent(extent);
// Compute the increments.
vtkImageRegionChangeVectorCoordinateSystem(this->Data->GetIncrements(),
this->Data->GetAxes(),
this->Increments, this->Axes);
}
return this->Data;
}
//----------------------------------------------------------------------------
// Description:
......
......@@ -78,10 +78,10 @@ public:
void UpdateImageInformation(vtkImageRegion *region);
unsigned long GetPipelineMTime();
void SetData(vtkImageData *data);
// Description:
// You can get the data object to share with another vtkImageRegion.
vtkGetObjectMacro(Data,vtkImageData);
// Set/Get the data object to share with other vtkImageRegions.
void SetData(vtkImageData *data);
vtkImageData *GetData();
// Description:
// Get the data type of this region.
vtkSetMacro(ScalarType,int);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment