mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: runTimePostProcessing - set the appropriate cell or point data type. Fixes #155
This commit is contained in:
@ -29,6 +29,7 @@ License
|
|||||||
|
|
||||||
// VTK includes
|
// VTK includes
|
||||||
#include "vtkArrowSource.h"
|
#include "vtkArrowSource.h"
|
||||||
|
#include "vtkCellData.h"
|
||||||
#include "vtkColorTransferFunction.h"
|
#include "vtkColorTransferFunction.h"
|
||||||
#include "vtkFloatArray.h"
|
#include "vtkFloatArray.h"
|
||||||
#include "vtkGlyph3D.h"
|
#include "vtkGlyph3D.h"
|
||||||
@ -136,7 +137,7 @@ void Foam::fieldVisualisationBase::addScalarBar
|
|||||||
vtkLookupTable* lut
|
vtkLookupTable* lut
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// add scalar bar legend
|
// Add scalar bar legend
|
||||||
if (!scalarBar_.visible_)
|
if (!scalarBar_.visible_)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -149,7 +150,7 @@ void Foam::fieldVisualisationBase::addScalarBar
|
|||||||
|
|
||||||
const vector textColour = colours_["text"]->value(position);
|
const vector textColour = colours_["text"]->value(position);
|
||||||
|
|
||||||
// workaround to supply our own scalarbar title
|
// Work-around to supply our own scalarbar title
|
||||||
vtkSmartPointer<vtkTextActor> titleActor =
|
vtkSmartPointer<vtkTextActor> titleActor =
|
||||||
vtkSmartPointer<vtkTextActor>::New();
|
vtkSmartPointer<vtkTextActor>::New();
|
||||||
sbar->SetTitle(" ");
|
sbar->SetTitle(" ");
|
||||||
@ -212,7 +213,7 @@ void Foam::fieldVisualisationBase::addScalarBar
|
|||||||
{
|
{
|
||||||
sbar->SetOrientationToHorizontal();
|
sbar->SetOrientationToHorizontal();
|
||||||
|
|
||||||
// adjustments since not using scalarbar title property
|
// Adjustments since not using scalarbar title property
|
||||||
sbar->SetWidth(0.75);
|
sbar->SetWidth(0.75);
|
||||||
sbar->SetHeight(0.07);
|
sbar->SetHeight(0.07);
|
||||||
sbar->SetBarRatio(0.5);
|
sbar->SetBarRatio(0.5);
|
||||||
@ -257,22 +258,40 @@ void Foam::fieldVisualisationBase::setField
|
|||||||
}
|
}
|
||||||
case cbField:
|
case cbField:
|
||||||
{
|
{
|
||||||
// create look-up table for colours
|
// Create look-up table for colours
|
||||||
vtkSmartPointer<vtkLookupTable> lut =
|
vtkSmartPointer<vtkLookupTable> lut =
|
||||||
vtkSmartPointer<vtkLookupTable>::New();
|
vtkSmartPointer<vtkLookupTable>::New();
|
||||||
setColourMap(lut);
|
setColourMap(lut);
|
||||||
lut->SetVectorMode(vtkScalarsToColors::MAGNITUDE);
|
lut->SetVectorMode(vtkScalarsToColors::MAGNITUDE);
|
||||||
|
|
||||||
// configure the mapper
|
// Configure the mapper
|
||||||
mapper->SelectColorArray(colourFieldName.c_str());
|
mapper->SelectColorArray(colourFieldName.c_str());
|
||||||
mapper->SetScalarRange(range_.first(), range_.second());
|
mapper->SetScalarRange(range_.first(), range_.second());
|
||||||
mapper->SetScalarModeToUsePointFieldData();
|
|
||||||
|
// Set to use either cell or point data
|
||||||
|
vtkPolyData* pData = mapper->GetInput();
|
||||||
|
const char* fieldName = colourFieldName.c_str();
|
||||||
|
if (pData->GetCellData()->HasArray(fieldName) == 1)
|
||||||
|
{
|
||||||
|
mapper->SetScalarModeToUseCellFieldData();
|
||||||
|
}
|
||||||
|
else if (pData->GetPointData()->HasArray(fieldName) == 1)
|
||||||
|
{
|
||||||
|
mapper->SetScalarModeToUsePointFieldData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "Unable to determine cell or point data type "
|
||||||
|
<< "- assuming point data";
|
||||||
|
mapper->SetScalarModeToUsePointFieldData();
|
||||||
|
}
|
||||||
|
|
||||||
mapper->SetColorModeToMapScalars();
|
mapper->SetColorModeToMapScalars();
|
||||||
mapper->SetLookupTable(lut);
|
mapper->SetLookupTable(lut);
|
||||||
mapper->ScalarVisibilityOn();
|
mapper->ScalarVisibilityOn();
|
||||||
|
|
||||||
// add the bar
|
// Add the bar
|
||||||
addScalarBar(position, renderer, lut);
|
addScalarBar(position, renderer, lut);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -313,7 +332,7 @@ void Foam::fieldVisualisationBase::addGlyphs
|
|||||||
vtkSmartPointer<vtkSphereSource>::New();
|
vtkSmartPointer<vtkSphereSource>::New();
|
||||||
sphere->SetCenter(0, 0, 0);
|
sphere->SetCenter(0, 0, 0);
|
||||||
sphere->SetRadius(0.5);
|
sphere->SetRadius(0.5);
|
||||||
// setting higher resolution slows the rendering significantly
|
// Setting higher resolution slows the rendering significantly
|
||||||
// sphere->SetPhiResolution(20);
|
// sphere->SetPhiResolution(20);
|
||||||
// sphere->SetThetaResolution(20);
|
// sphere->SetThetaResolution(20);
|
||||||
|
|
||||||
@ -323,7 +342,7 @@ void Foam::fieldVisualisationBase::addGlyphs
|
|||||||
{
|
{
|
||||||
double range[2];
|
double range[2];
|
||||||
|
|
||||||
// can use values to find range
|
// Can use values to find range
|
||||||
// vtkDataArray* values =
|
// vtkDataArray* values =
|
||||||
// data->GetPointData()->GetScalars(scaleFieldName.c_str());
|
// data->GetPointData()->GetScalars(scaleFieldName.c_str());
|
||||||
// values->GetRange(range);
|
// values->GetRange(range);
|
||||||
@ -374,7 +393,7 @@ void Foam::fieldVisualisationBase::addGlyphs
|
|||||||
values->GetRange(range);
|
values->GetRange(range);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// attempt to set range for vectors...
|
// Attempt to set range for vectors...
|
||||||
scalar x0 = sqrt(sqr(range_.first())/3.0);
|
scalar x0 = sqrt(sqr(range_.first())/3.0);
|
||||||
scalar x1 = sqrt(sqr(range_.second())/3.0);
|
scalar x1 = sqrt(sqr(range_.second())/3.0);
|
||||||
range[0] = x0;
|
range[0] = x0;
|
||||||
|
|||||||
Reference in New Issue
Block a user