Commit e3e6ea2b authored by Robert Maynard's avatar Robert Maynard

ENH: Added in basic support for time steps.

Currently time support has been aded to the parent algorithm so that we can support time everywhere. MTSD than just inherits from STSD and only has to redefine the requestdata since everything else is the same.
parent 5e49a42d
......@@ -3,6 +3,8 @@ PROJECT(AVTALGORITHMS)
SET(SOURCES
vtkAvtFileFormatAlgorithm.h
vtkAvtFileFormatAlgorithm.cxx
vtkAvtMTSDFileFormatAlgorithm.h
vtkAvtMTSDFileFormatAlgorithm.cxx
vtkAvtSTSDFileFormatAlgorithm.h
vtkAvtSTSDFileFormatAlgorithm.cxx
vtkAvtSTMDFileFormatAlgorithm.h
......
......@@ -130,43 +130,6 @@ void vtkAvtFileFormatAlgorithm::CleanupAVTReader()
}
}
//----------------------------------------------------------------------------
int vtkAvtFileFormatAlgorithm::ProcessRequest(vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector)
{
// generate the data
if(request->Has(vtkDemandDrivenPipeline::REQUEST_DATA()))
{
return this->RequestData(request, inputVector, outputVector);
}
if(request->Has(vtkStreamingDemandDrivenPipeline::REQUEST_UPDATE_EXTENT()))
{
return this->RequestUpdateExtent(request, inputVector, outputVector);
}
// Create data object output
if(request->Has(vtkDemandDrivenPipeline::REQUEST_DATA_OBJECT()))
{
return this->RequestDataObject(request, inputVector, outputVector);
}
// execute information
if(request->Has(vtkDemandDrivenPipeline::REQUEST_INFORMATION()))
{
return this->RequestInformation(request, inputVector, outputVector);
}
return this->Superclass::ProcessRequest(request, inputVector, outputVector);
}
//-----------------------------------------------------------------------------
int vtkAvtFileFormatAlgorithm::RequestDataObject(vtkInformation *request,
vtkInformationVector **inputVector, vtkInformationVector *outputVector)
{
return 1;
}
//-----------------------------------------------------------------------------
int vtkAvtFileFormatAlgorithm::RequestInformation(vtkInformation *request,
......@@ -186,6 +149,25 @@ int vtkAvtFileFormatAlgorithm::RequestInformation(vtkInformation *request,
//setup user selection of arrays to load
this->SetupDataArraySelections();
//setup time information
if( this->AvtFile->FormatGetTime() != avtFileFormat::INVALID_TIME )
{
vtkstd::vector< double > timesteps;
this->AvtFile->FormatGetTimes( timesteps );
int numTimeValues = static_cast<int>(timesteps.size());
if ( numTimeValues > 0 )
{
outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(),
&timesteps[0],numTimeValues);
double timeRange[2];
timeRange[0] = timesteps[0];
timeRange[1] = timesteps[numTimeValues-1];
outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(),
timeRange, 2);
}
}
return 1;
}
......
......@@ -32,7 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _vtkVisItReader_h
#define _vtkVisItReader_h
#include "vtkAlgorithm.h"
#include "vtkCompositeDataSetAlgorithm.h"
#include "vtkStdString.h"
class vtkDataArraySelection;
......@@ -45,11 +45,11 @@ class avtDatabaseMetaData;
class avtVariableCache;
//ETX
class VTK_EXPORT vtkAvtFileFormatAlgorithm : public vtkAlgorithm
class VTK_EXPORT vtkAvtFileFormatAlgorithm : public vtkCompositeDataSetAlgorithm
{
public:
static vtkAvtFileFormatAlgorithm *New();
vtkTypeMacro(vtkAvtFileFormatAlgorithm,vtkAlgorithm);
vtkTypeMacro(vtkAvtFileFormatAlgorithm,vtkCompositeDataSetAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
......@@ -77,13 +77,6 @@ public:
void SetPointArrayStatus(const char* name, int status);
void SetCellArrayStatus(const char* name, int status);
// Description:
// see vtkAlgorithm for details
virtual int ProcessRequest(vtkInformation*,
vtkInformationVector**,
vtkInformationVector*);
protected:
vtkAvtFileFormatAlgorithm();
~vtkAvtFileFormatAlgorithm();
......@@ -92,14 +85,6 @@ protected:
virtual bool InitializeAVTReader();
virtual void CleanupAVTReader();
// Description:
// This is called by the superclass.
// This is the method you should override.
virtual int RequestDataObject(vtkInformation*,
vtkInformationVector**,
vtkInformationVector*);
// Description:
// This is called by the superclass.
// This is the method you should override.
......
/*=========================================================================
Program: ParaView
Module: vtkAvtMTSDFileFormatAlgorithm.cxx
Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
#include "vtkAvtMTSDFileFormatAlgorithm.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkDataObject.h"
#include "vtkDataSet.h"
#include "vtkMultiPieceDataSet.h"
#include "vtkPointSet.h"
#include "vtkPolyData.h"
#include "vtkRectilinearGrid.h"
#include "vtkStructuredGrid.h"
#include "vtkUniformGrid.h"
#include "vtkUnstructuredGrid.h"
#include "vtkCellData.h"
#include "vtkFieldData.h"
#include "vtkPointData.h"
#include "vtkUnstructuredGridRelevantPointsFilter.h"
#include "vtkCleanPolyData.h"
#include "avtMTSDFileFormat.h"
#include "avtDomainNesting.h"
#include "avtDatabaseMetaData.h"
#include "avtVariableCache.h"
#include "avtScalarMetaData.h"
#include "avtVectorMetaData.h"
#include "TimingsManager.h"
#include "limits.h"
vtkStandardNewMacro(vtkAvtMTSDFileFormatAlgorithm);
//-----------------------------------------------------------------------------
vtkAvtMTSDFileFormatAlgorithm::vtkAvtMTSDFileFormatAlgorithm()
{
this->OutputType = VTK_MULTIPIECE_DATA_SET;
}
//-----------------------------------------------------------------------------
vtkAvtMTSDFileFormatAlgorithm::~vtkAvtMTSDFileFormatAlgorithm()
{
}
//-----------------------------------------------------------------------------
int vtkAvtMTSDFileFormatAlgorithm::RequestData(vtkInformation *request,
vtkInformationVector **inputVector, vtkInformationVector *outputVector)
{
if (!this->InitializeAVTReader())
{
return 0;
}
vtkInformation* outInfo = outputVector->GetInformationObject(0);
int tsLength =
outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
double* steps =
outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
double TimeStep = 0;
// Check if a particular time was requested by the pipeline.
// This overrides the ivar.
if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS()) && tsLength>0)
{
// Get the requested time step. We only supprt requests of a single time
// step in this reader right now
double *requestedTimeSteps =
outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS());
// find the first time value larger than requested time value
// this logic could be improved
int cnt = 0;
while (cnt < tsLength-1 && steps[cnt] < requestedTimeSteps[0])
{
cnt++;
}
TimeStep = steps[cnt];
}
//we have to make sure the visit reader populates its cache
//with the proper timestep
avtMTSDFileFormat *mtsdFF = static_cast<avtMTSDFileFormat*>(this->AvtFile);
mtsdFF->ActivateTimestep( TimeStep );
vtkMultiPieceDataSet *output = vtkMultiPieceDataSet::SafeDownCast(
outInfo->Get(vtkDataObject::DATA_OBJECT()));
if (!output)
{
vtkErrorMacro("Was unable to determine output type");
return 0;
}
int size = this->MetaData->GetNumMeshes();
output->SetNumberOfPieces( size );
vtkstd::string name;
for ( int i=0; i < size; ++i)
{
const avtMeshMetaData meshMetaData = this->MetaData->GetMeshes( i );
name = meshMetaData.name;
vtkDataSet *data = this->AvtFile->GetMesh(TimeStep, 0, name.c_str() );
if ( data )
{
this->AssignProperties( data, name, TimeStep, 0);
//clean the mesh of all points that are not part of a cell
if ( meshMetaData.meshType == AVT_UNSTRUCTURED_MESH)
{
vtkUnstructuredGrid *ugrid = vtkUnstructuredGrid::SafeDownCast(data);
vtkUnstructuredGridRelevantPointsFilter *clean =
vtkUnstructuredGridRelevantPointsFilter::New();
clean->SetInput( ugrid );
clean->Update();
output->SetPiece(i,clean->GetOutput());
clean->Delete();
}
else if(meshMetaData.meshType == AVT_SURFACE_MESH)
{
vtkCleanPolyData *clean = vtkCleanPolyData::New();
clean->SetInput( data );
clean->ToleranceIsAbsoluteOn();
clean->SetAbsoluteTolerance(0.0);
clean->ConvertStripsToPolysOff();
clean->ConvertPolysToLinesOff();
clean->ConvertLinesToPointsOff();
clean->Update();
output->SetPiece(i,clean->GetOutput());
clean->Delete();
}
data->Delete();
output->GetMetaData(i)->Set(vtkCompositeDataSet::NAME(),name.c_str());
}
}
this->CleanupAVTReader();
return 1;
}
//-----------------------------------------------------------------------------
void vtkAvtMTSDFileFormatAlgorithm::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
/*=========================================================================
Program: ParaView
Module: vtkAvtMTSDFileFormatAlgorithm.h
Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
#ifndef _vtkAvtMTSDFileFormatAlgorithm_h
#define _vtkAvtMTSDFileFormatAlgorithm_h
#include "vtkAvtSTSDFileFormatAlgorithm.h"
#include "vtkAvtAlgorithmsExport.h"
//BTX
class avtDatabaseMetaData;
class avtVariableCache;
//ETX
class AVTALGORITHMS_EXPORT vtkAvtMTSDFileFormatAlgorithm : public vtkAvtSTSDFileFormatAlgorithm
{
public:
static vtkAvtMTSDFileFormatAlgorithm *New();
vtkTypeMacro(vtkAvtMTSDFileFormatAlgorithm,vtkAvtSTSDFileFormatAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
protected:
vtkAvtMTSDFileFormatAlgorithm();
~vtkAvtMTSDFileFormatAlgorithm();
// Description:
// This is called by the superclass.
// This is the method you should override.
virtual int RequestData(vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector);
private:
vtkAvtMTSDFileFormatAlgorithm(const vtkAvtMTSDFileFormatAlgorithm&);
void operator = (const vtkAvtMTSDFileFormatAlgorithm&);
};
#endif
......@@ -36,7 +36,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "vtkAvtAlgorithmsExport.h"
//BTX
class avtSTSDFileFormat;
class avtDatabaseMetaData;
class avtVariableCache;
//ETX
......
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