Loading...
Searching...
No Matches
STLsurfaceFormat.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) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2016-2024 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::fileFormats::STLsurfaceFormat
29
30Description
31 Provide a means of reading/writing STL files (ASCII and BINARY).
32
33 Output stream options: ASCII/BINARY, compression for ASCII only
34
35 Output dictionary options: ignored
36
37Note
38 For efficiency, the zones are sorted before creating the faces.
39 The class is thus derived from MeshedSurface.
40
41SourceFiles
42 STLsurfaceFormat.C
43 STLsurfaceFormatASCII.L
44
45\*---------------------------------------------------------------------------*/
46
47#ifndef Foam_STLsurfaceFormat_H
48#define Foam_STLsurfaceFormat_H
49
50#include "STLReader.H"
51#include "MeshedSurface.H"
52#include "MeshedSurfaceProxy.H"
54
55// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56
57namespace Foam
58{
59namespace fileFormats
60{
61
62/*---------------------------------------------------------------------------*\
63 Class fileFormats::STLsurfaceFormat Declaration
64\*---------------------------------------------------------------------------*/
65
66template<class Face>
68:
69 public MeshedSurface<Face>,
70 public STLCore
71{
72 // Private Member Functions
73
74 //- Write Face (ASCII)
75 static inline void writeShell
76 (
77 Ostream& os,
78 const UList<point>& pts,
79 const Face& f
80 );
81
82 //- Write Face (BINARY)
83 static inline void writeShell
84 (
85 ostream& os,
86 const UList<point>& pts,
87 const Face& f,
88 const label zoneI
89 );
90
91
92public:
93
94 // Constructors
95
96 //- Construct from file name
97 explicit STLsurfaceFormat(const fileName& filename);
98
99
100 //- Destructor
101 virtual ~STLsurfaceFormat() = default;
102
103
104 // Static Functions
105
106 //- Write surface mesh components by proxy (as ASCII)
107 static void writeAscii
108 (
109 const fileName& filename,
110 const MeshedSurfaceProxy<Face>& surf,
112 );
113
114 //- Write surface mesh components by proxy (as BINARY)
115 static void writeBinary
116 (
117 const fileName& filename,
118 const MeshedSurfaceProxy<Face>& surf
119 );
120
121 //- Write UnsortedMeshedSurface (as ASCII) sorted by zone
122 static void writeAscii
123 (
124 const fileName& filename,
125 const UnsortedMeshedSurface<Face>& surf,
127 );
128
129 //- Write UnsortedMeshedSurface (as BINARY) unsorted by zone
130 static void writeBinary
131 (
132 const fileName& filename,
134 );
135
136 //- Write surface mesh components (by proxy) in STL format
137 //- as ASCII or BINARY or dependent on the extension
138 static void write
139 (
140 const fileName& filename,
141 const MeshedSurfaceProxy<Face>& surf,
142 const STLFormat format,
144 );
145
146 //- Write UnsortedMeshedSurface
147 // as ASCII or BINARY or dependent on the extension
148 static void write
149 (
150 const fileName& filename,
151 const UnsortedMeshedSurface<Face>& surf,
152 const STLFormat format,
154 );
155
156
157 //- Write surface mesh components (by proxy) in STL format
158 //- as ASCII or BINARY, depending on the extension
159 static void write
160 (
161 const fileName& filename,
162 const MeshedSurfaceProxy<Face>& surf,
163 IOstreamOption streamOpt = IOstreamOption(),
164 const dictionary& options = dictionary::null
165 );
166
167 //- Write UnsortedMeshedSurface
168 //- as ASCII or BINARY, depending on the extension
169 static void write
170 (
171 const fileName& filename,
172 const UnsortedMeshedSurface<Face>& surf,
173 IOstreamOption streamOpt = IOstreamOption(),
174 const dictionary& options = dictionary::null
175 );
176
177
178 // Member Functions
179
180 //- Read from file
181 virtual bool read(const fileName& filename) override;
182
183 //- Write surface mesh to file (by proxy)
184 virtual void write
185 (
186 const fileName& name,
187 IOstreamOption streamOpt = IOstreamOption(),
188 const dictionary& options = dictionary::null
189 ) const override
190 {
191 write(name, MeshedSurfaceProxy<Face>(*this), streamOpt, options);
192 }
193
194 //- Write surface mesh to file (by proxy)
195 virtual void write
196 (
197 const fileName& name,
198 const word& fileType, /* ignored */
199 IOstreamOption streamOpt = IOstreamOption(),
200 const dictionary& options = dictionary::null
201 ) const override
202 {
203 write(name, MeshedSurfaceProxy<Face>(*this), streamOpt, options);
204 }
205};
206
207
208// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209
210} // End namespace fileFormats
211} // End namespace Foam
212
213// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214
215#ifdef NoRepository
216 #include "STLsurfaceFormat.C"
217#endif
218
219// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220
221#endif
222
223// ************************************************************************* //
A simple container for options an IOstream can normally have.
compressionType
Compression treatment (UNCOMPRESSED | COMPRESSED).
@ UNCOMPRESSED
compression = false
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats.
friend class UnsortedMeshedSurface
friend class MeshedSurface
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
Definition dictionary.H:487
STLCore()=default
Default construct.
STLFormat
Enumeration for the format of data in the stream.
Definition STLCore.H:60
static void writeBinary(const fileName &filename, const MeshedSurfaceProxy< Face > &surf)
Write surface mesh components by proxy (as BINARY).
STLsurfaceFormat(const fileName &filename)
Construct from file name.
static void writeAscii(const fileName &filename, const MeshedSurfaceProxy< Face > &surf, IOstreamOption::compressionType comp=IOstreamOption::UNCOMPRESSED)
Write surface mesh components by proxy (as ASCII).
virtual bool read(const fileName &filename) override
Read from file.
virtual ~STLsurfaceFormat()=default
Destructor.
virtual void write(const fileName &name, const word &fileType, IOstreamOption streamOpt=IOstreamOption(), const dictionary &options=dictionary::null) const override
Write surface mesh to file (by proxy).
virtual void write(const fileName &name, IOstreamOption streamOpt=IOstreamOption(), const dictionary &options=dictionary::null) const override
Write surface mesh to file (by proxy).
A class for handling file names.
Definition fileName.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
OBJstream os(runTime.globalPath()/outputName)
Namespace to isolate specifics for file formats, and some common utilities.
Namespace for OpenFOAM.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
runTime write()
word format(conversionProperties.get< word >("format"))
labelList f(nPoints)
const pointField & pts