STLsurfaceFormatCore.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::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  //- Disallow default bitwise copy construct
78 
79  //- Disallow default bitwise assignment
80  void operator=(const STLsurfaceFormatCore&);
81 
82  //- Determine the file type
83  static int detectBINARY(const fileName&);
84 
85  //- Read ASCII
86  bool readASCII(istream&, const off_t);
87 
88  //- Read BINARY
89  bool readBINARY(istream&, const off_t);
90 
91 
92 public:
93 
94  // Static Data
95 
96  //- The number of bytes in the STL binary header
97  static const unsigned int headerSize = 80;
98 
99 
100  // Static Member Functions
101 
102  //- Write "STL binary file" and number of triangles to stream
103  static void writeHeaderBINARY(ostream&, unsigned int);
104 
105 
106  // Constructors
107 
108  //- Read from file, filling in the information
110 
111 
112  //- Destructor
114 
115 
116  // Member Functions
117 
118  //- File read was already sorted
119  bool sorted() const
120  {
121  return sorted_;
122  }
123 
124  //- Flush all values
125  void clear()
126  {
127  sorted_ = true;
128  points_.clear();
129  zoneIds_.clear();
130  names_.clear();
131  sizes_.clear();
132  }
133 
134  //- Return full access to the points
135  pointField& points()
136  {
137  return points_;
138  }
139 
140  //- Return full access to the zoneIds
142  {
143  return zoneIds_;
144  }
145 
146  //- The list of solid names in the order of their first appearance
147  List<word>& names()
148  {
149  return names_;
150  }
151 
152  //- The list of solid sizes in the order of their first appearance
153  List<label>& sizes()
154  {
155  return sizes_;
156  }
157 };
158 
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 } // End namespace fileFormats
163 } // End namespace Foam
164 
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 
167 #endif
168 
169 // ************************************************************************* //
A class for handling file names.
Definition: fileName.H:69
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:124
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.