ENH: improve file reader support for runTimePostProcessing (#1091)

- support .vtp format for geometry, surface, line, cloud.

- use native reader for handling vtk, vtp, obj, stl surface files.
  For other formats, use the MeshedSurface (the surfMesh lib) to
  handle reading and Foam::vtk::Tools::Patch to handle the
  conversion to vtkPolyData. This combination is more memory efficient.

- update tutorial case to include vtp surface geometry
This commit is contained in:
Mark Olesen
2018-12-16 19:14:22 +01:00
parent b6983e6af5
commit c3507f74f2
33 changed files with 681 additions and 441 deletions

View File

@ -35,10 +35,12 @@ License
#include "vtkSmartPointer.h"
#include "vtkPolyData.h"
#include "vtkPolyDataMapper.h"
#include "vtkXMLPolyDataReader.h"
#include "vtkPolyDataReader.h"
#include "vtkProperty.h"
// VTK Readers
#include "vtkPolyDataReader.h"
#include "vtkXMLPolyDataReader.h"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
namespace Foam
@ -60,7 +62,7 @@ Foam::functionObjects::runTimePostPro::functionObjectCloud::functionObjectCloud
(
const runTimePostProcessing& parent,
const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours
const HashPtrTable<Function1<vector>>& colours
)
:
pointData(parent, dict, colours),
@ -101,7 +103,6 @@ addGeometryToScene
// containing all fields.
inputFileName_ = getFileName("file", cloudName_);
inputFileName_.expand();
if (inputFileName_.empty())
{
@ -113,6 +114,7 @@ addGeometryToScene
return;
}
vtkSmartPointer<vtkPolyData> dataset;
if (inputFileName_.hasExt("vtp"))
@ -128,9 +130,17 @@ addGeometryToScene
// Invalid name - ignore.
// Don't support VTK legacy format at all - it is too wasteful
// and cumbersome.
WarningInFunction
<< "Could not read "<< inputFileName_ << nl
<< "Only VTK (.vtp) files are supported"
<< ". Cloud will not be processed"
<< endl;
inputFileName_.clear();
}
if (dataset)
{
auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();