Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
openfoam
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
openfoam
Commits
cd8be89b
Commit
cd8be89b
authored
9 years ago
by
Andrew Heather
Browse files
Options
Downloads
Patches
Plain Diff
BUG: runTimePostProcessing - correct the glyph behaviour when dealing with cell data. Fixes
#186
parent
2d695acf
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/postProcessing/functionObjects/graphics/runTimePostProcessing/fieldVisualisationBase.C
+77
-63
77 additions, 63 deletions
...s/graphics/runTimePostProcessing/fieldVisualisationBase.C
with
77 additions
and
63 deletions
src/postProcessing/functionObjects/graphics/runTimePostProcessing/fieldVisualisationBase.C
+
77
−
63
View file @
cd8be89b
...
...
@@ -43,6 +43,7 @@ License
#include
"vtkSphereSource.h"
#include
"vtkTextActor.h"
#include
"vtkTextProperty.h"
#include
"vtkCellDataToPointData.h"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
...
...
@@ -151,6 +152,9 @@ void Foam::fieldVisualisationBase::addScalarBar
const
vector
textColour
=
colours_
[
"text"
]
->
value
(
position
);
// Work-around to supply our own scalarbar title
// - Default scalar bar title text is scales by the scalar bar box
// dimensions so if the title is a long string, the text is shrunk to fit
// Instead, suppress title and set the title using a vtkTextActor
vtkSmartPointer
<
vtkTextActor
>
titleActor
=
vtkSmartPointer
<
vtkTextActor
>::
New
();
sbar
->
SetTitle
(
" "
);
...
...
@@ -170,19 +174,18 @@ void Foam::fieldVisualisationBase::addScalarBar
titleActor
->
GetPositionCoordinate
()
->
SetCoordinateSystemToNormalizedViewport
();
/*
sbar->SetTitle(scalarBar_.title_.c_str());
sbar->GetTitleTextProperty()->SetColor
(
textColour[0],
textColour[1],
textColour[2]
);
sbar->GetTitleTextProperty()->SetFontSize(scalarBar_.fontSize_);
sbar->GetTitleTextProperty()->ShadowOff();
sbar->GetTitleTextProperty()->BoldOn();
sbar->GetTitleTextProperty()->ItalicOff();
*/
// How to use the standard scalar bar text
// sbar->SetTitle(scalarBar_.title_.c_str());
// sbar->GetTitleTextProperty()->SetColor
// (
// textColour[0],
// textColour[1],
// textColour[2]
// );
// sbar->GetTitleTextProperty()->SetFontSize(scalarBar_.fontSize_);
// sbar->GetTitleTextProperty()->ShadowOff();
// sbar->GetTitleTextProperty()->BoldOn();
// sbar->GetTitleTextProperty()->ItalicOff();
sbar
->
GetLabelTextProperty
()
->
SetColor
(
...
...
@@ -217,8 +220,8 @@ void Foam::fieldVisualisationBase::addScalarBar
sbar
->
SetWidth
(
0
.
75
);
sbar
->
SetHeight
(
0
.
07
);
sbar
->
SetBarRatio
(
0
.
5
);
//
sbar->SetHeight(0.1);
//
sbar->SetTitleRatio(0.01);
//
sbar->SetHeight(0.1);
//
sbar->SetTitleRatio(0.01);
sbar
->
SetTextPositionToPrecedeScalarBar
();
}
...
...
@@ -228,10 +231,10 @@ void Foam::fieldVisualisationBase::addScalarBar
scalarBar_
.
position_
.
second
()
+
sbar
->
GetHeight
()
);
//
sbar->DrawFrameOn();
//
sbar->DrawBackgroundOn();
//
sbar->UseOpacityOff();
//
sbar->VisibilityOff();
//
sbar->DrawFrameOn();
//
sbar->DrawBackgroundOn();
//
sbar->UseOpacityOff();
//
sbar->VisibilityOff();
sbar
->
VisibilityOn
();
renderer
->
AddActor
(
sbar
);
...
...
@@ -268,25 +271,7 @@ void Foam::fieldVisualisationBase::setField
// Configure the mapper
mapper
->
SelectColorArray
(
colourFieldName
.
c_str
());
mapper
->
SetScalarRange
(
range_
.
first
(),
range_
.
second
());
// Set to use either cell or point data
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
->
SetScalarModeToDefault
();
// try points, then cells
mapper
->
SetColorModeToMapScalars
();
mapper
->
SetLookupTable
(
lut
);
mapper
->
ScalarVisibilityOn
();
...
...
@@ -322,9 +307,37 @@ void Foam::fieldVisualisationBase::addGlyphs
glyph
->
ScalingOn
();
bool
ok
=
true
;
label
nComponents
=
data
->
GetPointData
()
->
GetArray
(
scaleFieldName
.
c_str
())
->
GetNumberOfComponents
();
// Determine whether we have scalar or vector data
label
nComponents
=
-
1
;
const
char
*
scaleFieldNameChar
=
scaleFieldName
.
c_str
();
if
(
data
->
GetPointData
()
->
HasArray
(
scaleFieldNameChar
)
==
1
)
{
nComponents
=
data
->
GetPointData
()
->
GetArray
(
scaleFieldNameChar
)
->
GetNumberOfComponents
();
}
else
if
(
data
->
GetCellData
()
->
HasArray
(
scaleFieldNameChar
)
==
1
)
{
// Need to convert cell data to point data
vtkSmartPointer
<
vtkCellDataToPointData
>
cellToPoint
=
vtkSmartPointer
<
vtkCellDataToPointData
>::
New
();
cellToPoint
->
SetInputData
(
data
);
cellToPoint
->
Update
();
vtkDataSet
*
pds
=
cellToPoint
->
GetOutput
();
vtkDataArray
*
pData
=
pds
->
GetPointData
()
->
GetArray
(
scaleFieldNameChar
);
// Store in main vtkPolyData
data
->
GetPointData
()
->
AddArray
(
pData
);
nComponents
=
pData
->
GetNumberOfComponents
();
}
else
{
WarningInFunction
<<
"Glyphs can only be added to scalar or vector data. "
<<
"Unable to process field "
<<
scaleFieldName
<<
endl
;
return
;
}
if
(
nComponents
==
1
)
{
...
...
@@ -332,9 +345,10 @@ void Foam::fieldVisualisationBase::addGlyphs
vtkSmartPointer
<
vtkSphereSource
>::
New
();
sphere
->
SetCenter
(
0
,
0
,
0
);
sphere
->
SetRadius
(
0
.
5
);
// Setting higher resolution slows the rendering significantly
// sphere->SetPhiResolution(20);
// sphere->SetThetaResolution(20);
// Setting higher resolution slows the rendering significantly
// sphere->SetPhiResolution(20);
// sphere->SetThetaResolution(20);
glyph
->
SetSourceConnection
(
sphere
->
GetOutputPort
());
...
...
@@ -342,18 +356,18 @@ void Foam::fieldVisualisationBase::addGlyphs
{
double
range
[
2
];
// Can use values to find range
//
vtkDataArray* values =
//
data->GetPointData()->GetScalars(scaleFieldName
.c_str()
);
//
values->GetRange(range);
// Can use values to find range
//
vtkDataArray* values =
//
data->GetPointData()->GetScalars(scaleFieldName
Char
);
//
values->GetRange(range);
//
s
et range accoding to user-supplied limits
//
S
et range accoding to user-supplied limits
range
[
0
]
=
range_
.
first
();
range
[
1
]
=
range_
.
second
();
glyph
->
ClampingOn
();
glyph
->
SetRange
(
range
);
//
i
f range[0] != min(value), maxGlyphLength behaviour will not
//
I
f range[0] != min(value), maxGlyphLength behaviour will not
// be correct...
glyph
->
SetScaleFactor
(
maxGlyphLength
);
}
...
...
@@ -370,7 +384,7 @@ void Foam::fieldVisualisationBase::addGlyphs
0
,
0
,
vtkDataObject
::
FIELD_ASSOCIATION_POINTS
,
scaleFieldName
.
c_str
()
scaleFieldName
Char
);
}
else
if
(
nComponents
==
3
)
...
...
@@ -388,21 +402,21 @@ void Foam::fieldVisualisationBase::addGlyphs
if
(
maxGlyphLength
>
0
)
{
vtkDataArray
*
values
=
data
->
GetPointData
()
->
GetVectors
(
scaleFieldName
.
c_str
());
data
->
GetPointData
()
->
GetVectors
(
scaleFieldNameChar
);
double
range
[
6
];
values
->
GetRange
(
range
);
/*
// Attempt to set range for vectors...
scalar x0 = sqrt(sqr(range_.first())/3.0);
scalar x1 = sqrt(sqr(range_.second())/3.0);
range[0] = x0;
range[1] = x0;
range[2] = x0;
range[3] = x1;
range[4] = x1;
range[5] = x1;
*/
//
scalar x0 = sqrt(sqr(range_.first())/3.0);
//
scalar x1 = sqrt(sqr(range_.second())/3.0);
//
range[0] = x0;
//
range[1] = x0;
//
range[2] = x0;
//
range[3] = x1;
//
range[4] = x1;
//
range[5] = x1;
glyph
->
ClampingOn
();
glyph
->
SetRange
(
range
);
glyph
->
SetScaleFactor
(
maxGlyphLength
);
...
...
@@ -421,7 +435,7 @@ void Foam::fieldVisualisationBase::addGlyphs
0
,
0
,
vtkDataObject
::
FIELD_ASSOCIATION_POINTS
,
scaleFieldName
.
c_str
()
scaleFieldName
Char
);
}
else
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment