35 #include "vtkFloatArray.h" 36 #include "vtkCellData.h" 37 #include "vtkPointData.h" 38 #include "vtkSmartPointer.h" 43 vtkSmartPointer<vtkCellArray>
48 #ifdef VTK_CELL_ARRAY_V2 53 const vtkIdType nOffsets(faces.
size()+1);
57 vtkIdType nConnect(0);
59 offsets->SetNumberOfTuples(nOffsets);
61 vtkIdType* iter = offsets->WritePointer(0, nOffsets);
66 for (
const auto&
f : faces)
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)
142 template<
class PatchType>
143 vtkSmartPointer<vtkPoints>
151 template<
class PatchType>
152 vtkSmartPointer<vtkCellArray>
159 template<
class PatchType>
160 vtkSmartPointer<vtkPolyData>
166 vtkmesh->SetPolys(faces(
p));
173 vtkSmartPointer<vtkPolyData>
189 template<
class PatchType>
190 vtkSmartPointer<vtkFloatArray>
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_);
223 template<
class PatchType>
224 vtkSmartPointer<vtkPoints>
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,
265 const UList<Type>&
input,
271 if (array->GetNumberOfComponents() != nComp)
274 <<
"vtk array '" << array->GetName()
275 <<
"' has mismatch in number of components for type '" 276 << pTraits<Type>::typeName
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() <<
")" 314 for (
const Type& val :
input)
317 array->SetTuple(start++, scratch);
325 vtkSmartPointer<vtkFloatArray>
334 data->SetName(
name.c_str());
336 data->SetNumberOfTuples(size);
339 #if (VTK_MAJOR_VERSION < 8) 340 for (
int i = 0; i < data->GetNumberOfComponents(); ++i)
342 data->FillComponent(i, 0);
353 vtkSmartPointer<vtkFloatArray>
362 data->SetName(
name.c_str());
364 data->SetNumberOfTuples(
fld.size());
void size(const label n)
Older name for setAddressableSize.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
constexpr char nl
The newline '\n' character (0x0a)
A traits class, which is primarily used for primitives and vector-space.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
::Foam::direction nComponents(const expressions::valueTypeCode) noexcept
The number of components associated with given valueTypeCode.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
A class for handling words, derived from Foam::string.
static Istream & input(Istream &is, IntRange< T > &range)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
#define WarningInFunction
Report a warning using Foam::Warning.