VERSION "1.0"
MODULES StaticMeshModule
MODULE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/StaticMeshModule/vtk.module"
- SERVER_MANAGER_XML sources.xml
+ SERVER_MANAGER_XML sources.xml readers.xml filters.xml
)
install(TARGETS StaticMesh
)
set(classes
+ vtkForceStaticMesh
+ vtkGenericStaticEnSightReader
vtkTemporalUGWavelet
vtkStaticMeshObjectFactory
)
VTK::CommonDataModel
VTK::CommonExecutionModel
VTK::FiltersCore
- VTK::FiltersModeling
VTK::FiltersGeometry
- VTK::FiltersParallelGeometry
+ VTK::FiltersModeling
VTK::ImagingCore
VTK::IOCore
VTK::IOGeometry
VTK::IOEnSight
+OPTIONAL_DEPENDS
+ VTK::FiltersParallelGeometry
PRIVATE_DEPENDS
VTK::CommonMisc
VTK::CommonSystem
--- /dev/null
+/*=========================================================================
+
+ Program: Visualization Toolkit
+ Module: vtkForceStaticMesh.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 "vtkForceStaticMesh.h"
+
+#include <vtkCellData.h>
+#include <vtkInformation.h>
+#include <vtkInformationVector.h>
+#include <vtkMultiBlockDataSet.h>
+#include <vtkObjectFactory.h>
+#include <vtkPointData.h>
+#include <vtkUnstructuredGrid.h>
+#include <vtksys/SystemTools.hxx>
+
+vtkStandardNewMacro(vtkForceStaticMesh);
+
+//------------------------------------------------------------------------------
+void vtkForceStaticMesh::PrintSelf(ostream& os, vtkIndent indent)
+{
+ this->Superclass::PrintSelf(os, indent);
+ os << indent << "ForceCacheComputation: " << (this->ForceCacheComputation ? "on" : "off") << endl;
+}
+
+//------------------------------------------------------------------------------
+int vtkForceStaticMesh::FillInputPortInformation(int, vtkInformation* info)
+{
+ info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataObject");
+ return 1;
+}
+
+//------------------------------------------------------------------------------
+int vtkForceStaticMesh::RequestData(vtkInformation* vtkNotUsed(request),
+ vtkInformationVector** inputVector, vtkInformationVector* outputVector)
+{
+ vtkUnstructuredGrid* input = vtkUnstructuredGrid::GetData(inputVector[0]);
+ vtkMultiBlockDataSet* inputMB = vtkMultiBlockDataSet::GetData(inputVector[0]);
+
+ // Recover the first block
+ if (inputMB && inputMB->GetNumberOfBlocks() >= 1)
+ {
+ input = vtkUnstructuredGrid::SafeDownCast(inputMB->GetBlock(0));
+ }
+
+ if (!input)
+ {
+ vtkErrorMacro("Input is invalid, it should be either an unstructured grid or a multiblock a unstructured grid in the first block");
+ return 0;
+ }
+
+ if (inputMB && inputMB->GetNumberOfBlocks() > 1)
+ {
+ vtkWarningMacro("Only the first block will be passed");
+ }
+
+ vtkUnstructuredGrid* output = vtkUnstructuredGrid::GetData(outputVector);
+
+ bool validCache = this->CacheInitialized;
+ if (validCache)
+ {
+ if (input->GetNumberOfPoints() != this->Cache->GetNumberOfPoints())
+ {
+ vtkWarningMacro("Cache has been invalidated, the number of points in input changed, from " << this->Cache->GetNumberOfPoints() << " to " << input->GetNumberOfPoints());
+ validCache = false;
+ }
+ if (input->GetNumberOfCells() != this->Cache->GetNumberOfCells())
+ {
+ vtkWarningMacro("Cache has been invalidated, the number of cells in input changed, from " << this->Cache->GetNumberOfCells() << " to " << input->GetNumberOfCells());
+ validCache = false;
+ }
+ }
+
+ if (this->ForceCacheComputation || !validCache)
+ {
+ // Cache is invalid
+ if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
+ {
+ vtkWarningMacro("Building static mesh cache");
+ }
+
+ this->Cache->DeepCopy(input);
+ this->CacheInitialized = true;
+ }
+ else
+ {
+ // Cache mesh is up to date, use it to generate data
+ if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
+ {
+ vtkWarningMacro("Using static mesh cache");
+ }
+
+ this->Cache->GetPointData()->ShallowCopy(input->GetPointData());
+ this->Cache->GetCellData()->ShallowCopy(input->GetCellData());
+ this->Cache->GetFieldData()->ShallowCopy(input->GetFieldData());
+ }
+
+ output->ShallowCopy(this->Cache);
+ return 1;
+}
--- /dev/null
+/*=========================================================================
+
+ Program: Visualization Toolkit
+ Module: vtkForceStaticMesh.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.
+
+=========================================================================*/
+/**
+ * @class vtkForceStaticMesh
+ * @brief Takes in input as a cache the first time it is executed then use it as a static mesh
+ *
+ * The Force Static Mesh filter create a cache the first time it is used using its input. It will then only
+ * update PointData, CellData and FieldData from the input if their dimensions are valid.
+ * This filter operates only on vtkUnstructuredGrid or on vtkMultiBlockDataSet containing a single vtkUnstructuredGrid
+ */
+
+#ifndef vtkForceStaticMesh_h
+#define vtkForceStaticMesh_h
+
+#include <vtkUnstructuredGridAlgorithm.h>
+#include <vtkNew.h>
+
+#include "StaticMeshModuleModule.h"
+
+class vtkUnstructuredGrid;
+
+class STATICMESHMODULE_EXPORT vtkForceStaticMesh : public vtkUnstructuredGridAlgorithm
+{
+public:
+ static vtkForceStaticMesh* New();
+ vtkTypeMacro(vtkForceStaticMesh, vtkUnstructuredGridAlgorithm);
+ void PrintSelf(ostream& os, vtkIndent indent) override;
+
+ //@{
+ /**
+ * When set to true, this will force this filter to recompute its cache.
+ * Default is false.
+ */
+ vtkSetMacro(ForceCacheComputation, vtkTypeBool);
+ vtkGetMacro(ForceCacheComputation, vtkTypeBool);
+ vtkBooleanMacro(ForceCacheComputation, vtkTypeBool);
+ //@}
+
+protected:
+ vtkForceStaticMesh() = default;
+ ~vtkForceStaticMesh() override = default;
+
+ int FillInputPortInformation(int port, vtkInformation* info) override;
+ int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
+
+private:
+ vtkForceStaticMesh(const vtkForceStaticMesh&) = delete;
+ void operator=(const vtkForceStaticMesh&) = delete;
+
+ bool ForceCacheComputation = false;
+ bool CacheInitialized = false;
+ vtkNew<vtkUnstructuredGrid> Cache;
+};
+
+#endif
--- /dev/null
+/*=========================================================================
+
+ Program: Visualization Toolkit
+ Module: vtkGenericStaticEnSightReader.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 "vtkGenericStaticEnSightReader.h"
+#include "vtkObjectFactory.h"
+
+#include "vtkStaticEnSight6BinaryReader.h"
+#include "vtkStaticEnSight6Reader.h"
+#include "vtkStaticEnSightGoldBinaryReader.h"
+#include "vtkStaticEnSightGoldReader.h"
+
+vtkStandardNewMacro(vtkGenericStaticEnSightReader);
+
+//------------------------------------------------------------------------------
+int vtkGenericStaticEnSightReader::RequestInformation(
+ vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector)
+{
+ int ri = this->Superclass::RequestInformation(request, inputVector, outputVector);
+
+ // 6 binary
+ vtkStaticEnSight6BinaryReader* es6binary =
+ vtkStaticEnSight6BinaryReader::SafeDownCast(this->Reader);
+ if (es6binary)
+ {
+ es6binary->SetUseStaticMesh(this->UseStaticMesh);
+ return ri;
+ }
+
+ // 6
+ vtkStaticEnSight6Reader* es6 = vtkStaticEnSight6Reader::SafeDownCast(this->Reader);
+ if (es6)
+ {
+ es6->SetUseStaticMesh(this->UseStaticMesh);
+ return ri;
+ }
+
+ // Gold binary
+ vtkStaticEnSightGoldBinaryReader* goldBinary =
+ vtkStaticEnSightGoldBinaryReader::SafeDownCast(this->Reader);
+ if (goldBinary)
+ {
+ goldBinary->SetUseStaticMesh(this->UseStaticMesh);
+ return ri;
+ }
+
+ // Gold
+ vtkStaticEnSightGoldReader* gold = vtkStaticEnSightGoldReader::SafeDownCast(this->Reader);
+ if (gold)
+ {
+ gold->SetUseStaticMesh(this->UseStaticMesh);
+ return ri;
+ }
+
+ vtkErrorMacro("Failed to determine static mesh version of the EnSight reader.");
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+void vtkGenericStaticEnSightReader::PrintSelf(ostream& os, vtkIndent indent)
+{
+ this->Superclass::PrintSelf(os, indent);
+ os << "UseStaticMesh: " << this->UseStaticMesh << std::endl;
+}
--- /dev/null
+/*=========================================================================
+
+ Program: Visualization Toolkit
+ Module: vtkGenericStaticEnSightReader.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.
+
+=========================================================================*/
+/**
+ * @class vtkGenericStaticEnSightReader
+ * @brief class to read any type of EnSight files
+ *
+ * The class vtkGenericStaticEnSightReader inherit from the
+ * vtkGenericEnSightReader. In addition to allowing the user to read
+ * various types of EnSight files, it add a boolean to control whether
+ * or not the output mesh should be considered static.
+ *
+ * Keep this boolean to false for non-static EnSight files.
+ */
+
+#ifndef vtkGenericStaticEnSightReader_h
+#define vtkGenericStaticEnSightReader_h
+
+#include <vtkGenericEnSightReader.h>
+#include <vtkSetGet.h>
+
+#include "StaticMeshModuleModule.h"
+
+class STATICMESHMODULE_EXPORT vtkGenericStaticEnSightReader : public vtkGenericEnSightReader
+{
+public:
+ static vtkGenericStaticEnSightReader* New();
+ vtkTypeMacro(vtkGenericStaticEnSightReader, vtkGenericEnSightReader);
+ void PrintSelf(ostream& os, vtkIndent indent) override;
+
+ // @{
+ /**
+ * This boolean control whether or not the output
+ * should be considered a static mesh.
+ */
+ vtkGetMacro(UseStaticMesh, bool);
+ vtkSetMacro(UseStaticMesh, bool);
+ vtkBooleanMacro(UseStaticMesh, bool);
+ // @}
+
+protected:
+ vtkGenericStaticEnSightReader() = default;
+ ~vtkGenericStaticEnSightReader() override = default;
+
+ /**
+ * see vtkDataSetAlgorithm
+ */
+ int RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
+
+private:
+ vtkGenericStaticEnSightReader(const vtkGenericStaticEnSightReader&) = delete;
+ void operator=(const vtkGenericStaticEnSightReader&) = delete;
+
+ bool UseStaticMesh = false;
+};
+
+#endif
#include <vtkObjectFactory.h>
#include <vtkPointData.h>
#include <vtkUnstructuredGrid.h>
+#include <vtksys/SystemTools.hxx>
vtkStandardNewMacro(vtkStaticDataSetSurfaceFilter);
-//----------------------------------------------------------------------------
-vtkStaticDataSetSurfaceFilter::vtkStaticDataSetSurfaceFilter()
-{
- this->InputMeshTime = 0;
- this->FilterMTime = 0;
-}
-
-//----------------------------------------------------------------------------
-vtkStaticDataSetSurfaceFilter::~vtkStaticDataSetSurfaceFilter()
-{
-}
-
//-----------------------------------------------------------------------------
int vtkStaticDataSetSurfaceFilter::UnstructuredGridExecute(vtkDataSet* input, vtkPolyData* output)
{
return this->Superclass::UnstructuredGridExecute(input, output);
}
- // Check is cache is still valid
+ // Check if cache is still valid
if (this->InputMeshTime == inputUG->GetMeshMTime() && this->FilterMTime == this->GetMTime())
{
+ if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
+ {
+ vtkWarningMacro("Using static mesh cache");
+ }
+
// Use cache as base
output->ShallowCopy(this->Cache.Get());
vtkCellData* inCD = input->GetCellData();
// Update output point data
- vtkIdType* tmpIds = new vtkIdType[origPointArray->GetNumberOfTuples()];
- memcpy(tmpIds, reinterpret_cast<vtkIdType*>(origPointArray->GetVoidPointer(0)),
- sizeof(vtkIdType) * origPointArray->GetNumberOfTuples());
vtkNew<vtkIdList> pointIds;
- pointIds->SetArray(tmpIds, origPointArray->GetNumberOfTuples());
+ const vtkIdType origPANbTuples = origPointArray->GetNumberOfTuples();
+ pointIds->SetNumberOfIds(origPANbTuples);
+ for (vtkIdType i = 0; i < origPANbTuples; i++)
+ {
+ pointIds->SetId(i, origPointArray->GetTuple1(i));
+ }
// Remove array that have disappeared from input
for (int iArr = outPD->GetNumberOfArrays() - 1; iArr >= 0; iArr--)
outArr->SetNumberOfTuples(output->GetNumberOfPoints());
inArr->GetTuples(pointIds.Get(), outArr);
outPD->AddArray(outArr);
+ outArr->Delete();
}
}
// Update output cell data
- tmpIds = new vtkIdType[origCellArray->GetNumberOfTuples()];
- memcpy(tmpIds, reinterpret_cast<vtkIdType*>(origCellArray->GetVoidPointer(0)),
- sizeof(vtkIdType) * origCellArray->GetNumberOfTuples());
vtkNew<vtkIdList> cellIds;
- cellIds->SetArray(tmpIds, origCellArray->GetNumberOfTuples());
+ const vtkIdType origCANbTuples = origCellArray->GetNumberOfTuples();
+ cellIds->SetNumberOfIds(origCANbTuples);
+ for (vtkIdType i = 0; i < origCANbTuples; i++)
+ {
+ cellIds->SetId(i, origCellArray->GetTuple1(i));
+ }
// Remove array that have disappeared from input
for (int iArr = outCD->GetNumberOfArrays() - 1; iArr >= 0; iArr--)
outArr->SetNumberOfTuples(output->GetNumberOfCells());
inArr->GetTuples(cellIds.Get(), outArr);
outCD->AddArray(outArr);
+ outArr->Delete();
}
-
}
// Update output field data
else
{
// Cache is not valid, Execute supercall algorithm
+ if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
+ {
+ vtkWarningMacro("Building static mesh cache");
+ }
+
int ret = this->Superclass::UnstructuredGridExecute(input, output);
// Update the cache with superclass output
*
* @sa
* vtkStaticMeshObjectFactory
-*/
+ */
#ifndef vtkStaticDataSetSurfaceFilter_h
#define vtkStaticDataSetSurfaceFilter_h
#include <vtkDataSetSurfaceFilter.h>
#include <vtkNew.h>
+#include "StaticMeshModuleModule.h"
+
class vtkPolyData;
-class vtkStaticDataSetSurfaceFilter : public vtkDataSetSurfaceFilter
+class STATICMESHMODULE_EXPORT vtkStaticDataSetSurfaceFilter : public vtkDataSetSurfaceFilter
{
public:
static vtkStaticDataSetSurfaceFilter* New();
- typedef vtkDataSetSurfaceFilter
- Superclass; // vtkTypeMacro can't be used with a factory built object
+ // vtkTypeMacro can't be used with a factory built object
+ using Superclass = vtkDataSetSurfaceFilter;
void PrintSelf(ostream& os, vtkIndent indent) override;
+ /**
+ * if the input is an unstructured grid and the cache is valid, this
+ * method only updates attributes (points, cells and field data)
+ */
int UnstructuredGridExecute(vtkDataSet* input, vtkPolyData* output) override;
protected:
- vtkStaticDataSetSurfaceFilter();
- ~vtkStaticDataSetSurfaceFilter() override;
-
- vtkNew<vtkPolyData> Cache;
- vtkMTimeType InputMeshTime;
- vtkMTimeType FilterMTime;
+ vtkStaticDataSetSurfaceFilter() = default;
+ ~vtkStaticDataSetSurfaceFilter() override = default;
private:
// Hide these from the user and the compiler.
vtkStaticDataSetSurfaceFilter(const vtkStaticDataSetSurfaceFilter&) = delete;
void operator=(const vtkStaticDataSetSurfaceFilter&) = delete;
+
+ vtkNew<vtkPolyData> Cache;
+ vtkMTimeType InputMeshTime = 0;
+ vtkMTimeType FilterMTime = 0;
};
#endif
#include <vtkMultiBlockDataSet.h>
#include <vtkObjectFactory.h>
#include <vtkStreamingDemandDrivenPipeline.h>
+#include <vtksys/SystemTools.hxx>
vtkStandardNewMacro(vtkStaticEnSight6BinaryReader);
//----------------------------------------------------------------------------
-int vtkStaticEnSight6BinaryReader::RequestData(
- vtkInformation *vtkNotUsed(request),
- vtkInformationVector **vtkNotUsed(inputVector),
- vtkInformationVector *outputVector)
+int vtkStaticEnSight6BinaryReader::RequestData(vtkInformation* vtkNotUsed(request),
+ vtkInformationVector** vtkNotUsed(inputVector), vtkInformationVector* outputVector)
{
- vtkDebugMacro("In execute ");
+ vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::GetData(outputVector);
- vtkInformation *outInfo = outputVector->GetInformationObject(0);
- vtkMultiBlockDataSet *output = vtkMultiBlockDataSet::SafeDownCast(
- outInfo->Get(vtkDataObject::DATA_OBJECT()));
-
- int tsLength =
- outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
- double* steps =
- outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
+ vtkInformation* outInfo = outputVector->GetInformationObject(0);
+ int tsLength = outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
+ double* steps = outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
this->ActualTimeValue = this->TimeValue;
// Check if a particular time was requested by the pipeline.
// This overrides the ivar.
- if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()) && tsLength>0)
+ if (outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()) && tsLength > 0)
{
// Get the requested time step. We only support requests of a single time
// step in this reader right now
- double requestedTimeStep =
- outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
+ double requestedTimeStep = outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
// find the first time value larger than requested time value
// this logic could be improved
int cnt = 0;
- while (cnt < tsLength-1 && steps[cnt] < requestedTimeStep)
+ while (cnt < tsLength - 1 && steps[cnt] < requestedTimeStep)
{
cnt++;
}
this->ActualTimeValue = steps[cnt];
}
- vtkDebugMacro("Executing with: " << this->ActualTimeValue);
-
- if (this->CacheMTime < this->GetMTime())
+ if (!this->UseStaticMesh || this->CacheMTime < this->GetMTime())
{
- int i, timeSet, fileSet, timeStep, timeStepInFile, fileNum;
- vtkDataArray *times;
- vtkIdList *numStepsList, *filenameNumbers;
- float newTime;
- int numSteps;
- char* fileName;
- int filenameNum;
+ if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
+ {
+ vtkWarningMacro("Building static mesh cache");
+ }
- if ( ! this->CaseFileRead)
+ if (!this->CaseFileRead)
{
vtkErrorMacro("error reading case file");
return 0;
this->NumberOfGeometryParts = 0;
if (this->GeometryFileName)
{
- timeStep = timeStepInFile = 1;
- fileNum = 1;
- fileName = new char[strlen(this->GeometryFileName) + 10];
- strcpy(fileName, this->GeometryFileName);
+ vtkIdType timeStep = 1;
+ vtkIdType timeStepInFile = 1;
+ int fileNum = 1;
+ std::string fileName(this->GeometryFileName);
+ fileName.resize(fileName.size() + 10);
if (this->UseTimeSets)
{
- timeSet = this->TimeSetIds->IsId(this->GeometryTimeSet);
+ vtkIdType timeSet = this->TimeSetIds->IsId(this->GeometryTimeSet);
if (timeSet >= 0)
{
- times = this->TimeSets->GetItem(timeSet);
+ vtkDataArray* times = this->TimeSets->GetItem(timeSet);
this->GeometryTimeValue = times->GetComponent(0, 0);
- for (i = 1; i < times->GetNumberOfTuples(); i++)
+ for (vtkIdType i = 1; i < times->GetNumberOfTuples(); i++)
{
- newTime = times->GetComponent(i, 0);
- if (newTime <= this->ActualTimeValue &&
- newTime > this->GeometryTimeValue)
+ double newTime = times->GetComponent(i, 0);
+ if (newTime <= this->ActualTimeValue && newTime > this->GeometryTimeValue)
{
this->GeometryTimeValue = newTime;
timeStep++;
}
if (this->TimeSetFileNameNumbers->GetNumberOfItems() > 0)
{
- int collectionNum = this->TimeSetsWithFilenameNumbers->
- IsId(this->GeometryTimeSet);
+ int collectionNum = this->TimeSetsWithFilenameNumbers->IsId(this->GeometryTimeSet);
if (collectionNum > -1)
{
- filenameNumbers =
- this->TimeSetFileNameNumbers->GetItem(collectionNum);
- filenameNum = filenameNumbers->GetId(timeStep-1);
- if (! this->UseFileSets)
+ vtkIdList* filenameNumbers = this->TimeSetFileNameNumbers->GetItem(collectionNum);
+ int filenameNum = filenameNumbers->GetId(timeStep - 1);
+ if (!this->UseFileSets)
{
- this->ReplaceWildcards(fileName, filenameNum);
+ this->ReplaceWildcards(&fileName[0], filenameNum);
}
}
}
// There can only be file sets if there are also time sets.
if (this->UseFileSets)
{
- fileSet = this->FileSets->IsId(this->GeometryFileSet);
- numStepsList = static_cast<vtkIdList*>(this->FileSetNumberOfSteps->
- GetItemAsObject(fileSet));
+ vtkIdType fileSet = this->FileSets->IsId(this->GeometryFileSet);
+ vtkIdList* numStepsList =
+ static_cast<vtkIdList*>(this->FileSetNumberOfSteps->GetItemAsObject(fileSet));
if (timeStep > numStepsList->GetId(0))
{
- numSteps = numStepsList->GetId(0);
+ vtkIdType numSteps = numStepsList->GetId(0);
timeStepInFile -= numSteps;
fileNum = 2;
- for (i = 1; i < numStepsList->GetNumberOfIds(); i++)
+ for (vtkIdType i = 1; i < numStepsList->GetNumberOfIds(); i++)
{
numSteps += numStepsList->GetId(i);
if (timeStep > numSteps)
}
if (this->FileSetFileNameNumbers->GetNumberOfItems() > 0)
{
- int collectionNum = this->FileSetsWithFilenameNumbers->
- IsId(this->GeometryFileSet);
+ int collectionNum = this->FileSetsWithFilenameNumbers->IsId(this->GeometryFileSet);
if (collectionNum > -1)
{
- filenameNumbers = this->FileSetFileNameNumbers->
- GetItem(collectionNum);
- filenameNum = filenameNumbers->GetId(fileNum-1);
- this->ReplaceWildcards(fileName, filenameNum);
+ vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(collectionNum);
+ int filenameNum = filenameNumbers->GetId(fileNum - 1);
+ this->ReplaceWildcards(&fileName[0], filenameNum);
}
}
}
}
}
- if (!this->ReadGeometryFile(fileName, timeStepInFile, this->Cache))
+ if (!this->ReadGeometryFile(fileName.data(), timeStepInFile, this->Cache))
{
vtkErrorMacro("error reading geometry file");
- delete [] fileName;
return 0;
}
-
- delete [] fileName;
}
if (this->MeasuredFileName)
{
- timeStep = timeStepInFile = 1;
- fileNum = 1;
- fileName = new char[strlen(this->MeasuredFileName) + 10];
- strcpy(fileName, this->MeasuredFileName);
+ vtkIdType timeStep = 1;
+ vtkIdType timeStepInFile = 1;
+ int fileNum = 1;
+ std::string fileName(this->MeasuredFileName);
+ fileName.resize(fileName.size() + 10);
if (this->UseTimeSets)
{
- timeSet = this->TimeSetIds->IsId(this->MeasuredTimeSet);
+ vtkIdType timeSet = this->TimeSetIds->IsId(this->MeasuredTimeSet);
if (timeSet >= 0)
{
- times = this->TimeSets->GetItem(timeSet);
+ vtkDataArray* times = this->TimeSets->GetItem(timeSet);
this->MeasuredTimeValue = times->GetComponent(0, 0);
- for (i = 1; i < times->GetNumberOfTuples(); i++)
+ for (vtkIdType i = 1; i < times->GetNumberOfTuples(); i++)
{
- newTime = times->GetComponent(i, 0);
- if (newTime <= this->ActualTimeValue &&
- newTime > this->MeasuredTimeValue)
+ double newTime = times->GetComponent(i, 0);
+ if (newTime <= this->ActualTimeValue && newTime > this->MeasuredTimeValue)
{
this->MeasuredTimeValue = newTime;
timeStep++;
}
if (this->TimeSetFileNameNumbers->GetNumberOfItems() > 0)
{
- int collectionNum = this->TimeSetsWithFilenameNumbers->
- IsId(this->MeasuredTimeSet);
+ int collectionNum = this->TimeSetsWithFilenameNumbers->IsId(this->MeasuredTimeSet);
if (collectionNum > -1)
{
- filenameNumbers = this->TimeSetFileNameNumbers->
- GetItem(collectionNum);
- filenameNum = filenameNumbers->GetId(timeStep-1);
- if (! this->UseFileSets)
+ vtkIdList* filenameNumbers = this->TimeSetFileNameNumbers->GetItem(collectionNum);
+ int filenameNum = filenameNumbers->GetId(timeStep - 1);
+ if (!this->UseFileSets)
{
- this->ReplaceWildcards(fileName, filenameNum);
+ this->ReplaceWildcards(&fileName[0], filenameNum);
}
}
}
// There can only be file sets if there are also time sets.
if (this->UseFileSets)
{
- fileSet = this->FileSets->IsId(this->MeasuredFileSet);
- numStepsList = static_cast<vtkIdList*>(this->FileSetNumberOfSteps->
- GetItemAsObject(fileSet));
+ vtkIdType fileSet = this->FileSets->IsId(this->MeasuredFileSet);
+ vtkIdList* numStepsList =
+ static_cast<vtkIdList*>(this->FileSetNumberOfSteps->GetItemAsObject(fileSet));
if (timeStep > numStepsList->GetId(0))
{
- numSteps = numStepsList->GetId(0);
+ vtkIdType numSteps = numStepsList->GetId(0);
timeStepInFile -= numSteps;
fileNum = 2;
- for (i = 1; i < numStepsList->GetNumberOfIds(); i++)
+ for (vtkIdType i = 1; i < numStepsList->GetNumberOfIds(); i++)
{
numSteps += numStepsList->GetId(i);
if (timeStep > numSteps)
}
if (this->FileSetFileNameNumbers->GetNumberOfItems() > 0)
{
- int collectionNum = this->FileSetsWithFilenameNumbers->
- IsId(this->MeasuredFileSet);
+ int collectionNum = this->FileSetsWithFilenameNumbers->IsId(this->MeasuredFileSet);
if (collectionNum > -1)
{
- filenameNumbers = this->FileSetFileNameNumbers->
- GetItem(fileSet);
- filenameNum = filenameNumbers->GetId(fileNum-1);
- this->ReplaceWildcards(fileName, filenameNum);
+ vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(fileSet);
+ int filenameNum = filenameNumbers->GetId(fileNum - 1);
+ this->ReplaceWildcards(&fileName[0], filenameNum);
}
}
}
}
}
- if (!this->ReadMeasuredGeometryFile(fileName, timeStepInFile, this->Cache))
+ if (!this->ReadMeasuredGeometryFile(fileName.data(), timeStepInFile, this->Cache))
{
vtkErrorMacro("error reading measured geometry file");
- delete [] fileName;
return 0;
}
- delete [] fileName;
}
this->CacheMTime.Modified();
}
* of the pipeline because (due to the nature of the file format) it is
* not possible to know ahead of time how many outputs you will have or
* what types they will be.
- * This reader can only handle static EnSight datasets (both static geometry
- * and variables).
-*/
+ * If UseStaticMesh is true, this reader generates an unstructured grid
+ * with static geometry.
+ */
#ifndef vtkStaticEnSight6BinaryReader_h
#define vtkStaticEnSight6BinaryReader_h
#include <vtkEnSight6BinaryReader.h>
#include <vtkNew.h>
+#include "StaticMeshModuleModule.h"
+
class vtkMultiBlockDataSet;
-class vtkStaticEnSight6BinaryReader : public vtkEnSight6BinaryReader
+class STATICMESHMODULE_EXPORT vtkStaticEnSight6BinaryReader : public vtkEnSight6BinaryReader
{
public:
- static vtkStaticEnSight6BinaryReader *New();
+ static vtkStaticEnSight6BinaryReader* New();
vtkTypeMacro(vtkStaticEnSight6BinaryReader, vtkEnSight6BinaryReader);
+ // @{
+ /**
+ * This boolean control whether or not the output
+ * should be considered a static mesh.
+ */
+ vtkGetMacro(UseStaticMesh, bool);
+ vtkSetMacro(UseStaticMesh, bool);
+ vtkBooleanMacro(UseStaticMesh, bool);
+ // @}
+
protected:
vtkStaticEnSight6BinaryReader() = default;
~vtkStaticEnSight6BinaryReader() override = default;
- int RequestData(vtkInformation*,
- vtkInformationVector**,
- vtkInformationVector*) override;
-
- vtkNew<vtkMultiBlockDataSet> Cache;
- vtkTimeStamp CacheMTime;
+ /**
+ * see vtkDataSetAlgorithm
+ */
+ int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
private:
vtkStaticEnSight6BinaryReader(const vtkStaticEnSight6BinaryReader&) = delete;
void operator=(const vtkStaticEnSight6BinaryReader&) = delete;
+
+ bool UseStaticMesh = false;
+ vtkNew<vtkMultiBlockDataSet> Cache;
+ vtkTimeStamp CacheMTime;
};
#endif
-
#include <vtkMultiBlockDataSet.h>
#include <vtkObjectFactory.h>
#include <vtkStreamingDemandDrivenPipeline.h>
+#include <vtksys/SystemTools.hxx>
vtkStandardNewMacro(vtkStaticEnSight6Reader);
//----------------------------------------------------------------------------
-int vtkStaticEnSight6Reader::RequestData(
- vtkInformation *vtkNotUsed(request),
- vtkInformationVector **vtkNotUsed(inputVector),
- vtkInformationVector *outputVector)
+int vtkStaticEnSight6Reader::RequestData(vtkInformation* vtkNotUsed(request),
+ vtkInformationVector** vtkNotUsed(inputVector), vtkInformationVector* outputVector)
{
- vtkDebugMacro("In execute ");
+ vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::GetData(outputVector);
- vtkInformation *outInfo = outputVector->GetInformationObject(0);
- vtkMultiBlockDataSet *output = vtkMultiBlockDataSet::SafeDownCast(
- outInfo->Get(vtkDataObject::DATA_OBJECT()));
-
- int tsLength =
- outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
- double* steps =
- outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
+ vtkInformation* outInfo = outputVector->GetInformationObject(0);
+ int tsLength = outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
+ double* steps = outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
this->ActualTimeValue = this->TimeValue;
// Check if a particular time was requested by the pipeline.
// This overrides the ivar.
- if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()) && tsLength>0)
+ if (outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()) && tsLength > 0)
{
// Get the requested time step. We only support requests of a single time
// step in this reader right now
- double requestedTimeStep =
- outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
+ double requestedTimeStep = outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
// find the first time value larger than requested time value
// this logic could be improved
int cnt = 0;
- while (cnt < tsLength-1 && steps[cnt] < requestedTimeStep)
+ while (cnt < tsLength - 1 && steps[cnt] < requestedTimeStep)
{
cnt++;
}
this->ActualTimeValue = steps[cnt];
}
- vtkDebugMacro("Executing with: " << this->ActualTimeValue);
-
- if (this->CacheMTime < this->GetMTime())
+ if (!this->UseStaticMesh || this->CacheMTime < this->GetMTime())
{
- int i, timeSet, fileSet, timeStep, timeStepInFile, fileNum;
- vtkDataArray *times;
- vtkIdList *numStepsList, *filenameNumbers;
- float newTime;
- int numSteps;
- char* fileName;
- int filenameNum;
+ if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
+ {
+ vtkWarningMacro("Building static mesh cache");
+ }
- if ( ! this->CaseFileRead)
+ if (!this->CaseFileRead)
{
vtkErrorMacro("error reading case file");
return 0;
this->NumberOfGeometryParts = 0;
if (this->GeometryFileName)
{
- timeStep = timeStepInFile = 1;
- fileNum = 1;
- fileName = new char[strlen(this->GeometryFileName) + 10];
- strcpy(fileName, this->GeometryFileName);
+ vtkIdType timeStep = 1;
+ vtkIdType timeStepInFile = 1;
+ int fileNum = 1;
+ std::string fileName(this->GeometryFileName);
+ fileName.resize(fileName.size() + 10);
if (this->UseTimeSets)
{
- timeSet = this->TimeSetIds->IsId(this->GeometryTimeSet);
+ vtkIdType timeSet = this->TimeSetIds->IsId(this->GeometryTimeSet);
if (timeSet >= 0)
{
- times = this->TimeSets->GetItem(timeSet);
+ vtkDataArray* times = this->TimeSets->GetItem(timeSet);
this->GeometryTimeValue = times->GetComponent(0, 0);
- for (i = 1; i < times->GetNumberOfTuples(); i++)
+ for (vtkIdType i = 1; i < times->GetNumberOfTuples(); i++)
{
- newTime = times->GetComponent(i, 0);
- if (newTime <= this->ActualTimeValue &&
- newTime > this->GeometryTimeValue)
+ double newTime = times->GetComponent(i, 0);
+ if (newTime <= this->ActualTimeValue && newTime > this->GeometryTimeValue)
{
this->GeometryTimeValue = newTime;
timeStep++;
}
if (this->TimeSetFileNameNumbers->GetNumberOfItems() > 0)
{
- int collectionNum = this->TimeSetsWithFilenameNumbers->
- IsId(this->GeometryTimeSet);
+ int collectionNum = this->TimeSetsWithFilenameNumbers->IsId(this->GeometryTimeSet);
if (collectionNum > -1)
{
- filenameNumbers =
- this->TimeSetFileNameNumbers->GetItem(collectionNum);
- filenameNum = filenameNumbers->GetId(timeStep-1);
- if (! this->UseFileSets)
+ vtkIdList* filenameNumbers = this->TimeSetFileNameNumbers->GetItem(collectionNum);
+ int filenameNum = filenameNumbers->GetId(timeStep - 1);
+ if (!this->UseFileSets)
{
- this->ReplaceWildcards(fileName, filenameNum);
+ this->ReplaceWildcards(&fileName[0], filenameNum);
}
}
}
// There can only be file sets if there are also time sets.
if (this->UseFileSets)
{
- fileSet = this->FileSets->IsId(this->GeometryFileSet);
- numStepsList = static_cast<vtkIdList*>(this->FileSetNumberOfSteps->
- GetItemAsObject(fileSet));
+ vtkIdType fileSet = this->FileSets->IsId(this->GeometryFileSet);
+ vtkIdList* numStepsList =
+ static_cast<vtkIdList*>(this->FileSetNumberOfSteps->GetItemAsObject(fileSet));
if (timeStep > numStepsList->GetId(0))
{
- numSteps = numStepsList->GetId(0);
+ vtkIdType numSteps = numStepsList->GetId(0);
timeStepInFile -= numSteps;
fileNum = 2;
- for (i = 1; i < numStepsList->GetNumberOfIds(); i++)
+ for (vtkIdType i = 1; i < numStepsList->GetNumberOfIds(); i++)
{
numSteps += numStepsList->GetId(i);
if (timeStep > numSteps)
}
if (this->FileSetFileNameNumbers->GetNumberOfItems() > 0)
{
- int collectionNum = this->FileSetsWithFilenameNumbers->
- IsId(this->GeometryFileSet);
+ int collectionNum = this->FileSetsWithFilenameNumbers->IsId(this->GeometryFileSet);
if (collectionNum > -1)
{
- filenameNumbers = this->FileSetFileNameNumbers->
- GetItem(collectionNum);
- filenameNum = filenameNumbers->GetId(fileNum-1);
- this->ReplaceWildcards(fileName, filenameNum);
+ vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(collectionNum);
+ int filenameNum = filenameNumbers->GetId(fileNum - 1);
+ this->ReplaceWildcards(&fileName[0], filenameNum);
}
}
}
}
}
- if (!this->ReadGeometryFile(fileName, timeStepInFile, this->Cache))
+ if (!this->ReadGeometryFile(fileName.data(), timeStepInFile, this->Cache))
{
vtkErrorMacro("error reading geometry file");
- delete [] fileName;
return 0;
}
-
- delete [] fileName;
}
if (this->MeasuredFileName)
{
- timeStep = timeStepInFile = 1;
- fileNum = 1;
- fileName = new char[strlen(this->MeasuredFileName) + 10];
- strcpy(fileName, this->MeasuredFileName);
+ vtkIdType timeStep = 1;
+ vtkIdType timeStepInFile = 1;
+ int fileNum = 1;
+ std::string fileName(this->MeasuredFileName);
+ fileName.resize(fileName.size() + 10);
if (this->UseTimeSets)
{
- timeSet = this->TimeSetIds->IsId(this->MeasuredTimeSet);
+ vtkIdType timeSet = this->TimeSetIds->IsId(this->MeasuredTimeSet);
if (timeSet >= 0)
{
- times = this->TimeSets->GetItem(timeSet);
+ vtkDataArray* times = this->TimeSets->GetItem(timeSet);
this->MeasuredTimeValue = times->GetComponent(0, 0);
- for (i = 1; i < times->GetNumberOfTuples(); i++)
+ for (vtkIdType i = 1; i < times->GetNumberOfTuples(); i++)
{
- newTime = times->GetComponent(i, 0);
- if (newTime <= this->ActualTimeValue &&
- newTime > this->MeasuredTimeValue)
+ double newTime = times->GetComponent(i, 0);
+ if (newTime <= this->ActualTimeValue && newTime > this->MeasuredTimeValue)
{
this->MeasuredTimeValue = newTime;
timeStep++;
}
if (this->TimeSetFileNameNumbers->GetNumberOfItems() > 0)
{
- int collectionNum = this->TimeSetsWithFilenameNumbers->
- IsId(this->MeasuredTimeSet);
+ int collectionNum = this->TimeSetsWithFilenameNumbers->IsId(this->MeasuredTimeSet);
if (collectionNum > -1)
{
- filenameNumbers = this->TimeSetFileNameNumbers->
- GetItem(collectionNum);
- filenameNum = filenameNumbers->GetId(timeStep-1);
- if (! this->UseFileSets)
+ vtkIdList* filenameNumbers = this->TimeSetFileNameNumbers->GetItem(collectionNum);
+ int filenameNum = filenameNumbers->GetId(timeStep - 1);
+ if (!this->UseFileSets)
{
- this->ReplaceWildcards(fileName, filenameNum);
+ this->ReplaceWildcards(&fileName[0], filenameNum);
}
}
}
// There can only be file sets if there are also time sets.
if (this->UseFileSets)
{
- fileSet = this->FileSets->IsId(this->MeasuredFileSet);
- numStepsList = static_cast<vtkIdList*>(this->FileSetNumberOfSteps->
- GetItemAsObject(fileSet));
+ vtkIdType fileSet = this->FileSets->IsId(this->MeasuredFileSet);
+ vtkIdList* numStepsList =
+ static_cast<vtkIdList*>(this->FileSetNumberOfSteps->GetItemAsObject(fileSet));
if (timeStep > numStepsList->GetId(0))
{
- numSteps = numStepsList->GetId(0);
+ vtkIdType numSteps = numStepsList->GetId(0);
timeStepInFile -= numSteps;
fileNum = 2;
- for (i = 1; i < numStepsList->GetNumberOfIds(); i++)
+ for (vtkIdType i = 1; i < numStepsList->GetNumberOfIds(); i++)
{
numSteps += numStepsList->GetId(i);
if (timeStep > numSteps)
}
if (this->FileSetFileNameNumbers->GetNumberOfItems() > 0)
{
- int collectionNum = this->FileSetsWithFilenameNumbers->
- IsId(this->MeasuredFileSet);
+ int collectionNum = this->FileSetsWithFilenameNumbers->IsId(this->MeasuredFileSet);
if (collectionNum > -1)
{
- filenameNumbers = this->FileSetFileNameNumbers->
- GetItem(fileSet);
- filenameNum = filenameNumbers->GetId(fileNum-1);
- this->ReplaceWildcards(fileName, filenameNum);
+ vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(fileSet);
+ int filenameNum = filenameNumbers->GetId(fileNum - 1);
+ this->ReplaceWildcards(&fileName[0], filenameNum);
}
}
}
}
}
- if (!this->ReadMeasuredGeometryFile(fileName, timeStepInFile, this->Cache))
+ if (!this->ReadMeasuredGeometryFile(fileName.data(), timeStepInFile, this->Cache))
{
vtkErrorMacro("error reading measured geometry file");
- delete [] fileName;
return 0;
}
- delete [] fileName;
}
this->CacheMTime.Modified();
}
* of the pipeline because (due to the nature of the file format) it is
* not possible to know ahead of time how many outputs you will have or
* what types they will be.
- * This reader can only handle static EnSight datasets (both static geometry
- * and variables).
-*/
+ * If UseStaticMesh is true, this reader generates an unstructured grid
+ * with static geometry.
+ */
#ifndef vtkStaticEnSight6Reader_h
#define vtkStaticEnSight6Reader_h
#include <vtkEnSight6Reader.h>
#include <vtkNew.h>
+#include "StaticMeshModuleModule.h"
+
class vtkMultiBlockDataSet;
-class vtkStaticEnSight6Reader : public vtkEnSight6Reader
+class STATICMESHMODULE_EXPORT vtkStaticEnSight6Reader : public vtkEnSight6Reader
{
public:
- static vtkStaticEnSight6Reader *New();
+ static vtkStaticEnSight6Reader* New();
vtkTypeMacro(vtkStaticEnSight6Reader, vtkEnSight6Reader);
+ // @{
+ /**
+ * This boolean control whether or not the output
+ * should be considered a static mesh.
+ */
+ vtkGetMacro(UseStaticMesh, bool);
+ vtkSetMacro(UseStaticMesh, bool);
+ vtkBooleanMacro(UseStaticMesh, bool);
+ // @}
+
protected:
vtkStaticEnSight6Reader() = default;
~vtkStaticEnSight6Reader() override = default;
- int RequestData(vtkInformation*,
- vtkInformationVector**,
- vtkInformationVector*) override;
-
- vtkNew<vtkMultiBlockDataSet> Cache;
- vtkTimeStamp CacheMTime;
+ /**
+ * see vtkDataSetAlgorithm
+ */
+ int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
private:
vtkStaticEnSight6Reader(const vtkStaticEnSight6Reader&) = delete;
void operator=(const vtkStaticEnSight6Reader&) = delete;
+
+ bool UseStaticMesh = false;
+
+ vtkNew<vtkMultiBlockDataSet> Cache;
+ vtkTimeStamp CacheMTime;
};
#endif
-
#include <vtkMultiBlockDataSet.h>
#include <vtkObjectFactory.h>
#include <vtkStreamingDemandDrivenPipeline.h>
+#include <vtksys/SystemTools.hxx>
vtkStandardNewMacro(vtkStaticEnSightGoldBinaryReader);
//----------------------------------------------------------------------------
-int vtkStaticEnSightGoldBinaryReader::RequestData(
- vtkInformation *vtkNotUsed(request),
- vtkInformationVector **vtkNotUsed(inputVector),
- vtkInformationVector *outputVector)
+int vtkStaticEnSightGoldBinaryReader::RequestData(vtkInformation* vtkNotUsed(request),
+ vtkInformationVector** vtkNotUsed(inputVector), vtkInformationVector* outputVector)
{
- vtkDebugMacro("In execute ");
+ vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::GetData(outputVector);
- vtkInformation *outInfo = outputVector->GetInformationObject(0);
- vtkMultiBlockDataSet *output = vtkMultiBlockDataSet::SafeDownCast(
- outInfo->Get(vtkDataObject::DATA_OBJECT()));
-
- int tsLength =
- outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
- double* steps =
- outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
+ vtkInformation* outInfo = outputVector->GetInformationObject(0);
+ int tsLength = outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
+ double* steps = outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
this->ActualTimeValue = this->TimeValue;
// Check if a particular time was requested by the pipeline.
// This overrides the ivar.
- if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()) && tsLength>0)
+ if (outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()) && tsLength > 0)
{
// Get the requested time step. We only support requests of a single time
// step in this reader right now
- double requestedTimeStep =
- outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
+ double requestedTimeStep = outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
// find the first time value larger than requested time value
// this logic could be improved
int cnt = 0;
- while (cnt < tsLength-1 && steps[cnt] < requestedTimeStep)
+ while (cnt < tsLength - 1 && steps[cnt] < requestedTimeStep)
{
cnt++;
}
this->ActualTimeValue = steps[cnt];
}
- vtkDebugMacro("Executing with: " << this->ActualTimeValue);
-
- if (this->CacheMTime < this->GetMTime())
+ if (!this->UseStaticMesh || this->CacheMTime < this->GetMTime())
{
- int i, timeSet, fileSet, timeStep, timeStepInFile, fileNum;
- vtkDataArray *times;
- vtkIdList *numStepsList, *filenameNumbers;
- float newTime;
- int numSteps;
- char* fileName;
- int filenameNum;
+ if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
+ {
+ vtkWarningMacro("Building static mesh cache");
+ }
- if ( ! this->CaseFileRead)
+ if (!this->CaseFileRead)
{
vtkErrorMacro("error reading case file");
return 0;
this->NumberOfGeometryParts = 0;
if (this->GeometryFileName)
{
- timeStep = timeStepInFile = 1;
- fileNum = 1;
- fileName = new char[strlen(this->GeometryFileName) + 10];
- strcpy(fileName, this->GeometryFileName);
+ vtkIdType timeStep = 1;
+ vtkIdType timeStepInFile = 1;
+ int fileNum = 1;
+ std::string fileName(this->GeometryFileName);
+ fileName.resize(fileName.size() + 10);
if (this->UseTimeSets)
{
- timeSet = this->TimeSetIds->IsId(this->GeometryTimeSet);
+ vtkIdType timeSet = this->TimeSetIds->IsId(this->GeometryTimeSet);
if (timeSet >= 0)
{
- times = this->TimeSets->GetItem(timeSet);
+ vtkDataArray* times = this->TimeSets->GetItem(timeSet);
this->GeometryTimeValue = times->GetComponent(0, 0);
- for (i = 1; i < times->GetNumberOfTuples(); i++)
+ for (vtkIdType i = 1; i < times->GetNumberOfTuples(); i++)
{
- newTime = times->GetComponent(i, 0);
- if (newTime <= this->ActualTimeValue &&
- newTime > this->GeometryTimeValue)
+ double newTime = times->GetComponent(i, 0);
+ if (newTime <= this->ActualTimeValue && newTime > this->GeometryTimeValue)
{
this->GeometryTimeValue = newTime;
timeStep++;
}
if (this->TimeSetFileNameNumbers->GetNumberOfItems() > 0)
{
- int collectionNum = this->TimeSetsWithFilenameNumbers->
- IsId(this->GeometryTimeSet);
+ int collectionNum = this->TimeSetsWithFilenameNumbers->IsId(this->GeometryTimeSet);
if (collectionNum > -1)
{
- filenameNumbers =
- this->TimeSetFileNameNumbers->GetItem(collectionNum);
- filenameNum = filenameNumbers->GetId(timeStep-1);
- if (! this->UseFileSets)
+ vtkIdList* filenameNumbers = this->TimeSetFileNameNumbers->GetItem(collectionNum);
+ int filenameNum = filenameNumbers->GetId(timeStep - 1);
+ if (!this->UseFileSets)
{
- this->ReplaceWildcards(fileName, filenameNum);
+ this->ReplaceWildcards(&fileName[0], filenameNum);
}
}
}
// There can only be file sets if there are also time sets.
if (this->UseFileSets)
{
- fileSet = this->FileSets->IsId(this->GeometryFileSet);
- numStepsList = static_cast<vtkIdList*>(this->FileSetNumberOfSteps->
- GetItemAsObject(fileSet));
+ vtkIdType fileSet = this->FileSets->IsId(this->GeometryFileSet);
+ vtkIdList* numStepsList =
+ static_cast<vtkIdList*>(this->FileSetNumberOfSteps->GetItemAsObject(fileSet));
if (timeStep > numStepsList->GetId(0))
{
- numSteps = numStepsList->GetId(0);
+ vtkIdType numSteps = numStepsList->GetId(0);
timeStepInFile -= numSteps;
fileNum = 2;
- for (i = 1; i < numStepsList->GetNumberOfIds(); i++)
+ for (vtkIdType i = 1; i < numStepsList->GetNumberOfIds(); i++)
{
numSteps += numStepsList->GetId(i);
if (timeStep > numSteps)
}
if (this->FileSetFileNameNumbers->GetNumberOfItems() > 0)
{
- int collectionNum = this->FileSetsWithFilenameNumbers->
- IsId(this->GeometryFileSet);
+ int collectionNum = this->FileSetsWithFilenameNumbers->IsId(this->GeometryFileSet);
if (collectionNum > -1)
{
- filenameNumbers = this->FileSetFileNameNumbers->
- GetItem(collectionNum);
- filenameNum = filenameNumbers->GetId(fileNum-1);
- this->ReplaceWildcards(fileName, filenameNum);
+ vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(collectionNum);
+ int filenameNum = filenameNumbers->GetId(fileNum - 1);
+ this->ReplaceWildcards(&fileName[0], filenameNum);
}
}
}
}
}
- if (!this->ReadGeometryFile(fileName, timeStepInFile, this->Cache))
+ if (!this->ReadGeometryFile(fileName.data(), timeStepInFile, this->Cache))
{
vtkErrorMacro("error reading geometry file");
- delete [] fileName;
return 0;
}
-
- delete [] fileName;
}
if (this->MeasuredFileName)
{
- timeStep = timeStepInFile = 1;
- fileNum = 1;
- fileName = new char[strlen(this->MeasuredFileName) + 10];
- strcpy(fileName, this->MeasuredFileName);
+ vtkIdType timeStep = 1;
+ vtkIdType timeStepInFile = 1;
+ int fileNum = 1;
+ std::string fileName(this->MeasuredFileName);
+ fileName.resize(fileName.size() + 10);
if (this->UseTimeSets)
{
- timeSet = this->TimeSetIds->IsId(this->MeasuredTimeSet);
+ vtkIdType timeSet = this->TimeSetIds->IsId(this->MeasuredTimeSet);
if (timeSet >= 0)
{
- times = this->TimeSets->GetItem(timeSet);
+ vtkDataArray* times = this->TimeSets->GetItem(timeSet);
this->MeasuredTimeValue = times->GetComponent(0, 0);
- for (i = 1; i < times->GetNumberOfTuples(); i++)
+ for (vtkIdType i = 1; i < times->GetNumberOfTuples(); i++)
{
- newTime = times->GetComponent(i, 0);
- if (newTime <= this->ActualTimeValue &&
- newTime > this->MeasuredTimeValue)
+ double newTime = times->GetComponent(i, 0);
+ if (newTime <= this->ActualTimeValue && newTime > this->MeasuredTimeValue)
{
this->MeasuredTimeValue = newTime;
timeStep++;
}
if (this->TimeSetFileNameNumbers->GetNumberOfItems() > 0)
{
- int collectionNum = this->TimeSetsWithFilenameNumbers->
- IsId(this->MeasuredTimeSet);
+ int collectionNum = this->TimeSetsWithFilenameNumbers->IsId(this->MeasuredTimeSet);
if (collectionNum > -1)
{
- filenameNumbers = this->TimeSetFileNameNumbers->
- GetItem(collectionNum);
- filenameNum = filenameNumbers->GetId(timeStep-1);
- if (! this->UseFileSets)
+ vtkIdList* filenameNumbers = this->TimeSetFileNameNumbers->GetItem(collectionNum);
+ int filenameNum = filenameNumbers->GetId(timeStep - 1);
+ if (!this->UseFileSets)
{
- this->ReplaceWildcards(fileName, filenameNum);
+ this->ReplaceWildcards(&fileName[0], filenameNum);
}
}
}
// There can only be file sets if there are also time sets.
if (this->UseFileSets)
{
- fileSet = this->FileSets->IsId(this->MeasuredFileSet);
- numStepsList = static_cast<vtkIdList*>(this->FileSetNumberOfSteps->
- GetItemAsObject(fileSet));
+ vtkIdType fileSet = this->FileSets->IsId(this->MeasuredFileSet);
+ vtkIdList* numStepsList =
+ static_cast<vtkIdList*>(this->FileSetNumberOfSteps->GetItemAsObject(fileSet));
if (timeStep > numStepsList->GetId(0))
{
- numSteps = numStepsList->GetId(0);
+ vtkIdType numSteps = numStepsList->GetId(0);
timeStepInFile -= numSteps;
fileNum = 2;
- for (i = 1; i < numStepsList->GetNumberOfIds(); i++)
+ for (vtkIdType i = 1; i < numStepsList->GetNumberOfIds(); i++)
{
numSteps += numStepsList->GetId(i);
if (timeStep > numSteps)
}
if (this->FileSetFileNameNumbers->GetNumberOfItems() > 0)
{
- int collectionNum = this->FileSetsWithFilenameNumbers->
- IsId(this->MeasuredFileSet);
+ int collectionNum = this->FileSetsWithFilenameNumbers->IsId(this->MeasuredFileSet);
if (collectionNum > -1)
{
- filenameNumbers = this->FileSetFileNameNumbers->
- GetItem(fileSet);
- filenameNum = filenameNumbers->GetId(fileNum-1);
- this->ReplaceWildcards(fileName, filenameNum);
+ vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(fileSet);
+ int filenameNum = filenameNumbers->GetId(fileNum - 1);
+ this->ReplaceWildcards(&fileName[0], filenameNum);
}
}
}
}
}
- if (!this->ReadMeasuredGeometryFile(fileName, timeStepInFile, this->Cache))
+ if (!this->ReadMeasuredGeometryFile(fileName.data(), timeStepInFile, this->Cache))
{
vtkErrorMacro("error reading measured geometry file");
- delete [] fileName;
return 0;
}
- delete [] fileName;
}
this->CacheMTime.Modified();
}
* of the pipeline because (due to the nature of the file format) it is
* not possible to know ahead of time how many outputs you will have or
* what types they will be.
- * This reader can only handle static EnSight datasets (both static geometry
- * and variables).
-*/
+ * If UseStaticMesh is true, this reader generates an unstructured grid
+ * with static geometry.
+ */
#ifndef vtkStaticEnSightGoldBinaryReader_h
#define vtkStaticEnSightGoldBinaryReader_h
#include <vtkEnSightGoldBinaryReader.h>
#include <vtkNew.h>
+#include "StaticMeshModuleModule.h"
+
class vtkMultiBlockDataSet;
-class vtkStaticEnSightGoldBinaryReader : public vtkEnSightGoldBinaryReader
+class STATICMESHMODULE_EXPORT vtkStaticEnSightGoldBinaryReader : public vtkEnSightGoldBinaryReader
{
public:
- static vtkStaticEnSightGoldBinaryReader *New();
+ static vtkStaticEnSightGoldBinaryReader* New();
vtkTypeMacro(vtkStaticEnSightGoldBinaryReader, vtkEnSightGoldBinaryReader);
+ // @{
+ /**
+ * This boolean control whether or not the output
+ * should be considered a static mesh.
+ */
+ vtkGetMacro(UseStaticMesh, bool);
+ vtkSetMacro(UseStaticMesh, bool);
+ vtkBooleanMacro(UseStaticMesh, bool);
+ // @}
+
protected:
vtkStaticEnSightGoldBinaryReader() = default;
~vtkStaticEnSightGoldBinaryReader() override = default;
- int RequestData(vtkInformation*,
- vtkInformationVector**,
- vtkInformationVector*) override;
-
- vtkNew<vtkMultiBlockDataSet> Cache;
- vtkTimeStamp CacheMTime;
+ /**
+ * see vtkDataSetAlgorithm
+ */
+ int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
private:
vtkStaticEnSightGoldBinaryReader(const vtkStaticEnSightGoldBinaryReader&) = delete;
void operator=(const vtkStaticEnSightGoldBinaryReader&) = delete;
+
+ bool UseStaticMesh = false;
+
+ vtkNew<vtkMultiBlockDataSet> Cache;
+ vtkTimeStamp CacheMTime;
};
#endif
-
#include <vtkMultiBlockDataSet.h>
#include <vtkObjectFactory.h>
#include <vtkStreamingDemandDrivenPipeline.h>
+#include <vtksys/SystemTools.hxx>
vtkStandardNewMacro(vtkStaticEnSightGoldReader);
//----------------------------------------------------------------------------
-int vtkStaticEnSightGoldReader::RequestData(
- vtkInformation *vtkNotUsed(request),
- vtkInformationVector **vtkNotUsed(inputVector),
- vtkInformationVector *outputVector)
+int vtkStaticEnSightGoldReader::RequestData(vtkInformation* vtkNotUsed(request),
+ vtkInformationVector** vtkNotUsed(inputVector), vtkInformationVector* outputVector)
{
- vtkDebugMacro("In execute ");
+ vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::GetData(outputVector);
- vtkInformation *outInfo = outputVector->GetInformationObject(0);
- vtkMultiBlockDataSet *output = vtkMultiBlockDataSet::SafeDownCast(
- outInfo->Get(vtkDataObject::DATA_OBJECT()));
-
- int tsLength =
- outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
- double* steps =
- outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
+ vtkInformation* outInfo = outputVector->GetInformationObject(0);
+ int tsLength = outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
+ double* steps = outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
this->ActualTimeValue = this->TimeValue;
// Check if a particular time was requested by the pipeline.
// This overrides the ivar.
- if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()) && tsLength>0)
+ if (outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()) && tsLength > 0)
{
// Get the requested time step. We only support requests of a single time
// step in this reader right now
- double requestedTimeStep =
- outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
+ double requestedTimeStep = outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
// find the first time value larger than requested time value
// this logic could be improved
int cnt = 0;
- while (cnt < tsLength-1 && steps[cnt] < requestedTimeStep)
+ while (cnt < tsLength - 1 && steps[cnt] < requestedTimeStep)
{
cnt++;
}
this->ActualTimeValue = steps[cnt];
}
- vtkDebugMacro("Executing with: " << this->ActualTimeValue);
-
- if (this->CacheMTime < this->GetMTime())
+ if (!this->UseStaticMesh || this->CacheMTime < this->GetMTime())
{
- int i, timeSet, fileSet, timeStep, timeStepInFile, fileNum;
- vtkDataArray *times;
- vtkIdList *numStepsList, *filenameNumbers;
- float newTime;
- int numSteps;
- char* fileName;
- int filenameNum;
+ if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
+ {
+ vtkWarningMacro("Building static mesh cache");
+ }
- if ( ! this->CaseFileRead)
+ if (!this->CaseFileRead)
{
vtkErrorMacro("error reading case file");
return 0;
this->NumberOfGeometryParts = 0;
if (this->GeometryFileName)
{
- timeStep = timeStepInFile = 1;
- fileNum = 1;
- fileName = new char[strlen(this->GeometryFileName) + 10];
- strcpy(fileName, this->GeometryFileName);
+ vtkIdType timeStep = 1;
+ vtkIdType timeStepInFile = 1;
+ int fileNum = 1;
+ std::string fileName(this->GeometryFileName);
+ fileName.resize(fileName.size() + 10);
if (this->UseTimeSets)
{
- timeSet = this->TimeSetIds->IsId(this->GeometryTimeSet);
+ vtkIdType timeSet = this->TimeSetIds->IsId(this->GeometryTimeSet);
if (timeSet >= 0)
{
- times = this->TimeSets->GetItem(timeSet);
+ vtkDataArray* times = this->TimeSets->GetItem(timeSet);
this->GeometryTimeValue = times->GetComponent(0, 0);
- for (i = 1; i < times->GetNumberOfTuples(); i++)
+ for (vtkIdType i = 1; i < times->GetNumberOfTuples(); i++)
{
- newTime = times->GetComponent(i, 0);
- if (newTime <= this->ActualTimeValue &&
- newTime > this->GeometryTimeValue)
+ double newTime = times->GetComponent(i, 0);
+ if (newTime <= this->ActualTimeValue && newTime > this->GeometryTimeValue)
{
this->GeometryTimeValue = newTime;
timeStep++;
}
if (this->TimeSetFileNameNumbers->GetNumberOfItems() > 0)
{
- int collectionNum = this->TimeSetsWithFilenameNumbers->
- IsId(this->GeometryTimeSet);
+ int collectionNum = this->TimeSetsWithFilenameNumbers->IsId(this->GeometryTimeSet);
if (collectionNum > -1)
{
- filenameNumbers =
- this->TimeSetFileNameNumbers->GetItem(collectionNum);
- filenameNum = filenameNumbers->GetId(timeStep-1);
- if (! this->UseFileSets)
+ vtkIdList* filenameNumbers = this->TimeSetFileNameNumbers->GetItem(collectionNum);
+ int filenameNum = filenameNumbers->GetId(timeStep - 1);
+ if (!this->UseFileSets)
{
- this->ReplaceWildcards(fileName, filenameNum);
+ this->ReplaceWildcards(&fileName[0], filenameNum);
}
}
}
// There can only be file sets if there are also time sets.
if (this->UseFileSets)
{
- fileSet = this->FileSets->IsId(this->GeometryFileSet);
- numStepsList = static_cast<vtkIdList*>(this->FileSetNumberOfSteps->
- GetItemAsObject(fileSet));
+ vtkIdType fileSet = this->FileSets->IsId(this->GeometryFileSet);
+ vtkIdList* numStepsList =
+ static_cast<vtkIdList*>(this->FileSetNumberOfSteps->GetItemAsObject(fileSet));
if (timeStep > numStepsList->GetId(0))
{
- numSteps = numStepsList->GetId(0);
+ vtkIdType numSteps = numStepsList->GetId(0);
timeStepInFile -= numSteps;
fileNum = 2;
- for (i = 1; i < numStepsList->GetNumberOfIds(); i++)
+ for (vtkIdType i = 1; i < numStepsList->GetNumberOfIds(); i++)
{
numSteps += numStepsList->GetId(i);
if (timeStep > numSteps)
}
if (this->FileSetFileNameNumbers->GetNumberOfItems() > 0)
{
- int collectionNum = this->FileSetsWithFilenameNumbers->
- IsId(this->GeometryFileSet);
+ int collectionNum = this->FileSetsWithFilenameNumbers->IsId(this->GeometryFileSet);
if (collectionNum > -1)
{
- filenameNumbers = this->FileSetFileNameNumbers->
- GetItem(collectionNum);
- filenameNum = filenameNumbers->GetId(fileNum-1);
- this->ReplaceWildcards(fileName, filenameNum);
+ vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(collectionNum);
+ int filenameNum = filenameNumbers->GetId(fileNum - 1);
+ this->ReplaceWildcards(&fileName[0], filenameNum);
}
}
}
}
}
- if (!this->ReadGeometryFile(fileName, timeStepInFile, this->Cache))
+ if (!this->ReadGeometryFile(fileName.data(), timeStepInFile, this->Cache))
{
vtkErrorMacro("error reading geometry file");
- delete [] fileName;
return 0;
}
-
- delete [] fileName;
}
if (this->MeasuredFileName)
{
- timeStep = timeStepInFile = 1;
- fileNum = 1;
- fileName = new char[strlen(this->MeasuredFileName) + 10];
- strcpy(fileName, this->MeasuredFileName);
+ vtkIdType timeStep = 1;
+ vtkIdType timeStepInFile = 1;
+ int fileNum = 1;
+ std::string fileName(this->MeasuredFileName);
+ fileName.resize(fileName.size() + 10);
if (this->UseTimeSets)
{
- timeSet = this->TimeSetIds->IsId(this->MeasuredTimeSet);
+ vtkIdType timeSet = this->TimeSetIds->IsId(this->MeasuredTimeSet);
if (timeSet >= 0)
{
- times = this->TimeSets->GetItem(timeSet);
+ vtkDataArray* times = this->TimeSets->GetItem(timeSet);
this->MeasuredTimeValue = times->GetComponent(0, 0);
- for (i = 1; i < times->GetNumberOfTuples(); i++)
+ for (vtkIdType i = 1; i < times->GetNumberOfTuples(); i++)
{
- newTime = times->GetComponent(i, 0);
- if (newTime <= this->ActualTimeValue &&
- newTime > this->MeasuredTimeValue)
+ double newTime = times->GetComponent(i, 0);
+ if (newTime <= this->ActualTimeValue && newTime > this->MeasuredTimeValue)
{
this->MeasuredTimeValue = newTime;
timeStep++;
}
if (this->TimeSetFileNameNumbers->GetNumberOfItems() > 0)
{
- int collectionNum = this->TimeSetsWithFilenameNumbers->
- IsId(this->MeasuredTimeSet);
+ int collectionNum = this->TimeSetsWithFilenameNumbers->IsId(this->MeasuredTimeSet);
if (collectionNum > -1)
{
- filenameNumbers = this->TimeSetFileNameNumbers->
- GetItem(collectionNum);
- filenameNum = filenameNumbers->GetId(timeStep-1);
- if (! this->UseFileSets)
+ vtkIdList* filenameNumbers = this->TimeSetFileNameNumbers->GetItem(collectionNum);
+ int filenameNum = filenameNumbers->GetId(timeStep - 1);
+ if (!this->UseFileSets)
{
- this->ReplaceWildcards(fileName, filenameNum);
+ this->ReplaceWildcards(&fileName[0], filenameNum);
}
}
}
// There can only be file sets if there are also time sets.
if (this->UseFileSets)
{
- fileSet = this->FileSets->IsId(this->MeasuredFileSet);
- numStepsList = static_cast<vtkIdList*>(this->FileSetNumberOfSteps->
- GetItemAsObject(fileSet));
+ vtkIdType fileSet = this->FileSets->IsId(this->MeasuredFileSet);
+ vtkIdList* numStepsList =
+ static_cast<vtkIdList*>(this->FileSetNumberOfSteps->GetItemAsObject(fileSet));
if (timeStep > numStepsList->GetId(0))
{
- numSteps = numStepsList->GetId(0);
+ vtkIdType numSteps = numStepsList->GetId(0);
timeStepInFile -= numSteps;
fileNum = 2;
- for (i = 1; i < numStepsList->GetNumberOfIds(); i++)
+ for (vtkIdType i = 1; i < numStepsList->GetNumberOfIds(); i++)
{
numSteps += numStepsList->GetId(i);
if (timeStep > numSteps)
}
if (this->FileSetFileNameNumbers->GetNumberOfItems() > 0)
{
- int collectionNum = this->FileSetsWithFilenameNumbers->
- IsId(this->MeasuredFileSet);
+ int collectionNum = this->FileSetsWithFilenameNumbers->IsId(this->MeasuredFileSet);
if (collectionNum > -1)
{
- filenameNumbers = this->FileSetFileNameNumbers->
- GetItem(fileSet);
- filenameNum = filenameNumbers->GetId(fileNum-1);
- this->ReplaceWildcards(fileName, filenameNum);
+ vtkIdList* filenameNumbers = this->FileSetFileNameNumbers->GetItem(fileSet);
+ int filenameNum = filenameNumbers->GetId(fileNum - 1);
+ this->ReplaceWildcards(&fileName[0], filenameNum);
}
}
}
}
}
- if (!this->ReadMeasuredGeometryFile(fileName, timeStepInFile, this->Cache))
+ if (!this->ReadMeasuredGeometryFile(fileName.data(), timeStepInFile, this->Cache))
{
vtkErrorMacro("error reading measured geometry file");
- delete [] fileName;
return 0;
}
- delete [] fileName;
}
this->CacheMTime.Modified();
}
* of the pipeline because (due to the nature of the file format) it is
* not possible to know ahead of time how many outputs you will have or
* what types they will be.
- * This reader can only handle static EnSight datasets (both static geometry
- * and variables).
-*/
+ * If UseStaticMesh is true, this reader generates an unstructured grid
+ * with static geometry.
+ */
#ifndef vtkStaticEnSightGoldReader_h
#define vtkStaticEnSightGoldReader_h
#include <vtkEnSightGoldReader.h>
#include <vtkNew.h>
+#include "StaticMeshModuleModule.h"
+
class vtkMultiBlockDataSet;
-class vtkStaticEnSightGoldReader : public vtkEnSightGoldReader
+class STATICMESHMODULE_EXPORT vtkStaticEnSightGoldReader : public vtkEnSightGoldReader
{
public:
- static vtkStaticEnSightGoldReader *New();
+ static vtkStaticEnSightGoldReader* New();
vtkTypeMacro(vtkStaticEnSightGoldReader, vtkEnSightGoldReader);
+ // @{
+ /**
+ * This boolean control whether or not the output
+ * should be considered a static mesh.
+ */
+ vtkGetMacro(UseStaticMesh, bool);
+ vtkSetMacro(UseStaticMesh, bool);
+ vtkBooleanMacro(UseStaticMesh, bool);
+ // @}
+
protected:
vtkStaticEnSightGoldReader() = default;
~vtkStaticEnSightGoldReader() override = default;
- int RequestData(vtkInformation*,
- vtkInformationVector**,
- vtkInformationVector*) override;
-
- vtkNew<vtkMultiBlockDataSet> Cache;
- vtkTimeStamp CacheMTime;
+ /**
+ * see vtkDataSetAlgorithm
+ */
+ int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
private:
vtkStaticEnSightGoldReader(const vtkStaticEnSightGoldReader&) = delete;
void operator=(const vtkStaticEnSightGoldReader&) = delete;
+
+ bool UseStaticMesh = false;
+
+ vtkNew<vtkMultiBlockDataSet> Cache;
+ vtkTimeStamp CacheMTime;
};
#endif
-
/*=========================================================================
Program: Visualization Toolkit
- Module: vtkStaticDataSetSurfaceFilter.cxx
+ Module: vtkStaticMeshObjectFactory.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
VTK_CREATE_CREATE_FUNCTION(vtkStaticPUnstructuredGridGhostCellsGenerator);
#endif
+//-----------------------------------------------------------------------------
vtkStaticMeshObjectFactory::vtkStaticMeshObjectFactory()
{
- vtkDebugMacro("Create vtkStaticMeshObjectFactory");
-
this->RegisterOverride("vtkDataSetSurfaceFilter", "vtkStaticDataSetSurfaceFilter",
"StaticDataSetSurfaceFilter", 1, vtkObjectFactoryCreatevtkStaticDataSetSurfaceFilter);
this->RegisterOverride("vtkPlaneCutter", "vtkStaticPlaneCutter", "StaticPlaneCutter", 1,
vtkObjectFactoryCreatevtkStaticPlaneCutter);
- this->RegisterOverride("vtkEnSight6BinaryReader", "vtkStaticEnSight6BinaryReader", "StaticEnSight6BinaryReader", 1,
- vtkObjectFactoryCreatevtkStaticEnSight6BinaryReader);
+ this->RegisterOverride("vtkEnSight6BinaryReader", "vtkStaticEnSight6BinaryReader",
+ "StaticEnSight6BinaryReader", 1, vtkObjectFactoryCreatevtkStaticEnSight6BinaryReader);
this->RegisterOverride("vtkEnSight6Reader", "vtkStaticEnSight6Reader", "StaticEnSight6Reader", 1,
vtkObjectFactoryCreatevtkStaticEnSight6Reader);
- this->RegisterOverride("vtkEnSightGoldReader", "vtkStaticEnSight6BinaryReader", "StaticEnSight6BinaryReader", 1,
- vtkObjectFactoryCreatevtkStaticEnSightGoldReader);
- this->RegisterOverride("vtkEnSightGoldBinaryReader", "vtkStaticEnSightGoldBinaryReader", "StaticEnSightGoldBinaryReader", 1,
- vtkObjectFactoryCreatevtkStaticEnSightGoldBinaryReader);
+ this->RegisterOverride("vtkEnSightGoldReader", "vtkStaticEnSight6BinaryReader",
+ "StaticEnSight6BinaryReader", 1, vtkObjectFactoryCreatevtkStaticEnSightGoldReader);
+ this->RegisterOverride("vtkEnSightGoldBinaryReader", "vtkStaticEnSightGoldBinaryReader",
+ "StaticEnSightGoldBinaryReader", 1, vtkObjectFactoryCreatevtkStaticEnSightGoldBinaryReader);
#ifdef PARAVIEW_USE_MPI
this->RegisterOverride("vtkPUnstructuredGridGhostCellsGenerator",
#endif
}
-vtkStaticMeshObjectFactory::~vtkStaticMeshObjectFactory()
-{
- vtkDebugMacro("Delete vtkStaticMeshObjectFactory");
-}
-
+//-----------------------------------------------------------------------------
void vtkStaticMeshObjectFactory::PrintSelf(ostream& os, vtkIndent indent)
{
- os << indent << "VTK Static Mesh Extension Factory" << endl;
+ os << indent << this->GetDescription() << endl;
}
+//-----------------------------------------------------------------------------
const char* vtkStaticMeshObjectFactory::GetVTKSourceVersion()
{
return VTK_SOURCE_VERSION;
}
+//-----------------------------------------------------------------------------
const char* vtkStaticMeshObjectFactory::GetDescription()
{
return "VTK Static Mesh Extension Factory";
}
+//-----------------------------------------------------------------------------
class StaticFactoryInitialize
{
public:
bool hasStaticPluginFactory = false;
vtkObjectFactoryCollection* collection = vtkObjectFactory::GetRegisteredFactories();
collection->InitTraversal();
- vtkObjectFactory* f = collection->GetNextItem();
- while (f)
+ vtkObjectFactory* f;
+ while ((f = collection->GetNextItem()))
{
if (f->IsA("vtkStaticMeshObjectFactory"))
{
hasStaticPluginFactory = true;
break;
}
- f = collection->GetNextItem();
}
if (!hasStaticPluginFactory)
{
- vtkStaticMeshObjectFactory* instance = vtkStaticMeshObjectFactory::New();
+ vtkNew<vtkStaticMeshObjectFactory> instance;
vtkObjectFactory::RegisterFactory(instance);
- instance->Delete();
}
}
/*=========================================================================
Program: Visualization Toolkit
- Module: vtkStaticDataSetSurfaceFilter.h
+ Module: vtkStaticMeshObjectFactor.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
=========================================================================*/
/**
* @class vtkStaticMeshObjectFactory
- * @brief Generate static version of dataset and filter for statix mesh plugin
+ * @brief Generate static version of dataset and filter for static mesh plugin
*
* vtkStaticMeshObjectFactory is a vtk object factory, instantiating static version
- * of some dataset and filters.
-*/
+ * of some readers and filters.
+ */
#ifndef vtkStaticMeshObjectFactory_h
#define vtkStaticMeshObjectFactory_h
#include <vtkObjectFactory.h> // Must be included before singletons
-class vtkStaticMeshObjectFactory : public vtkObjectFactory
+#include "StaticMeshModuleModule.h"
+
+class STATICMESHMODULE_EXPORT vtkStaticMeshObjectFactory : public vtkObjectFactory
{
public:
vtkTypeMacro(vtkStaticMeshObjectFactory, vtkObjectFactory);
protected:
vtkStaticMeshObjectFactory();
- ~vtkStaticMeshObjectFactory() override;
+ ~vtkStaticMeshObjectFactory() override = default;
private:
vtkStaticMeshObjectFactory(const vtkStaticMeshObjectFactory&) = delete;
#include <vtkTable.h>
#include <vtkUnsignedCharArray.h>
#include <vtkUnstructuredGrid.h>
+#include <vtksys/SystemTools.hxx>
static const int SUGGCG_SIZE_EXCHANGE_TAG = 9002;
static const int SUGGCG_DATA_EXCHANGE_TAG = 9003;
//----------------------------------------------------------------------------
vtkStaticPUnstructuredGridGhostCellsGenerator::vtkStaticPUnstructuredGridGhostCellsGenerator()
{
- this->InputMeshTime = 0;
- this->FilterMTime = 0;
-
vtkMPIController* controller =
vtkMPIController::SafeDownCast(vtkMultiProcessController::GetGlobalController());
if (controller)
this->GhostPointsToSend.resize(controller->GetNumberOfProcesses());
this->GhostCellsToReceive.resize(controller->GetNumberOfProcesses());
this->GhostCellsToSend.resize(controller->GetNumberOfProcesses());
-
- int nProc = controller->GetNumberOfProcesses();
-
- for (int i = 0; i < nProc; i++)
- {
- this->GhostCellsToReceive[i] = vtkSmartPointer<vtkIdList>::New();
- this->GhostCellsToSend[i] = vtkSmartPointer<vtkIdList>::New();
- this->GhostPointsToReceive[i] = vtkSmartPointer<vtkIdList>::New();
- this->GhostPointsToSend[i] = vtkSmartPointer<vtkIdList>::New();
- }
}
}
-//----------------------------------------------------------------------------
-vtkStaticPUnstructuredGridGhostCellsGenerator::~vtkStaticPUnstructuredGridGhostCellsGenerator()
-{
-}
-
//-----------------------------------------------------------------------------
int vtkStaticPUnstructuredGridGhostCellsGenerator::RequestData(
vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector)
{
// get the inputs and outputs
- vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
- vtkInformation* outInfo = outputVector->GetInformationObject(0);
- vtkUnstructuredGridBase* input =
- vtkUnstructuredGridBase::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
- vtkUnstructuredGrid* output =
- vtkUnstructuredGrid::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
+ vtkUnstructuredGridBase* input = vtkUnstructuredGridBase::GetData(inputVector[0]);
+ vtkUnstructuredGrid* output = vtkUnstructuredGrid::GetData(outputVector);
// Recover the static unstructured grid
vtkUnstructuredGrid* inputUG = vtkUnstructuredGrid::SafeDownCast(input);
if (this->InputMeshTime == inputUG->GetMeshMTime() && this->FilterMTime == this->GetMTime())
{
// Cache mesh is up to date, use it to generate data
+ if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
+ {
+ vtkWarningMacro("Using static mesh cache");
+ }
+
// Update the cache data
this->UpdateCacheData(input);
}
else
{
+ // Cache is outdated, build it.
+ if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
+ {
+ vtkWarningMacro("Building static mesh cache");
+ }
+
// Add Arrays Ids needed
vtkNew<vtkUnstructuredGrid> tmpInput;
this->AddIdsArrays(input, tmpInput.Get());
vtkWarningMacro("Arrays are missing from cache, cache is discarded");
this->InputMeshTime = 0;
this->FilterMTime = 0;
+ return;
}
- else
+
+ // Compute list of remote ghost point ids
+ // and corresponding local point ids.
+ std::vector<std::vector<vtkIdType> > remoteGhostPoints;
+ remoteGhostPoints.resize(nProc);
+ for (vtkIdType i = 0; i < pointGhostArray->GetNumberOfTuples(); i++)
{
- // Compute list of remote ghost point ids
- // and corresponding local point ids.
- std::vector<std::vector<vtkIdType> > remoteGhostPoints;
- remoteGhostPoints.resize(nProc);
- for (vtkIdType i = 0; i < pointGhostArray->GetNumberOfTuples(); i++)
+ if (pointGhostArray->GetValue(i) != 0)
{
- if (pointGhostArray->GetValue(i) != 0)
- {
- this->GhostPointsToReceive[pointProcIds->GetValue(i)]->InsertNextId(i);
- remoteGhostPoints[pointProcIds->GetValue(i)].push_back(pointIds->GetValue(i));
- }
+ this->GhostPointsToReceive[pointProcIds->GetValue(i)]->InsertNextId(i);
+ remoteGhostPoints[pointProcIds->GetValue(i)].emplace_back(pointIds->GetValue(i));
}
+ }
- // Compute list of remote ghost cell ids
- // and corresponding local cell ids.
- std::vector<std::vector<vtkIdType> > remoteGhostCells;
- remoteGhostCells.resize(nProc);
- for (vtkIdType i = 0; i < cellGhostArray->GetNumberOfTuples(); i++)
+ // Compute list of remote ghost cell ids
+ // and corresponding local cell ids.
+ std::vector<std::vector<vtkIdType> > remoteGhostCells;
+ remoteGhostCells.resize(nProc);
+ for (vtkIdType i = 0; i < cellGhostArray->GetNumberOfTuples(); i++)
+ {
+ if (cellGhostArray->GetValue(i) != 0)
{
- if (cellGhostArray->GetValue(i) != 0)
- {
- this->GhostCellsToReceive[cellProcIds->GetValue(i)]->InsertNextId(i);
- remoteGhostCells[cellProcIds->GetValue(i)].push_back(cellIds->GetValue(i));
- }
+ this->GhostCellsToReceive[cellProcIds->GetValue(i)]->InsertNextId(i);
+ remoteGhostCells[cellProcIds->GetValue(i)].emplace_back(cellIds->GetValue(i));
}
+ }
- // Send requested ghost point ids to their own rank
- vtkMPICommunicator::Request pointSizeReqs[nProc];
- vtkMPICommunicator::Request pointIdsReqs[nProc];
- vtkIdType lengths[nProc];
- for (int i = 0; i < nProc; i++)
+ // Send requested ghost point ids to their own rank
+ vtkMPICommunicator::Request pointSizeReqs[nProc];
+ vtkMPICommunicator::Request pointIdsReqs[nProc];
+ vtkIdType lengths[nProc];
+ for (int i = 0; i < nProc; i++)
+ {
+ if (i != rank)
{
- if (i != rank)
- {
- lengths[i] = remoteGhostPoints[i].size();
- controller->NoBlockSend(&lengths[i], 1, i, SUGGCG_SIZE_EXCHANGE_TAG, pointSizeReqs[i]);
- controller->NoBlockSend(&remoteGhostPoints[i][0], remoteGhostPoints[i].size(), i,
- SUGGCG_DATA_EXCHANGE_TAG, pointIdsReqs[i]);
- }
+ lengths[i] = remoteGhostPoints[i].size();
+ controller->NoBlockSend(&lengths[i], 1, i, SUGGCG_SIZE_EXCHANGE_TAG, pointSizeReqs[i]);
+ controller->NoBlockSend(&remoteGhostPoints[i][0], remoteGhostPoints[i].size(), i,
+ SUGGCG_DATA_EXCHANGE_TAG, pointIdsReqs[i]);
}
+ }
- // Receive and store requested ghost point ids.
- for (int i = 0; i < nProc; i++)
+ // Receive and store requested ghost point ids.
+ for (int i = 0; i < nProc; i++)
+ {
+ if (i != rank)
{
- if (i != rank)
- {
- vtkIdType length;
- controller->Receive(&length, 1, i, SUGGCG_SIZE_EXCHANGE_TAG);
- this->GhostPointsToSend[i]->SetNumberOfIds(length);
- controller->Receive(
- this->GhostPointsToSend[i]->GetPointer(0), length, i, SUGGCG_DATA_EXCHANGE_TAG);
- }
+ vtkIdType length;
+ controller->Receive(&length, 1, i, SUGGCG_SIZE_EXCHANGE_TAG);
+ this->GhostPointsToSend[i]->SetNumberOfIds(length);
+ controller->Receive(
+ this->GhostPointsToSend[i]->GetPointer(0), length, i, SUGGCG_DATA_EXCHANGE_TAG);
}
- controller->Barrier();
+ }
+ controller->Barrier();
- // Send requested ghost cell ids to their own rank
- vtkMPICommunicator::Request cellSizeReqs[nProc];
- vtkMPICommunicator::Request cellIdsReqs[nProc];
- for (int i = 0; i < nProc; i++)
+ // Send requested ghost cell ids to their own rank
+ vtkMPICommunicator::Request cellSizeReqs[nProc];
+ vtkMPICommunicator::Request cellIdsReqs[nProc];
+ for (int i = 0; i < nProc; i++)
+ {
+ if (i != rank)
{
- if (i != rank)
- {
- lengths[i] = remoteGhostCells[i].size();
- controller->NoBlockSend(&lengths[i], 1, i, SUGGCG_SIZE_EXCHANGE_TAG, cellSizeReqs[i]);
- controller->NoBlockSend(
- &remoteGhostCells[i][0], lengths[i], i, SUGGCG_DATA_EXCHANGE_TAG, cellIdsReqs[i]);
- }
+ lengths[i] = remoteGhostCells[i].size();
+ controller->NoBlockSend(&lengths[i], 1, i, SUGGCG_SIZE_EXCHANGE_TAG, cellSizeReqs[i]);
+ controller->NoBlockSend(
+ &remoteGhostCells[i][0], lengths[i], i, SUGGCG_DATA_EXCHANGE_TAG, cellIdsReqs[i]);
}
- // Receive and store requested ghost cell ids.
- for (int i = 0; i < nProc; i++)
+ }
+ // Receive and store requested ghost cell ids.
+ for (int i = 0; i < nProc; i++)
+ {
+ if (i != rank)
{
- if (i != rank)
- {
- vtkIdType length;
- controller->Receive(&length, 1, i, SUGGCG_SIZE_EXCHANGE_TAG);
- this->GhostCellsToSend[i]->SetNumberOfIds(length);
- controller->Receive(
- this->GhostCellsToSend[i]->GetPointer(0), length, i, SUGGCG_DATA_EXCHANGE_TAG);
- }
+ vtkIdType length;
+ controller->Receive(&length, 1, i, SUGGCG_SIZE_EXCHANGE_TAG);
+ this->GhostCellsToSend[i]->SetNumberOfIds(length);
+ controller->Receive(
+ this->GhostCellsToSend[i]->GetPointer(0), length, i, SUGGCG_DATA_EXCHANGE_TAG);
}
- controller->Barrier();
}
- }
+ controller->Barrier();
+
+ } // end if (controller)
}
//-----------------------------------------------------------------------------
{
// Create Ids array
generateIdScalars->SetInputData(tmpInput);
- generateIdScalars->SetIdsArrayName("Ids");
+ generateIdScalars->SetPointIds(true);
+ generateIdScalars->SetCellIds(true);
+ generateIdScalars->SetPointIdsArrayName("Ids");
+ generateIdScalars->SetCellIdsArrayName("Ids");
generateIdScalars->Update();
tmpInput = generateIdScalars->GetOutput();
}
SUGGCG_DATA_EXCHANGE_TAG, dataReqs[i]);
}
}
- // Foe each rank
+ // For each rank
for (int i = 0; i < nProc; i++)
{
if (i != rank && this->GhostPointsToReceive[i]->GetNumberOfIds() > 0)
*
* @sa
* vtkPUnstructuredGridGhostCellsGenerator
-*/
+ */
#ifndef vtkStaticPUnstructuredGridGhostCellsGenerator_h
#define vtkStaticPUnstructuredGridGhostCellsGenerator_h
-#include <vtkIdList.h>
#include <vtkNew.h>
#include <vtkPUnstructuredGridGhostCellsGenerator.h>
-#include <vtkSmartPointer.h>
#include <vector>
+#include "StaticMeshModuleModule.h"
+
+class vtkIdList;
class vtkUnstructuredGrid;
-class vtkStaticPUnstructuredGridGhostCellsGenerator : public vtkPUnstructuredGridGhostCellsGenerator
+class STATICMESHMODULE_EXPORT vtkStaticPUnstructuredGridGhostCellsGenerator
+ : public vtkPUnstructuredGridGhostCellsGenerator
{
public:
static vtkStaticPUnstructuredGridGhostCellsGenerator* New();
protected:
vtkStaticPUnstructuredGridGhostCellsGenerator();
- ~vtkStaticPUnstructuredGridGhostCellsGenerator() override;
+ ~vtkStaticPUnstructuredGridGhostCellsGenerator() override = default;
/**
* Check input for "ProcessId" and "Ids" point and cell array,
*/
virtual void UpdateCacheGhostCellAndPointData(vtkDataSet* input);
- vtkNew<vtkUnstructuredGrid> Cache;
- vtkMTimeType InputMeshTime;
- vtkMTimeType FilterMTime;
-
- std::vector<vtkSmartPointer<vtkIdList> > GhostCellsToReceive;
- std::vector<vtkSmartPointer<vtkIdList> > GhostCellsToSend;
- std::vector<vtkSmartPointer<vtkIdList> > GhostPointsToReceive;
- std::vector<vtkSmartPointer<vtkIdList> > GhostPointsToSend;
-
private:
- // Hide these from the user and the compiler.
vtkStaticPUnstructuredGridGhostCellsGenerator(
const vtkStaticPUnstructuredGridGhostCellsGenerator&) = delete;
void operator=(const vtkStaticPUnstructuredGridGhostCellsGenerator&) = delete;
+
+ vtkNew<vtkUnstructuredGrid> Cache;
+ vtkMTimeType InputMeshTime = 0;
+ vtkMTimeType FilterMTime = 0;
+
+ std::vector<vtkNew<vtkIdList> > GhostCellsToReceive;
+ std::vector<vtkNew<vtkIdList> > GhostCellsToSend;
+ std::vector<vtkNew<vtkIdList> > GhostPointsToReceive;
+ std::vector<vtkNew<vtkIdList> > GhostPointsToSend;
};
#endif
#include <vtkCellData.h>
#include <vtkCompositeDataIterator.h>
+#include <vtkGenericCell.h>
#include <vtkIdFilter.h>
#include <vtkIdList.h>
#include <vtkInformation.h>
#include <vtkPointData.h>
#include <vtkPolyData.h>
#include <vtkUnstructuredGrid.h>
-#include <vtkGenericCell.h>
+#include <vtksys/SystemTools.hxx>
vtkStandardNewMacro(vtkStaticPlaneCutter);
static const char* IdsArrayName = "__vtkSPC_Ids";
-//----------------------------------------------------------------------------
-vtkStaticPlaneCutter::vtkStaticPlaneCutter()
-{
- this->InputMeshTime = 0;
- this->FilterMTime = 0;
-}
-
-//----------------------------------------------------------------------------
-vtkStaticPlaneCutter::~vtkStaticPlaneCutter()
-{
- this->ClearWeightsVector();
-}
-
//-----------------------------------------------------------------------------
int vtkStaticPlaneCutter::RequestData(
vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector)
{
// get the inputs and outputs
- vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
- vtkInformation* outInfo = outputVector->GetInformationObject(0);
- vtkUnstructuredGrid* input = vtkUnstructuredGrid::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
- vtkMultiBlockDataSet* inputMB = vtkMultiBlockDataSet::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
- vtkMultiBlockDataSet* mb =
- vtkMultiBlockDataSet::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
+
+ vtkUnstructuredGrid* input = vtkUnstructuredGrid::GetData(inputVector[0]);
+ vtkMultiBlockDataSet* inputMB = vtkMultiBlockDataSet::GetData(inputVector[0]);
+ vtkMultiBlockDataSet* mb = vtkMultiBlockDataSet::GetData(outputVector);
if (!mb)
{
vtkErrorMacro("Ouput information does not contain expected type of data object");
if (this->InputMeshTime == input->GetMeshMTime() && this->FilterMTime == this->GetMTime())
{
// Cache mesh is up to date, use it to generate data
+ if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
+ {
+ vtkWarningMacro("Using static mesh cache");
+ }
+
if (this->InterpolateAttributes)
{
// Update the cache data
}
// Copy the updated cache into the output
- mb->SetBlock(0, this->Cache.Get());
+ mb->SetBlock(0, this->Cache);
return 1;
}
else
{
// Cache is invalid
+ if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
+ {
+ vtkWarningMacro("Building static mesh cache");
+ }
+
// Add needed Arrays
vtkNew<vtkUnstructuredGrid> tmpInput;
- this->AddIdsArray(input, tmpInput.Get());
+ this->AddIdsArray(input, tmpInput);
// Create an input vector to pass the completed input to the superclass
// RequestData method
vtkNew<vtkInformationVector> tmpInputVec;
tmpInputVec->Copy(inputVector[0], 1);
vtkInformation* tmpInInfo = tmpInputVec->GetInformationObject(0);
- tmpInInfo->Set(vtkDataObject::DATA_OBJECT(), tmpInput.Get());
- vtkInformationVector* tmpInputVecPt = tmpInputVec.Get();
+ tmpInInfo->Set(vtkDataObject::DATA_OBJECT(), tmpInput);
+ vtkInformationVector* tmpInputVecPt = tmpInputVec;
int ret = this->Superclass::RequestData(request, &tmpInputVecPt, outputVector);
// Update the cache with superclass output
vtkNew<vtkIdFilter> generateIdScalars;
// Check for Ids array
- vtkIdTypeArray *cellIdsTmp = vtkIdTypeArray::SafeDownCast(input->GetCellData()->GetAbstractArray(IdsArrayName));
+ vtkIdTypeArray* cellIdsTmp =
+ vtkIdTypeArray::SafeDownCast(input->GetCellData()->GetAbstractArray(IdsArrayName));
if (!cellIdsTmp)
{
// Create Ids array
generateIdScalars->SetInputData(tmpInput);
- generateIdScalars->SetIdsArrayName(IdsArrayName);
+ generateIdScalars->SetPointIds(true);
+ generateIdScalars->SetCellIds(true);
+ generateIdScalars->SetPointIdsArrayName(IdsArrayName);
+ generateIdScalars->SetCellIdsArrayName(IdsArrayName);
generateIdScalars->FieldDataOn();
generateIdScalars->Update();
tmpInput = generateIdScalars->GetOutput();
}
}
-//-----------------------------------------------------------------------------
-void vtkStaticPlaneCutter::ClearWeightsVector()
-{
- for(auto& weightsVector : this->WeightsVectorCompo)
- {
- delete[] weightsVector[0].second;
- }
- this->WeightsVectorCompo.clear();
-}
-
//-----------------------------------------------------------------------------
void vtkStaticPlaneCutter::ComputeIds(vtkUnstructuredGrid* input)
{
this->CellToCopyFrom.clear();
this->CellToCopyTo.clear();
- this->ClearWeightsVector();
+ this->WeightsVectorCompo.clear();
+
+ const vtkIdType nbPieces = this->Cache->GetNumberOfPieces();
+ this->WeightsVectorCompo.reserve(nbPieces);
// Iterate over each piece of the multipiece output
vtkNew<vtkGenericCell> tmpCell;
- vtkSmartPointer<vtkCompositeDataIterator> iter;
- iter.TakeReference(this->Cache->NewIterator());
+ vtkSmartPointer<vtkCompositeDataIterator> iter =
+ vtkSmartPointer<vtkCompositeDataIterator>::Take(this->Cache->NewIterator());
iter->SkipEmptyNodesOn();
for (iter->GoToFirstItem(); !iter->IsDoneWithTraversal(); iter->GoToNextItem())
{
{
// For each piece, recover the Ids of the cells sliced and the corresponding
// cellId in the slice
- vtkSmartPointer<vtkIdList> cellIdsFrom = vtkSmartPointer<vtkIdList>::New();
- vtkSmartPointer<vtkIdList> cellIdsTo = vtkSmartPointer<vtkIdList>::New();
- this->CellToCopyFrom.push_back(cellIdsFrom);
- this->CellToCopyTo.push_back(cellIdsTo);
+ this->CellToCopyFrom.emplace_back();
+ this->CellToCopyTo.emplace_back();
+ auto& cellIdsFrom = this->CellToCopyFrom.back();
+ auto& cellIdsTo = this->CellToCopyTo.back();
- vtkIdTypeArray* ids = vtkIdTypeArray::SafeDownCast(slice->GetCellData()->GetArray(IdsArrayName));
+ vtkIdTypeArray* ids =
+ vtkIdTypeArray::SafeDownCast(slice->GetCellData()->GetArray(IdsArrayName));
assert(ids);
cellIdsFrom->SetNumberOfIds(ids->GetNumberOfValues());
cellIdsTo->SetNumberOfIds(ids->GetNumberOfValues());
{
slice->BuildLinks();
vtkIdType maxCellSize = input->GetMaxCellSize();
- std::vector<std::pair<vtkSmartPointer<vtkIdList>, double*>> weightsVector;
+ std::vector<WeightsVectorElmt> weightsVector;
weightsVector.resize(sliceNbPoints);
- double *allWeights = new double[maxCellSize * sliceNbPoints];
for (vtkIdType i = 0; i < sliceNbPoints; i++)
{
vtkNew<vtkIdList> ptIds;
- double *weights = &allWeights[maxCellSize * i];
- unsigned short ncells;
- vtkIdType *cells;
+ weightsVector[i].pointsWeights.resize(maxCellSize);
+ vtkIdType ncells;
+ vtkIdType* cells;
slice->GetPointCells(i, ncells, cells);
vtkIdType cellId = cellIdsFrom->GetId(cells[0]);
assert(cellId < input->GetNumberOfCells());
input->GetCell(cellId, tmpCell);
input->GetCellPoints(cellId, ptIds);
double dist, pcoords[3], x[3], p[3];
- int subId = 0;
+ int subId;
slice->GetPoint(i, p);
- tmpCell->EvaluatePosition(p, x, subId, pcoords, dist, weights);
- weightsVector[i] = { ptIds, weights };
+ tmpCell->EvaluatePosition(
+ p, x, subId, pcoords, dist, weightsVector[i].pointsWeights.data());
+ weightsVector[i].pointsList = ptIds;
}
- this->WeightsVectorCompo.push_back(weightsVector);
+ this->WeightsVectorCompo.emplace_back(std::move(weightsVector));
}
}
}
vtkCellData* inCD = input->GetCellData();
vtkPointData* inPD = input->GetPointData();
+ int blockId = 0;
vtkSmartPointer<vtkCompositeDataIterator> iter;
iter.TakeReference(this->Cache->NewIterator());
iter->SkipEmptyNodesOn();
- int blockId = 0;
for (iter->GoToFirstItem(); !iter->IsDoneWithTraversal(); iter->GoToNextItem())
{
vtkPolyData* slice = vtkPolyData::SafeDownCast(iter->GetCurrentDataObject());
if (arrayToCopyIn)
{
// Copy the tuples from the input cell ids to the slice cell ids
- arrayToCopyIn->InsertTuples(this->CellToCopyTo[blockId].Get(), this->CellToCopyFrom[blockId].Get(),
+ arrayToCopyIn->InsertTuples(this->CellToCopyTo[blockId], this->CellToCopyFrom[blockId],
inCD->GetAbstractArray(iArr));
}
}
auto& weightsVector = this->WeightsVectorCompo[blockId];
for (vtkIdType ptIdx = 0; ptIdx < sliceNbPoints; ptIdx++)
{
- slicePD->InterpolatePoint(inPD, ptIdx, weightsVector[ptIdx].first, weightsVector[ptIdx].second);
+ slicePD->InterpolatePoint(inPD, ptIdx, weightsVector[ptIdx].pointsList,
+ weightsVector[ptIdx].pointsWeights.data());
}
}
=========================================================================*/
/**
* @class vtkStaticPlaneCutter
- * @brief StaticMesh aware implementation of vtkPlaneCutter vtk vtkUnstructuredGrid
+ * @brief StaticMesh aware implementation of vtkPlaneCutter for vtkUnstructuredGrid
*
* This class specialize vtkPlaneCutter for vtkUnstructuredGrid input.
* It uses a cache when the associated data chage over time but not the geometry.
* Contrary to its parent, this class does not interpolate point data,
* only transmit cell data.
*
- *
* @sa
* vtkPlaneCutter
-*/
+ */
#ifndef vtkStaticPlaneCutter_h
#define vtkStaticPlaneCutter_h
#include <vector>
+#include "StaticMeshModuleModule.h"
+
class vtkMultiPieceDataSet;
-class vtkStaticPlaneCutter : public vtkPlaneCutter
+class STATICMESHMODULE_EXPORT vtkStaticPlaneCutter : public vtkPlaneCutter
{
public:
static vtkStaticPlaneCutter* New();
typedef vtkPlaneCutter Superclass; // vtkTypeMacro can't be used with a factory built object
- void PrintSelf(ostream &os, vtkIndent indent) override;
+ void PrintSelf(ostream& os, vtkIndent indent) override;
+ /**
+ * see vtkDataSetAlgorithm
+ */
int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
protected:
- vtkStaticPlaneCutter();
- ~vtkStaticPlaneCutter() override;
+ vtkStaticPlaneCutter() = default;
+ ~vtkStaticPlaneCutter() override = default;
/**
* Check input for Ids cell array, if absent, compute and add them.
*/
void ComputeIds(vtkUnstructuredGrid* input);
- void ClearWeightsVector();
-
- vtkNew<vtkMultiPieceDataSet> Cache;
- std::vector<vtkSmartPointer<vtkIdList> > CellToCopyFrom;
- std::vector<vtkSmartPointer<vtkIdList> > CellToCopyTo;
- std::vector<std::vector<std::pair<vtkSmartPointer<vtkIdList>, double*>>> WeightsVectorCompo;
- vtkMTimeType InputMeshTime;
- vtkMTimeType FilterMTime;
-
private:
// Hide these from the user and the compiler.
vtkStaticPlaneCutter(const vtkStaticPlaneCutter&) = delete;
void operator=(const vtkStaticPlaneCutter&) = delete;
+
+ struct WeightsVectorElmt
+ {
+ vtkSmartPointer<vtkIdList> pointsList;
+ std::vector<double> pointsWeights;
+ };
+
+ vtkNew<vtkMultiPieceDataSet> Cache;
+ std::vector<vtkNew<vtkIdList> > CellToCopyFrom;
+ std::vector<vtkNew<vtkIdList> > CellToCopyTo;
+ std::vector<std::vector<WeightsVectorElmt> > WeightsVectorCompo;
+ vtkMTimeType InputMeshTime = 0;
+ vtkMTimeType FilterMTime = 0;
};
#endif
/*=========================================================================
Program: Visualization Toolkit
- Module: vtkRTAnalyticSource.cxx
+ Module: vtkTemporalUGWavelet.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
#include <vtkImageData.h>
#include <vtkInformation.h>
#include <vtkInformationVector.h>
-#include <vtkMultiProcessController.h>
#include <vtkNew.h>
#include <vtkObjectFactory.h>
#include <vtkPointData.h>
-#include <vtkRTAnalyticSource.h>
#include <vtkStreamingDemandDrivenPipeline.h>
#include <vtkUnstructuredGrid.h>
+#include <vtksys/SystemTools.hxx>
-vtkStandardNewMacro(vtkTemporalUGWavelet);
-
-// ----------------------------------------------------------------------------
-vtkTemporalUGWavelet::vtkTemporalUGWavelet()
-{
- this->Cache = vtkUnstructuredGrid::New();
- this->NumberOfTimeSteps = 10;
-}
+#include <numeric>
-// ----------------------------------------------------------------------------
-vtkTemporalUGWavelet::~vtkTemporalUGWavelet()
-{
- this->Cache->Delete();
-}
+vtkStandardNewMacro(vtkTemporalUGWavelet);
//----------------------------------------------------------------------------
int vtkTemporalUGWavelet::FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info)
vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector)
{
vtkInformation* outInfo = outputVector->GetInformationObject(0);
- double range[2] = { 0, static_cast<double>(this->NumberOfTimeSteps - 1) };
+ double range[2] = { 0., static_cast<double>(this->NumberOfTimeSteps - 1) };
outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(), range, 2);
- double* outTimes = new double[this->NumberOfTimeSteps];
- for (int i = 0; i < this->NumberOfTimeSteps; i++)
- {
- outTimes[i] = i;
- }
- outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), outTimes, this->NumberOfTimeSteps);
+
+ std::vector<double> outTimes(this->NumberOfTimeSteps);
+ std::iota(outTimes.begin(), outTimes.end(), 0);
+ outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), outTimes.data(), outTimes.size());
+
outInfo->Set(CAN_HANDLE_PIECE_REQUEST(), 1);
+
return Superclass::RequestInformation(request, inputVector, outputVector);
}
vtkUnstructuredGrid* data = vtkUnstructuredGrid::GetData(outInfo);
if (this->CacheMTime < this->GetMTime())
{
+ if (vtksys::SystemTools::HasEnv("VTK_DEBUG_STATIC_MESH"))
+ {
+ vtkWarningMacro("Building static mesh cache");
+ }
+
// Create an output vector to recover the output image data
// RequestData method
vtkNew<vtkInformationVector> tmpOutputVec;
vtkNew<vtkImageData> image;
tmpOutputVec->Copy(outputVector, 1);
vtkInformation* tmpOutInfo = tmpOutputVec->GetInformationObject(0);
- tmpOutInfo->Set(vtkDataObject::DATA_OBJECT(), image.Get());
+ tmpOutInfo->Set(vtkDataObject::DATA_OBJECT(), image);
// Generate wavelet
- int ret = this->Superclass::RequestData(request, inputVector, tmpOutputVec.Get());
+ int ret = this->Superclass::RequestData(request, inputVector, tmpOutputVec);
if (ret == 0)
{
return ret;
// Transform it to unstructured grid
vtkNew<vtkDataSetTriangleFilter> tetra;
- tetra->SetInputData(image.Get());
+ tetra->SetInputData(image);
tetra->Update();
// Create the cache
vtkNew<vtkFloatArray> pointArray;
pointArray->SetName("tPoint");
pointArray->SetNumberOfValues(nbPoints);
- data->GetPointData()->AddArray(pointArray.Get());
+ data->GetPointData()->AddArray(pointArray);
for (vtkIdType i = 0; i < nbPoints; i++)
{
pointArray->SetValue(
vtkNew<vtkFloatArray> cellArray;
cellArray->SetName("tCell");
cellArray->SetNumberOfValues(nbCells);
- data->GetCellData()->AddArray(cellArray.Get());
-
+ data->GetCellData()->AddArray(cellArray);
for (vtkIdType i = 0; i < nbCells; i++)
{
cellArray->SetValue(i, static_cast<int>(i + t * (nbCells / this->NumberOfTimeSteps)) % nbCells);
*
* vtkTemporalUGWavelet specialize vtkRTAnalyticSource to create
* a wavelet converted to vtkUnstructuredGrid, with timesteps.
- * The "tPoint" and "tCell" arrays are the only data actually changing over time
- * make the output a static mesh with data evolving over time.
-*/
+ * The "tPoint" and "tCell" arrays are the only data actually changing
+ * over time, the geometry is generated once and then not modified.
+ */
#ifndef vtkTemporalUGWavelet_h
#define vtkTemporalUGWavelet_h
+#include <vtkNew.h>
#include <vtkRTAnalyticSource.h>
+#include "StaticMeshModuleModule.h"
+
class vtkUnstructuredGrid;
-class vtkTemporalUGWavelet : public vtkRTAnalyticSource
+class STATICMESHMODULE_EXPORT vtkTemporalUGWavelet : public vtkRTAnalyticSource
{
public:
static vtkTemporalUGWavelet* New();
//@}
protected:
- vtkTemporalUGWavelet();
- ~vtkTemporalUGWavelet();
+ vtkTemporalUGWavelet() = default;
+ ~vtkTemporalUGWavelet() override = default;
+ //@{
+ /**
+ * see vtkDataSetAlgorithm
+ */
int FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info) override;
-
int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
vtkInformationVector* outputVector) override;
-
int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
-
- int NumberOfTimeSteps;
- vtkUnstructuredGrid* Cache;
- vtkTimeStamp CacheMTime;
+ //@}
private:
vtkTemporalUGWavelet(const vtkTemporalUGWavelet&) = delete;
void operator=(const vtkTemporalUGWavelet&) = delete;
+
+ int NumberOfTimeSteps = 10;
+ vtkNew<vtkUnstructuredGrid> Cache;
+ vtkTimeStamp CacheMTime;
};
#endif
--- /dev/null
+<ServerManagerConfiguration>
+ <ProxyGroup name="filters">
+ <SourceProxy name="ForceStaticMesh" class="vtkForceStaticMesh" label="Force Static Mesh">
+ <Documentation
+ long_help="This filter caches its input the first time it is executed then use it as a static mesh"
+ short_help="Force output to be a static mesh">
+ The Force Static Mesh filter create a cache the first time it is executed using its input. It will then only
+ update PointData, CellData and FieldData from the input as long as their dimensions stay the same.
+ This filter operates only on a vtkUnstructuredGrid input or on the first block of a multiblock input
+ if it is a vtkUnstructuredGrid.
+ </Documentation>
+ <InputProperty command="SetInputConnection"
+ name="Input">
+ <ProxyGroupDomain name="groups">
+ <Group name="sources" />
+ <Group name="filters" />
+ </ProxyGroupDomain>
+ <DataTypeDomain name="input_type">
+ <DataType value="vtkUnstructuredGrid" />
+ <DataType value="vtkCompositeDataSet" />
+ </DataTypeDomain>
+ <Documentation>This property specifies the input of the filter.</Documentation>
+ </InputProperty>
+ <IntVectorProperty
+ name="ForceCacheComputation"
+ command="SetCacheComputation"
+ default_values="0"
+ panel_visibility="advanced" >
+ <BooleanDomain name="bool" />
+ <Documentation>
+ Set this to true to force this filter to recompute the cache instead of using it.
+ </Documentation>
+ </IntVectorProperty>
+ </SourceProxy>
+ </ProxyGroup>
+</ServerManagerConfiguration>
--- /dev/null
+<ServerManagerConfiguration>
+ <ProxyGroup name="sources">
+
+ <!-- This proxy is a copy paste of the one in:
+ paraview/VTKExtensions/IOEnSight/Resources/readers_pv_ioensight.xml
+ with an additional entry: the UseStaticMesh boolean.
+ -->
+ <SourceProxy label="EnSight Reader"
+ name="ensight"
+ class="vtkGenericStaticEnSightReader">
+ <Documentation long_help="Reads EnSight 6 and Gold files (static version)."
+ short_help="Read EnSight files (static version).">The
+ EnSight reader reads files in the format produced by
+ CEI's EnSight. EnSight 6 and Gold files (both ASCII
+ and binary) are supported. This version allows to generate
+ static meshes, on which geometry is considered constant
+ between time steps. The default extension is .case. The
+ output of this reader is a multiblock dataset.
+ </Documentation>
+
+ <!-- Additional boolean to control static mesh generation -->
+ <IntVectorProperty
+ name="UseStaticMesh"
+ command="SetUseStaticMesh"
+ label="Use static mesh"
+ number_of_elements="1"
+ default_values="1">
+ <BooleanDomain name="bool"/>
+ <Documentation>
+ Control static output mesh generation. When this option is checked,
+ the first time this reader is executed a mesh will be generated,
+ then only points, cells and fields data will be updated without
+ rereading and recreating the mesh geometry. Keep unchecked for
+ non-static EnSight files.
+ </Documentation>
+ </IntVectorProperty>
+
+ <!-- Original XML -->
+ <StringVectorProperty animateable="0"
+ command="SetCaseFileName"
+ name="CaseFileName"
+ number_of_elements="1">
+ <FileListDomain name="files" />
+ <Documentation>This property specifies the case file name for the
+ EnSight reader.</Documentation>
+ </StringVectorProperty>
+ <DoubleVectorProperty information_only="1"
+ name="TimestepValues"
+ repeatable="1">
+ <TimeStepsInformationHelper />
+ <Documentation>Available timestep values.</Documentation>
+ </DoubleVectorProperty>
+ <StringVectorProperty information_only="1"
+ name="CellArrayInfo">
+ <ArraySelectionInformationHelper attribute_name="Cell" />
+ </StringVectorProperty>
+ <StringVectorProperty command="SetCellArrayStatus"
+ element_types="2 0"
+ information_property="CellArrayInfo"
+ label="Cell Arrays"
+ name="CellArrayStatus"
+ number_of_elements="0"
+ number_of_elements_per_command="2"
+ repeat_command="1">
+ <ArraySelectionDomain name="array_list">
+ <RequiredProperties>
+ <Property function="ArrayList"
+ name="CellArrayInfo" />
+ </RequiredProperties>
+ </ArraySelectionDomain>
+ <Documentation>This property lists which cell-centered arrays to
+ read.</Documentation>
+ </StringVectorProperty>
+ <StringVectorProperty information_only="1"
+ name="PointArrayInfo">
+ <ArraySelectionInformationHelper attribute_name="Point" />
+ </StringVectorProperty>
+ <StringVectorProperty command="SetPointArrayStatus"
+ element_types="2 0"
+ information_property="PointArrayInfo"
+ label="Point Arrays"
+ name="PointArrayStatus"
+ number_of_elements="0"
+ number_of_elements_per_command="2"
+ repeat_command="1">
+ <ArraySelectionDomain name="array_list">
+ <RequiredProperties>
+ <Property function="ArrayList"
+ name="PointArrayInfo" />
+ </RequiredProperties>
+ </ArraySelectionDomain>
+ <Documentation>This property lists which point-centered arrays to
+ read.</Documentation>
+ </StringVectorProperty>
+
+ <Hints>
+ <ReaderFactory extensions="case CASE Case"
+ file_description="EnSight Files" />
+ </Hints>
+ </SourceProxy>
+
+ </ProxyGroup>
+</ServerManagerConfiguration>
<ServerManagerConfiguration>
<ProxyGroup name="sources">
+
<SourceProxy class="vtkTemporalUGWavelet"
label="Temporal Unstructured Grid Wavelet"
name="TemporalUGWavelet">
<Documentation long_help="Create a unstructured grid in up to three dimensions with values varying according to a periodic function as well as temporal varying point and cell data."
short_help="Create a temporal unstructured grid containing a wavelet">
See Wavelet documentation.
- This is a wavelet converted into an unstructured grid.
- It contains timesteps yet the mesh is statis over time.
- It also contains tPoint and tCell wich are scalar array varying over time.</Documentation>
+ The output is a wavelet converted into an unstructured grid.
+ It contains timesteps yet the mesh is static over time.
+ It also contains "tPoint" and "tCell", wich are scalar arrays varying over time.
+ </Documentation>
<DoubleVectorProperty information_only="1"
name="TimestepValues"
repeatable="1">