Commit 30ee37f8 authored by Mark Olesen's avatar Mark Olesen

STYLE: use labelRange and range-based-for in paraview readers

- also use updated forAll* macros
parent 64e4ec6d
......@@ -146,7 +146,7 @@ vtkPVFoamReader::~vtkPVFoamReader()
if (FileName)
{
delete [] FileName;
delete[] FileName;
}
if (output0_)
......@@ -525,13 +525,11 @@ void vtkPVFoamReader::updatePatchNamesView(const bool show)
}
// Get all the pqRenderView instances
QList<pqRenderView*> renderViews = smModel->findItems<pqRenderView*>();
for (int viewI=0; viewI < renderViews.size(); ++viewI)
for (auto view : smModel->findItems<pqRenderView*>())
{
backend_->renderPatchNames
(
renderViews[viewI]->getRenderViewProxy()->GetRenderer(),
view->getRenderViewProxy()->GetRenderer(),
show
);
}
......
......@@ -50,7 +50,7 @@ namespace Foam
vtkTextActor* Foam::vtkPVFoam::createTextActor
(
const string& s,
const std::string& s,
const point& pt
)
{
......@@ -79,15 +79,15 @@ vtkTextActor* Foam::vtkPVFoam::createTextActor
void Foam::vtkPVFoam::resetCounters()
{
// Reset array range information (ids and sizes)
arrayRangeVolume_.reset();
arrayRangePatches_.reset();
arrayRangeLagrangian_.reset();
arrayRangeCellZones_.reset();
arrayRangeFaceZones_.reset();
arrayRangePointZones_.reset();
arrayRangeCellSets_.reset();
arrayRangeFaceSets_.reset();
arrayRangePointSets_.reset();
rangeVolume_.reset();
rangePatches_.reset();
rangeLagrangian_.reset();
rangeCellZones_.reset();
rangeFaceZones_.reset();
rangePointZones_.reset();
rangeCellSets_.reset();
rangeFaceSets_.reset();
rangePointSets_.reset();
}
......@@ -260,15 +260,15 @@ Foam::vtkPVFoam::vtkPVFoam
timeIndex_(-1),
meshChanged_(true),
fieldsChanged_(true),
arrayRangeVolume_("unzoned"),
arrayRangePatches_("patches"),
arrayRangeLagrangian_("lagrangian"),
arrayRangeCellZones_("cellZone"),
arrayRangeFaceZones_("faceZone"),
arrayRangePointZones_("pointZone"),
arrayRangeCellSets_("cellSet"),
arrayRangeFaceSets_("faceSet"),
arrayRangePointSets_("pointSet")
rangeVolume_("unzoned"),
rangePatches_("patches"),
rangeLagrangian_("lagrangian"),
rangeCellZones_("cellZone"),
rangeFaceZones_("faceZone"),
rangePointZones_("pointZone"),
rangeCellSets_("cellSet"),
rangeFaceSets_("faceSet"),
rangePointSets_("pointSet")
{
if (debug)
{
......@@ -653,7 +653,7 @@ void Foam::vtkPVFoam::renderPatchNames
hashedWordList selectedPatches = getSelected
(
reader_->GetPartSelection(),
arrayRangePatches_
rangePatches_
);
if (selectedPatches.empty())
......
......@@ -35,7 +35,6 @@ SourceFiles
vtkPVFoamMeshVolume.C
vtkPVFoamTemplates.C
vtkPVFoamUpdateInfo.C
vtkPVFoamUtils.C
vtkPVFoamFieldTemplates.C
vtkPVFoamUpdateTemplates.C
......@@ -197,15 +196,15 @@ class vtkPVFoam
//- First instance and size of various mesh parts
// used to index into partStatus_ and partDataset_
arrayRange arrayRangeVolume_;
arrayRange arrayRangePatches_;
arrayRange arrayRangeLagrangian_;
arrayRange arrayRangeCellZones_;
arrayRange arrayRangeFaceZones_;
arrayRange arrayRangePointZones_;
arrayRange arrayRangeCellSets_;
arrayRange arrayRangeFaceSets_;
arrayRange arrayRangePointSets_;
arrayRange rangeVolume_;
arrayRange rangePatches_;
arrayRange rangeLagrangian_;
arrayRange rangeCellZones_;
arrayRange rangeFaceZones_;
arrayRange rangePointZones_;
arrayRange rangeCellSets_;
arrayRange rangeFaceSets_;
arrayRange rangePointSets_;
//- Decomposed cells information (mesh regions)
// TODO: regions
......@@ -224,7 +223,11 @@ class vtkPVFoam
// Private Member Functions
//- Create a text actor
static vtkTextActor* createTextActor(const string& s, const point& pt);
static vtkTextActor* createTextActor
(
const std::string& s,
const point& pt
);
//- Reset data counters
void resetCounters();
......
......@@ -83,7 +83,7 @@ void Foam::vtkPVFoam::convertVolField
fld,
ptfPtr,
output,
arrayRangeVolume_,
rangeVolume_,
regionPolyDecomp_
);
......@@ -93,7 +93,7 @@ void Foam::vtkPVFoam::convertVolField
fld,
ptfPtr,
output,
arrayRangeCellZones_,
rangeCellZones_,
zonePolyDecomp_
);
......@@ -103,7 +103,7 @@ void Foam::vtkPVFoam::convertVolField
fld,
ptfPtr,
output,
arrayRangeCellSets_,
rangeCellSets_,
csetPolyDecomp_
);
......@@ -111,12 +111,7 @@ void Foam::vtkPVFoam::convertVolField
//
// Convert patches - if activated
//
for
(
int partId = arrayRangePatches_.start();
partId < arrayRangePatches_.end();
++partId
)
for (auto partId : rangePatches_)
{
const word patchName = getPartName(partId);
const label datasetNo = partDataset_[partId];
......@@ -129,7 +124,7 @@ void Foam::vtkPVFoam::convertVolField
vtkPolyData* vtkmesh = getDataFromBlock<vtkPolyData>
(
output, arrayRangePatches_, datasetNo
output, rangePatches_, datasetNo
);
if (!vtkmesh)
......@@ -195,12 +190,7 @@ void Foam::vtkPVFoam::convertVolField
//
// Convert face zones - if activated
//
for
(
int partId = arrayRangeFaceZones_.start();
partId < arrayRangeFaceZones_.end();
++partId
)
for (auto partId : rangeFaceZones_)
{
const word zoneName = getPartName(partId);
const label datasetNo = partDataset_[partId];
......@@ -220,7 +210,7 @@ void Foam::vtkPVFoam::convertVolField
vtkPolyData* vtkmesh = getDataFromBlock<vtkPolyData>
(
output, arrayRangeFaceZones_, datasetNo
output, rangeFaceZones_, datasetNo
);
if (vtkmesh)
......@@ -241,12 +231,7 @@ void Foam::vtkPVFoam::convertVolField
//
// Convert face sets - if activated
//
for
(
int partId = arrayRangeFaceSets_.start();
partId < arrayRangeFaceSets_.end();
++partId
)
for (auto partId : rangeFaceSets_)
{
const word selectName = getPartName(partId);
const label datasetNo = partDataset_[partId];
......@@ -258,7 +243,7 @@ void Foam::vtkPVFoam::convertVolField
vtkPolyData* vtkmesh = getDataFromBlock<vtkPolyData>
(
output, arrayRangeFaceSets_, datasetNo
output, rangeFaceSets_, datasetNo
);
if (!vtkmesh)
......@@ -291,7 +276,7 @@ void Foam::vtkPVFoam::convertVolFields
vtkMultiBlockDataSet* output
)
{
forAllConstIter(IOobjectList, objects, iter)
forAllConstIters(objects, iter)
{
// restrict to GeometricField<Type, ...>
if
......@@ -327,7 +312,7 @@ void Foam::vtkPVFoam::convertDimFields
{
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
forAllConstIter(IOobjectList, objects, iter)
forAllConstIters(objects, iter)
{
// restrict to DimensionedField<Type, ...>
if
......@@ -387,7 +372,7 @@ void Foam::vtkPVFoam::convertVolFieldBlock
const List<polyDecomp>& decompLst
)
{
for (int partId = range.start(); partId < range.end(); ++partId)
for (auto partId : range)
{
const label datasetNo = partDataset_[partId];
......@@ -437,7 +422,7 @@ void Foam::vtkPVFoam::convertPointFields
const polyMesh& mesh = pMesh.mesh();
const polyBoundaryMesh& patches = mesh.boundaryMesh();
forAllConstIter(IOobjectList, objects, iter)
forAllConstIters(objects, iter)
{
const word& fieldName = iter()->name();
// restrict to this GeometricField<Type, ...>
......@@ -463,7 +448,7 @@ void Foam::vtkPVFoam::convertPointFields
(
pfld,
output,
arrayRangeVolume_,
rangeVolume_,
regionPolyDecomp_
);
......@@ -472,7 +457,7 @@ void Foam::vtkPVFoam::convertPointFields
(
pfld,
output,
arrayRangeCellZones_,
rangeCellZones_,
zonePolyDecomp_
);
......@@ -481,7 +466,7 @@ void Foam::vtkPVFoam::convertPointFields
(
pfld,
output,
arrayRangeCellSets_,
rangeCellSets_,
csetPolyDecomp_
);
......@@ -489,12 +474,7 @@ void Foam::vtkPVFoam::convertPointFields
//
// Convert patches - if activated
//
for
(
int partId = arrayRangePatches_.start();
partId < arrayRangePatches_.end();
++partId
)
for (auto partId : rangePatches_)
{
const word patchName = getPartName(partId);
const label datasetNo = partDataset_[partId];
......@@ -507,7 +487,7 @@ void Foam::vtkPVFoam::convertPointFields
vtkPolyData* vtkmesh = getDataFromBlock<vtkPolyData>
(
output, arrayRangePatches_, datasetNo
output, rangePatches_, datasetNo
);
if (vtkmesh)
......@@ -526,12 +506,7 @@ void Foam::vtkPVFoam::convertPointFields
//
// Convert faceZones - if activated
//
for
(
int partId = arrayRangeFaceZones_.start();
partId < arrayRangeFaceZones_.end();
++partId
)
for (auto partId : rangeFaceZones_)
{
const word zoneName = getPartName(partId);
const label datasetNo = partDataset_[partId];
......@@ -544,7 +519,7 @@ void Foam::vtkPVFoam::convertPointFields
vtkPolyData* vtkmesh = getDataFromBlock<vtkPolyData>
(
output, arrayRangeFaceZones_, datasetNo
output, rangeFaceZones_, datasetNo
);
if (vtkmesh)
......@@ -575,31 +550,31 @@ void Foam::vtkPVFoam::convertPointFieldBlock
const List<polyDecomp>& decompLst
)
{
for (int partId = range.start(); partId < range.end(); ++partId)
{
const label datasetNo = partDataset_[partId];
if (!partStatus_[partId])
{
continue;
}
vtkUnstructuredGrid* vtkmesh = getDataFromBlock<vtkUnstructuredGrid>
(
output, range, datasetNo
);
if (vtkmesh)
{
convertPointField
(
vtkmesh,
pfld,
GeometricField<Type, fvPatchField, volMesh>::null(),
decompLst[datasetNo]
);
}
}
for (auto partId : range)
{
const label datasetNo = partDataset_[partId];
if (!partStatus_[partId])
{
continue;
}
vtkUnstructuredGrid* vtkmesh = getDataFromBlock<vtkUnstructuredGrid>
(
output, range, datasetNo
);
if (vtkmesh)
{
convertPointField
(
vtkmesh,
pfld,
GeometricField<Type, fvPatchField, volMesh>::null(),
decompLst[datasetNo]
);
}
}
}
......@@ -731,9 +706,9 @@ void Foam::vtkPVFoam::convertLagrangianFields
const label datasetNo
)
{
const arrayRange& range = arrayRangeLagrangian_;
const arrayRange& range = rangeLagrangian_;
forAllConstIter(IOobjectList, objects, iter)
forAllConstIters(objects, iter)
{
// restrict to this IOField<Type>
if (iter()->headerClassName() == IOField<Type>::typeName)
......
......@@ -52,7 +52,7 @@ void Foam::vtkPVFoam::pruneObjectList
}
// only retain specified fields
forAllIter(IOobjectList, objects, iter)
forAllIters(objects, iter)
{
if (!retain.found(iter()->name()))
{
......@@ -93,7 +93,7 @@ void Foam::vtkPVFoam::convertVolFields
if (debug)
{
Info<< "<beg> convert volume fields" << endl;
forAllConstIter(IOobjectList, objects, iter)
forAllConstIters(objects, iter)
{
Info<< " " << iter()->name()
<< " == " << iter()->objectPath() << endl;
......@@ -175,7 +175,7 @@ void Foam::vtkPVFoam::convertPointFields
if (debug)
{
Info<< "<beg> convert volume -> point fields" << endl;
forAllConstIter(IOobjectList, objects, iter)
forAllConstIters(objects, iter)
{
Info<< " " << iter()->name()
<< " == " << iter()->objectPath() << endl;
......@@ -205,7 +205,7 @@ void Foam::vtkPVFoam::convertLagrangianFields
vtkMultiBlockDataSet* output
)
{
arrayRange& range = arrayRangeLagrangian_;
arrayRange& range = rangeLagrangian_;
const fvMesh& mesh = *meshPtr_;
hashedWordList selectedFields = getSelected
......@@ -224,7 +224,7 @@ void Foam::vtkPVFoam::convertLagrangianFields
printMemory();
}
for (int partId = range.start(); partId < range.end(); ++partId)
for (auto partId : range)
{
const word cloudName = getPartName(partId);
const label datasetNo = partDataset_[partId];
......@@ -253,7 +253,7 @@ void Foam::vtkPVFoam::convertLagrangianFields
if (debug)
{
Info<< "converting OpenFOAM lagrangian fields" << endl;
forAllConstIter(IOobjectList, objects, iter)
forAllConstIters(objects, iter)
{
Info<< " " << iter()->name()
<< " == " << iter()->objectPath() << endl;
......
......@@ -47,7 +47,7 @@ void Foam::vtkPVFoam::convertMeshVolume
int& blockNo
)
{
arrayRange& range = arrayRangeVolume_;
arrayRange& range = rangeVolume_;
range.block(blockNo); // set output block
label datasetNo = 0; // restart at dataset 0
const fvMesh& mesh = *meshPtr_;
......@@ -63,7 +63,7 @@ void Foam::vtkPVFoam::convertMeshVolume
// Convert the internalMesh
// this looks like more than one part, but it isn't
for (int partId = range.start(); partId < range.end(); ++partId)
for (auto partId : range)
{
const word partName = "internalMesh";
......@@ -107,7 +107,7 @@ void Foam::vtkPVFoam::convertMeshLagrangian
int& blockNo
)
{
arrayRange& range = arrayRangeLagrangian_;
arrayRange& range = rangeLagrangian_;
range.block(blockNo); // set output block
label datasetNo = 0; // restart at dataset 0
const fvMesh& mesh = *meshPtr_;
......@@ -118,7 +118,7 @@ void Foam::vtkPVFoam::convertMeshLagrangian
printMemory();
}
for (int partId = range.start(); partId < range.end(); ++partId)
for (auto partId : range)
{
const word cloudName = getPartName(partId);
......@@ -158,7 +158,7 @@ void Foam::vtkPVFoam::convertMeshPatches
int& blockNo
)
{
arrayRange& range = arrayRangePatches_;
arrayRange& range = rangePatches_;
range.block(blockNo); // set output block
label datasetNo = 0; // restart at dataset 0
const fvMesh& mesh = *meshPtr_;
......@@ -170,7 +170,7 @@ void Foam::vtkPVFoam::convertMeshPatches
printMemory();
}
for (int partId = range.start(); partId < range.end(); ++partId)
for (auto partId : range)
{
if (!partStatus_[partId])
{
......@@ -197,15 +197,15 @@ void Foam::vtkPVFoam::convertMeshPatches
{
// Patch group. Collect patch faces.
label sz = 0;
forAllConstIter(labelHashSet, patchIds, iter)
for (auto id : patchIds)
{
sz += patches[iter.key()].size();
sz += patches[id].size();
}
labelList faceLabels(sz);
sz = 0;
forAllConstIter(labelHashSet, patchIds, iter)
for (auto id : patchIds)
{
const polyPatch& pp = patches[iter.key()];
const auto& pp = patches[id];
forAll(pp, i)
{
faceLabels[sz++] = pp.start()+i;
......@@ -254,7 +254,7 @@ void Foam::vtkPVFoam::convertMeshCellZones
int& blockNo
)
{
arrayRange& range = arrayRangeCellZones_;
arrayRange& range = rangeCellZones_;
range.block(blockNo); // set output block
label datasetNo = 0; // restart at dataset 0
const fvMesh& mesh = *meshPtr_;
......@@ -274,7 +274,7 @@ void Foam::vtkPVFoam::convertMeshCellZones
}
const cellZoneMesh& zMesh = mesh.cellZones();
for (int partId = range.start(); partId < range.end(); ++partId)
for (auto partId : range)
{
const word zoneName = getPartName(partId);
const label zoneId = zMesh.findZoneID(zoneName);
......@@ -343,7 +343,7 @@ void Foam::vtkPVFoam::convertMeshCellSets
int& blockNo
)
{
arrayRange& range = arrayRangeCellSets_;
arrayRange& range = rangeCellSets_;
range.block(blockNo); // set output block
label datasetNo = 0; // restart at dataset 0
const fvMesh& mesh = *meshPtr_;
......@@ -357,7 +357,7 @@ void Foam::vtkPVFoam::convertMeshCellSets
printMemory();
}
for (int partId = range.start(); partId < range.end(); ++partId)
for (auto partId : range)
{
const word partName = getPartName(partId);
......@@ -425,7 +425,7 @@ void Foam::vtkPVFoam::convertMeshFaceZones
int& blockNo
)
{
arrayRange& range = arrayRangeFaceZones_;
arrayRange& range = rangeFaceZones_;
range.block(blockNo); // set output block
label datasetNo = 0; // restart at dataset 0
const fvMesh& mesh = *meshPtr_;
......@@ -442,7 +442,7 @@ void Foam::vtkPVFoam::convertMeshFaceZones
}
const faceZoneMesh& zMesh = mesh.faceZones();
for (int partId = range.start(); partId < range.end(); ++partId)
for (auto partId : range)
{
const word zoneName = getPartName(partId);
const label zoneId = zMesh.findZoneID(zoneName);
......@@ -489,7 +489,7 @@ void Foam::vtkPVFoam::convertMeshFaceSets
int& blockNo
)
{
arrayRange& range = arrayRangeFaceSets_;
arrayRange& range = rangeFaceSets_;
range.block(blockNo); // set output block
label datasetNo = 0; // restart at dataset 0
const fvMesh& mesh = *meshPtr_;
......@@ -500,7 +500,7 @@ void Foam::vtkPVFoam::convertMeshFaceSets
printMemory();
}
for (int partId = range.start(); partId < range.end(); ++partId)
for (auto partId : range)
{
const word partName = getPartName(partId);
......@@ -560,7 +560,7 @@ void Foam::vtkPVFoam::convertMeshPointZones
int& blockNo
)
{
arrayRange& range = arrayRangePointZones_;
arrayRange& range = rangePointZones_;
range.block(blockNo); // set output block
label datasetNo = 0; // restart at dataset 0
const fvMesh& mesh = *meshPtr_;
......@@ -574,10 +574,10 @@ void Foam::vtkPVFoam::convertMeshPointZones
if (range.size())
{
const pointZoneMesh& zMesh = mesh.pointZones();
for (int partId = range.start(); partId < range.end(); ++partId)
for (auto partId : range)
{
word zoneName = getPartName(partId);
label zoneId = zMesh.findZoneID(zoneName);
const word zoneName = getPartName(partId);
const label zoneId = zMesh.findZoneID(zoneName);
if (!partStatus_[partId] || zoneId < 0)
{
......@@ -630,7 +630,7 @@ void Foam::vtkPVFoam::convertMeshPointSets
int& blockNo
)
{
arrayRange& range = arrayRangePointSets_;
arrayRange& range = rangePointSets_;
range.block(blockNo); // set output block