Commit 19e69143 authored by Berk Geveci's avatar Berk Geveci Committed by George Zagaris
Browse files

Cleaned up extent translators.

- Removed unused extent translator subclasses
- Removed unnecessary refereces to the extent translator
- Moved extent translator into Common/ExecutionModel

Change-Id: Idc53dd66891297b1f6a06ea3eb1baf394cb24b20
parent ac6f1854
......@@ -205,7 +205,6 @@ set(Module_SRCS
vtkAMRDataInternals.cxx
vtkUniformGridAMR.cxx
vtkUniformGridAMRDataIterator.cxx
vtkExtentTranslator.cxx # needed by vtkDataSet
)
set(${vtk-module}_HDRS
......
......@@ -18,7 +18,6 @@
#include "vtkCellData.h"
#include "vtkCellTypes.h"
#include "vtkDataSetCellIterator.h"
#include "vtkExtentTranslator.h"
#include "vtkGenericCell.h"
#include "vtkIdList.h"
#include "vtkInformation.h"
......
......@@ -44,7 +44,6 @@ class vtkCell;
class vtkCellData;
class vtkCellIterator;
class vtkCellTypes;
class vtkExtentTranslator;
class vtkGenericCell;
class vtkIdList;
class vtkPointData;
......
......@@ -13,6 +13,7 @@ SET(Module_SRCS
vtkDirectedGraphAlgorithm.cxx
vtkExecutive.cxx
vtkExtentSplitter.cxx
vtkExtentTranslator.cxx
vtkFilteringInformationKeyManager.cxx
vtkGraphAlgorithm.cxx
vtkHierarchicalBoxDataSetAlgorithm.cxx
......@@ -27,7 +28,6 @@ SET(Module_SRCS
vtkInformationExecutivePortVectorKey.cxx
vtkMultiBlockDataSetAlgorithm.cxx
vtkMultiTimeStepAlgorithm.cxx
vtkOnePieceExtentTranslator.cxx
vtkPassInputTypeAlgorithm.cxx
vtkPiecewiseFunctionAlgorithm.cxx
vtkPiecewiseFunctionShiftScale.cxx
......@@ -40,7 +40,6 @@ SET(Module_SRCS
vtkStreamingDemandDrivenPipeline.cxx
vtkStructuredGridAlgorithm.cxx
vtkTableAlgorithm.cxx
vtkTableExtentTranslator.cxx
vtkSMPProgressObserver.cxx
vtkThreadedCompositeDataPipeline.cxx
vtkThreadedImageAlgorithm.cxx
......
......@@ -19,17 +19,15 @@
// extent. It uses a recursive scheme that splits the largest axis. A hard
// coded extent can be used for a starting point.
// .SECTION Caveats
// This object is still under development.
#ifndef __vtkExtentTranslator_h
#define __vtkExtentTranslator_h
#include "vtkCommonDataModelModule.h" // For export macro
#include "vtkCommonExecutionModelModule.h" // For export macro
#include "vtkObject.h"
class VTKCOMMONDATAMODEL_EXPORT vtkExtentTranslator : public vtkObject
class VTKCOMMONEXECUTIONMODEL_EXPORT vtkExtentTranslator : public vtkObject
{
public:
static vtkExtentTranslator *New();
......
/*=========================================================================
Program: Visualization Toolkit
Module: vtkOnePieceExtentTranslator.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkOnePieceExtentTranslator.h"
#include "vtkObjectFactory.h"
vtkStandardNewMacro(vtkOnePieceExtentTranslator);
//-----------------------------------------------------------------------------
vtkOnePieceExtentTranslator::vtkOnePieceExtentTranslator()
{
}
//-----------------------------------------------------------------------------
vtkOnePieceExtentTranslator::~vtkOnePieceExtentTranslator()
{
}
//-----------------------------------------------------------------------------
int vtkOnePieceExtentTranslator::PieceToExtentThreadSafe(
int vtkNotUsed(piece),
int vtkNotUsed(numPieces),
int vtkNotUsed(ghostLevel),
int *wholeExtent, int *resultExtent,
int vtkNotUsed(splitMode),
int vtkNotUsed(byPoints))
{
memcpy(resultExtent, wholeExtent, sizeof(int)*6);
return 1;
}
//-----------------------------------------------------------------------------
void vtkOnePieceExtentTranslator::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
/*=========================================================================
Program: Visualization Toolkit
Module: vtkOnePieceExtentTranslator.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkOnePieceExtentTranslator - Returns the whole extent for any piece..
// vtkOnePieceExtentTranslator returns the whole extent for any piece.
#ifndef __vtkOnePieceExtentTranslator_h
#define __vtkOnePieceExtentTranslator_h
#include "vtkCommonExecutionModelModule.h" // For export macro
#include "vtkExtentTranslator.h"
class VTKCOMMONEXECUTIONMODEL_EXPORT vtkOnePieceExtentTranslator : public vtkExtentTranslator
{
public:
static vtkOnePieceExtentTranslator* New();
vtkTypeMacro(vtkOnePieceExtentTranslator, vtkExtentTranslator);
void PrintSelf(ostream& os, vtkIndent indent);
protected:
vtkOnePieceExtentTranslator();
~vtkOnePieceExtentTranslator();
virtual int PieceToExtentThreadSafe(int vtkNotUsed(piece),
int vtkNotUsed(numPieces),
int vtkNotUsed(ghostLevel),
int *wholeExtent, int *resultExtent,
int vtkNotUsed(splitMode),
int vtkNotUsed(byPoints));
private:
vtkOnePieceExtentTranslator(const vtkOnePieceExtentTranslator&); // Not implemented.
void operator=(const vtkOnePieceExtentTranslator&); // Not implemented.
};
#endif
// VTK-HeaderTest-Exclude: vtkOnePieceExtentTranslator.h
/*=========================================================================
Program: Visualization Toolkit
Module: vtkTableExtentTranslator.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkTableExtentTranslator.h"
#include "vtkObjectFactory.h"
vtkStandardNewMacro(vtkTableExtentTranslator);
//----------------------------------------------------------------------------
vtkTableExtentTranslator::vtkTableExtentTranslator()
{
this->ExtentTable = 0;
this->MaximumGhostLevel = 0;
this->PieceAvailable = 0;
this->NumberOfPiecesInTable = 0;
}
//----------------------------------------------------------------------------
vtkTableExtentTranslator::~vtkTableExtentTranslator()
{
this->SetNumberOfPiecesInTable(0);
}
//----------------------------------------------------------------------------
void vtkTableExtentTranslator::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
if(this->ExtentTable)
{
vtkIndent nextIndent = indent.GetNextIndent();
int* extent = this->ExtentTable;
int i;
os << indent << "ExtentTable: 0: "
<< extent[0] << " " << extent[1] << " "
<< extent[2] << " " << extent[3] << " "
<< extent[4] << " " << extent[5] << "\n";
for(i=1;i < this->NumberOfPiecesInTable;++i)
{
extent += 6;
os << nextIndent << " " << i << ": "
<< extent[0] << " " << extent[1] << " "
<< extent[2] << " " << extent[3] << " "
<< extent[4] << " " << extent[5] << "\n";
}
}
else
{
os << indent << "ExtentTable: (none)\n";
}
os << indent << "MaximumGhostLevel: " << this->MaximumGhostLevel << "\n";
os << indent << "NumberOfPiecesInTable: "
<< this->NumberOfPiecesInTable << "\n";
if(this->PieceAvailable)
{
vtkIndent nextIndent = indent.GetNextIndent();
int* available = this->PieceAvailable;
int i;
os << indent << "PieceAvailable: 0: " << *available << "\n";
for(i=1;i < this->NumberOfPiecesInTable;++i)
{
++available;
os << nextIndent << " " << i << ": "
<< *available << "\n";
}
}
else
{
os << indent << "PieceAvailable: (none)\n";
}
}
//----------------------------------------------------------------------------
void vtkTableExtentTranslator::SetNumberOfPieces(int pieces)
{
// Allocate a table for this number of pieces.
if(this->NumberOfPiecesInTable == 0)
{
this->SetNumberOfPiecesInTable(pieces);
}
this->Superclass::SetNumberOfPieces(pieces);
}
//----------------------------------------------------------------------------
void vtkTableExtentTranslator::SetNumberOfPiecesInTable(int pieces)
{
// Make sure we are really changing the number of pieces.
if(this->NumberOfPiecesInTable == pieces)
{
return;
}
// The default number of pieces returned is the real number of
// pieces.
this->Superclass::SetNumberOfPieces(pieces);
this->NumberOfPiecesInTable = pieces;
// Clean out any old extent table.
delete [] this->ExtentTable;
this->ExtentTable = 0;
delete [] this->PieceAvailable;
this->PieceAvailable = 0;
// Create and initialize a new extent table if there are any pieces.
// Assume all pieces are available.
if(this->NumberOfPiecesInTable > 0)
{
this->ExtentTable = new int[this->NumberOfPiecesInTable*6];
this->PieceAvailable = new int[this->NumberOfPiecesInTable];
int i;
for(i=0;i < this->NumberOfPiecesInTable;++i)
{
int* extent = this->ExtentTable + i*6;
extent[0] = extent[2] = extent[4] = 0;
extent[1] = extent[3] = extent[5] = -1;
this->PieceAvailable[i] = 1;
}
}
}
//----------------------------------------------------------------------------
void vtkTableExtentTranslator::SetExtentForPiece(int piece, int* extent)
{
if((!this->ExtentTable) || (piece < 0) ||
(piece >= this->NumberOfPiecesInTable))
{
vtkErrorMacro("Piece " << piece << " does not exist. "
"NumberOfPiecesInTable is " << this->NumberOfPiecesInTable);
return;
}
memcpy(this->ExtentTable+piece*6, extent, sizeof(int)*6);
}
//----------------------------------------------------------------------------
void vtkTableExtentTranslator::GetExtentForPiece(int piece, int* extent)
{
if((!this->ExtentTable) || (piece < 0) ||
(piece >= this->NumberOfPiecesInTable))
{
vtkErrorMacro("Piece " << piece << " does not exist. "
"NumberOfPiecesInTable is " << this->NumberOfPiecesInTable);
extent[0] = extent[2] = extent[4] = 0;
extent[1] = extent[3] = extent[5] = -1;
return;
}
memcpy(extent, this->ExtentTable+piece*6, sizeof(int)*6);
}
//----------------------------------------------------------------------------
int* vtkTableExtentTranslator::GetExtentForPiece(int piece)
{
static int emptyExtent[6] = {0,-1,0,-1,0,-1};
if((!this->ExtentTable) || (piece < 0) ||
(piece >= this->NumberOfPiecesInTable))
{
vtkErrorMacro("Piece " << piece << " does not exist. "
"NumberOfPiecesInTable is " << this->NumberOfPiecesInTable);
return emptyExtent;
}
return this->ExtentTable+piece*6;
}
//----------------------------------------------------------------------------
void vtkTableExtentTranslator::SetPieceAvailable(int piece, int available)
{
if((!this->ExtentTable) || (piece < 0) ||
(piece >= this->NumberOfPiecesInTable))
{
vtkErrorMacro("Piece " << piece << " does not exist. "
"NumberOfPiecesInTable is " << this->NumberOfPiecesInTable);
return;
}
this->PieceAvailable[piece] = available?1:0;
}
//----------------------------------------------------------------------------
int vtkTableExtentTranslator::GetPieceAvailable(int piece)
{
if((!this->ExtentTable) || (piece < 0) ||
(piece >= this->NumberOfPiecesInTable))
{
vtkErrorMacro("Piece " << piece << " does not exist. "
"NumberOfPiecesInTable is " << this->NumberOfPiecesInTable);
return 0;
}
return this->PieceAvailable[piece];
}
//----------------------------------------------------------------------------
int vtkTableExtentTranslator::PieceToExtentByPoints()
{
vtkErrorMacro("PieceToExtentByPoints not supported.");
return 0;
}
//----------------------------------------------------------------------------
int
vtkTableExtentTranslator::PieceToExtentThreadSafe(int piece, int numPieces,
int ghostLevel,
int *wholeExtent,
int *resultExtent,
int vtkNotUsed(splitMode),
int byPoints)
{
if (byPoints)
{
vtkErrorMacro("PieceToExtentByPoints not supported.");
return 0;
}
if((!this->ExtentTable) || (piece < 0) ||
(piece >= numPieces))
{
vtkErrorMacro("Piece " << piece << " does not exist.");
return 0;
}
if(ghostLevel > this->MaximumGhostLevel)
{
vtkWarningMacro("Ghost level " << ghostLevel
<< " is larger than MaximumGhostLevel "
<< this->MaximumGhostLevel << ". Using the maximum.");
ghostLevel = this->MaximumGhostLevel;
}
if(numPieces == 1)
{
// The number of pieces requested is one. Return the whole extent.
memcpy(resultExtent, wholeExtent, sizeof(int)*6);
}
else if(piece < this->NumberOfPiecesInTable)
{
// Return the extent from the table entry.
memcpy(resultExtent, this->ExtentTable+piece*6, sizeof(int)*6);
}
else
{
// The requested piece is beyond the table. Return an empty extent.
resultExtent[0] = 0;
resultExtent[1] = -1;
resultExtent[2] = 0;
resultExtent[3] = -1;
resultExtent[4] = 0;
resultExtent[5] = -1;
}
if(((resultExtent[1] - resultExtent[0] + 1)*
(resultExtent[3] - resultExtent[2] + 1)*
(resultExtent[5] - resultExtent[4] + 1)) == 0)
{
return 0;
}
if(ghostLevel > 0)
{
resultExtent[0] -= this->GhostLevel;
resultExtent[1] += this->GhostLevel;
resultExtent[2] -= this->GhostLevel;
resultExtent[3] += this->GhostLevel;
resultExtent[4] -= this->GhostLevel;
resultExtent[5] += this->GhostLevel;
if (resultExtent[0] < wholeExtent[0])
{
resultExtent[0] = wholeExtent[0];
}
if (resultExtent[1] > wholeExtent[1])
{
resultExtent[1] = wholeExtent[1];
}
if (resultExtent[2] < wholeExtent[2])
{
resultExtent[2] = wholeExtent[2];
}
if (resultExtent[3] > wholeExtent[3])
{
resultExtent[3] = wholeExtent[3];
}
if (resultExtent[4] < wholeExtent[4])
{
resultExtent[4] = wholeExtent[4];
}
if (resultExtent[5] > wholeExtent[5])
{
resultExtent[5] = wholeExtent[5];
}
}
return 1;
}
//----------------------------------------------------------------------------
int vtkTableExtentTranslator::PieceToExtent()
{
return this->PieceToExtentThreadSafe(this->Piece, this->NumberOfPieces,
this->GhostLevel,
this->WholeExtent,
this->Extent,
this->SplitMode,
0);
}
/*=========================================================================
Program: Visualization Toolkit
Module: vtkTableExtentTranslator.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkTableExtentTranslator - Extent translation through lookup table.
// .SECTION Description
// vtkTableExtentTranslator provides a vtkExtentTranslator that is
// programmed with a specific extent corresponding to each piece
// number. Readers can provide this to an application to allow the
// pipeline to execute using the same piece breakdown that is provided
// in the input file.
#ifndef __vtkTableExtentTranslator_h
#define __vtkTableExtentTranslator_h
#include "vtkCommonExecutionModelModule.h" // For export macro
#include "vtkExtentTranslator.h"
class VTKCOMMONEXECUTIONMODEL_EXPORT vtkTableExtentTranslator : public vtkExtentTranslator
{
public:
vtkTypeMacro(vtkTableExtentTranslator,vtkExtentTranslator);
void PrintSelf(ostream& os, vtkIndent indent);
static vtkTableExtentTranslator* New();
// Description:
// Set the number of pieces into which the whole extent will be
// split. If this is 1 then the whole extent will be returned. If
// this is more than the number of pieces in the table then the
// extra pieces will be empty data. If this is more than one but
// less than the number of pieces in the table then only this many
// pieces will be returned (FIXME).
void SetNumberOfPieces(int pieces);
// Description:
// Set the real number of pieces in the extent table.
void SetNumberOfPiecesInTable(int pieces);
vtkGetMacro(NumberOfPiecesInTable, int);
// Description:
// Called to translate the current piece into an extent. This is
// not thread safe.
int PieceToExtent();
// Description:
// Not supported by this subclass of vtkExtentTranslator.
int PieceToExtentByPoints();
// Description:
// Not supported by this subclass of vtkExtentTranslator.
int PieceToExtentThreadSafe(int piece, int numPieces,
int ghostLevel, int *wholeExtent,
int *resultExtent, int splitMode,
int byPoints);
// Description:
// Set the extent to be used for a piece. This sets the extent table
// entry for the piece.
virtual void SetExtentForPiece(int piece, int* extent);
// Description:
// Get the extent table entry for the given piece. This is only for
// code that is setting up the table. Extent translation should
// always be done through the PieceToExtent method.
virtual void GetExtentForPiece(int piece, int* extent);
virtual int* GetExtentForPiece(int piece);
// Description:
// Set the maximum ghost level that can be requested. This can be
// used by a reader to make sure an extent request does not go
// outside the boundaries of the piece's file.
vtkSetMacro(MaximumGhostLevel, int);
vtkGetMacro(MaximumGhostLevel, int);
// Description:
// Get/Set whether the given piece is available. Requesting a piece
// that is not available will produce errors in the pipeline.
virtual void SetPieceAvailable(int piece, int available);
virtual int GetPieceAvailable(int piece);
protected:
vtkTableExtentTranslator();
~vtkTableExtentTranslator();
// Store the extent table in a single array. Every 6 values form an extent.
int* ExtentTable;
int NumberOfPiecesInTable;
int MaximumGhostLevel;
// Store a flag for the availability of each piece.
int* PieceAvailable;
private:
vtkTableExtentTranslator(const vtkTableExtentTranslator&); // Not implemented.
void operator=(const vtkTableExtentTranslator&); // Not implemented.
};