FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 <OpenFOAM/triFace.H>
41 #include <OpenFOAM/IFstream.H>
42 #include <OpenFOAM/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
113 
115 
116 
117  // Member Functions
118 
119  //- File read was already sorted
120  bool sorted() const
121  {
122  return sorted_;
123  }
124 
125  //- Flush all values
126  void clear()
127  {
128  sorted_ = true;
129  points_.clear();
130  zoneIds_.clear();
131  names_.clear();
132  sizes_.clear();
133  }
134 
135  //- Return full access to the points
137  {
138  return points_;
139  }
140 
141  //- Return full access to the zoneIds
143  {
144  return zoneIds_;
145  }
146 
147  //- The list of solid names in the order of their first appearance
149  {
150  return names_;
151  }
152 
153  //- The list of solid sizes in the order of their first appearance
155  {
156  return sizes_;
157  }
158 };
159 
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 
163 } // End namespace fileFormats
164 } // End namespace Foam
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 #endif
169 
170 // ************************ vim: set sw=4 sts=4 et: ************************ //