foamGltfObject.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2021 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::glTF::object
28 
29 Description
30  glTF binary object
31 
32 Note
33  Implements the glTF v2 specification
34 
35 SourceFiles
36  foamGltfObject.C
37  foamGltfObjectTemplates.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef foam_gltf_object_H
42 #define foam_gltf_object_H
43 
44 #include "foamGltfBase.H"
45 #include "List.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 namespace glTF
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class glTF::object Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class object
59 :
60  public base
61 {
62  // Private Data
63 
64  //- Buffer storage
65  Foam::List<float> data_;
66 
67 
68 public:
69 
70  // Constructors
71 
72  //- Default construct
73  object();
74 
75  //- Construct with name
76  explicit object(const word& name);
77 
78 
79  // Public Member Functions
80 
81  //- Add data to the buffer
82  template<class Type>
83  void addData(const Type& fld);
84 
85  //- Add data to the buffer from 2 containers of the same size
86  // E.g. to combine vector and scalar to create RGBA data
87  template<class Type1, class Type2>
88  void addData(const Type1& fld1, const Type2& fld2);
89 
90  //- Return const access to the data buffer
91  const Foam::List<float>& data() const noexcept;
92 };
93 
94 
95 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
96 
97 } // End namespace glTF
98 } // End namespace Foam
99 
100 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
101 
102 #ifdef NoRepository
103  #include "foamGltfObjectTemplates.C"
104 #endif
105 
106 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
107 
108 #endif
109 
110 // ************************************************************************* //
object()
Default construct.
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))
void addData(const Type &fld)
Add data to the buffer.
glTF binary object
A class for handling words, derived from Foam::string.
Definition: word.H:63
const word & name() const noexcept
Return const access to the name.
Definition: foamGltfBase.H:173
const direction noexcept
Definition: scalarImpl.H:265
Base class for glTF entities.
Definition: foamGltfBase.H:115
const Foam::List< float > & data() const noexcept
Return const access to the data buffer.
Namespace for OpenFOAM.