All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
STLsurfaceFormatCore.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-2019 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::STLsurfaceFormatCore
26 
27 Description
28  Internal class used by the STLsurfaceFormat
29 
30 SourceFiles
31  STLsurfaceFormatCore.C
32  STLsurfaceFormatASCII.L
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef STLsurfaceFormatCore_H
37 #define STLsurfaceFormatCore_H
38 
39 #include "STLtriangle.H"
40 #include "triFace.H"
41 #include "IFstream.H"
42 #include "Ostream.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 namespace fileFormats
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class STLsurfaceFormatCore Declaration
53 \*---------------------------------------------------------------------------*/
54 
56 {
57  // Private Data
58 
59  bool sorted_;
60 
61  //- The points supporting the facets
62  pointField points_;
63 
64  //- The zones associated with the faces
65  List<label> zoneIds_;
66 
67  //- The solid names, in the order of their first appearance
68  List<word> names_;
69 
70  //- The solid count, in the order of their first appearance
71  List<label> sizes_;
72 
73 
74  // Private Member Functions
75 
76  //- Determine the file type
77  static int detectBINARY(const fileName&);
78 
79  //- Read ASCII
80  bool readASCII(istream&, const off_t);
81 
82  //- Read BINARY
83  bool readBINARY(istream&, const off_t);
84 
85 
86 public:
87 
88  // Static Data
89 
90  //- The number of bytes in the STL binary header
91  static const unsigned int headerSize = 80;
92 
93 
94  // Static Member Functions
95 
96  //- Write "STL binary file" and number of triangles to stream
97  static void writeHeaderBINARY(ostream&, unsigned int);
98 
99 
100  // Constructors
101 
102  //- Read from file, filling in the information
104 
105  //- Disallow default bitwise copy construction
107 
108 
109  //- Destructor
111 
112 
113  // Member Functions
114 
115  //- File read was already sorted
116  bool sorted() const
117  {
118  return sorted_;
119  }
120 
121  //- Flush all values
122  void clear()
123  {
124  sorted_ = true;
125  points_.clear();
126  zoneIds_.clear();
127  names_.clear();
128  sizes_.clear();
129  }
130 
131  //- Return full access to the points
132  pointField& points()
133  {
134  return points_;
135  }
136 
137  //- Return full access to the zoneIds
139  {
140  return zoneIds_;
141  }
142 
143  //- The list of solid names in the order of their first appearance
144  List<word>& names()
145  {
146  return names_;
147  }
148 
149  //- The list of solid sizes in the order of their first appearance
150  List<label>& sizes()
151  {
152  return sizes_;
153  }
154 
155 
156  // Member Operators
157 
158  //- Disallow default bitwise assignment
159  void operator=(const STLsurfaceFormatCore&) = delete;
160 };
161 
162 
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 
165 } // End namespace fileFormats
166 } // End namespace Foam
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 #endif
171 
172 // ************************************************************************* //
STLsurfaceFormatCore(const fileName &)
Read from file, filling in the information.
A class for handling file names.
Definition: fileName.H:79
List< label > & sizes()
The list of solid sizes in the order of their first appearance.
static void writeHeaderBINARY(ostream &, unsigned int)
Write "STL binary file" and number of triangles to stream.
Internal class used by the STLsurfaceFormat.
List< word > & names()
The list of solid names in the order of their first appearance.
pointField & points()
Return full access to the points.
void clear()
Clear the list, i.e. set size to zero.
Definition: ListI.H:125
void operator=(const STLsurfaceFormatCore &)=delete
Disallow default bitwise assignment.
List< label > & zoneIds()
Return full access to the zoneIds.
bool sorted() const
File read was already sorted.
static const unsigned int headerSize
The number of bytes in the STL binary header.
Namespace for OpenFOAM.