gltfSetWriter< Type > Class Template Reference

Writes point data in glTF v2 format. More...

Inheritance diagram for gltfSetWriter< Type >:
[legend]
Collaboration diagram for gltfSetWriter< Type >:
[legend]

Public Types

enum  fieldOption { UNIFORM, FIELD }
 Field option used for colours. More...
 

Public Member Functions

 TypeName ("gltf")
 Runtime type information. More...
 
 gltfSetWriter ()
 Default construct. More...
 
 gltfSetWriter (const dictionary &dict)
 Construct from dictionary. More...
 
virtual ~gltfSetWriter ()=default
 Destructor. More...
 
virtual fileName getFileName (const coordSet &, const wordList &) const
 Return the file name. More...
 
virtual void write (const coordSet &, const wordList &, const List< const Field< Type > * > &, Ostream &) const
 Write. More...
 
virtual void write (const bool writeTracks, const List< scalarField > &times, const PtrList< coordSet > &, const wordList &valueSetNames, const List< List< Field< Type >>> &, Ostream &) const
 Write tracks (main entry point) More...
 
virtual void writeAnimateTracks (const bool writeTracks, const List< scalarField > &times, const PtrList< coordSet > &tracks, const wordList &valueSetNames, const List< List< Field< Type >>> &valueSets, Ostream &) const
 Write animated tracks. More...
 
virtual void writeStaticTracks (const bool writeTracks, const List< scalarField > &times, const PtrList< coordSet > &tracks, const wordList &valueSetNames, const List< List< Field< Type >>> &valueSets, Ostream &) const
 Write static tracks. More...
 
- Public Member Functions inherited from writer< Type >
 TypeName ("writer")
 Runtime type information. More...
 
 declareRunTimeSelectionTable (autoPtr, writer, word,(),())
 
 declareRunTimeSelectionTable (autoPtr, writer, dict,(const dictionary &formatOptions),(formatOptions))
 
 writer ()
 Default construct. More...
 
 writer (const dictionary &dict)
 Construct with dictionary. More...
 
virtual ~writer ()=default
 Destructor. More...
 
virtual void write (const coordSet &, const wordList &, const List< Field< Type >> &, Ostream &) const
 General entry point for writing. More...
 
virtual Ostreamwrite (const scalar, Ostream &) const
 Write scalar as ascii. More...
 
template<class VSType >
OstreamwriteVS (const VSType &, Ostream &) const
 
virtual Ostreamwrite (const vector &, Ostream &) const
 Write vector. Tab separated ascii. More...
 
virtual Ostreamwrite (const sphericalTensor &, Ostream &) const
 Write sphericalTensor. Tab separated ascii. More...
 
virtual Ostreamwrite (const symmTensor &, Ostream &) const
 Write symmTensor. Tab separated ascii. More...
 
virtual Ostreamwrite (const tensor &, Ostream &) const
 Write tensor. Tab separated ascii. More...
 
template<class VSType >
Foam::OstreamwriteVS (const VSType &value, Ostream &os) const
 

Static Public Attributes

static const Enum< fieldOptionfieldOptionNames_
 Strings corresponding to the field options. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from writer< Type >
static autoPtr< writerNew (const word &writeFormat)
 Return a reference to the selected writer. More...
 
static autoPtr< writerNew (const word &writeFormat, const dictionary &formatOptions)
 Return a reference to the selected writer. More...
 
- Protected Member Functions inherited from writer< Type >
fileName getBaseName (const coordSet &, const wordList &) const
 Generates filename from coordSet and sampled fields. More...
 
void writeCoord (const coordSet &, const label sampleI, Ostream &) const
 
void writeTable (const coordSet &, const List< Type > &, Ostream &) const
 Writes single-column ascii write. Column 1 is coordSet coordinate,. More...
 
void writeTable (const coordSet &, const List< const List< Type > * > &, Ostream &os) const
 Writes multi-column ascii write. Column 1 is coordSet coordinate,. More...
 
virtual void writeSeparator (Ostream &os) const
 Writes a separator. Used by write functions. More...
 

Detailed Description

template<class Type>
class Foam::gltfSetWriter< Type >

Writes point data in glTF v2 format.

Two files are generated:

  • filename.bin : a binary file containing all scene entities
  • filename.gltf : a JSON file that ties fields to the binary data

The output can contain both geometry and fields, with additional support for colours using a user-supplied colour map, and animation of particle tracks.

Controls are provided via the optional formatOptions dictionary.

For non-particle track data:

formatOptions
{
    // Apply colours flag (yes | no ) [optional]
    colours     yes;

    // List of options per field
    fieldInfo
    {
        p
        {
            // Colour map [optional]
            colourMap       <colourMap>;

            // Colour map minimum and maximum limits [optional]
            // Uses field min and max if not specified
            min             0;
            max             1;

            // Alpha channel [optional] (uniform | field)
            alpha           uniform;
            alphaValue      0.5;

            //alpha           field;
            //alphaField      T;
            //normalise       yes;
        }
    }
}
\verbatim

For particle tracks:

\verbatim
formatOptions
{
    // Apply colours flag (yes | no) [optional]
    colours     yes;

    // Animate tracks (yes | no) [optional]
    animate     yes;

    // Animation properties [optional]
    animationInfo
    {
        // Colour map [optional]
        colourMap       <colourMap>;

        // Colour [optional] (uniform | field)
        colour          uniform;
        colourValue     (1 0 0); // RGB in range [0-1]

        //colour          field;
        //colourField     d;

        // Colour map minimum and maximum limits [optional]
        // Note: for colour = field option
        // Uses field min and max if not specified
        min             0;
        max             1;

        // Alpha channel [optional] (uniform | field)
        alpha           uniform;
        alphaValue      0.5;

        //alpha           field;
        //alphaField      T;
        //normalise       yes;
    }
}
Note
When writing particle animations, the particle field and colour properties correspond to initial particle state (first data point) and cannot be animated (limitation of the file format).

For more information on the specification see https://www.khronos.org/registry/glTF/

Source files

Definition at line 144 of file gltfSetWriter.H.

Member Enumeration Documentation

◆ fieldOption

enum fieldOption
strong

Field option used for colours.

Enumerator
UNIFORM 

Uniform value.

FIELD 

field value

Definition at line 153 of file gltfSetWriter.H.

Constructor & Destructor Documentation

◆ gltfSetWriter() [1/2]

Default construct.

Definition at line 290 of file gltfSetWriter.C.

◆ gltfSetWriter() [2/2]

gltfSetWriter ( const dictionary dict)
explicit

Construct from dictionary.

Definition at line 301 of file gltfSetWriter.C.

◆ ~gltfSetWriter()

virtual ~gltfSetWriter ( )
virtualdefault

Destructor.

Member Function Documentation

◆ TypeName()

TypeName ( "gltf"  )

Runtime type information.

◆ getFileName()

Foam::fileName getFileName ( const coordSet points,
const wordList valueSetNames 
) const
virtual

Return the file name.

Implements writer< Type >.

Definition at line 327 of file gltfSetWriter.C.

References points.

◆ write() [1/2]

void write ( const coordSet points,
const wordList valueSetNames,
const List< const Field< Type > * > &  valueSets,
Ostream os 
) const
virtual

Write.

Implements writer< Type >.

Definition at line 338 of file gltfSetWriter.C.

References scene::addColourToMesh(), scene::addFieldToMesh(), scene::addMesh(), Foam::constant::atomic::alpha, Foam::component(), dict, Foam::endl(), Foam::exit(), f(), Foam::FatalError, FatalErrorInFunction, field(), forAll, Foam::max(), maxValue, Foam::min(), minValue, Foam::name(), os(), points, dictionary::subOrEmptyDict(), and scene::write().

Here is the call graph for this function:

◆ write() [2/2]

void write ( const bool  writeTracks,
const List< scalarField > &  times,
const PtrList< coordSet > &  tracks,
const wordList valueSetNames,
const List< List< Field< Type >>> &  valueSets,
Ostream os 
) const
virtual

Write tracks (main entry point)

Implements writer< Type >.

Definition at line 412 of file gltfSetWriter.C.

References Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, and os().

Here is the call graph for this function:

◆ writeAnimateTracks()

void writeAnimateTracks ( const bool  writeTracks,
const List< scalarField > &  times,
const PtrList< coordSet > &  tracks,
const wordList valueSetNames,
const List< List< Field< Type >>> &  valueSets,
Ostream os 
) const
virtual

Write animated tracks.

Definition at line 540 of file gltfSetWriter.C.

References scene::addColourToMesh(), scene::addField(), scene::addFieldToMesh(), scene::addMesh(), scene::addToAnimation(), Foam::constant::atomic::alpha, scene::createAnimation(), field(), forAll, Foam::name(), os(), and scene::write().

Here is the call graph for this function:

◆ writeStaticTracks()

void writeStaticTracks ( const bool  writeTracks,
const List< scalarField > &  times,
const PtrList< coordSet > &  tracks,
const wordList valueSetNames,
const List< List< Field< Type >>> &  valueSets,
Ostream os 
) const
virtual

Write static tracks.

Definition at line 458 of file gltfSetWriter.C.

References scene::addColourToMesh(), scene::addFieldToMesh(), scene::addMesh(), Foam::constant::atomic::alpha, Foam::component(), dict, f(), field(), forAll, Foam::max(), maxValue, Foam::min(), minValue, Foam::name(), os(), dictionary::subOrEmptyDict(), scene::write(), and Foam::Zero.

Here is the call graph for this function:

Member Data Documentation

◆ fieldOptionNames_

const Foam::Enum< typename Foam::gltfSetWriter< Type >::fieldOption > fieldOptionNames_
static

Strings corresponding to the field options.

Definition at line 161 of file gltfSetWriter.H.


The documentation for this class was generated from the following files: