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-2021 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 STLsurfaceFormat_H
48#define 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 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
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
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);
182
183 //- Write surface mesh to file
184 virtual void write
185 (
186 const fileName& name,
187 IOstreamOption streamOpt = IOstreamOption(),
188 const dictionary& options = dictionary::null
189 ) const
190 {
191 write(name, MeshedSurfaceProxy<Face>(*this), streamOpt, options);
192 }
193};
194
195
196// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197
198} // End namespace fileFormats
199} // End namespace Foam
200
201// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202
203#ifdef NoRepository
204 #include "STLsurfaceFormat.C"
205#endif
206
207// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208
209#endif
210
211// ************************************************************************* //
The IOstreamOption is 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.
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
Definition: MeshedSurface.H:99
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
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:94
A surface geometry mesh, in which the surface zone information is conveyed by the 'zoneId' associated...
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Core routines used when reading/writing STL files.
Definition: STLCore.H:55
STLFormat
Enumeration for the format of data in the stream.
Definition: STLCore.H:62
Provide a means of reading/writing STL files (ASCII and BINARY).
virtual void write(const fileName &name, IOstreamOption streamOpt=IOstreamOption(), const dictionary &options=dictionary::null) const
Write surface mesh to file.
static void writeBinary(const fileName &filename, const MeshedSurfaceProxy< Face > &surf)
Write surface mesh components by proxy (as BINARY)
static void writeAscii(const fileName &filename, const MeshedSurfaceProxy< Face > &surf, IOstreamOption::compressionType comp=IOstreamOption::UNCOMPRESSED)
Write surface mesh components by proxy (as ASCII)
virtual ~STLsurfaceFormat()=default
Destructor.
virtual bool read(const fileName &filename)
Read from file.
A class for handling file names.
Definition: fileName.H:76
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
runTime write()
word format(conversionProperties.get< word >("format"))
labelList f(nPoints)