STLsurfaceFormat.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::fileFormats::STLsurfaceFormat
26 
27 Description
28  Provide a means of reading/writing STL files (ASCII and binary).
29 
30  Note:
31  For efficiency, the zones are sorted before creating the faces.
32  The class is thus derived from MeshedSurface.
33 
34 SourceFiles
35  STLsurfaceFormat.C
36  STLsurfaceFormatASCII.L
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef STLsurfaceFormat_H
41 #define STLsurfaceFormat_H
42 
43 #include "STLsurfaceFormatCore.H"
44 #include "MeshedSurface.H"
45 #include "MeshedSurfaceProxy.H"
46 #include "UnsortedMeshedSurface.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 namespace fileFormats
53 {
54 
55 /*---------------------------------------------------------------------------*\
56  Class STLsurfaceFormat Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 template<class Face>
60 class STLsurfaceFormat
61 :
62  public MeshedSurface<Face>
63 {
64  // Private Member Functions
65 
66  //- Write Face (ASCII)
67  static inline void writeShell
68  (
69  Ostream&,
70  const pointField&,
71  const Face&
72  );
73 
74  //- Write Face (BINARY)
75  static inline void writeShell
76  (
77  ostream&,
78  const pointField&,
79  const Face&,
80  const label zoneI
81  );
82 
83 
84 public:
85 
86  // Constructors
87 
88  //- Construct from file name
89  STLsurfaceFormat(const fileName&);
90 
91  //- Disallow default bitwise copy construction
93 
94 
95  // Selectors
96 
97  //- Read file and return surface
99  {
101  (
103  );
104  }
105 
106 
107  //- Destructor
108  virtual ~STLsurfaceFormat()
109  {}
110 
111 
112  // Member Functions
113 
114  //- Write surface mesh components by proxy (as ASCII)
115  static void writeAscii
116  (
117  const fileName&,
119  );
120 
121  //- Write surface mesh components by proxy (as BINARY)
122  static void writeBinary
123  (
124  const fileName&,
126  );
127 
128  //- Write surface mesh components by proxy
129  // as ASCII or BINARY, depending on the extension
130  static void write(const fileName&, const MeshedSurfaceProxy<Face>&);
131 
132  //- Write UnsortedMeshedSurface (as ASCII) sorted by zone
133  static void writeAscii
134  (
135  const fileName&,
137  );
138 
139  //- Write UnsortedMeshedSurface (as BINARY) unsorted by zone
140  static void writeBinary
141  (
142  const fileName&,
144  );
145 
146  //- Write UnsortedMeshedSurface
147  // as ASCII or BINARY, depending on the extension
148  static void write(const fileName&, const UnsortedMeshedSurface<Face>&);
149 
150  //- Read from file
151  virtual bool read(const fileName&);
152 
153  //- Write object
154  virtual void write(const fileName& name) const
155  {
157  }
158 
159 
160  // Member Operators
161 
162  //- Disallow default bitwise assignment
163  void operator=(const STLsurfaceFormat<Face>&) = delete;
164 };
165 
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 } // End namespace fileFormats
170 } // End namespace Foam
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 #ifdef NoRepository
175  #include "STLsurfaceFormat.C"
176 #endif
177 
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 
180 #endif
181 
182 // ************************************************************************* //
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:85
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A surface geometry mesh, in which the surface zone information is conveyed by the 'zoneId' associated...
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Provide a means of reading/writing STL files (ASCII and binary).
STLsurfaceFormat(const fileName &)
Construct from file name.
void operator=(const STLsurfaceFormat< Face > &)=delete
Disallow default bitwise assignment.
static void write(const fileName &, const MeshedSurfaceProxy< Face > &)
Write surface mesh components by proxy.
static void writeBinary(const fileName &, const MeshedSurfaceProxy< Face > &)
Write surface mesh components by proxy (as BINARY)
virtual bool read(const fileName &)
Read from file.
static autoPtr< MeshedSurface< Face > > New(const fileName &name)
Read file and return surface.
static void writeAscii(const fileName &, const MeshedSurfaceProxy< Face > &)
Write surface mesh components by proxy (as ASCII)
A class for handling file names.
Definition: fileName.H:82
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39