mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: arbitrary face types for vtk::Tools::Patch::faces()
- the patch could use face or triFace (labelledTriFace) - avoid trigger patch faceNormals unnecessarily
This commit is contained in:
@ -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)
|
|||||||
// 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)
|
|||||||
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())
|
||||||
{
|
{
|
||||||
array->SetTuple(faceId++, n.v_);
|
for (const vector& n : p.faceNormals())
|
||||||
|
{
|
||||||
|
array->SetTuple(faceId++, n.v_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (const auto& f : p)
|
||||||
|
{
|
||||||
|
const vector n(f.unitNormal(p.points()));
|
||||||
|
array->SetTuple(faceId++, n.v_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
|
|||||||
Reference in New Issue
Block a user