Skip to content
Snippets Groups Projects
Commit 24c8f5a5 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

ENH: arbitrary face types for vtk::Tools::Patch::faces()

- the patch could use face or triFace (labelledTriFace)

- avoid trigger patch faceNormals unnecessarily
parent dc8179f5
Branches
Tags
No related merge requests found
...@@ -65,11 +65,11 @@ template<class PatchType> ...@@ -65,11 +65,11 @@ template<class PatchType>
vtkSmartPointer<vtkCellArray> vtkSmartPointer<vtkCellArray>
Foam::vtk::Tools::Patch::faces(const PatchType& p) Foam::vtk::Tools::Patch::faces(const PatchType& p)
{ {
// Faces as polygons // List of faces or triFaces
const faceList& fcs = p.localFaces(); const auto& fcs = p.localFaces();
label nAlloc = fcs.size(); label nAlloc = fcs.size();
for (const face& f : fcs) for (const auto& f : fcs)
{ {
nAlloc += f.size(); nAlloc += f.size();
} }
...@@ -81,7 +81,7 @@ Foam::vtk::Tools::Patch::faces(const PatchType& p) ...@@ -81,7 +81,7 @@ Foam::vtk::Tools::Patch::faces(const PatchType& p)
// Cell connectivity for polygons // Cell connectivity for polygons
// [size, verts..., size, verts... ] // [size, verts..., size, verts... ]
auto iter = list.begin(); auto iter = list.begin();
for (const face& f : fcs) for (const auto& f : fcs)
{ {
*(iter++) = f.size(); *(iter++) = f.size();
...@@ -118,15 +118,24 @@ Foam::vtk::Tools::Patch::faceNormals(const PatchType& p) ...@@ -118,15 +118,24 @@ Foam::vtk::Tools::Patch::faceNormals(const PatchType& p)
array->SetNumberOfTuples(p.size()); array->SetNumberOfTuples(p.size());
// Unit normals for patch faces. // Unit normals for patch faces.
// If not already cached, could be more memory efficient to loop over // Cached values if available or loop over faces (avoid triggering cache)
// the individual faces instead.
const vectorField& norms = p.faceNormals();
vtkIdType faceId = 0; vtkIdType faceId = 0;
for (const vector& n : norms)
if (p.hasFaceNormals())
{
for (const vector& n : p.faceNormals())
{
array->SetTuple(faceId++, n.v_);
}
}
else
{ {
array->SetTuple(faceId++, n.v_); for (const auto& f : p)
{
const vector n(f.unitNormal(p.points()));
array->SetTuple(faceId++, n.v_);
}
} }
return array; return array;
......
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