35#include "vtkFloatArray.h"
36#include "vtkCellData.h"
37#include "vtkPointData.h"
38#include "vtkSmartPointer.h"
43vtkSmartPointer<vtkCellArray>
46 auto cells = vtkSmartPointer<vtkCellArray>::New();
48 #ifdef VTK_CELL_ARRAY_V2
53 const vtkIdType nOffsets(faces.
size()+1);
55 auto offsets = vtkSmartPointer<vtkIdTypeArray>::New();
57 vtkIdType nConnect(0);
59 offsets->SetNumberOfTuples(nOffsets);
61 vtkIdType* iter = offsets->WritePointer(0, nOffsets);
66 for (
const auto&
f : faces)
78 auto connect = vtkSmartPointer<vtkIdTypeArray>::New();
81 connect->SetNumberOfTuples(nConnect);
83 vtkIdType* iter = connect->WritePointer(0, nConnect);
87 for (
const auto&
f : faces)
89 for (
const label verti :
f)
98 cells->SetData(offsets, connect);
109 const vtkIdType nElem(faces.
size());
112 vtkIdType nConnect(faces.
size());
113 for (
const auto&
f : faces)
115 nConnect +=
f.size();
119 cells->GetData()->SetNumberOfTuples(nConnect);
121 vtkIdType* iter =
cells->WritePointer(nElem, nConnect);
125 for (
const auto&
f : faces)
127 *(iter++) =
f.size();
129 for (
const label verti :
f)
142template<
class PatchType>
143vtkSmartPointer<vtkPoints>
151template<
class PatchType>
152vtkSmartPointer<vtkCellArray>
159template<
class PatchType>
160vtkSmartPointer<vtkPolyData>
163 auto vtkmesh = vtkSmartPointer<vtkPolyData>::New();
166 vtkmesh->SetPolys(faces(
p));
173vtkSmartPointer<vtkPolyData>
180 auto vtkmesh = vtkSmartPointer<vtkPolyData>::New();
189template<
class PatchType>
190vtkSmartPointer<vtkFloatArray>
193 auto array = vtkSmartPointer<vtkFloatArray>::New();
195 array->SetNumberOfComponents(3);
196 array->SetNumberOfTuples(
p.size());
203 if (
p.hasFaceNormals())
205 for (
const vector&
n :
p.faceNormals())
207 array->SetTuple(
faceId++,
n.v_);
212 for (
const auto&
f :
p)
214 const vector n(
f.unitNormal(
p.points()));
215 array->SetTuple(
faceId++,
n.v_);
223template<
class PatchType>
224vtkSmartPointer<vtkPoints>
227 auto vtkpoints = vtkSmartPointer<vtkPoints>::New();
229 vtkpoints->SetNumberOfPoints(
p.size());
234 vtkIdType pointId = 0;
236 if (
p.hasFaceCentres())
238 for (
const point& pt :
p.faceCentres())
240 vtkpoints->SetPoint(pointId++, pt.v_);
245 for (
const auto&
f :
p)
247 const point pt(
f.centre(
p.points()));
248 vtkpoints->SetPoint(pointId++, pt.
v_);
264 vtkFloatArray* array,
271 if (array->GetNumberOfComponents() != nComp)
274 <<
"vtk array '" << array->GetName()
275 <<
"' has mismatch in number of components for type '"
277 <<
"' : target array has " << array->GetNumberOfComponents()
278 <<
" components instead of " << nComp
282 const vtkIdType maxSize = array->GetNumberOfTuples();
283 const vtkIdType endPos = start + vtkIdType(
input.size());
290 else if (start < 0 || vtkIdType(start) >= maxSize)
293 <<
"vtk array '" << array->GetName()
294 <<
"' copy with out-of-range [0," << long(maxSize) <<
")"
295 <<
" starting at " << long(start)
300 else if (endPos > maxSize)
303 <<
"vtk array '" << array->GetName()
304 <<
"' copy ends out-of-range (" << long(maxSize) <<
")"
305 <<
" using sizing (start,size) = ("
306 << long(start) <<
"," <<
input.size() <<
")"
312 float scratch[pTraits<Type>::nComponents];
314 for (
const Type& val :
input)
317 array->SetTuple(start++, scratch);
325vtkSmartPointer<vtkFloatArray>
332 auto data = vtkSmartPointer<vtkFloatArray>::New();
336 data->SetNumberOfTuples(size);
339 #if (VTK_MAJOR_VERSION < 8)
340 for (
int i = 0; i <
data->GetNumberOfComponents(); ++i)
342 data->FillComponent(i, 0);
353vtkSmartPointer<vtkFloatArray>
360 auto data = vtkSmartPointer<vtkFloatArray>::New();
364 data->SetNumberOfTuples(
fld.size());
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void size(const label n)
Older name for setAddressableSize.
Cmpt v_[Ncmpts]
The components of this vector space.
static const FixedList< vector, 6 > faceNormals
The unit normal per face.
static const faceList faces
Faces to point addressing, as per a 'hex' cell.
Database for solution data, solver performance and other reduced data.
A traits class, which is primarily used for primitives.
const vectorField & faceCentres() const
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
static Istream & input(Istream &is, IntRange< T > &range)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
constexpr char nl
The newline '\n' character (0x0a)