Commit 6cdb80b2 authored by Mark Olesen's avatar Mark Olesen

ENH: add vtk::Tools::Patch faceCentres() method

parent 60513758
......@@ -195,7 +195,7 @@ namespace Tools
//- Convert OpenFOAM patch to vtkPolyData
struct Patch
{
//- Convert local patch points to vtkPoints
//- Return local patch points as vtkPoints
template<class PatchType>
static vtkSmartPointer<vtkPoints> points(const PatchType& p);
......@@ -210,6 +210,10 @@ namespace Tools
//- Convert patch face normals to vtkFloatArray
template<class PatchType>
static vtkSmartPointer<vtkFloatArray> faceNormals(const PatchType& p);
//- Return patch face centres as vtkPoints
template<class PatchType>
static vtkSmartPointer<vtkPoints> faceCentres(const PatchType& p);
};
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -139,6 +139,39 @@ Foam::vtk::Tools::Patch::faceNormals(const PatchType& p)
}
template<class PatchType>
vtkSmartPointer<vtkPoints>
Foam::vtk::Tools::Patch::faceCentres(const PatchType& p)
{
auto vtkpoints = vtkSmartPointer<vtkPoints>::New();
vtkpoints->SetNumberOfPoints(p.size());
// Use cached values if available or loop over faces
// (avoid triggering cache)
vtkIdType pointId = 0;
if (p.hasFaceCentres())
{
for (const point& pt : p.faceCentres())
{
vtkpoints->SetPoint(pointId++, pt.v_);
}
}
else
{
for (const auto& f : p)
{
const point pt(f.centre(p.points()));
vtkpoints->SetPoint(pointId++, pt.v_);
}
}
return vtkpoints;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//
// Low-Level conversions
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment