libMesh
stl_io.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2025 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_STL_IO_H
21 #define LIBMESH_STL_IO_H
22 
23 // Local includes
24 #include "libmesh/libmesh_common.h"
25 #include "libmesh/mesh_output.h"
26 #include "libmesh/mesh_input.h"
27 
28 // C++ includes
29 #include <map>
30 
31 namespace libMesh
32 {
33 
34 // Forward declarations
35 class MeshBase;
36 enum ElemType : int;
37 
45 class STLIO : public MeshInput<MeshBase>,
46  public MeshOutput<MeshBase>
47 {
48 public:
49 
54  explicit
55  STLIO (const MeshBase &);
56 
61  explicit
62  STLIO (MeshBase &);
63 
68  virtual void write (const std::string &) override;
69 
73  virtual void read (const std::string & mesh_file) override;
74 
79  virtual void read_ascii (std::istream & input);
80 
88  virtual void read_binary (std::istream & input,
89  std::size_t input_size = 0);
90 
94  const std::string & name () { return _name; }
95 
99  virtual void set_name (const std::string & name) { _name = name; }
100 
106 
107  void set_subdivide_second_order(bool subdivide)
108  { _subdivide_second_order = subdivide; }
109 
110 private:
111 
115  std::unique_ptr<std::istream> open_file(const std::string & filename);
116 
121 
122  std::string _name;
123 };
124 
125 } // namespace libMesh
126 
127 
128 #endif // LIBMESH_STL_IO_H
ElemType
Defines an enum for geometric element types.
std::unique_ptr< std::istream > open_file(const std::string &filename)
Helper to open possibly-zipped files.
Definition: stl_io.C:223
This class implements reading and writing triangle meshes in the STL format.
Definition: stl_io.h:45
virtual void set_name(const std::string &name)
This method sets a name to write.
Definition: stl_io.h:99
virtual void read(const std::string &mesh_file) override
This method implements reading a mesh from a specified file.
Definition: stl_io.C:165
This class defines an abstract interface for Mesh output.
Definition: mesh_output.h:53
The libMesh namespace provides an interface to certain functionality in the library.
This is the MeshBase class.
Definition: mesh_base.h:75
virtual void read_ascii(std::istream &input)
This method implements reading a mesh from a specified ASCII input stream.
Definition: stl_io.C:257
virtual void write(const std::string &) override
This method implements writing a mesh to a specified file.
Definition: stl_io.C:81
This class defines an abstract interface for Mesh input.
Definition: mesh_base.h:57
bool _subdivide_second_order
Flag to subdivide second order elements.
Definition: stl_io.h:120
bool subdivide_second_order()
Flag indicating whether or not to subdivide second order elements when writing.
Definition: stl_io.h:105
virtual void read_binary(std::istream &input, std::size_t input_size=0)
This method implements reading a mesh from a specified binary input stream.
Definition: stl_io.C:434
std::string _name
Definition: stl_io.h:122
STLIO(const MeshBase &)
Constructor.
Definition: stl_io.C:64
void set_subdivide_second_order(bool subdivide)
Definition: stl_io.h:107
const std::string & name()
This method gets a name after a set or an ASCII read.
Definition: stl_io.h:94
void ErrorVector unsigned int
Definition: adjoints_ex3.C:360