27 #include "vtkPV4blockMeshReader.h"
32 #include "patchZones.H"
36 #include "vtkDataArraySelection.h"
37 #include "vtkMultiBlockDataSet.h"
38 #include "vtkRenderer.h"
39 #include "vtkTextActor.h"
40 #include "vtkTextProperty.h"
63 vtkDataArraySelection* arraySelection
68 Info<<
"<beg> Foam::vtkPV4blockMesh::updateInfoBlocks"
69 <<
" [meshPtr=" << (meshPtr_ ?
"set" :
"NULL") <<
"]" <<
endl;
72 arrayRangeBlocks_.reset( arraySelection->GetNumberOfArrays() );
74 const blockMesh& blkMesh = *meshPtr_;
75 const int nBlocks = blkMesh.size();
76 for (
int blockI = 0; blockI < nBlocks; ++blockI)
78 const blockDescriptor& blockDef = blkMesh[blockI].blockDef();
83 if (!blockDef.zoneName().empty())
85 partName +=
" - " + blockDef.zoneName();
89 arraySelection->AddArray(partName.c_str());
92 arrayRangeBlocks_ += nBlocks;
99 Info<<
"<end> Foam::vtkPV4blockMesh::updateInfoBlocks" <<
endl;
106 vtkDataArraySelection* arraySelection
111 Info<<
"<beg> Foam::vtkPV4blockMesh::updateInfoEdges"
112 <<
" [meshPtr=" << (meshPtr_ ?
"set" :
"NULL") <<
"]" <<
endl;
115 arrayRangeEdges_.reset( arraySelection->GetNumberOfArrays() );
117 const blockMesh& blkMesh = *meshPtr_;
120 const int nEdges = edges.
size();
125 ostr<< edges[edgeI].start() <<
":" << edges[edgeI].end() <<
" - "
126 << edges[edgeI].type();
129 arraySelection->AddArray(ostr.str().c_str());
132 arrayRangeEdges_ += nEdges;
139 Info<<
"<end> Foam::vtkPV4blockMesh::updateInfoEdges" <<
endl;
148 const char*
const FileName,
149 vtkPV4blockMeshReader* reader
155 meshRegion_(polyMesh::defaultRegion),
156 meshDir_(polyMesh::meshSubDir),
157 arrayRangeBlocks_(
"block"),
158 arrayRangeEdges_(
"edges"),
159 arrayRangeCorners_(
"corners")
163 Info<<
"Foam::vtkPV4blockMesh::vtkPV4blockMesh - "
168 fileName fullCasePath(fileName(FileName).
path());
170 if (!
isDir(fullCasePath))
174 if (fullCasePath ==
".")
176 fullCasePath =
cwd();
180 if (fullCasePath.name().find(
"processor", 0) == 0)
182 const fileName globalCase = fullCasePath.path();
184 setEnv(
"FOAM_CASE", globalCase,
true);
185 setEnv(
"FOAM_CASENAME", globalCase.name(),
true);
189 setEnv(
"FOAM_CASE", fullCasePath,
true);
190 setEnv(
"FOAM_CASENAME", fullCasePath.name(),
true);
196 string caseName(fileName(FileName).lessExt());
202 beg != string::npos && caseName[beg] ==
'{'
203 &&
end != string::npos &&
end == caseName.size()-1
206 meshRegion_ = caseName.substr(beg+1,
end-beg-1);
209 if (meshRegion_.empty())
222 Info<<
"fullCasePath=" << fullCasePath <<
nl
223 <<
"FOAM_CASE=" <<
getEnv(
"FOAM_CASE") <<
nl
224 <<
"FOAM_CASENAME=" <<
getEnv(
"FOAM_CASENAME") <<
endl;
233 fileName(fullCasePath.path()),
234 fileName(fullCasePath.name())
238 dbPtr_().functionObjects().off();
250 Info<<
"<end> Foam::vtkPV4blockMesh::~vtkPV4blockMesh" <<
endl;
255 forAll(pointNumberTextActorsPtrs_, pointI)
257 pointNumberTextActorsPtrs_[pointI]->Delete();
259 pointNumberTextActorsPtrs_.clear();
271 Info<<
"<beg> Foam::vtkPV4blockMesh::updateInfo"
272 <<
" [meshPtr=" << (meshPtr_ ?
"set" :
"NULL") <<
"] " <<
endl;
277 vtkDataArraySelection* blockSelection = reader_->GetBlockSelection();
278 vtkDataArraySelection* edgeSelection = reader_->GetCurvedEdgesSelection();
284 bool firstTime =
false;
285 if (!blockSelection->GetNumberOfArrays() && !meshPtr_)
296 blockSelection->RemoveAllArrays();
297 edgeSelection->RemoveAllArrays();
303 updateInfoBlocks( blockSelection );
306 updateInfoEdges( edgeSelection );
317 Info<<
"<end> Foam::vtkPV4blockMesh::updateInfo" <<
endl;
326 Info<<
"<beg> Foam::vtkPV4blockMesh::updateFoamMesh" <<
endl;
334 Info<<
"Creating blockMesh at time=" << dbPtr_().timeName()
339 const word
dictName(
"blockMeshDict");
355 IOdictionary meshDict
367 meshPtr_ =
new blockMesh(meshDict, meshRegion_);
373 Info<<
"<end> Foam::vtkPV4blockMesh::updateFoamMesh" <<
endl;
380 vtkMultiBlockDataSet* output
383 reader_->UpdateProgress(0.1);
386 updateBoolListStatus(blockStatus_, reader_->GetBlockSelection());
389 updateBoolListStatus(edgeStatus_, reader_->GetCurvedEdgesSelection());
391 reader_->UpdateProgress(0.2);
395 reader_->UpdateProgress(0.5);
400 convertMeshCorners(output, blockNo);
401 convertMeshBlocks(output, blockNo);
402 convertMeshEdges(output, blockNo);
404 reader_->UpdateProgress(0.8);
411 reader_->UpdateProgress(1.0);
417 vtkRenderer* renderer,
423 forAll(pointNumberTextActorsPtrs_, pointI)
425 renderer->RemoveViewProp(pointNumberTextActorsPtrs_[pointI]);
426 pointNumberTextActorsPtrs_[pointI]->Delete();
428 pointNumberTextActorsPtrs_.clear();
430 if (show && meshPtr_)
432 const pointField& cornerPts = meshPtr_->blockPointField();
433 const scalar scaleFactor = meshPtr_->scaleFactor();
435 pointNumberTextActorsPtrs_.setSize(cornerPts.size());
443 vtkTextProperty* tprop = txt->GetTextProperty();
444 tprop->SetFontFamilyToArial();
447 tprop->SetLineSpacing(1.0);
448 tprop->SetFontSize(14);
449 tprop->SetColor(1.0, 0.0, 1.0);
450 tprop->SetJustificationToCentered();
453 txt->GetPositionCoordinate()->SetCoordinateSystemToWorld();
455 txt->GetPositionCoordinate()->SetValue
457 cornerPts[pointI].
x()*scaleFactor,
458 cornerPts[pointI].
y()*scaleFactor,
459 cornerPts[pointI].z()*scaleFactor
463 renderer->AddViewProp(txt);
467 pointNumberTextActorsPtrs_[pointI] = txt;
477 os <<
indent <<
"Number of nodes: "
478 << (meshPtr_ ? meshPtr_->nPoints() : 0) <<
"\n";
480 os <<
indent <<
"Number of cells: "
481 << (meshPtr_ ? meshPtr_->nCells() : 0) <<
"\n";
483 os <<
indent <<
"Number of available time steps: "
484 << (dbPtr_.valid() ? dbPtr_().times().size() : 0) <<
endl;