mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: avoid deprecated paraview method SetImmediateUpdate()
- add support for patch names in block mesh reader.
This commit is contained in:
@ -14,20 +14,32 @@
|
||||
<Documentation>The filename for the OpenFOAM blockMesh reader.</Documentation>
|
||||
</StringVectorProperty>
|
||||
|
||||
<!-- Refresh button (push button) -->
|
||||
<IntVectorProperty animateable="0"
|
||||
<!-- Refresh (push button) -->
|
||||
<Property
|
||||
name="Refresh"
|
||||
command="SetRefresh"
|
||||
command="Refresh"
|
||||
panel_visibility="default">
|
||||
<Documentation>Rescan for updated blockMeshDict.</Documentation>
|
||||
</Property>
|
||||
|
||||
<!-- General Controls -->
|
||||
|
||||
<!-- Show Patch Names (check-box) -->
|
||||
<IntVectorProperty animateable="0"
|
||||
name="ShowPatchNames"
|
||||
label="Patch Names"
|
||||
command="SetShowPatchNames"
|
||||
default_values="0"
|
||||
number_of_elements="1"
|
||||
panel_visibility="default">
|
||||
<BooleanDomain name="bool"/>
|
||||
<Documentation>Rescan for updated blockMeshDict.</Documentation>
|
||||
<Documentation>Show patch names in render window.</Documentation>
|
||||
</IntVectorProperty>
|
||||
|
||||
<!-- Show Point Numbers (check-box) -->
|
||||
<IntVectorProperty animateable="0"
|
||||
name="ShowPointNumbers"
|
||||
label="Point Numbers"
|
||||
command="SetShowPointNumbers"
|
||||
default_values="1"
|
||||
number_of_elements="1"
|
||||
@ -36,9 +48,15 @@
|
||||
<Documentation>Show point numbers in render window.</Documentation>
|
||||
</IntVectorProperty>
|
||||
|
||||
<!--
|
||||
| Selections
|
||||
-->
|
||||
<PropertyGroup
|
||||
label="General Controls"
|
||||
panel_widget="openfoam_blockMesh_general_controls">
|
||||
<Property name="Refresh"/>
|
||||
<Property name="ShowPatchNames"/>
|
||||
<Property name="ShowPointNumbers"/>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Selections -->
|
||||
|
||||
<!-- Available Blocks array -->
|
||||
<StringVectorProperty
|
||||
@ -86,19 +104,6 @@
|
||||
<Documentation>The list of curved edges</Documentation>
|
||||
</StringVectorProperty>
|
||||
|
||||
<Hints>
|
||||
<ReaderFactory
|
||||
extensions="blockMesh"
|
||||
file_description="OpenFOAM blockMesh"/>
|
||||
</Hints>
|
||||
|
||||
<PropertyGroup
|
||||
label="General Controls"
|
||||
panel_widget="openfoam_blockMesh_general_controls">
|
||||
<Property name="Refresh"/>
|
||||
<Property name="ShowPointNumbers"/>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup label="Selections">
|
||||
<Property name="BlockArrayStatus"/>
|
||||
<Property name="BlockStatus"/>
|
||||
@ -106,6 +111,12 @@
|
||||
<Property name="CurvedEdgesStatus"/>
|
||||
</PropertyGroup>
|
||||
|
||||
<Hints>
|
||||
<ReaderFactory
|
||||
extensions="blockMesh"
|
||||
file_description="OpenFOAM blockMesh"/>
|
||||
</Hints>
|
||||
|
||||
</SourceProxy>
|
||||
</ProxyGroup>
|
||||
</ServerManagerConfiguration>
|
||||
|
||||
@ -29,7 +29,7 @@ License
|
||||
#include <QGridLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "pqApplicationCore.h"
|
||||
#include "pqPVApplicationCore.h"
|
||||
#include "pqView.h"
|
||||
#include "vtkSMDocumentation.h"
|
||||
#include "vtkSMIntVectorProperty.h"
|
||||
@ -43,8 +43,7 @@ License
|
||||
static QAbstractButton* setButtonProperties
|
||||
(
|
||||
QAbstractButton* b,
|
||||
vtkSMIntVectorProperty* prop,
|
||||
bool initChecked = true
|
||||
vtkSMProperty* prop
|
||||
)
|
||||
{
|
||||
QString tip;
|
||||
@ -66,10 +65,14 @@ static QAbstractButton* setButtonProperties
|
||||
}
|
||||
b->setFocusPolicy(Qt::NoFocus); // avoid dotted border
|
||||
|
||||
// initial checked state
|
||||
if (initChecked)
|
||||
|
||||
vtkSMIntVectorProperty* intProp =
|
||||
vtkSMIntVectorProperty::SafeDownCast(prop);
|
||||
|
||||
// initial checked state for integer (bool) properties
|
||||
if (intProp)
|
||||
{
|
||||
b->setChecked(prop->GetElement(0));
|
||||
b->setChecked(intProp->GetElement(0));
|
||||
}
|
||||
|
||||
return b;
|
||||
@ -93,23 +96,61 @@ static vtkSMIntVectorProperty* lookupIntProp
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void pqFoamBlockMeshControls::fireCommand(vtkSMProperty* prop)
|
||||
{
|
||||
vtkSMProxy* pxy = this->proxy();
|
||||
|
||||
// Fire off command
|
||||
prop->Modified();
|
||||
pxy->UpdateProperty(pxy->GetPropertyName(prop));
|
||||
}
|
||||
|
||||
|
||||
void pqFoamBlockMeshControls::fireCommand
|
||||
(
|
||||
vtkSMIntVectorProperty* prop,
|
||||
bool checked
|
||||
)
|
||||
{
|
||||
vtkSMProxy* pxy = this->proxy();
|
||||
|
||||
prop->SetElement(0, checked); // Toogle bool
|
||||
|
||||
// Fire off command
|
||||
prop->Modified();
|
||||
pxy->UpdateProperty(pxy->GetPropertyName(prop));
|
||||
}
|
||||
|
||||
|
||||
void pqFoamBlockMeshControls::updateParts()
|
||||
{
|
||||
vtkSMProxy* pxy = this->proxy();
|
||||
|
||||
pxy->UpdatePropertyInformation(pxy->GetProperty("BlockArrayStatus"));
|
||||
pxy->UpdatePropertyInformation(pxy->GetProperty("CurvedEdgesArrayStatus"));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void pqFoamBlockMeshControls::refreshPressed()
|
||||
{
|
||||
// Update everything
|
||||
refresh_->Modified();
|
||||
fireCommand(refresh_);
|
||||
|
||||
vtkSMSourceProxy::SafeDownCast(this->proxy())->UpdatePipeline();
|
||||
|
||||
// Render all views
|
||||
pqApplicationCore::instance()->render();
|
||||
// Trigger a rendering (all views)
|
||||
pqPVApplicationCore::instance()->render();
|
||||
|
||||
updateParts();
|
||||
}
|
||||
|
||||
|
||||
void pqFoamBlockMeshControls::showPointNumbers(bool checked)
|
||||
void pqFoamBlockMeshControls::showPatchNames(bool checked)
|
||||
{
|
||||
showPointNumbers_->SetElement(0, checked);
|
||||
fireCommand(showPatchNames_, checked);
|
||||
|
||||
// Update the active view
|
||||
if (this->view())
|
||||
@ -118,7 +159,22 @@ void pqFoamBlockMeshControls::showPointNumbers(bool checked)
|
||||
}
|
||||
|
||||
// OR: update all views
|
||||
// pqApplicationCore::instance()->render();
|
||||
// pqPVApplicationCore::instance()->render();
|
||||
}
|
||||
|
||||
|
||||
void pqFoamBlockMeshControls::showPointNumbers(bool checked)
|
||||
{
|
||||
fireCommand(showPointNumbers_, checked);
|
||||
|
||||
// Update the active view
|
||||
if (this->view())
|
||||
{
|
||||
this->view()->render();
|
||||
}
|
||||
|
||||
// OR: update all views
|
||||
// pqPVApplicationCore::instance()->render();
|
||||
}
|
||||
|
||||
|
||||
@ -132,7 +188,8 @@ pqFoamBlockMeshControls::pqFoamBlockMeshControls
|
||||
)
|
||||
:
|
||||
Superclass(proxy, parent),
|
||||
refresh_(lookupIntProp(group, "Refresh")),
|
||||
refresh_(group->GetProperty("Refresh")),
|
||||
showPatchNames_(lookupIntProp(group, "ShowPatchNames")),
|
||||
showPointNumbers_(lookupIntProp(group, "ShowPointNumbers"))
|
||||
{
|
||||
QGridLayout* form = new QGridLayout(this);
|
||||
@ -140,21 +197,28 @@ pqFoamBlockMeshControls::pqFoamBlockMeshControls
|
||||
if (refresh_)
|
||||
{
|
||||
QPushButton* b = new QPushButton(this);
|
||||
setButtonProperties(b, refresh_, false);
|
||||
setButtonProperties(b, refresh_);
|
||||
form->addWidget(b, 0, 0, Qt::AlignLeft);
|
||||
|
||||
connect(b, SIGNAL(clicked()), this, SLOT(refreshPressed()));
|
||||
refresh_->SetImmediateUpdate(true);
|
||||
}
|
||||
|
||||
if (showPatchNames_)
|
||||
{
|
||||
QCheckBox* b = new QCheckBox(this);
|
||||
setButtonProperties(b, showPatchNames_);
|
||||
form->addWidget(b, 0, 1, Qt::AlignLeft);
|
||||
|
||||
connect(b, SIGNAL(toggled(bool)), this, SLOT(showPatchNames(bool)));
|
||||
}
|
||||
|
||||
if (showPointNumbers_)
|
||||
{
|
||||
QCheckBox* b = new QCheckBox(this);
|
||||
setButtonProperties(b, showPointNumbers_);
|
||||
form->addWidget(b, 0, 1, Qt::AlignLeft);
|
||||
form->addWidget(b, 0, 2, Qt::AlignLeft);
|
||||
|
||||
connect(b, SIGNAL(toggled(bool)), this, SLOT(showPointNumbers(bool)));
|
||||
showPointNumbers_->SetImmediateUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ Class
|
||||
Description
|
||||
Customized property controls for the ParaView blockMesh reader.
|
||||
|
||||
Refresh and ShowPointNumbers.
|
||||
Refresh, ShowPatchNames, ShowPointNumbers.
|
||||
|
||||
SourceFiles
|
||||
pqFoamBlockMeshControls.cxx
|
||||
@ -39,6 +39,7 @@ SourceFiles
|
||||
#include "pqPropertyWidget.h"
|
||||
|
||||
// Forward declarations (ParaView)
|
||||
class vtkSMProperty;
|
||||
class vtkSMIntVectorProperty;
|
||||
|
||||
|
||||
@ -55,8 +56,11 @@ class pqFoamBlockMeshControls
|
||||
|
||||
// Private data
|
||||
|
||||
//- Refresh (bool property - as push button)
|
||||
vtkSMIntVectorProperty* refresh_;
|
||||
//- Refresh (push button)
|
||||
vtkSMProperty* refresh_;
|
||||
|
||||
//- Show Patch Names (bool property)
|
||||
vtkSMIntVectorProperty* showPatchNames_;
|
||||
|
||||
//- Show Point Numbers (bool property)
|
||||
vtkSMIntVectorProperty* showPointNumbers_;
|
||||
@ -64,6 +68,16 @@ class pqFoamBlockMeshControls
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Update property
|
||||
void fireCommand(vtkSMProperty* prop);
|
||||
|
||||
//- Toggle and update bool property
|
||||
void fireCommand(vtkSMIntVectorProperty* prop, bool checked);
|
||||
|
||||
//- Update "BlockArrayStatus", "CurvedEdgesArrayStatus" information
|
||||
void updateParts();
|
||||
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
pqFoamBlockMeshControls(const pqFoamBlockMeshControls&) = delete;
|
||||
|
||||
@ -78,6 +92,9 @@ protected slots:
|
||||
//- Trigger refresh
|
||||
void refreshPressed();
|
||||
|
||||
//- Sync property with changed checkbox state, update rendered view(s)
|
||||
void showPatchNames(bool checked);
|
||||
|
||||
//- Sync property with changed checkbox state, update rendered view(s)
|
||||
void showPointNumbers(bool checked);
|
||||
|
||||
|
||||
@ -59,6 +59,7 @@ vtkPVblockMeshReader::vtkPVblockMeshReader()
|
||||
FileName = nullptr;
|
||||
backend_ = nullptr;
|
||||
|
||||
ShowPatchNames = false;
|
||||
ShowPointNumbers = true;
|
||||
|
||||
BlockSelection = vtkDataArraySelection::New();
|
||||
@ -95,9 +96,12 @@ vtkPVblockMeshReader::~vtkPVblockMeshReader()
|
||||
|
||||
if (backend_)
|
||||
{
|
||||
// Remove point numbers
|
||||
// Remove text actors
|
||||
updatePatchNamesView(false);
|
||||
updatePointNumbersView(false);
|
||||
|
||||
delete backend_;
|
||||
backend_ = nullptr;
|
||||
}
|
||||
|
||||
if (FileName)
|
||||
@ -110,6 +114,7 @@ vtkPVblockMeshReader::~vtkPVblockMeshReader()
|
||||
|
||||
SelectionObserver->Delete();
|
||||
BlockSelection->Delete();
|
||||
CurvedEdgesSelection->Delete();
|
||||
}
|
||||
|
||||
|
||||
@ -124,35 +129,25 @@ int vtkPVblockMeshReader::RequestInformation
|
||||
{
|
||||
vtkDebugMacro(<<"RequestInformation");
|
||||
|
||||
if (Foam::vtkPVblockMesh::debug)
|
||||
{
|
||||
cout<<"REQUEST_INFORMATION\n";
|
||||
}
|
||||
|
||||
if (!FileName)
|
||||
{
|
||||
vtkErrorMacro("FileName has to be specified!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nInfo = outputVector->GetNumberOfInformationObjects();
|
||||
|
||||
if (Foam::vtkPVblockMesh::debug)
|
||||
{
|
||||
cout<<"RequestInformation with " << nInfo << " item(s)\n";
|
||||
for (int infoI = 0; infoI < nInfo; ++infoI)
|
||||
{
|
||||
outputVector->GetInformationObject(infoI)->Print(cout);
|
||||
}
|
||||
cout<<"REQUEST_INFORMATION\n";
|
||||
outputVector->GetInformationObject(0)->Print(cout);
|
||||
}
|
||||
|
||||
if (!backend_)
|
||||
if (backend_)
|
||||
{
|
||||
backend_ = new Foam::vtkPVblockMesh(FileName, this);
|
||||
backend_->updateInfo();
|
||||
}
|
||||
else
|
||||
{
|
||||
backend_->updateInfo();
|
||||
backend_ = new Foam::vtkPVblockMesh(FileName, this);
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -181,15 +176,10 @@ int vtkPVblockMeshReader::RequestData
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nInfo = outputVector->GetNumberOfInformationObjects();
|
||||
|
||||
if (Foam::vtkPVblockMesh::debug)
|
||||
{
|
||||
cout<<"RequestData with " << nInfo << " item(s)\n";
|
||||
for (int infoI = 0; infoI < nInfo; ++infoI)
|
||||
{
|
||||
outputVector->GetInformationObject(infoI)->Print(cout);
|
||||
}
|
||||
cout<<"REQUEST_DATA:\n";
|
||||
outputVector->GetInformationObject(0)->Print(cout);
|
||||
}
|
||||
|
||||
vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast
|
||||
@ -207,6 +197,8 @@ int vtkPVblockMeshReader::RequestData
|
||||
}
|
||||
|
||||
backend_->Update(output);
|
||||
|
||||
updatePatchNamesView(ShowPatchNames);
|
||||
updatePointNumbersView(ShowPointNumbers);
|
||||
|
||||
// Do any cleanup on the OpenFOAM side
|
||||
@ -216,17 +208,30 @@ int vtkPVblockMeshReader::RequestData
|
||||
}
|
||||
|
||||
|
||||
void vtkPVblockMeshReader::SetRefresh(bool val)
|
||||
void vtkPVblockMeshReader::Refresh()
|
||||
{
|
||||
// Delete the current blockMesh to force re-read and update
|
||||
if (backend_)
|
||||
{
|
||||
// Remove text actors
|
||||
updatePatchNamesView(false);
|
||||
updatePointNumbersView(false);
|
||||
|
||||
delete backend_;
|
||||
backend_ = nullptr;
|
||||
}
|
||||
|
||||
Modified();
|
||||
this->Modified();
|
||||
}
|
||||
|
||||
|
||||
void vtkPVblockMeshReader::SetShowPatchNames(bool val)
|
||||
{
|
||||
if (ShowPatchNames != val)
|
||||
{
|
||||
ShowPatchNames = val;
|
||||
updatePatchNamesView(ShowPatchNames);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -240,6 +245,38 @@ void vtkPVblockMeshReader::SetShowPointNumbers(bool val)
|
||||
}
|
||||
|
||||
|
||||
void vtkPVblockMeshReader::updatePatchNamesView(const bool show)
|
||||
{
|
||||
pqApplicationCore* appCore = pqApplicationCore::instance();
|
||||
|
||||
// Need to check this, since our destructor calls this
|
||||
if (!appCore)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Server manager model for querying items in the server manager
|
||||
pqServerManagerModel* smModel = appCore->getServerManagerModel();
|
||||
if (!smModel || !backend_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get all the pqRenderView instances
|
||||
QList<pqRenderView*> renderViews = smModel->findItems<pqRenderView*>();
|
||||
for (int viewI=0; viewI<renderViews.size(); ++viewI)
|
||||
{
|
||||
backend_->renderPatchNames
|
||||
(
|
||||
renderViews[viewI]->getRenderViewProxy()->GetRenderer(),
|
||||
show
|
||||
);
|
||||
}
|
||||
|
||||
// Use refresh here?
|
||||
}
|
||||
|
||||
|
||||
void vtkPVblockMeshReader::updatePointNumbersView(const bool show)
|
||||
{
|
||||
pqApplicationCore* appCore = pqApplicationCore::instance();
|
||||
@ -257,7 +294,6 @@ void vtkPVblockMeshReader::updatePointNumbersView(const bool show)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Get all the pqRenderView instances
|
||||
QList<pqRenderView*> renderViews = smModel->findItems<pqRenderView*>();
|
||||
for (int viewI=0; viewI<renderViews.size(); ++viewI)
|
||||
@ -290,39 +326,30 @@ void vtkPVblockMeshReader::PrintSelf(ostream& os, vtkIndent indent)
|
||||
|
||||
vtkDataArraySelection* vtkPVblockMeshReader::GetBlockSelection()
|
||||
{
|
||||
vtkDebugMacro(<<"GetBlockSelection");
|
||||
return BlockSelection;
|
||||
}
|
||||
|
||||
|
||||
int vtkPVblockMeshReader::GetNumberOfBlockArrays()
|
||||
{
|
||||
vtkDebugMacro(<<"GetNumberOfBlockArrays");
|
||||
return BlockSelection->GetNumberOfArrays();
|
||||
}
|
||||
|
||||
|
||||
const char* vtkPVblockMeshReader::GetBlockArrayName(int index)
|
||||
{
|
||||
vtkDebugMacro(<<"GetBlockArrayName");
|
||||
return BlockSelection->GetArrayName(index);
|
||||
}
|
||||
|
||||
|
||||
int vtkPVblockMeshReader::GetBlockArrayStatus(const char* name)
|
||||
{
|
||||
vtkDebugMacro(<<"GetBlockArrayStatus");
|
||||
return BlockSelection->ArrayIsEnabled(name);
|
||||
}
|
||||
|
||||
|
||||
void vtkPVblockMeshReader::SetBlockArrayStatus
|
||||
(
|
||||
const char* name,
|
||||
int status
|
||||
)
|
||||
{
|
||||
vtkDebugMacro(<<"SetBlockArrayStatus");
|
||||
if (status)
|
||||
{
|
||||
BlockSelection->EnableArray(name);
|
||||
@ -339,39 +366,30 @@ void vtkPVblockMeshReader::SetBlockArrayStatus
|
||||
|
||||
vtkDataArraySelection* vtkPVblockMeshReader::GetCurvedEdgesSelection()
|
||||
{
|
||||
vtkDebugMacro(<<"GetCurvedEdgesSelection");
|
||||
return CurvedEdgesSelection;
|
||||
}
|
||||
|
||||
|
||||
int vtkPVblockMeshReader::GetNumberOfCurvedEdgesArrays()
|
||||
{
|
||||
vtkDebugMacro(<<"GetNumberOfCurvedEdgesArrays");
|
||||
return CurvedEdgesSelection->GetNumberOfArrays();
|
||||
}
|
||||
|
||||
|
||||
const char* vtkPVblockMeshReader::GetCurvedEdgesArrayName(int index)
|
||||
{
|
||||
vtkDebugMacro(<<"GetCurvedEdgesArrayName");
|
||||
return CurvedEdgesSelection->GetArrayName(index);
|
||||
}
|
||||
|
||||
|
||||
int vtkPVblockMeshReader::GetCurvedEdgesArrayStatus(const char* name)
|
||||
{
|
||||
vtkDebugMacro(<<"GetCurvedEdgesArrayStatus");
|
||||
return CurvedEdgesSelection->ArrayIsEnabled(name);
|
||||
}
|
||||
|
||||
|
||||
void vtkPVblockMeshReader::SetCurvedEdgesArrayStatus
|
||||
(
|
||||
const char* name,
|
||||
int status
|
||||
)
|
||||
{
|
||||
vtkDebugMacro(<<"SetCurvedEdgesArrayStatus");
|
||||
if (status)
|
||||
{
|
||||
CurvedEdgesSelection->EnableArray(name);
|
||||
|
||||
@ -71,6 +71,11 @@ public:
|
||||
vtkSetStringMacro(FileName);
|
||||
vtkGetStringMacro(FileName);
|
||||
|
||||
// Description:
|
||||
// Display patch names
|
||||
virtual void SetShowPatchNames(bool);
|
||||
vtkGetMacro(ShowPatchNames, bool);
|
||||
|
||||
// Description:
|
||||
// Display corner point labels
|
||||
virtual void SetShowPointNumbers(bool);
|
||||
@ -78,22 +83,22 @@ public:
|
||||
|
||||
// Description:
|
||||
// Refresh blockMesh from changes to blockMeshDict
|
||||
virtual void SetRefresh(bool);
|
||||
virtual void Refresh();
|
||||
|
||||
// Description:
|
||||
// Blocks selection list control
|
||||
vtkDataArraySelection* GetBlockSelection();
|
||||
int GetNumberOfBlockArrays();
|
||||
int GetBlockArrayStatus(const char*);
|
||||
void SetBlockArrayStatus(const char*, int status);
|
||||
int GetBlockArrayStatus(const char* name);
|
||||
void SetBlockArrayStatus(const char* name, int status);
|
||||
const char* GetBlockArrayName(int index);
|
||||
|
||||
// Description:
|
||||
// CurvedEdges selection list control
|
||||
vtkDataArraySelection* GetCurvedEdgesSelection();
|
||||
int GetNumberOfCurvedEdgesArrays();
|
||||
int GetCurvedEdgesArrayStatus(const char*);
|
||||
void SetCurvedEdgesArrayStatus(const char*, int status);
|
||||
int GetCurvedEdgesArrayStatus(const char* name);
|
||||
void SetCurvedEdgesArrayStatus(const char* name, int status);
|
||||
const char* GetCurvedEdgesArrayName(int index);
|
||||
|
||||
// Description:
|
||||
@ -119,17 +124,17 @@ protected:
|
||||
//- Return information about mesh, times, etc without loading anything
|
||||
virtual int RequestInformation
|
||||
(
|
||||
vtkInformation*,
|
||||
vtkInformationVector**,
|
||||
vtkInformationVector*
|
||||
vtkInformation* unusedRequest,
|
||||
vtkInformationVector** unusedInputVector,
|
||||
vtkInformationVector* outputVector
|
||||
);
|
||||
|
||||
//- Get the mesh/fields for a particular time
|
||||
//- Get the mesh for a particular time
|
||||
virtual int RequestData
|
||||
(
|
||||
vtkInformation*,
|
||||
vtkInformationVector**,
|
||||
vtkInformationVector*
|
||||
vtkInformation* unusedRequest,
|
||||
vtkInformationVector** unusedInputVector,
|
||||
vtkInformationVector* outputVector
|
||||
);
|
||||
|
||||
//- Fill in additional port information
|
||||
@ -149,15 +154,20 @@ private:
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const vtkPVblockMeshReader&) = delete;
|
||||
|
||||
//- Add/remove patch names to/from the view
|
||||
void updatePatchNamesView(const bool show);
|
||||
|
||||
//- Add/remove point numbers to/from the view
|
||||
void updatePointNumbersView(const bool show);
|
||||
|
||||
|
||||
//- Show Patch Names
|
||||
bool ShowPatchNames;
|
||||
|
||||
//- Show Point Numbers
|
||||
bool ShowPointNumbers;
|
||||
|
||||
vtkDataArraySelection* BlockSelection;
|
||||
|
||||
vtkDataArraySelection* CurvedEdgesSelection;
|
||||
|
||||
//- Backend portion of the reader
|
||||
|
||||
@ -28,6 +28,7 @@ License
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "blockMesh.H"
|
||||
#include "blockMeshTools.H"
|
||||
#include "Time.H"
|
||||
#include "patchZones.H"
|
||||
#include "OStringStream.H"
|
||||
@ -47,6 +48,34 @@ namespace Foam
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
vtkTextActor* Foam::vtkPVblockMesh::createTextActor
|
||||
(
|
||||
const string& s,
|
||||
const point& pt
|
||||
)
|
||||
{
|
||||
vtkTextActor* txt = vtkTextActor::New();
|
||||
txt->SetInput(s.c_str());
|
||||
|
||||
// Set text properties
|
||||
vtkTextProperty* tprop = txt->GetTextProperty();
|
||||
tprop->SetFontFamilyToArial();
|
||||
tprop->BoldOn();
|
||||
tprop->ShadowOff();
|
||||
tprop->SetLineSpacing(1.0);
|
||||
tprop->SetFontSize(14);
|
||||
tprop->SetColor(1.0, 0.0, 1.0);
|
||||
tprop->SetJustificationToCentered();
|
||||
|
||||
txt->GetPositionCoordinate()->SetCoordinateSystemToWorld();
|
||||
txt->GetPositionCoordinate()->SetValue(pt.x(), pt.y(), pt.z());
|
||||
|
||||
return txt;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::vtkPVblockMesh::resetCounters()
|
||||
@ -60,7 +89,7 @@ void Foam::vtkPVblockMesh::resetCounters()
|
||||
|
||||
void Foam::vtkPVblockMesh::updateInfoBlocks
|
||||
(
|
||||
vtkDataArraySelection* arraySelection
|
||||
vtkDataArraySelection* select
|
||||
)
|
||||
{
|
||||
arrayRange& range = arrayRangeBlocks_;
|
||||
@ -71,7 +100,7 @@ void Foam::vtkPVblockMesh::updateInfoBlocks
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "null") << "]" << endl;
|
||||
}
|
||||
|
||||
range.reset(arraySelection->GetNumberOfArrays());
|
||||
range.reset(select->GetNumberOfArrays());
|
||||
|
||||
const blockMesh& blkMesh = *meshPtr_;
|
||||
|
||||
@ -92,7 +121,7 @@ void Foam::vtkPVblockMesh::updateInfoBlocks
|
||||
}
|
||||
|
||||
// Add "blockId" or "blockId - zoneName" to GUI list
|
||||
arraySelection->AddArray(ostr.str().c_str());
|
||||
select->AddArray(ostr.str().c_str());
|
||||
}
|
||||
|
||||
range += nBlocks;
|
||||
@ -106,7 +135,7 @@ void Foam::vtkPVblockMesh::updateInfoBlocks
|
||||
|
||||
void Foam::vtkPVblockMesh::updateInfoEdges
|
||||
(
|
||||
vtkDataArraySelection* arraySelection
|
||||
vtkDataArraySelection* select
|
||||
)
|
||||
{
|
||||
arrayRange& range = arrayRangeEdges_;
|
||||
@ -117,7 +146,7 @@ void Foam::vtkPVblockMesh::updateInfoEdges
|
||||
<< " [meshPtr=" << (meshPtr_ ? "set" : "null") << "]" << endl;
|
||||
}
|
||||
|
||||
range.reset(arraySelection->GetNumberOfArrays());
|
||||
range.reset(select->GetNumberOfArrays());
|
||||
|
||||
const blockMesh& blkMesh = *meshPtr_;
|
||||
const blockEdgeList& edges = blkMesh.edges();
|
||||
@ -131,7 +160,7 @@ void Foam::vtkPVblockMesh::updateInfoEdges
|
||||
ostr << " - " << edges[edgeI].type();
|
||||
|
||||
// Add "beg:end - type" to GUI list
|
||||
arraySelection->AddArray(ostr.str().c_str());
|
||||
select->AddArray(ostr.str().c_str());
|
||||
}
|
||||
|
||||
range += edges.size();
|
||||
@ -251,14 +280,6 @@ Foam::vtkPVblockMesh::~vtkPVblockMesh()
|
||||
Info<< "~vtkPVblockMesh" << endl;
|
||||
}
|
||||
|
||||
// Hmm. pointNumberTextActors are not getting removed
|
||||
//
|
||||
forAll(pointNumberTextActorsPtrs_, pointi)
|
||||
{
|
||||
pointNumberTextActorsPtrs_[pointi]->Delete();
|
||||
}
|
||||
pointNumberTextActorsPtrs_.clear();
|
||||
|
||||
delete meshPtr_;
|
||||
}
|
||||
|
||||
@ -411,6 +432,103 @@ void Foam::vtkPVblockMesh::CleanUp()
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVblockMesh::renderPatchNames
|
||||
(
|
||||
vtkRenderer* renderer,
|
||||
const bool show
|
||||
)
|
||||
{
|
||||
// always remove old actors first
|
||||
forAll(patchTextActorsPtrs_, actori)
|
||||
{
|
||||
renderer->RemoveViewProp(patchTextActorsPtrs_[actori]);
|
||||
patchTextActorsPtrs_[actori]->Delete();
|
||||
}
|
||||
patchTextActorsPtrs_.clear();
|
||||
|
||||
// the number of text actors
|
||||
label nActors = 0;
|
||||
|
||||
if (show && meshPtr_)
|
||||
{
|
||||
const blockMesh& blkMesh = *meshPtr_;
|
||||
const dictionary& meshDescription = blkMesh.meshDict();
|
||||
const pointField& cornerPts = blkMesh.vertices();
|
||||
const scalar scaleFactor = blkMesh.scaleFactor();
|
||||
|
||||
if (!meshDescription.found("boundary"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 8 sides per block is plenty
|
||||
patchTextActorsPtrs_.setSize(8*blkMesh.size());
|
||||
|
||||
// Collect all variables
|
||||
dictionary varDict(meshDescription.subOrEmptyDict("namedVertices"));
|
||||
varDict.merge(meshDescription.subOrEmptyDict("namedBlocks"));
|
||||
|
||||
// Read like boundary file
|
||||
const PtrList<entry> patchesInfo(meshDescription.lookup("boundary"));
|
||||
|
||||
forAll(patchesInfo, patchi)
|
||||
{
|
||||
const entry& patchInfo = patchesInfo[patchi];
|
||||
|
||||
if (!patchInfo.isDict())
|
||||
{
|
||||
IOWarningInFunction(meshDescription)
|
||||
<< "Entry " << patchInfo << " in boundary section is not a"
|
||||
<< " valid dictionary."
|
||||
<< endl;
|
||||
break;
|
||||
}
|
||||
|
||||
const word& patchName = patchInfo.keyword();
|
||||
|
||||
// Read block faces
|
||||
faceList patchFaces = blockMeshTools::read<face>
|
||||
(
|
||||
patchInfo.dict().lookup("faces"),
|
||||
varDict
|
||||
);
|
||||
|
||||
forAll(patchFaces, facei)
|
||||
{
|
||||
const face& f = patchFaces[facei];
|
||||
|
||||
// Into a list for later removal
|
||||
patchTextActorsPtrs_[nActors++] = createTextActor
|
||||
(
|
||||
patchName,
|
||||
f.centre(cornerPts) * scaleFactor
|
||||
);
|
||||
|
||||
if (nActors == patchTextActorsPtrs_.size())
|
||||
{
|
||||
// hit max allocated space - bail out
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (nActors == patchTextActorsPtrs_.size())
|
||||
{
|
||||
// hit max allocated space - bail out
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
patchTextActorsPtrs_.setSize(nActors);
|
||||
}
|
||||
|
||||
// Add text to each renderer
|
||||
forAll(patchTextActorsPtrs_, actori)
|
||||
{
|
||||
renderer->AddViewProp(patchTextActorsPtrs_[actori]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVblockMesh::renderPointNumbers
|
||||
(
|
||||
vtkRenderer* renderer,
|
||||
@ -419,12 +537,12 @@ void Foam::vtkPVblockMesh::renderPointNumbers
|
||||
{
|
||||
// always remove old actors first
|
||||
|
||||
forAll(pointNumberTextActorsPtrs_, pointi)
|
||||
forAll(pointTextActorsPtrs_, actori)
|
||||
{
|
||||
renderer->RemoveViewProp(pointNumberTextActorsPtrs_[pointi]);
|
||||
pointNumberTextActorsPtrs_[pointi]->Delete();
|
||||
renderer->RemoveViewProp(pointTextActorsPtrs_[actori]);
|
||||
pointTextActorsPtrs_[actori]->Delete();
|
||||
}
|
||||
pointNumberTextActorsPtrs_.clear();
|
||||
pointTextActorsPtrs_.clear();
|
||||
|
||||
if (show && meshPtr_)
|
||||
{
|
||||
@ -432,49 +550,29 @@ void Foam::vtkPVblockMesh::renderPointNumbers
|
||||
const pointField& cornerPts = blkMesh.vertices();
|
||||
const scalar scaleFactor = blkMesh.scaleFactor();
|
||||
|
||||
pointNumberTextActorsPtrs_.setSize(cornerPts.size());
|
||||
pointTextActorsPtrs_.setSize(cornerPts.size());
|
||||
forAll(cornerPts, pointi)
|
||||
{
|
||||
vtkTextActor* txt = vtkTextActor::New();
|
||||
|
||||
// Display either pointi as a number or with its name
|
||||
// (looked up from blockMeshDict)
|
||||
{
|
||||
OStringStream os;
|
||||
blockVertex::write(os, pointi, blkMesh.meshDict());
|
||||
txt->SetInput(os.str().c_str());
|
||||
}
|
||||
OStringStream os;
|
||||
blockVertex::write(os, pointi, blkMesh.meshDict());
|
||||
|
||||
// Set text properties
|
||||
vtkTextProperty* tprop = txt->GetTextProperty();
|
||||
tprop->SetFontFamilyToArial();
|
||||
tprop->BoldOn();
|
||||
tprop->ShadowOff();
|
||||
tprop->SetLineSpacing(1.0);
|
||||
tprop->SetFontSize(14);
|
||||
tprop->SetColor(1.0, 0.0, 1.0);
|
||||
tprop->SetJustificationToCentered();
|
||||
|
||||
// Set text to use 3-D world co-ordinates
|
||||
txt->GetPositionCoordinate()->SetCoordinateSystemToWorld();
|
||||
|
||||
txt->GetPositionCoordinate()->SetValue
|
||||
// Into a list for later removal
|
||||
pointTextActorsPtrs_[pointi] = createTextActor
|
||||
(
|
||||
cornerPts[pointi].x()*scaleFactor,
|
||||
cornerPts[pointi].y()*scaleFactor,
|
||||
cornerPts[pointi].z()*scaleFactor
|
||||
os.str(),
|
||||
cornerPts[pointi]*scaleFactor
|
||||
);
|
||||
|
||||
// Add text to each renderer
|
||||
renderer->AddViewProp(txt);
|
||||
|
||||
// Maintain a list of text labels added so that they can be
|
||||
// removed later
|
||||
pointNumberTextActorsPtrs_[pointi] = txt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add text to each renderer
|
||||
forAll(pointTextActorsPtrs_, actori)
|
||||
{
|
||||
renderer->AddViewProp(pointTextActorsPtrs_[actori]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vtkPVblockMesh::PrintSelf(ostream& os, vtkIndent indent) const
|
||||
|
||||
@ -109,38 +109,38 @@ class vtkPVblockMesh
|
||||
//- First instance and size of block corners (only partially used)
|
||||
arrayRange arrayRangeCorners_;
|
||||
|
||||
//- List of patch names for rendering to window
|
||||
List<vtkTextActor*> patchTextActorsPtrs_;
|
||||
|
||||
//- List of point numbers for rendering to window
|
||||
List<vtkTextActor*> pointNumberTextActorsPtrs_;
|
||||
List<vtkTextActor*> pointTextActorsPtrs_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Create a text actor
|
||||
static vtkTextActor* createTextActor(const string& s, const point& pt);
|
||||
|
||||
//- Reset data counters
|
||||
void resetCounters();
|
||||
|
||||
// Update information helper functions
|
||||
//- OpenFOAM mesh
|
||||
void updateFoamMesh();
|
||||
|
||||
//- Internal block info
|
||||
void updateInfoBlocks(vtkDataArraySelection*);
|
||||
//- Internal block info
|
||||
void updateInfoBlocks(vtkDataArraySelection* select);
|
||||
|
||||
//- Block curved edges info
|
||||
void updateInfoEdges(vtkDataArraySelection*);
|
||||
//- Block curved edges info
|
||||
void updateInfoEdges(vtkDataArraySelection* select);
|
||||
|
||||
// Update helper functions
|
||||
//- Mesh blocks
|
||||
void convertMeshBlocks(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
//- OpenFOAM mesh
|
||||
void updateFoamMesh();
|
||||
//- Mesh curved edges
|
||||
void convertMeshEdges(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
// Mesh conversion functions
|
||||
|
||||
//- Mesh blocks
|
||||
void convertMeshBlocks(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
//- Mesh curved edges
|
||||
void convertMeshEdges(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
//- Mesh corners
|
||||
void convertMeshCorners(vtkMultiBlockDataSet*, int& blockNo);
|
||||
//- Mesh corners
|
||||
void convertMeshCorners(vtkMultiBlockDataSet*, int& blockNo);
|
||||
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
@ -181,6 +181,9 @@ public:
|
||||
//- Clean any storage
|
||||
void CleanUp();
|
||||
|
||||
//- Add/remove patch names to/from the view
|
||||
void renderPatchNames(vtkRenderer*, const bool show);
|
||||
|
||||
//- Add/remove point numbers to/from the view
|
||||
void renderPointNumbers(vtkRenderer*, const bool show);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user