OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

vtkPV3Foam.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "vtkPV3Foam.H"
00028 #include "vtkPV3FoamReader.h"
00029 
00030 // Foam includes
00031 #include "fvMesh.H"
00032 #include "Time.H"
00033 #include "patchZones.H"
00034 
00035 // VTK includes
00036 #include "vtkDataArraySelection.h"
00037 #include "vtkMultiBlockDataSet.h"
00038 #include "vtkRenderer.h"
00039 #include "vtkTextActor.h"
00040 #include "vtkTextProperty.h"
00041 
00042 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00043 
00044 defineTypeNameAndDebug(Foam::vtkPV3Foam, 0);
00045 
00046 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00047 
00048 #include "vtkPV3FoamAddToSelection.H"
00049 #include "vtkPV3FoamUpdateInfoFields.H"
00050 
00051 void Foam::vtkPV3Foam::resetCounters()
00052 {
00053     // Reset mesh part ids and sizes
00054     partInfoVolume_.reset();
00055     partInfoPatches_.reset();
00056     partInfoLagrangian_.reset();
00057     partInfoCellZones_.reset();
00058     partInfoFaceZones_.reset();
00059     partInfoPointZones_.reset();
00060     partInfoCellSets_.reset();
00061     partInfoFaceSets_.reset();
00062     partInfoPointSets_.reset();
00063 }
00064 
00065 
00066 void Foam::vtkPV3Foam::reduceMemory()
00067 {
00068     forAll(regionPolyDecomp_, i)
00069     {
00070         regionPolyDecomp_[i].clear();
00071     }
00072 
00073     forAll(zonePolyDecomp_, i)
00074     {
00075         zonePolyDecomp_[i].clear();
00076     }
00077 
00078     forAll(csetPolyDecomp_, i)
00079     {
00080         csetPolyDecomp_[i].clear();
00081     }
00082 
00083     if (!reader_->GetCacheMesh())
00084     {
00085         delete meshPtr_;
00086         meshPtr_ = NULL;
00087     }
00088 }
00089 
00090 
00091 
00092 
00093 int Foam::vtkPV3Foam::setTime(int nRequest, const double requestTimes[])
00094 {
00095     if (debug)
00096     {
00097         Info<< "<beg> Foam::vtkPV3Foam::setTime(";
00098         for (int requestI = 0; requestI < nRequest; ++requestI)
00099         {
00100             if (requestI)
00101             {
00102                 Info<< ", ";
00103             }
00104 
00105             Info<< requestTimes[requestI];
00106         }
00107         Info << ") - previousIndex = " << timeIndex_ << endl;
00108     }
00109 
00110     Time& runTime = dbPtr_();
00111 
00112     // Get times list
00113     instantList Times = runTime.times();
00114 
00115     int nearestIndex = timeIndex_;
00116     for (int requestI = 0; requestI < nRequest; ++requestI)
00117     {
00118         int index = Time::findClosestTimeIndex(Times, requestTimes[requestI]);
00119         if (index >= 0 && index != timeIndex_)
00120         {
00121             nearestIndex = index;
00122             break;
00123         }
00124     }
00125 
00126     if (nearestIndex < 0)
00127     {
00128         nearestIndex = 0;
00129     }
00130 
00131 
00132     // see what has changed
00133     if (timeIndex_ != nearestIndex)
00134     {
00135         timeIndex_ = nearestIndex;
00136         runTime.setTime(Times[nearestIndex], nearestIndex);
00137 
00138         // the fields change each time
00139         fieldsChanged_ = true;
00140 
00141         if (meshPtr_)
00142         {
00143             if (meshPtr_->readUpdate() != polyMesh::UNCHANGED)
00144             {
00145                 meshChanged_ = true;
00146             }
00147         }
00148         else
00149         {
00150             meshChanged_ = true;
00151         }
00152 
00153         reader_->UpdateProgress(0.05);
00154 
00155         // this seems to be needed for catching Lagrangian fields
00156         updateInfo();
00157     }
00158 
00159     if (debug)
00160     {
00161         Info<< "<end> Foam::vtkPV3Foam::setTime() - selectedTime="
00162             << Times[nearestIndex].name() << " index=" << timeIndex_
00163             << "/" << Times.size()
00164             << " meshChanged=" << Switch(meshChanged_)
00165             << " fieldsChanged=" << Switch(fieldsChanged_) << endl;
00166     }
00167 
00168     return nearestIndex;
00169 }
00170 
00171 
00172 void Foam::vtkPV3Foam::updateMeshPartsStatus()
00173 {
00174     if (debug)
00175     {
00176         Info<< "<beg> Foam::vtkPV3Foam::updateMeshPartsStatus" << endl;
00177     }
00178 
00179     vtkDataArraySelection* selection = reader_->GetPartSelection();
00180     label nElem = selection->GetNumberOfArrays();
00181 
00182     if (partStatus_.size() != nElem)
00183     {
00184         partStatus_.setSize(nElem);
00185         partStatus_ = false;
00186         meshChanged_ = true;
00187     }
00188 
00189     // this needs fixing if we wish to re-use the datasets
00190     partDataset_.setSize(nElem);
00191     partDataset_ = -1;
00192 
00193     // Read the selected mesh parts (zones, patches ...) and add to list
00194     forAll(partStatus_, partId)
00195     {
00196         const int setting = selection->GetArraySetting(partId);
00197 
00198         if (partStatus_[partId] != setting)
00199         {
00200             partStatus_[partId] = setting;
00201             meshChanged_ = true;
00202         }
00203 
00204         if (debug)
00205         {
00206             Info<< "  part[" << partId << "] = "
00207                 << partStatus_[partId]
00208                 << " : " << selection->GetArrayName(partId) << endl;
00209         }
00210     }
00211     if (debug)
00212     {
00213         Info<< "<end> Foam::vtkPV3Foam::updateMeshPartsStatus" << endl;
00214     }
00215 }
00216 
00217 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00218 
00219 Foam::vtkPV3Foam::vtkPV3Foam
00220 (
00221     const char* const FileName,
00222     vtkPV3FoamReader* reader
00223 )
00224 :
00225     reader_(reader),
00226     dbPtr_(NULL),
00227     meshPtr_(NULL),
00228     meshRegion_(polyMesh::defaultRegion),
00229     meshDir_(polyMesh::meshSubDir),
00230     timeIndex_(-1),
00231     meshChanged_(true),
00232     fieldsChanged_(true),
00233     partInfoVolume_("unzoned"),
00234     partInfoPatches_("patches"),
00235     partInfoLagrangian_("lagrangian"),
00236     partInfoCellZones_("cellZone"),
00237     partInfoFaceZones_("faceZone"),
00238     partInfoPointZones_("pointZone"),
00239     partInfoCellSets_("cellSet"),
00240     partInfoFaceSets_("faceSet"),
00241     partInfoPointSets_("pointSet")
00242 {
00243     if (debug)
00244     {
00245         Info<< "Foam::vtkPV3Foam::vtkPV3Foam - " << FileName << endl;
00246         printMemory();
00247     }
00248 
00249     // avoid argList and get rootPath/caseName directly from the file
00250     fileName fullCasePath(fileName(FileName).path());
00251 
00252     if (!isDir(fullCasePath))
00253     {
00254         return;
00255     }
00256     if (fullCasePath == ".")
00257     {
00258         fullCasePath = cwd();
00259     }
00260 
00261     // Set the case as an environment variable - some BCs might use this
00262     if (fullCasePath.name().find("processor", 0) == 0)
00263     {
00264         const fileName globalCase = fullCasePath.path();
00265 
00266         setEnv("FOAM_CASE", globalCase, true);
00267         setEnv("FOAM_CASENAME", globalCase.name(), true);
00268     }
00269     else
00270     {
00271         setEnv("FOAM_CASE", fullCasePath, true);
00272         setEnv("FOAM_CASENAME", fullCasePath.name(), true);
00273     }
00274 
00275     // look for 'case{region}.OpenFOAM'
00276     // could be stringent and insist the prefix match the directory name...
00277     // Note: cannot use fileName::name() due to the embedded '{}'
00278     string caseName(fileName(FileName).lessExt());
00279     string::size_type beg = caseName.find_last_of("/{");
00280     string::size_type end = caseName.find('}', beg);
00281 
00282     if
00283     (
00284         beg != string::npos && caseName[beg] == '{'
00285      && end != string::npos && end == caseName.size()-1
00286     )
00287     {
00288         meshRegion_ = caseName.substr(beg+1, end-beg-1);
00289 
00290         // some safety
00291         if (!meshRegion_.size())
00292         {
00293             meshRegion_ = polyMesh::defaultRegion;
00294         }
00295 
00296         if (meshRegion_ != polyMesh::defaultRegion)
00297         {
00298             meshDir_ = meshRegion_/polyMesh::meshSubDir;
00299         }
00300     }
00301 
00302     if (debug)
00303     {
00304         Info<< "fullCasePath=" << fullCasePath << nl
00305             << "FOAM_CASE=" << getEnv("FOAM_CASE") << nl
00306             << "FOAM_CASENAME=" << getEnv("FOAM_CASENAME") << nl
00307             << "region=" << meshRegion_ << endl;
00308     }
00309 
00310     // Create time object
00311     dbPtr_.reset
00312     (
00313         new Time
00314         (
00315             Time::controlDictName,
00316             fileName(fullCasePath.path()),
00317             fileName(fullCasePath.name())
00318         )
00319     );
00320 
00321     dbPtr_().functionObjects().off();
00322 
00323     updateInfo();
00324 }
00325 
00326 
00327 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00328 
00329 Foam::vtkPV3Foam::~vtkPV3Foam()
00330 {
00331     if (debug)
00332     {
00333         Info<< "<end> Foam::vtkPV3Foam::~vtkPV3Foam" << endl;
00334     }
00335 
00336     delete meshPtr_;
00337 }
00338 
00339 
00340 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00341 
00342 void Foam::vtkPV3Foam::updateInfo()
00343 {
00344     if (debug)
00345     {
00346         Info<< "<beg> Foam::vtkPV3Foam::updateInfo"
00347             << " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "] timeIndex="
00348             << timeIndex_ << endl;
00349     }
00350 
00351     resetCounters();
00352 
00353     vtkDataArraySelection* partSelection = reader_->GetPartSelection();
00354 
00355     // enable 'internalMesh' on the first call
00356     // or preserve the enabled selections
00357     stringList enabledEntries;
00358     if (!partSelection->GetNumberOfArrays() && !meshPtr_)
00359     {
00360         enabledEntries.setSize(1);
00361         enabledEntries[0] = "internalMesh";
00362     }
00363     else
00364     {
00365         enabledEntries = getSelectedArrayEntries(partSelection);
00366     }
00367 
00368     // Clear current mesh parts list
00369     partSelection->RemoveAllArrays();
00370 
00371     // Update mesh parts list - add Lagrangian at the bottom
00372     updateInfoInternalMesh();
00373     updateInfoPatches();
00374     updateInfoSets();
00375     updateInfoZones();
00376     updateInfoLagrangian();
00377 
00378     // restore the enabled selections
00379     setSelectedArrayEntries(partSelection, enabledEntries);
00380 
00381     if (meshChanged_)
00382     {
00383         fieldsChanged_ = true;
00384     }
00385 
00386     // Update volume, point and lagrangian fields
00387     updateInfoFields<fvPatchField, volMesh>
00388     (
00389         reader_->GetVolFieldSelection()
00390     );
00391     updateInfoFields<pointPatchField, pointMesh>
00392     (
00393         reader_->GetPointFieldSelection()
00394     );
00395     updateInfoLagrangianFields();
00396 
00397     if (debug)
00398     {
00399         Info<< "<end> Foam::vtkPV3Foam::updateInfo" << endl;
00400     }
00401 
00402 }
00403 
00404 
00405 void Foam::vtkPV3Foam::updateFoamMesh()
00406 {
00407     if (debug)
00408     {
00409         Info<< "<beg> Foam::vtkPV3Foam::updateFoamMesh" << endl;
00410         printMemory();
00411     }
00412 
00413     if (!reader_->GetCacheMesh())
00414     {
00415         delete meshPtr_;
00416         meshPtr_ = NULL;
00417     }
00418 
00419     // Check to see if the FOAM mesh has been created
00420     if (!meshPtr_)
00421     {
00422         if (debug)
00423         {
00424             Info<< "Creating Foam mesh for region " << meshRegion_
00425                 << " at time=" << dbPtr_().timeName()
00426                 << endl;
00427 
00428         }
00429 
00430         meshPtr_ = new fvMesh
00431         (
00432             IOobject
00433             (
00434                 meshRegion_,
00435                 dbPtr_().timeName(),
00436                 dbPtr_(),
00437                 IOobject::MUST_READ
00438             )
00439         );
00440 
00441         meshChanged_ = true;
00442     }
00443     else
00444     {
00445         if (debug)
00446         {
00447             Info<< "Using existing Foam mesh" << endl;
00448         }
00449     }
00450 
00451     if (debug)
00452     {
00453         Info<< "<end> Foam::vtkPV3Foam::updateFoamMesh" << endl;
00454         printMemory();
00455     }
00456 }
00457 
00458 
00459 void Foam::vtkPV3Foam::Update
00460 (
00461     vtkMultiBlockDataSet* output,
00462     vtkMultiBlockDataSet* lagrangianOutput
00463 )
00464 {
00465     if (debug)
00466     {
00467         cout<< "<beg> Foam::vtkPV3Foam::Update - output with "
00468             << output->GetNumberOfBlocks() << " and "
00469             << lagrangianOutput->GetNumberOfBlocks() << " blocks\n";
00470         output->Print(cout);
00471         lagrangianOutput->Print(cout);
00472         printMemory();
00473     }
00474     reader_->UpdateProgress(0.1);
00475 
00476     // Set up mesh parts selection(s)
00477     updateMeshPartsStatus();
00478 
00479     reader_->UpdateProgress(0.15);
00480 
00481     // Update the Foam mesh
00482     updateFoamMesh();
00483     reader_->UpdateProgress(0.4);
00484 
00485     // Convert meshes - start port0 at block=0
00486     int blockNo = 0;
00487 
00488     convertMeshVolume(output, blockNo);
00489     convertMeshPatches(output, blockNo);
00490     reader_->UpdateProgress(0.6);
00491 
00492     if (reader_->GetIncludeZones())
00493     {
00494         convertMeshCellZones(output, blockNo);
00495         convertMeshFaceZones(output, blockNo);
00496         convertMeshPointZones(output, blockNo);
00497         reader_->UpdateProgress(0.65);
00498     }
00499 
00500     if (reader_->GetIncludeSets())
00501     {
00502         convertMeshCellSets(output, blockNo);
00503         convertMeshFaceSets(output, blockNo);
00504         convertMeshPointSets(output, blockNo);
00505         reader_->UpdateProgress(0.7);
00506     }
00507 
00508 #ifdef VTKPV3FOAM_DUALPORT
00509     // restart port1 at block=0
00510     blockNo = 0;
00511 #endif
00512     convertMeshLagrangian(lagrangianOutput, blockNo);
00513 
00514     reader_->UpdateProgress(0.8);
00515 
00516     // Update fields
00517     convertVolFields(output);
00518     convertPointFields(output);
00519     convertLagrangianFields(lagrangianOutput);
00520     reader_->UpdateProgress(0.95);
00521 
00522     meshChanged_ = fieldsChanged_ = false;
00523 }
00524 
00525 
00526 void Foam::vtkPV3Foam::CleanUp()
00527 {
00528     // reclaim some memory
00529     reduceMemory();
00530     reader_->UpdateProgress(1.0);
00531 }
00532 
00533 
00534 double* Foam::vtkPV3Foam::findTimes(int& nTimeSteps)
00535 {
00536     int nTimes = 0;
00537     double* tsteps = NULL;
00538 
00539     if (dbPtr_.valid())
00540     {
00541         Time& runTime = dbPtr_();
00542         instantList timeLst = runTime.times();
00543 
00544         // find the first time for which this mesh appears to exist
00545         label timeI = 0;
00546         for (; timeI < timeLst.size(); ++timeI)
00547         {
00548             const word& timeName = timeLst[timeI].name();
00549 
00550             if
00551             (
00552                 isFile(runTime.path()/timeName/meshDir_/"points")
00553              && IOobject("points", timeName, meshDir_, runTime).headerOk()
00554             )
00555             {
00556                 break;
00557             }
00558         }
00559 
00560         nTimes = timeLst.size() - timeI;
00561 
00562         // always skip "constant" time if possible
00563         if (timeI == 0 && nTimes > 1)
00564         {
00565             timeI = 1;
00566             --nTimes;
00567         }
00568 
00569         if (nTimes)
00570         {
00571             tsteps = new double[nTimes];
00572             for (label stepI = 0; stepI < nTimes; ++stepI, ++timeI)
00573             {
00574                 tsteps[stepI] = timeLst[timeI].value();
00575             }
00576         }
00577     }
00578     else
00579     {
00580         if (debug)
00581         {
00582             cout<< "no valid dbPtr:\n";
00583         }
00584     }
00585 
00586     // vector length returned via the parameter
00587     nTimeSteps = nTimes;
00588 
00589     return tsteps;
00590 }
00591 
00592 
00593 void Foam::vtkPV3Foam::addPatchNames(vtkRenderer* renderer)
00594 {
00595     // Remove any patch names previously added to the renderer
00596     removePatchNames(renderer);
00597 
00598     // get the display patches, strip off any suffix
00599     wordHashSet selectedPatches = getSelected
00600     (
00601         reader_->GetPartSelection(),
00602         partInfoPatches_
00603     );
00604 
00605     if (!selectedPatches.size())
00606     {
00607         return;
00608     }
00609 
00610     if (debug)
00611     {
00612         Info<< "<beg> Foam::vtkPV3Foam::addPatchNames" << nl
00613             <<"... add patches: " << selectedPatches << endl;
00614     }
00615 
00616     const polyBoundaryMesh& pbMesh = meshPtr_->boundaryMesh();
00617 
00618     // Find the total number of zones
00619     // Each zone will take the patch name
00620     // Number of zones per patch ... zero zones should be skipped
00621     labelList nZones(pbMesh.size(), 0);
00622 
00623     // Per global zone number the average face centre position
00624     DynamicList<point> zoneCentre(pbMesh.size());
00625 
00626     if (debug)
00627     {
00628         Info<< "... determining patch zones" << endl;
00629     }
00630 
00631     // Loop through all patches to determine zones, and centre of each zone
00632     forAll(pbMesh, patchI)
00633     {
00634         const polyPatch& pp = pbMesh[patchI];
00635 
00636         // Only include the patch if it is selected
00637         if (!selectedPatches.found(pp.name()))
00638         {
00639             continue;
00640         }
00641 
00642         const labelListList& edgeFaces = pp.edgeFaces();
00643         const vectorField& n = pp.faceNormals();
00644 
00645         boolList featEdge(pp.nEdges(), false);
00646 
00647         forAll(edgeFaces, edgeI)
00648         {
00649             const labelList& eFaces = edgeFaces[edgeI];
00650 
00651             if (eFaces.size() == 1)
00652             {
00653                 // Note: could also do ones with > 2 faces but this gives
00654                 // too many zones for baffles
00655                 featEdge[edgeI] = true;
00656             }
00657             else if (mag(n[eFaces[0]] & n[eFaces[1]]) < 0.5)
00658             {
00659                 featEdge[edgeI] = true;
00660             }
00661         }
00662 
00663         // Do topological analysis of patch, find disconnected regions
00664         patchZones pZones(pp, featEdge);
00665 
00666         nZones[patchI] = pZones.nZones();
00667 
00668         labelList zoneNFaces(pZones.nZones(), 0);
00669 
00670         // Save start of information for current patch
00671         label patchStart = zoneCentre.size();
00672 
00673         // Create storage for additional zone centres
00674         forAll(zoneNFaces, zoneI)
00675         {
00676             zoneCentre.append(vector::zero);
00677         }
00678 
00679         // Do averaging per individual zone
00680         forAll(pp, faceI)
00681         {
00682             label zoneI = pZones[faceI];
00683             zoneCentre[patchStart+zoneI] += pp[faceI].centre(pp.points());
00684             zoneNFaces[zoneI]++;
00685         }
00686 
00687         for (label i=0; i<nZones[patchI]; i++)
00688         {
00689             zoneCentre[patchStart + i] /= zoneNFaces[i];
00690         }
00691     }
00692 
00693     // Count number of zones we're actually going to display. This is truncated
00694     // to a max per patch
00695 
00696     const label MAXPATCHZONES = 20;
00697 
00698     label displayZoneI = 0;
00699 
00700     forAll(pbMesh, patchI)
00701     {
00702         displayZoneI += min(MAXPATCHZONES, nZones[patchI]);
00703     }
00704 
00705 
00706     zoneCentre.shrink();
00707 
00708     if (debug)
00709     {
00710         Info<< "patch zone centres = " << zoneCentre << nl
00711             << "displayed zone centres = " << displayZoneI << nl
00712             << "zones per patch = " << nZones << endl;
00713     }
00714 
00715     // Set the size of the patch labels to max number of zones
00716     patchTextActorsPtrs_.setSize(displayZoneI);
00717 
00718     if (debug)
00719     {
00720         Info<< "constructing patch labels" << endl;
00721     }
00722 
00723     // Actor index
00724     displayZoneI = 0;
00725 
00726     // Index in zone centres
00727     label globalZoneI = 0;
00728 
00729     forAll(pbMesh, patchI)
00730     {
00731         const polyPatch& pp = pbMesh[patchI];
00732 
00733         // Only selected patches will have a non-zero number of zones
00734         label nDisplayZones = min(MAXPATCHZONES, nZones[patchI]);
00735         label increment = 1;
00736         if (nZones[patchI] >= MAXPATCHZONES)
00737         {
00738             increment = nZones[patchI]/MAXPATCHZONES;
00739         }
00740 
00741         for (label i = 0; i < nDisplayZones; i++)
00742         {
00743             if (debug)
00744             {
00745                 Info<< "patch name = " << pp.name() << nl
00746                     << "anchor = " << zoneCentre[globalZoneI] << nl
00747                     << "globalZoneI = " << globalZoneI << endl;
00748             }
00749 
00750             vtkTextActor* txt = vtkTextActor::New();
00751 
00752             txt->SetInput(pp.name().c_str());
00753 
00754             // Set text properties
00755             vtkTextProperty* tprop = txt->GetTextProperty();
00756             tprop->SetFontFamilyToArial();
00757             tprop->BoldOff();
00758             tprop->ShadowOff();
00759             tprop->SetLineSpacing(1.0);
00760             tprop->SetFontSize(12);
00761             tprop->SetColor(1.0, 0.0, 0.0);
00762             tprop->SetJustificationToCentered();
00763 
00764             // Set text to use 3-D world co-ordinates
00765             txt->GetPositionCoordinate()->SetCoordinateSystemToWorld();
00766 
00767             txt->GetPositionCoordinate()->SetValue
00768             (
00769                 zoneCentre[globalZoneI].x(),
00770                 zoneCentre[globalZoneI].y(),
00771                 zoneCentre[globalZoneI].z()
00772             );
00773 
00774             // Add text to each renderer
00775             renderer->AddViewProp(txt);
00776 
00777             // Maintain a list of text labels added so that they can be
00778             // removed later
00779             patchTextActorsPtrs_[displayZoneI] = txt;
00780 
00781             globalZoneI += increment;
00782             displayZoneI++;
00783         }
00784     }
00785 
00786     // Resize the patch names list to the actual number of patch names added
00787     patchTextActorsPtrs_.setSize(displayZoneI);
00788 
00789     if (debug)
00790     {
00791         Info<< "<end> Foam::vtkPV3Foam::addPatchNames" << endl;
00792     }
00793 }
00794 
00795 
00796 void Foam::vtkPV3Foam::removePatchNames(vtkRenderer* renderer)
00797 {
00798     forAll(patchTextActorsPtrs_, patchI)
00799     {
00800         renderer->RemoveViewProp(patchTextActorsPtrs_[patchI]);
00801         patchTextActorsPtrs_[patchI]->Delete();
00802     }
00803     patchTextActorsPtrs_.clear();
00804 }
00805 
00806 
00807 void Foam::vtkPV3Foam::PrintSelf(ostream& os, vtkIndent indent) const
00808 {
00809     os  << indent << "Number of nodes: "
00810         << (meshPtr_ ? meshPtr_->nPoints() : 0) << "\n";
00811 
00812     os  << indent << "Number of cells: "
00813         << (meshPtr_ ? meshPtr_->nCells() : 0) << "\n";
00814 
00815     os  << indent << "Number of available time steps: "
00816         << (dbPtr_.valid() ? dbPtr_().times().size() : 0) << endl;
00817 
00818     os  << indent << "mesh region: " << meshRegion_ << "\n";
00819 }
00820 
00821 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd