diff --git a/src/paraview-plugins/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx b/src/paraview-plugins/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx index 3c9570c27da751dcf7eb7f88bf7f85a4899d53a4..12872d614325912e05f547bd2f8c710d6fc4cab5 100644 --- a/src/paraview-plugins/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx +++ b/src/paraview-plugins/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx @@ -210,7 +210,7 @@ int vtkPV3FoamReader::RequestData if ( (UpdateGUIOld == GetUpdateGUI()) - || (output->GetNumberOfDataSets(0) == 0) + || (output->GetNumberOfBlocks() == 0) ) { foamData_->Update(output); diff --git a/src/paraview-plugins/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h b/src/paraview-plugins/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h index 318016f6733b62e888d6d1a663b9382d014cfffc..c9875f9673167ea45383e9059c728b11170f634b 100644 --- a/src/paraview-plugins/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h +++ b/src/paraview-plugins/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h @@ -41,7 +41,9 @@ class vtkDataArraySelection; class vtkCallbackCommand; -class VTK_IO_EXPORT vtkPV3FoamReader : public vtkMultiBlockDataSetAlgorithm +class VTK_IO_EXPORT vtkPV3FoamReader +: + public vtkMultiBlockDataSetAlgorithm { public: diff --git a/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C b/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C index 3e3d2af10c7c59be647083370d466ac0e117421d..61e33a5d7707c52b9d4fc6030330bf741438d316 100644 --- a/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C +++ b/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C @@ -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; } } diff --git a/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H b/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H index 21d02e4a9a0658bf7d1b15b6c2399ac00449adf6..8657a9b3e29bffcd88cb1856c46b05cf2bab6937 100644 --- a/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H +++ b/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H @@ -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(); diff --git a/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddFields.H b/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddFields.H index 357e260b1f97b0c1d3c9ff808abefe980236948f..4cf48293e77451969eabf36e96e108717550d178 100644 --- a/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddFields.H +++ b/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddFields.H @@ -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 \*---------------------------------------------------------------------------*/ diff --git a/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertLagrangianFields.H b/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertLagrangianFields.H index c52e3d69bd59b94b8f89bc9d43cb968200af5a05..9de17ee5611c189a3fe62ba76d594330bc6b4729 100644 --- a/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertLagrangianFields.H +++ b/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertLagrangianFields.H @@ -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(); diff --git a/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertMesh.C b/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertMesh.C index 95a07970810bbc8b0af6fb4f1c9ef8ebc8b20c9a..2edace96dcf5fcd903fcd4e69f7fe1417a8e16e6 100644 --- a/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertMesh.C +++ b/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertMesh.C @@ -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(); } diff --git a/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertPatchFaceField.H b/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertPatchFaceField.H index 938455ed7345e2f96ba541f14fd3a4864c494cc3..db24e175788e7283507154f5b0dfa4f1a6cf6d71 100644 --- a/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertPatchFaceField.H +++ b/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertPatchFaceField.H @@ -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(); diff --git a/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertPatchPointField.H b/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertPatchPointField.H index 50c258d1b0b04ec5c28bfcc77808dd9a65e00950..2ec93dffdc381fbc8495f088104218997683aa9e 100644 --- a/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertPatchPointField.H +++ b/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertPatchPointField.H @@ -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(); diff --git a/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertPointFields.H b/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertPointFields.H index 19777cc10973f3c9eaa663d62c5ef8168d7ed95c..4e6fe750650a55e6c8941cab24aa5c411a9f5220 100644 --- a/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertPointFields.H +++ b/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertPointFields.H @@ -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(); diff --git a/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertVolFields.H b/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertVolFields.H index f4520f0d7423163d5be522063069f24cac95a7dd..e27af752bb03198361da4705d4ce4c739531309f 100644 --- a/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertVolFields.H +++ b/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertVolFields.H @@ -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(); diff --git a/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamInsertNextPoint.H b/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamInsertNextPoint.H index 307fc811ccdb00f7a021287c43d2097c0c498434..107296e5fd57e55295ab05b8df82b63f1040e924 100644 --- a/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamInsertNextPoint.H +++ b/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamInsertNextPoint.H @@ -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 \*---------------------------------------------------------------------------*/ diff --git a/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformationFields.H b/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformationFields.H index fc32fc260fabfa415c421ea1bf92e1c2fa4896cf..da6f766bcf4cd2548507090fe484a6b737cbf90e 100644 --- a/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformationFields.H +++ b/src/paraview-plugins/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformationFields.H @@ -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 \*---------------------------------------------------------------------------*/