enabled block/dataset names to be added/shown in the PV reader module

This commit is contained in:
andy
2008-05-09 13:04:25 +01:00
parent ed43e5b2ed
commit 68f62c3bc9
8 changed files with 40 additions and 38 deletions

View File

@ -39,6 +39,7 @@ License
#include "vtkDataArraySelection.h" #include "vtkDataArraySelection.h"
#include "vtkDataSet.h" #include "vtkDataSet.h"
#include "vtkFieldData.h" #include "vtkFieldData.h"
#include "vtkInformation.h"
#include "vtkMultiBlockDataSet.h" #include "vtkMultiBlockDataSet.h"
#include "vtkRenderer.h" #include "vtkRenderer.h"
#include "vtkTextActor.h" #include "vtkTextActor.h"
@ -61,7 +62,8 @@ void Foam::vtkPV3Foam::AddToBlock
vtkMultiBlockDataSet* output, vtkMultiBlockDataSet* output,
unsigned int blockNo, unsigned int blockNo,
unsigned int datasetNo, unsigned int datasetNo,
vtkDataSet* dataset vtkDataSet* dataset,
const char* datasetName
) )
{ {
vtkDataObject* blockDO = output->GetBlock(blockNo); vtkDataObject* blockDO = output->GetBlock(blockNo);
@ -81,6 +83,10 @@ void Foam::vtkPV3Foam::AddToBlock
} }
block->SetBlock(datasetNo, dataset); block->SetBlock(datasetNo, dataset);
block->GetMetaData(datasetNo)->Set
(
vtkCompositeDataSet::NAME(), datasetName
);
} }
@ -138,25 +144,22 @@ void Foam::vtkPV3Foam::resetCounters()
} }
void Foam::vtkPV3Foam::SetName void Foam::vtkPV3Foam::SetBlockName
( (
vtkUnstructuredGrid* vtkMesh, vtkMultiBlockDataSet* blocks,
const int id,
const char* name const char* name
) )
{ {
if (debug) if (debug)
{ {
Info<< "entered Foam::vtkPV3Foam::setName" << endl; Info<< "entered Foam::vtkPV3Foam::setBlockName" << endl;
}
if (blocks->GetMetaData(id) != NULL)
{
blocks->GetMetaData(id)->Set(vtkCompositeDataSet::NAME(), name);
} }
vtkCharArray* nmArray = vtkCharArray::New();
nmArray->SetName("Name");
size_t len = strlen(name);
nmArray->SetNumberOfTuples(static_cast<vtkIdType>(len) + 1);
char* copy = nmArray->GetPointer(0);
memcpy(copy, name, len);
copy[len] = '\0';
vtkMesh->GetFieldData()->AddArray(nmArray);
nmArray->Delete();
} }
@ -423,7 +426,7 @@ Foam::vtkPV3Foam::vtkPV3Foam
// Set initial cloud name // Set initial cloud name
// TODO - TEMPORARY MEASURE UNTIL CAN PROCESS MULTIPLE CLOUDS // TODO - TEMPORARY MEASURE UNTIL CAN PROCESS MULTIPLE CLOUDS
cloudName_ = ""; cloudName_ = "cloud1";
} }

View File

@ -196,7 +196,8 @@ class vtkPV3Foam
vtkMultiBlockDataSet* output, vtkMultiBlockDataSet* output,
unsigned int blockNo, unsigned int blockNo,
unsigned int datasetNo, unsigned int datasetNo,
vtkDataSet* dataset vtkDataSet* dataset,
const char* datasetName
); );
// Convenience method use to convert the readers from VTK 5 // Convenience method use to convert the readers from VTK 5
@ -443,8 +444,13 @@ class vtkPV3Foam
); );
//- Set the name VTK objects //- Set the name of the block
void SetName(vtkUnstructuredGrid* vtkMesh, const char* name); void SetBlockName
(
vtkMultiBlockDataSet* blocks,
const int id,
const char* name
);
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
vtkPV3Foam(const vtkPV3Foam&); vtkPV3Foam(const vtkPV3Foam&);

View File

@ -51,8 +51,6 @@ void Foam::vtkPV3Foam::addFaceSetMesh
Info<< "entered add face set internal mesh" << endl; Info<< "entered add face set internal mesh" << endl;
} }
SetName(vtkMesh, "faceSetMesh");
// Construct primitivePatch of faces in fSet. // Construct primitivePatch of faces in fSet.
const faceList& faces = mesh.faces(); const faceList& faces = mesh.faces();

View File

@ -51,8 +51,6 @@ void Foam::vtkPV3Foam::addLagrangianMesh
Info<< "entered add Lagrangian mesh" << endl; Info<< "entered add Lagrangian mesh" << endl;
} }
SetName(vtkMesh, "LagrangianMesh");
fileNameList cloudDirs fileNameList cloudDirs
( (
readDir(mesh.time().timePath()/"lagrangian", fileName::DIRECTORY) readDir(mesh.time().timePath()/"lagrangian", fileName::DIRECTORY)

View File

@ -49,8 +49,6 @@ void Foam::vtkPV3Foam::addPatchMesh
Info<< "Adding patch: " << p.name() << endl; Info<< "Adding patch: " << p.name() << endl;
} }
SetName(vtkPatch, p.name().c_str());
if (debug) if (debug)
{ {
Info<< "converting points" << endl; Info<< "converting points" << endl;

View File

@ -50,8 +50,6 @@ void Foam::vtkPV3Foam::addPointSetMesh
Info<< "entered add point set mesh" << endl; Info<< "entered add point set mesh" << endl;
} }
SetName(vtkMesh, "pointSetMesh");
vtkPoints *vtkpoints = vtkPoints::New(); vtkPoints *vtkpoints = vtkPoints::New();
vtkpoints->Allocate(mesh.nPoints()); vtkpoints->Allocate(mesh.nPoints());

