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 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::Detail::STLAsciiParse
28 
29 Description
30  Internal class used when parsing STL ASCII format
31 
32 SourceFiles
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 
46 namespace Foam
47 {
48 namespace Detail
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class Detail::STLAsciiParse Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 class STLAsciiParse
56 {
57 protected:
58 
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'
73 
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 
111 public:
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
128  inline DynamicList<STLpoint>& 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 // ************************************************************************* //
Foam::Detail::STLAsciiParse::currVertex_
STLpoint currVertex_
Scratch space for reading 'vertex'.
Definition: STLAsciiParse.H:71
STLAsciiParseI.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::Detail::STLAsciiParse::clear
void clear()
Reset stored values.
Definition: STLAsciiParseI.H:147
Foam::Detail::STLAsciiParse::sizes
DynamicList< label > & sizes()
Solid sizes in the order of their appearance.
Definition: STLAsciiParseI.H:188
HashTable.H
Foam::Detail::STLAsciiParse::sizes_
DynamicList< label > sizes_
Definition: STLAsciiParse.H:76
Foam::DynamicList
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:55
Foam::Detail::STLAsciiParse::endFacet
void endFacet()
Action on 'endfacet'.
Definition: STLAsciiParseI.H:107
STLpoint.H
Foam::Detail::STLAsciiParse::facets_
DynamicList< label > facets_
Definition: STLAsciiParse.H:74
Foam::Detail::STLAsciiParse::sorted
bool sorted() const
Do all the solid groups appear in order?
Definition: STLAsciiParseI.H:164
Foam::Detail::STLAsciiParse
Internal class used when parsing STL ASCII format.
Definition: STLAsciiParse.H:54
Foam::Detail::STLAsciiParse::points_
DynamicList< STLpoint > points_
Definition: STLAsciiParse.H:73
Foam::Detail::STLAsciiParse::lineNum_
label lineNum_
Definition: STLAsciiParse.H:62
Foam::Detail::STLAsciiParse::facets
DynamicList< label > & facets()
Definition: STLAsciiParseI.H:176
Foam::Detail::STLAsciiParse::sorted_
bool sorted_
Definition: STLAsciiParse.H:60
Foam::Detail::STLAsciiParse::STLAsciiParse
STLAsciiParse(const STLAsciiParse &)=delete
No copy construct.
Foam::Detail::STLAsciiParse::resetVertex
void resetVertex()
Reset vertex component to zero.
Definition: STLAsciiParseI.H:70
Foam::Detail::STLAsciiParse::nVertexCmpt_
int nVertexCmpt_
Current vertex component when reading 'vertex'.
Definition: STLAsciiParse.H:68
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::Detail::STLAsciiParse::nameLookup_
HashTable< label > nameLookup_
Definition: STLAsciiParse.H:77
Foam::Detail::STLAsciiParse::points
DynamicList< STLpoint > & points()
A list of unstitched triangle points.
Definition: STLAsciiParseI.H:170
Foam::HashTable< label >
Foam::Detail::STLAsciiParse::nFacetPoints_
int nFacetPoints_
The number of local points on the current facet.
Definition: STLAsciiParse.H:65
Foam::Detail::STLAsciiParse::addVertexComponent
bool addVertexComponent(float val)
Add next vertex component. On each third call, adds the point.
Definition: STLAsciiParseI.H:76
Foam::Detail::STLAsciiParse::names
DynamicList< word > & names()
Solid names in the order of their appearance.
Definition: STLAsciiParseI.H:182
Foam::Detail::STLAsciiParse::groupId_
label groupId_
Definition: STLAsciiParse.H:61
Foam::Detail::STLAsciiParse::operator=
void operator=(const STLAsciiParse &)=delete
No copy assignment.
Foam::STLpoint
A vertex point or facet normal representation for STL files.
Definition: STLpoint.H:49
DynamicList.H
Foam::Detail::STLAsciiParse::beginSolid
void beginSolid(word solidName)
Action when entering 'solid'.
Definition: STLAsciiParseI.H:30
Foam::Detail::STLAsciiParse::beginFacet
void beginFacet()
Action when entering 'facet'.
Definition: STLAsciiParseI.H:63
Foam::Detail::STLAsciiParse::names_
DynamicList< word > names_
Definition: STLAsciiParse.H:75