49 const label lastMeshi = (meshes_.size() - 1);
53 meshi = (lastMeshi < 0 ? static_cast<label>(0) : lastMeshi);
56 if (meshi > lastMeshi)
59 <<
"Mesh " << meshi <<
" out of range: " << lastMeshi
63 return meshes_[meshi];
75 auto& gmesh = getMesh(meshi);
77 auto& bv = bufferViews_.create(
name);
78 bv.byteOffset() = bytes_;
79 bv.byteLength() =
fld.size()*3*
sizeof(float);
81 bytes_ += bv.byteLength();
83 auto& acc = accessors_.create(
name);
84 acc.bufferViewId() = bv.id();
87 auto& obj = objects_.create(
name);
95 bv.byteLength() +=
fld.size()*
sizeof(float);
96 bytes_ +=
fld.size()*
sizeof(float);
101 tmp<scalarField> talpha(
alpha);
108 obj.addData(
fld, talpha());
111 gmesh.addColour(acc.id());
119 animations_.create(
name);
120 return animations_.size() - 1;
126 const label animationi,
128 const label outputId,
133 if (animationi > animations_.size() - 1)
136 <<
"Animation " << animationi <<
" out of range "
137 << (animations_.size() - 1)
141 const label nodeId = meshId + 1;
145 if (nodeId > meshes_.size())
148 <<
"Node " << nodeId <<
" out of range " << meshes_.size()
152 animations_[animationi].addTranslation
182 binFile.replace_ext(
"bin");
187 auto& osbin = bin.stdStream();
189 label totalBytes = 0;
190 for (
const auto&
object : objects_.data())
192 for (
const auto& data :
object.data())
196 reinterpret_cast<const char*
>(&data),
200 totalBytes +=
sizeof(float);
208 <<
indent <<
"\"generator\" : \"OpenFOAM - www.openfoam.com\"," <<
nl
237 const label nodeId = meshi + 1;
241 if (meshi != meshes_.size() - 1)
os <<
", ";
257 if (meshi != meshes_.size() - 1)
os <<
",";
266 bufferViews_.write(
os,
"bufferViews");
268 accessors_.write(
os,
"accessors");
270 animations_.write(
os,
"animations");
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
virtual const std::ostream & stdStream() const override
Const access to underlying std::ostream.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
A class for handling file names.
fileName & replace_ext(const word &ending)
Remove extension (if any) and append a new one.
word name() const
Return basename (part beyond last /), including its extension.
static std::string path(const std::string &str)
Return directory path name (part before last /).
static std::string name(const std::string &str)
Return basename (part beyond last /), including its extension.
scene()
Default construct.
void write(const fileName &outputFile)
Write to file pair (.gltf, .bin).
label addColourToMesh(const vectorField &fld, const word &name, const label meshId, const scalarField &alpha=scalarField::null())
Add a colour field to the mesh, optionally with an alpha channel.
label createAnimation(const word &name)
Returns index of last animation.
void addToAnimation(const label animationi, const label inputId, const label outputId, const label meshId, const string &interpolation="LINEAR")
Add to existing animation.
Abstract base class for volume field interpolation.
A class for handling character strings derived from std::string.
A class for managing temporary objects.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
constexpr auto key(const Type &t) noexcept
Helper function to return the enum value.
@ ARRAY_BUFFER
vertex attributes
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Ostream & indent(Ostream &os)
Indent stream.
errorManip< error > abort(error &err)
Field< vector > vectorField
Specialisation of Field<T> for vector.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.