View File

@ -57,8 +57,6 @@ void Foam::vtkPV3Foam::addVolumeMesh
Info<< "entered add volume mesh" << endl; Info<< "entered add volume mesh" << endl;
} }
SetName(vtkMesh, "internalMesh");
// Number of additional points needed by the decomposition of polyhedra // Number of additional points needed by the decomposition of polyhedra
label nAddPoints = 0; label nAddPoints = 0;

View File

@ -63,10 +63,9 @@ void Foam::vtkPV3Foam::convertMeshVolume
const fvMesh& mesh = *meshPtr_; const fvMesh& mesh = *meshPtr_;
vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New(); vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New();
SetName(ugrid, "internalMesh");
addVolumeMesh(mesh, ugrid, superCells_); addVolumeMesh(mesh, ugrid, superCells_);
AddToBlock(output, VOLUME, 0, ugrid); AddToBlock(output, VOLUME, 0, ugrid, "internalMesh");
// reader_->SetBlock(output->GetNumberOfBlocks(), ugrid); SetBlockName(output, VOLUME, "Volume");
selectedRegionDatasetIds_[VOLUME] = 0; selectedRegionDatasetIds_[VOLUME] = 0;
ugrid->Delete(); ugrid->Delete();
} }
@ -97,7 +96,8 @@ void Foam::vtkPV3Foam::convertMeshLagrangian
vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New(); vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New();
addLagrangianMesh(mesh, ugrid); addLagrangianMesh(mesh, ugrid);
AddToBlock(output, LAGRANGIAN, 0, ugrid); AddToBlock(output, LAGRANGIAN, 0, ugrid, cloudName_.c_str());
SetBlockName(output, LAGRANGIAN, "Lagrangian");
selectedRegionDatasetIds_[LAGRANGIAN] = 0; selectedRegionDatasetIds_[LAGRANGIAN] = 0;
ugrid->Delete(); ugrid->Delete();
} }
@ -143,7 +143,7 @@ void Foam::vtkPV3Foam::convertMeshPatches
.findPatchID(regionName); .findPatchID(regionName);
addPatchMesh(patches[patchId], ugrid); addPatchMesh(patches[patchId], ugrid);
const label nextId = GetNumberOfDataSets(output, VOLUME); const label nextId = GetNumberOfDataSets(output, VOLUME);
AddToBlock(output, VOLUME, nextId, ugrid); AddToBlock(output, VOLUME, nextId, ugrid, regionName.c_str());
selectedRegionDatasetIds_[i] = nextId; selectedRegionDatasetIds_[i] = nextId;
ugrid->Delete(); ugrid->Delete();
} }
@ -188,7 +188,6 @@ void Foam::vtkPV3Foam::convertMeshCellSet
subsetter.setLargeCellSubset(cSet); subsetter.setLargeCellSubset(cSet);
vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New(); vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New();
SetName(ugrid, cSetName.c_str());
const label nextId = GetNumberOfDataSets(output, CELLSET); const label nextId = GetNumberOfDataSets(output, CELLSET);
addVolumeMesh addVolumeMesh
( (
@ -196,11 +195,13 @@ void Foam::vtkPV3Foam::convertMeshCellSet
ugrid, ugrid,
superCellSetCells_[nextId] superCellSetCells_[nextId]
); );
AddToBlock(output, CELLSET, nextId, ugrid); AddToBlock(output, CELLSET, nextId, ugrid, cSetName.c_str());
selectedRegionDatasetIds_[i] = nextId; selectedRegionDatasetIds_[i] = nextId;
ugrid->Delete(); ugrid->Delete();
} }
} }
SetBlockName(output, CELLSET, "CellSets");
} }
} }
@ -239,7 +240,6 @@ void Foam::vtkPV3Foam::convertMeshFaceSet
const faceSet fSet(mesh, fSetName); const faceSet fSet(mesh, fSetName);
vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New(); vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New();
SetName(ugrid, fSetName.c_str());
addFaceSetMesh addFaceSetMesh
( (
mesh, mesh,
@ -247,11 +247,13 @@ void Foam::vtkPV3Foam::convertMeshFaceSet
ugrid ugrid
); );
const label nextId = GetNumberOfDataSets(output, FACESET); const label nextId = GetNumberOfDataSets(output, FACESET);
AddToBlock(output, FACESET, nextId, ugrid); AddToBlock(output, FACESET, nextId, ugrid, fSetName.c_str());
selectedRegionDatasetIds_[i] = nextId; selectedRegionDatasetIds_[i] = nextId;
ugrid->Delete(); ugrid->Delete();
} }
} }
SetBlockName(output, FACESET, "FaceSets");
} }
} }
@ -290,7 +292,6 @@ void Foam::vtkPV3Foam::convertMeshPointSet
const pointSet pSet(mesh, pSetName); const pointSet pSet(mesh, pSetName);
vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New(); vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New();
SetName(ugrid, pSetName.c_str());
addPointSetMesh addPointSetMesh
( (
mesh, mesh,
@ -298,11 +299,13 @@ void Foam::vtkPV3Foam::convertMeshPointSet
ugrid ugrid
); );
label nextId = GetNumberOfDataSets(output, POINTSET); label nextId = GetNumberOfDataSets(output, POINTSET);
AddToBlock(output, POINTSET, nextId, ugrid); AddToBlock(output, POINTSET, nextId, ugrid, pSetName.c_str());
selectedRegionDatasetIds_[i] = nextId; selectedRegionDatasetIds_[i] = nextId;
ugrid->Delete(); ugrid->Delete();
} }
} }
SetBlockName(output, POINTSET, "PointSets");
} }
} }