STLAsciiParse.H
Go to the documentation of this file.
1/*--------------------------------*- C++ -*----------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2018 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::Detail::STLAsciiParse
28
29Description
30 Internal class used when parsing STL ASCII format
31
32SourceFiles
33 STLAsciiParse.C
34
35\*---------------------------------------------------------------------------*/
36
37#ifndef STLAsciiParse_H
38#define STLAsciiParse_H
39
40#include "DynamicList.H"
41#include "HashTable.H"
42#include "STLpoint.H"
43
44// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46namespace Foam
47{
48namespace Detail
49{
50
51/*---------------------------------------------------------------------------*\
52 Class Detail::STLAsciiParse Declaration
53\*---------------------------------------------------------------------------*/
55class STLAsciiParse
56{
57protected:
58
59 // Protected Data
61 bool sorted_;
62 label groupId_; // The current solid group
63 label lineNum_;
64
65 //- The number of local points on the current facet
66 int nFacetPoints_;
67
68 //- Current vertex component when reading 'vertex'
69 int nVertexCmpt_;
70
71 //- Scratch space for reading 'vertex'
79
80
81 // Protected Member Functions
82
83 //- Action when entering 'solid'
84 inline void beginSolid(word solidName);
85
86 //- Action when entering 'facet'
87 inline void beginFacet();
88
89 //- Reset vertex component to zero
90 inline void resetVertex();
91
92 //- Add next vertex component. On each third call, adds the point.
93 // \return true when point has been added (on the last component)
94 inline bool addVertexComponent(float val);
95
96 //- Add next vertex component. On each third call, adds the point.
97 // \return true when point has been added (on the last component)
98 inline bool addVertexComponent(const char* text);
99
100 //- Action on 'endfacet'
101 inline void endFacet();
102
103
104 //- No copy construct
105 STLAsciiParse(const STLAsciiParse&) = delete;
106
107 //- No copy assignment
108 void operator=(const STLAsciiParse&) = delete;
109
110
111public:
112
113 // Constructors
114
115 //- From input stream and the approximate number of vertices in the STL
116 inline STLAsciiParse(const label approxNpoints);
117
118
119 // Member Functions
120
121 //- Reset stored values
122 inline void clear();
123
124 //- Do all the solid groups appear in order?
125 inline bool sorted() const;
126
127 //- A list of unstitched triangle points
129
130 //- A list of facet IDs (group IDs)
131 //- corresponds to the number of triangles
132 inline DynamicList<label>& facets();
133
134 //- Solid names in the order of their appearance.
135 inline DynamicList<word>& names();
136
137 //- Solid sizes in the order of their appearance.
138 inline DynamicList<label>& sizes();
139};
140
141
142// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143
144} // End namespace Detail
145} // End namespace Foam
146
147// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148
149#include "STLAsciiParseI.H"
150
151// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152
153#endif
154
155// ************************************************************************* //
Internal class used when parsing STL ASCII format.
Definition: STLAsciiParse.H:55
DynamicList< label > facets_
Definition: STLAsciiParse.H:74
void beginFacet()
Action when entering 'facet'.
bool sorted() const
Do all the solid groups appear in order?
DynamicList< STLpoint > & points()
A list of unstitched triangle points.
HashTable< label > nameLookup_
Definition: STLAsciiParse.H:77
void beginSolid(word solidName)
Action when entering 'solid'.
bool addVertexComponent(float val)
Add next vertex component. On each third call, adds the point.
STLpoint currVertex_
Scratch space for reading 'vertex'.
Definition: STLAsciiParse.H:71
int nFacetPoints_
The number of local points on the current facet.
Definition: STLAsciiParse.H:65
DynamicList< word > names_
Definition: STLAsciiParse.H:75
void endFacet()
Action on 'endfacet'.
STLAsciiParse(const STLAsciiParse &)=delete
No copy construct.
DynamicList< STLpoint > points_
Definition: STLAsciiParse.H:73
DynamicList< label > sizes_
Definition: STLAsciiParse.H:76
int nVertexCmpt_
Current vertex component when reading 'vertex'.
Definition: STLAsciiParse.H:68
void clear()
Reset stored values.
void resetVertex()
Reset vertex component to zero.
DynamicList< label > & sizes()
Solid sizes in the order of their appearance.
void operator=(const STLAsciiParse &)=delete
No copy assignment.
DynamicList< word > & names()
Solid names in the order of their appearance.
DynamicList< label > & facets()
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
A HashTable similar to std::unordered_map.
Definition: HashTable.H:123
A vertex point or facet normal representation for STL files.
Definition: STLpoint.H:52
A class for handling words, derived from Foam::string.
Definition: word.H:68
Namespace for OpenFOAM.