Commit d44eb192 authored by Andrew Heather's avatar Andrew Heather

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

parent b842eda4
......@@ -39,6 +39,7 @@ License
#include "vtkDataArraySelection.h"
#include "vtkDataSet.h"
#include "vtkFieldData.h"
#include "vtkInformation.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkRenderer.h"
#include "vtkTextActor.h"
......@@ -61,7 +62,8 @@ void Foam::vtkPV3Foam::AddToBlock
vtkMultiBlockDataSet* output,
unsigned int blockNo,
unsigned int datasetNo,
vtkDataSet* dataset
vtkDataSet* dataset,
const char* datasetName
)
{
vtkDataObject* blockDO = output->GetBlock(blockNo);
......@@ -81,6 +83,10 @@ void Foam::vtkPV3Foam::AddToBlock
}
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
)
{
if (debug)
{
Info<< "entered Foam::vtkPV3Foam::setName" << endl;
}
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();
Info<< "entered Foam::vtkPV3Foam::setBlockName" << endl;
}
if (blocks->GetMetaData(id) != NULL)
{
blocks->GetMetaData(id)->Set(vtkCompositeDataSet::NAME(), name);
}
}
......@@ -423,7 +426,7 @@ Foam::vtkPV3Foam::vtkPV3Foam
// Set initial cloud name
// TODO - TEMPORARY MEASURE UNTIL CAN PROCESS MULTIPLE CLOUDS
cloudName_ = "";
cloudName_ = "cloud1";
}
......
......@@ -196,7 +196,8 @@ class vtkPV3Foam
vtkMultiBlockDataSet* output,
unsigned int blockNo,
unsigned int datasetNo,
vtkDataSet* dataset
vtkDataSet* dataset,
const char* datasetName
);
// Convenience method use to convert the readers from VTK 5
......@@ -443,8 +444,13 @@ class vtkPV3Foam
);
//- Set the name VTK objects
void SetName(vtkUnstructuredGrid* vtkMesh, const char* name);
//- Set the name of the block
void SetBlockName
(
vtkMultiBlockDataSet* blocks,
const int id,
const char* name
);
//- Disallow default bitwise copy construct
vtkPV3Foam(const vtkPV3Foam&);
......
......@@ -51,8 +51,6 @@ void Foam::vtkPV3Foam::addFaceSetMesh
Info<< "entered add face set internal mesh" << endl;
}
SetName(vtkMesh, "faceSetMesh");
// Construct primitivePatch of faces in fSet.
const faceList& faces = mesh.faces();
......
......@@ -51,8 +51,6 @@ void Foam::vtkPV3Foam::addLagrangianMesh
Info<< "entered add Lagrangian mesh" << endl;
}
SetName(vtkMesh, "LagrangianMesh");
fileNameList cloudDirs
(
readDir(mesh.time().timePath()/"lagrangian", fileName::DIRECTORY)
......
......@@ -49,8 +49,6 @@ void Foam::vtkPV3Foam::addPatchMesh
Info<< "Adding patch: " << p.name() << endl;
}
SetName(vtkPatch, p.name().c_str());
if (debug)
{
Info<< "converting points" << endl;
......
......@@ -50,8 +50,6 @@ void Foam::vtkPV3Foam::addPointSetMesh
Info<< "entered add point set mesh" << endl;
}
SetName(vtkMesh, "pointSetMesh");
vtkPoints *vtkpoints = vtkPoints::New();
vtkpoints->Allocate(mesh.nPoints());
......
......@@ -57,8 +57,6 @@ void Foam::vtkPV3Foam::addVolumeMesh
Info<< "entered add volume mesh" << endl;
}
SetName(vtkMesh, "internalMesh");
// Number of additional points needed by the decomposition of polyhedra
label nAddPoints = 0;
......
......@@ -63,10 +63,9 @@ void Foam::vtkPV3Foam::convertMeshVolume
const fvMesh& mesh = *meshPtr_;
vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New();
SetName(ugrid, "internalMesh");
addVolumeMesh(mesh, ugrid, superCells_);
AddToBlock(output, VOLUME, 0, ugrid);
// reader_->SetBlock(output->GetNumberOfBlocks(), ugrid);
AddToBlock(output, VOLUME, 0, ugrid, "internalMesh");
SetBlockName(output, VOLUME, "Volume");
selectedRegionDatasetIds_[VOLUME] = 0;
ugrid->Delete();
}
......@@ -97,7 +96,8 @@ void Foam::vtkPV3Foam::convertMeshLagrangian
vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New();
addLagrangianMesh(mesh, ugrid);
AddToBlock(output, LAGRANGIAN, 0, ugrid);
AddToBlock(output, LAGRANGIAN, 0, ugrid, cloudName_.c_str());
SetBlockName(output, LAGRANGIAN, "Lagrangian");
selectedRegionDatasetIds_[LAGRANGIAN] = 0;
ugrid->Delete();
}
......@@ -143,7 +143,7 @@ void Foam::vtkPV3Foam::convertMeshPatches
.findPatchID(regionName);
addPatchMesh(patches[patchId], ugrid);
const label nextId = GetNumberOfDataSets(output, VOLUME);
AddToBlock(output, VOLUME, nextId, ugrid);
AddToBlock(output, VOLUME, nextId, ugrid, regionName.c_str());
selectedRegionDatasetIds_[i] = nextId;
ugrid->Delete();
}
......@@ -188,7 +188,6 @@ void Foam::vtkPV3Foam::convertMeshCellSet
subsetter.setLargeCellSubset(cSet);
vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New();
SetName(ugrid, cSetName.c_str());
const label nextId = GetNumberOfDataSets(output, CELLSET);
addVolumeMesh
(
......@@ -196,11 +195,13 @@ void Foam::vtkPV3Foam::convertMeshCellSet
ugrid,
superCellSetCells_[nextId]
);
AddToBlock(output, CELLSET, nextId, ugrid);
AddToBlock(output, CELLSET, nextId, ugrid, cSetName.c_str());
selectedRegionDatasetIds_[i] = nextId;
ugrid->Delete();
}
}
SetBlockName(output, CELLSET, "CellSets");
}
}
......@@ -239,7 +240,6 @@ void Foam::vtkPV3Foam::convertMeshFaceSet
const faceSet fSet(mesh, fSetName);
vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New();
SetName(ugrid, fSetName.c_str());
addFaceSetMesh
(
mesh,
......@@ -247,11 +247,13 @@ void Foam::vtkPV3Foam::convertMeshFaceSet
ugrid
);
const label nextId = GetNumberOfDataSets(output, FACESET);
AddToBlock(output, FACESET, nextId, ugrid);
AddToBlock(output, FACESET, nextId, ugrid, fSetName.c_str());
selectedRegionDatasetIds_[i] = nextId;
ugrid->Delete();
}
}
SetBlockName(output, FACESET, "FaceSets");
}
}
......@@ -290,7 +292,6 @@ void Foam::vtkPV3Foam::convertMeshPointSet
const pointSet pSet(mesh, pSetName);
vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::New();
SetName(ugrid, pSetName.c_str());
addPointSetMesh
(
mesh,
......@@ -298,11 +299,13 @@ void Foam::vtkPV3Foam::convertMeshPointSet
ugrid
);
label nextId = GetNumberOfDataSets(output, POINTSET);
AddToBlock(output, POINTSET, nextId, ugrid);
AddToBlock(output, POINTSET, nextId, ugrid, pSetName.c_str());
selectedRegionDatasetIds_[i] = nextId;
ugrid->Delete();
}
}
SetBlockName(output, POINTSET, "PointSets");
}
}
......
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