Commit b842eda4 authored by henry's avatar henry
Browse files

Updated PV3Foam reader

parent 516d9eca
......@@ -210,7 +210,7 @@ int vtkPV3FoamReader::RequestData
if
(
(UpdateGUIOld == GetUpdateGUI())
|| (output->GetNumberOfDataSets(0) == 0)
|| (output->GetNumberOfBlocks() == 0)
)
{
foamData_->Update(output);
......
......@@ -41,7 +41,9 @@ class vtkDataArraySelection;
class vtkCallbackCommand;
class VTK_IO_EXPORT vtkPV3FoamReader : public vtkMultiBlockDataSetAlgorithm
class VTK_IO_EXPORT vtkPV3FoamReader
:
public vtkMultiBlockDataSetAlgorithm
{
public:
......
......@@ -37,6 +37,7 @@ License
// VTK includes
#include "vtkCharArray.h"
#include "vtkDataArraySelection.h"
#include "vtkDataSet.h"
#include "vtkFieldData.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkRenderer.h"
......@@ -55,6 +56,69 @@ defineTypeNameAndDebug(Foam::vtkPV3Foam, 0);
#include "vtkPV3FoamUpdateInformationFields.H"
void Foam::vtkPV3Foam::AddToBlock
(
vtkMultiBlockDataSet* output,
unsigned int blockNo,
unsigned int datasetNo,
vtkDataSet* dataset
)
{
vtkDataObject* blockDO = output->GetBlock(blockNo);
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
if (blockDO && !block)
{
FatalErrorIn("Foam::vtkPV3Foam::AddToBlock")
<< "Block already has a vtkDataSet assigned to it" << nl << endl;
return;
}
if (!block)
{
block = vtkMultiBlockDataSet::New();
output->SetBlock(blockNo, block);
block->Delete();
}
block->SetBlock(datasetNo, dataset);
}
vtkDataSet* Foam::vtkPV3Foam::GetDataSetFromBlock
(
vtkMultiBlockDataSet* output,
unsigned int blockNo,
unsigned int datasetNo
)
{
vtkDataObject* blockDO = output->GetBlock(blockNo);
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
if (block)
{
return vtkDataSet::SafeDownCast(block->GetBlock(datasetNo));
}
return 0;
}
Foam::label Foam::vtkPV3Foam::GetNumberOfDataSets
(
vtkMultiBlockDataSet* output,
unsigned int blockNo
)
{
vtkDataObject* blockDO = output->GetBlock(blockNo);
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO);
if (block)
{
return block->GetNumberOfBlocks();
}
return 0;
}
void Foam::vtkPV3Foam::resetCounters()
{
// Reset data size counts
......@@ -481,11 +545,11 @@ void Foam::vtkPV3Foam::Update
if (debug)
{
Info<< "Number of data sets after update" << nl
<< " VOLUME = " << output->GetNumberOfDataSets(VOLUME) << nl
<< " LAGRANGIAN = " << output->GetNumberOfDataSets(LAGRANGIAN)
<< nl << " CELLSET = " << output->GetNumberOfDataSets(CELLSET)
<< nl << " FACESET = " << output->GetNumberOfDataSets(FACESET)
<< nl << " POINTSET = " << output->GetNumberOfDataSets(POINTSET)
<< " VOLUME = " << GetNumberOfDataSets(output, VOLUME) << nl
<< " LAGRANGIAN = " << GetNumberOfDataSets(output, LAGRANGIAN)
<< nl << " CELLSET = " << GetNumberOfDataSets(output, CELLSET)
<< nl << " FACESET = " << GetNumberOfDataSets(output, FACESET)
<< nl << " POINTSET = " << GetNumberOfDataSets(output, POINTSET)
<< endl;
}
}
......
......@@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::vtkPV3Foam
vtkPV3Foam
Description
......@@ -65,6 +65,7 @@ SourceFiles
// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
class vtkDataArraySelection;
class vtkDataSet;
class vtkMultiBlockDataSet;
class vtkPoints;
class vtkPV3FoamReader;
......@@ -188,6 +189,33 @@ class vtkPV3Foam
// Private Member Functions
// Convenience method use to convert the readers from VTK 5
// multiblock API to the current composite data infrastructure
void AddToBlock
(
vtkMultiBlockDataSet* output,
unsigned int blockNo,
unsigned int datasetNo,
vtkDataSet* dataset
);
// Convenience method use to convert the readers from VTK 5
// multiblock API to the current composite data infrastructure
vtkDataSet* GetDataSetFromBlock
(
vtkMultiBlockDataSet* output,
unsigned int blockNo,
unsigned int datasetNo
);
// Convenience method use to convert the readers from VTK 5
// multiblock API to the current composite data infrastructure
label GetNumberOfDataSets
(
vtkMultiBlockDataSet* output,
unsigned int blockNo
);
//- Reset data counters
void resetCounters();
......
......@@ -22,8 +22,8 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
InClass
Foam::vtkPV3Foam
Class
vtkPV3Foam
\*---------------------------------------------------------------------------*/
......
......@@ -22,8 +22,8 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
InClass
Foam::vtkPV3Foam
Class
vtkPV3Foam
\*---------------------------------------------------------------------------*/
......@@ -102,7 +102,7 @@ void Foam::vtkPV3Foam::convertLagrangianField
{
vtkUnstructuredGrid* lagrangianMesh = vtkUnstructuredGrid::SafeDownCast
(
output->GetDataSet(LAGRANGIAN, 0)
GetDataSetFromBlock(output, LAGRANGIAN, 0)
);
vtkFloatArray *pointTypes = vtkFloatArray::New();
......@@ -144,7 +144,7 @@ void Foam::vtkPV3Foam::convertLagrangianField
{
vtkUnstructuredGrid* lagrangianMesh = vtkUnstructuredGrid::SafeDownCast
(
output->GetDataSet(LAGRANGIAN, 0)
GetDataSetFromBlock(output, LAGRANGIAN, 0)
);
vtkFloatArray *pointScalars = vtkFloatArray::New();
......
......@@ -65,7 +65,8 @@ void Foam::vtkPV3Foam::convertMeshVolume
vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New();
SetName(ugrid, "internalMesh");
addVolumeMesh(mesh, ugrid, superCells_);
output->SetDataSet(VOLUME, 0, ugrid);
AddToBlock(output, VOLUME, 0, ugrid);
// reader_->SetBlock(output->GetNumberOfBlocks(), ugrid);
selectedRegionDatasetIds_[VOLUME] = 0;
ugrid->Delete();
}
......@@ -96,7 +97,7 @@ void Foam::vtkPV3Foam::convertMeshLagrangian
vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New();
addLagrangianMesh(mesh, ugrid);
output->SetDataSet(LAGRANGIAN, 0, ugrid);
AddToBlock(output, LAGRANGIAN, 0, ugrid);
selectedRegionDatasetIds_[LAGRANGIAN] = 0;
ugrid->Delete();
}
......@@ -141,8 +142,8 @@ void Foam::vtkPV3Foam::convertMeshPatches
const label patchId = mesh.boundaryMesh()
.findPatchID(regionName);
addPatchMesh(patches[patchId], ugrid);
const label nextId = output->GetNumberOfDataSets(VOLUME);
output->SetDataSet(VOLUME, nextId, ugrid);
const label nextId = GetNumberOfDataSets(output, VOLUME);
AddToBlock(output, VOLUME, nextId, ugrid);
selectedRegionDatasetIds_[i] = nextId;
ugrid->Delete();
}
......@@ -188,14 +189,14 @@ void Foam::vtkPV3Foam::convertMeshCellSet
vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New();
SetName(ugrid, cSetName.c_str());
const label nextId = output->GetNumberOfDataSets(CELLSET);
const label nextId = GetNumberOfDataSets(output, CELLSET);
addVolumeMesh
(
subsetter.subMesh(),
ugrid,
superCellSetCells_[nextId]
);
output->SetDataSet(CELLSET, nextId, ugrid);
AddToBlock(output, CELLSET, nextId, ugrid);
selectedRegionDatasetIds_[i] = nextId;
ugrid->Delete();
}
......@@ -245,8 +246,8 @@ void Foam::vtkPV3Foam::convertMeshFaceSet
fSet,
ugrid
);
const label nextId = output->GetNumberOfDataSets(FACESET);
output->SetDataSet(FACESET, nextId, ugrid);
const label nextId = GetNumberOfDataSets(output, FACESET);
AddToBlock(output, FACESET, nextId, ugrid);
selectedRegionDatasetIds_[i] = nextId;
ugrid->Delete();
}
......@@ -296,8 +297,8 @@ void Foam::vtkPV3Foam::convertMeshPointSet
pSet,
ugrid
);
const label nextId = output->GetNumberOfDataSets(POINTSET);
output->SetDataSet(POINTSET, nextId, ugrid);
label nextId = GetNumberOfDataSets(output, POINTSET);
AddToBlock(output, POINTSET, nextId, ugrid);
selectedRegionDatasetIds_[i] = nextId;
ugrid->Delete();
}
......
......@@ -22,8 +22,8 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
InClass
Foam::vtkPV3Foam
Class
vtkPV3Foam
\*---------------------------------------------------------------------------*/
......@@ -49,7 +49,7 @@ void Foam::vtkPV3Foam::convertPatchFaceField
{
vtkUnstructuredGrid* vtkMesh = vtkUnstructuredGrid::SafeDownCast
(
output->GetDataSet(VOLUME, regioni)
GetDataSetFromBlock(output, VOLUME, regioni)
);
vtkFloatArray *cellTypes = vtkFloatArray::New();
......@@ -87,7 +87,7 @@ void Foam::vtkPV3Foam::convertPatchFaceField
{
vtkUnstructuredGrid* vtkMesh = vtkUnstructuredGrid::SafeDownCast
(
output->GetDataSet(VOLUME, regioni)
GetDataSetFromBlock(output, VOLUME, regioni)
);
vtkFloatArray *cellScalars = vtkFloatArray::New();
......
......@@ -22,8 +22,8 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
InClass
Foam::vtkPV3Foam
Class
vtkPV3Foam
\*---------------------------------------------------------------------------*/
......@@ -46,7 +46,7 @@ void Foam::vtkPV3Foam::convertPatchPointField
{
vtkUnstructuredGrid* vtkMesh = vtkUnstructuredGrid::SafeDownCast
(
output->GetDataSet(VOLUME, regioni)
GetDataSetFromBlock(output, VOLUME, regioni)
);
vtkFloatArray *pointTypes = vtkFloatArray::New();
......@@ -83,7 +83,7 @@ void Foam::vtkPV3Foam::convertPatchPointField
{
vtkUnstructuredGrid* vtkMesh = vtkUnstructuredGrid::SafeDownCast
(
output->GetDataSet(VOLUME, regioni)
GetDataSetFromBlock(output, VOLUME, regioni)
);
vtkFloatArray *pointScalars = vtkFloatArray::New();
......
......@@ -22,8 +22,8 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
InClass
Foam::vtkPV3Foam
Class
vtkPV3Foam
\*---------------------------------------------------------------------------*/
......@@ -130,7 +130,7 @@ void Foam::vtkPV3Foam::convertPointField
{
vtkUnstructuredGrid* internalMesh = vtkUnstructuredGrid::SafeDownCast
(
output->GetDataSet(VOLUME, 0)
GetDataSetFromBlock(output, VOLUME, 0)
);
vtkFloatArray *pointTypes = vtkFloatArray::New();
......@@ -197,7 +197,7 @@ void Foam::vtkPV3Foam::convertPointField
{
vtkUnstructuredGrid* internalMesh = vtkUnstructuredGrid::SafeDownCast
(
output->GetDataSet(VOLUME, 0)
GetDataSetFromBlock(output, VOLUME, 0)
);
vtkFloatArray *pointScalars = vtkFloatArray::New();
......
......@@ -22,8 +22,8 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
InClass
Foam::vtkPV3Foam
Class
vtkPV3Foam
\*---------------------------------------------------------------------------*/
......@@ -177,10 +177,10 @@ void Foam::vtkPV3Foam::convertVolField
{
vtkUnstructuredGrid* internalMesh = vtkUnstructuredGrid::SafeDownCast
(
output->GetDataSet(VOLUME, 0)
GetDataSetFromBlock(output, VOLUME, 0)
);
vtkFloatArray *cellTypes = vtkFloatArray::New();
vtkFloatArray* cellTypes = vtkFloatArray::New();
cellTypes->SetNumberOfTuples(superCells_.size());
cellTypes->SetNumberOfComponents(Type::nComponents);
cellTypes->Allocate(Type::nComponents*superCells_.size());
......@@ -220,7 +220,7 @@ void Foam::vtkPV3Foam::convertVolField
{
vtkUnstructuredGrid* internalMesh = vtkUnstructuredGrid::SafeDownCast
(
output->GetDataSet(VOLUME, 0)
GetDataSetFromBlock(output, VOLUME, 0)
);
vtkFloatArray *cellScalars = vtkFloatArray::New();
......
......@@ -22,8 +22,8 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
InClass
Foam::vtkPV3Foam
Class
vtkPV3Foam
\*---------------------------------------------------------------------------*/
......
......@@ -22,8 +22,8 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
InClass
Foam::vtkPV3Foam
Class
vtkPV3Foam
\*---------------------------------------------------------------------------*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment