mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
- Allows generation of images (currently PNG files) during the run - ... or afterwards by invoking the execFlowFunctionObjects utility - Wrapper around VTK functionality - Support for objects: - text - points (glyphs: sphere, arrow) - lines (tubes) - surfaces (wireframe, shaded, combination) - Colour using: - user-defined - field values (several colour maps availale) - For image sequences: - dynamic views (camera movement) - objects can appear/disappear using opacity - Building - VTK dependency v6+ - satisfied using ParaView from ThirdParty directory - or separate VTK installation
164 lines
4.5 KiB
C
164 lines
4.5 KiB
C
/*---------------------------------------------------------------------------*\
|
|
========= |
|
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
\\ / O peration |
|
|
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
|
\\/ M anipulation |
|
|
-------------------------------------------------------------------------------
|
|
License
|
|
This file is part of OpenFOAM.
|
|
|
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
// OpenFOAM includes
|
|
#include "functionObjectSurface.H"
|
|
#include "runTimePostProcessing.H"
|
|
#include "addToRunTimeSelectionTable.H"
|
|
|
|
// VTK includes
|
|
#include "vtkActor.h"
|
|
#include "vtkPolyDataMapper.h"
|
|
#include "vtkPolyDataReader.h"
|
|
#include "vtkProperty.h"
|
|
#include "vtkRenderer.h"
|
|
#include "vtkSmartPointer.h"
|
|
|
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
|
|
|
namespace Foam
|
|
{
|
|
defineTypeNameAndDebug(functionObjectSurface, 0);
|
|
addToRunTimeSelectionTable(surface, functionObjectSurface, dictionary);
|
|
}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
|
|
Foam::functionObjectSurface::functionObjectSurface
|
|
(
|
|
const runTimePostProcessing& parent,
|
|
const dictionary& dict,
|
|
const HashPtrTable<DataEntry<vector>, word>& colours
|
|
)
|
|
:
|
|
geometrySurface(parent, dict, colours, List<fileName>()),
|
|
fieldVisualisationBase(parent, dict, colours),
|
|
functionObject_("")
|
|
{
|
|
if (visible_)
|
|
{
|
|
dict.lookup("functionObject") >> functionObject_;
|
|
}
|
|
}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
|
|
Foam::functionObjectSurface::~functionObjectSurface()
|
|
{}
|
|
|
|
|
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
|
|
|
void Foam::functionObjectSurface::addGeometryToScene
|
|
(
|
|
const scalar position,
|
|
vtkRenderer* renderer
|
|
)
|
|
{
|
|
if (!visible_)
|
|
{
|
|
return;
|
|
}
|
|
|
|
const dictionary dict =
|
|
geometryBase::parent_.getObjectProperty
|
|
(
|
|
functionObject_,
|
|
fieldName_,
|
|
dictionary::null
|
|
);
|
|
|
|
fileName fName;
|
|
if (!dict.readIfPresent("file", fName))
|
|
{
|
|
WarningIn
|
|
(
|
|
"void Foam::functionObjectSurface::addToScene"
|
|
"("
|
|
"const scalar, "
|
|
"vtkRenderer*"
|
|
")"
|
|
)
|
|
<< "Unable to find function object " << functionObject_
|
|
<< " output for field " << fieldName_
|
|
<< ". Surface will not be processed"
|
|
<< endl;
|
|
return;
|
|
}
|
|
|
|
|
|
if (representation_ == rtGlyph)
|
|
{
|
|
vtkSmartPointer<vtkPolyDataReader> surf =
|
|
vtkSmartPointer<vtkPolyDataReader>::New();
|
|
surf->SetFileName(fName.c_str());
|
|
surf->Update();
|
|
|
|
addGlyphs
|
|
(
|
|
position,
|
|
fieldName_,
|
|
fieldName_,
|
|
maxGlyphLength_,
|
|
surf->GetOutput(),
|
|
surfaceActor_,
|
|
renderer
|
|
);
|
|
}
|
|
else
|
|
{
|
|
if ((colourBy_ == cbField) && (fName.ext() == "vtk"))
|
|
{
|
|
vtkSmartPointer<vtkPolyDataReader> surf =
|
|
vtkSmartPointer<vtkPolyDataReader>::New();
|
|
surf->SetFileName(fName.c_str());
|
|
surf->Update();
|
|
|
|
addFeatureEdges(renderer, surf->GetOutput());
|
|
|
|
vtkSmartPointer<vtkPolyDataMapper> mapper =
|
|
vtkSmartPointer<vtkPolyDataMapper>::New();
|
|
mapper->SetInputConnection(surf->GetOutputPort());
|
|
|
|
setField(position, fieldName_, mapper, renderer);
|
|
|
|
surfaceActor_->SetMapper(mapper);
|
|
|
|
setRepresentation(surfaceActor_);
|
|
|
|
renderer->AddActor(surfaceActor_);
|
|
}
|
|
else
|
|
{
|
|
geometrySurface::addGeometryToScene(position, renderer);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// ************************************************************************* //
|