Loading...
Searching...
No Matches
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-2023 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 Foam_STLAsciiParse_H
38#define Foam_STLAsciiParse_H
39
40#include "DynamicList.H"
41#include "HashTable.H"
42#include "STLpoint.H"
43
44// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46namespace Foam
47{
48namespace Detail
49{
51/*---------------------------------------------------------------------------*\
52 Class Detail::STLAsciiParse Declaration
53\*---------------------------------------------------------------------------*/
54
55class STLAsciiParse
57protected:
59 // Protected Data
60
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'
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 //- Construct with the estimated number of triangles in the STL
116 inline STLAsciiParse(const label nTrisEstimated);
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 bool is_sorted() const noexcept { return sorted_; }
126
127 //- A list of unstitched triangle points
129
130 //- A list of facet IDs (group IDs)
131 //- corresponds to the number of triangles
133
134 //- Solid names in the order of their appearance.
136
137 //- Solid sizes in the order of their appearance.
138 DynamicList<label>& sizes() noexcept { return sizes_; }
139};
140
141
142// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143
144} // End namespace Detail
145} // End namespace Foam
146
147// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148
149#include "STLAsciiParseI.H"
151// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152
153#endif
154
155// ************************************************************************* //
DynamicList< label > facets_
DynamicList< word > & names() noexcept
Solid names in the order of their appearance.
void beginFacet()
Action when entering 'facet'.
DynamicList< label > & sizes() noexcept
Solid sizes in the order of their appearance.
DynamicList< STLpoint > & points() noexcept
A list of unstitched triangle points.
HashTable< label > nameLookup_
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'.
int nFacetPoints_
The number of local points on the current facet.
DynamicList< word > names_
void endFacet()
Action on 'endfacet'.
STLAsciiParse(const STLAsciiParse &)=delete
No copy construct.
DynamicList< label > & facets() noexcept
A list of facet IDs (group IDs) corresponds to the number of triangles.
bool is_sorted() const noexcept
Do all the solid groups appear in order?
DynamicList< STLpoint > points_
DynamicList< label > sizes_
int nVertexCmpt_
Current vertex component when reading 'vertex'.
void clear()
Reset stored values.
void resetVertex()
Reset vertex component to zero.
void operator=(const STLAsciiParse &)=delete
No copy assignment.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
A HashTable similar to std::unordered_map.
Definition HashTable.H:124
A vertex point or facet normal representation for STL files.
Definition STLpoint.H:46
A class for handling words, derived from Foam::string.
Definition word.H:66
Implementation details for various OpenFOAM classes.
Definition zoneSubSet.C:30
Namespace for OpenFOAM.
const direction noexcept
Definition scalarImpl.H:265