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 | Copyright (C) 2011 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  //- Disallow default bitwise copy construct
85 
86  //- Disallow default bitwise assignment
87  void operator=(const STLsurfaceFormat<Face>&);
88 
89 
90 public:
91 
92  // Constructors
93 
94  //- Construct from file name
95  STLsurfaceFormat(const fileName&);
96 
97 
98  // Selectors
99 
100  //- Read file and return surface
102  {
104  (
106  );
107  }
108 
109 
110  //- Destructor
111  virtual ~STLsurfaceFormat()
112  {}
113 
114 
115  // Member Functions
116 
117  //- Write surface mesh components by proxy (as ASCII)
118  static void writeAscii
119  (
120  const fileName&,
122  );
123 
124  //- Write surface mesh components by proxy (as BINARY)
125  static void writeBinary
126  (
127  const fileName&,
129  );
130 
131  //- Write surface mesh components by proxy
132  // as ASCII or BINARY, depending on the extension
133  static void write(const fileName&, const MeshedSurfaceProxy<Face>&);
134 
135  //- Write UnsortedMeshedSurface (as ASCII) sorted by zone
136  static void writeAscii
137  (
138  const fileName&,
140  );
141 
142  //- Write UnsortedMeshedSurface (as BINARY) unsorted by zone
143  static void writeBinary
144  (
145  const fileName&,
147  );
148 
149  //- Write UnsortedMeshedSurface
150  // as ASCII or BINARY, depending on the extension
151  static void write(const fileName&, const UnsortedMeshedSurface<Face>&);
152 
153  //- Read from file
154  virtual bool read(const fileName&);
155 
156  //- Write object
157  virtual void write(const fileName& name) const
158  {
160  }
161 };
162 
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 } // End namespace fileFormats
167 } // End namespace Foam
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 #ifdef NoRepository
172 # include "STLsurfaceFormat.C"
173 #endif
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 #endif
178 
179 // ************************************************************************* //
Foam::fileFormats::STLsurfaceFormat::~STLsurfaceFormat
virtual ~STLsurfaceFormat()
Destructor.
Definition: STLsurfaceFormat.H:110
MeshedSurfaceProxy.H
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::fileFormats::STLsurfaceFormat
Provide a means of reading/writing STL files (ASCII and binary).
Definition: STLsurfaceFormat.H:59
Foam::MeshedSurfaceProxy
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats.
Definition: MeshedSurface.H:73
Foam::fileFormats::STLsurfaceFormat::writeBinary
static void writeBinary(const fileName &, const MeshedSurfaceProxy< Face > &)
Write surface mesh components by proxy (as BINARY)
Definition: STLsurfaceFormat.C:248
UnsortedMeshedSurface.H
STLsurfaceFormatCore.H
Foam::label
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
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::UnsortedMeshedSurface< Face >
Foam::fileFormats::STLsurfaceFormat::read
virtual bool read(const fileName &)
Read from file.
Definition: STLsurfaceFormat.C:127
Foam::fileFormats::STLsurfaceFormat::writeShell
static void writeShell(Ostream &, const pointField &, const Face &)
Write Face (ASCII)
Definition: STLsurfaceFormat.C:34
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::fileFormats::STLsurfaceFormat::STLsurfaceFormat
STLsurfaceFormat(const STLsurfaceFormat< Face > &)
Disallow default bitwise copy construct.
STLsurfaceFormat.C
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::fileFormats::STLsurfaceFormat::operator=
void operator=(const STLsurfaceFormat< Face > &)
Disallow default bitwise assignment.
Foam::fileFormats::STLsurfaceFormat::New
static autoPtr< MeshedSurface< Face > > New(const fileName &name)
Read file and return surface.
Definition: STLsurfaceFormat.H:100
Foam::fileFormats::STLsurfaceFormat::writeAscii
static void writeAscii(const fileName &, const MeshedSurfaceProxy< Face > &)
Write surface mesh components by proxy (as ASCII)
Definition: STLsurfaceFormat.C:192
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::MeshedSurface
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
Definition: MeshedSurface.H:72
Foam::fileFormats::STLsurfaceFormat::write
virtual void write(const fileName &name) const
Write object.
Definition: STLsurfaceFormat.H:156
Foam::fileFormats::STLsurfaceFormat::write
static void write(const fileName &, const MeshedSurfaceProxy< Face > &)
Write surface mesh components by proxy.
Definition: STLsurfaceFormat.C:428
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
MeshedSurface.H