mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add vtk::Tools::Patch faceCentres() method
This commit is contained in:
@ -195,7 +195,7 @@ namespace Tools
|
|||||||
//- Convert OpenFOAM patch to vtkPolyData
|
//- Convert OpenFOAM patch to vtkPolyData
|
||||||
struct Patch
|
struct Patch
|
||||||
{
|
{
|
||||||
//- Convert local patch points to vtkPoints
|
//- Return local patch points as vtkPoints
|
||||||
template<class PatchType>
|
template<class PatchType>
|
||||||
static vtkSmartPointer<vtkPoints> points(const PatchType& p);
|
static vtkSmartPointer<vtkPoints> points(const PatchType& p);
|
||||||
|
|
||||||
@ -210,6 +210,10 @@ namespace Tools
|
|||||||
//- Convert patch face normals to vtkFloatArray
|
//- Convert patch face normals to vtkFloatArray
|
||||||
template<class PatchType>
|
template<class PatchType>
|
||||||
static vtkSmartPointer<vtkFloatArray> faceNormals(const PatchType& p);
|
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
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
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
|
// Low-Level conversions
|
||||||
|
|||||||
Reference in New Issue
Block a user