TRIReader.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011 OpenFOAM Foundation
9  Copyright (C) 2017-2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::fileFormats::TRIReader
29 
30 Description
31  TRI (triangle) file reader.
32 
33  For TRI format (eg, AC3D).
34  Each input line has 9 floats (3 points, each 3 floats) followed by hex
35  colour. The colour is used to build regions numbered from 0 upwards.
36 
37  Reading and stitching similar to the STLReader.
38 
39 SourceFiles
40  TRIReader.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef Foam_TRIReader_H
45 #define Foam_TRIReader_H
46 
47 #include "STLpoint.H"
48 #include "labelList.H"
49 #include "surfaceFormatsCore.H"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 namespace fileFormats
56 {
57 
58 /*---------------------------------------------------------------------------*\
59  Class fileFormats::TRIReader Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 class TRIReader
63 :
64  public surfaceFormatsCore
65 {
66  // Private Data
67 
68  bool sorted_;
69 
70  //- The points supporting the facets
71  List<STLpoint> points_;
72 
73  //- The zones associated with the faces
74  List<label> zoneIds_;
75 
76  //- The zone names, in the order of their first appearance
77  List<word> names_;
78 
79  //- The solid count, in the order of their first appearance
80  List<label> sizes_;
81 
82 
83  // Private Member Functions
84 
85  bool readFile(const fileName& filename);
86 
87 
88 public:
89 
90  // Constructors
91 
92  //- Read from file, filling in the information
93  explicit TRIReader(const fileName& filename);
94 
95 
96  //- Destructor
97  ~TRIReader() = default;
98 
99 
100  // Member Functions
101 
102  //- Flush all values
103  void clear();
104 
105  //- Calculate merge points mapping, return old to new pointMap.
106  // Use merge tolerance as per STL ascii
107  // \return number of unique points
108  label mergePointsMap(labelList& pointMap) const;
109 
110  //- Calculate merge points mapping, return old to new pointMap.
111  // \return number of unique points
112  label mergePointsMap(const scalar mergeTol, labelList& pointMap) const;
113 
114 
115  //- File read was already in sorted order
116  bool is_sorted() const noexcept { return sorted_; }
117 
118  //- Return full access to the points
119  List<STLpoint>& points() noexcept { return points_; }
120 
121  //- Return full access to the zones
122  List<label>& zoneIds() noexcept { return zoneIds_; }
123 
124  //- The list of solid names in the order of their first appearance
125  List<word>& names() noexcept { return names_; }
126 
127  //- The list of zone sizes in the order of their first appearance
128  List<label>& sizes() noexcept { return sizes_; }
129 };
130 
131 
132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 } // End namespace fileFormats
135 } // End namespace Foam
136 
137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139 #endif
140 
141 // ************************************************************************* //
List< word > & names() noexcept
The list of solid names in the order of their first appearance.
Definition: TRIReader.H:148
A class for handling file names.
Definition: fileName.H:72
~TRIReader()=default
Destructor.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
List< label > & zoneIds() noexcept
Return full access to the zones.
Definition: TRIReader.H:143
TRIReader(const fileName &filename)
Read from file, filling in the information.
Definition: TRIReader.C:161
List< label > & sizes() noexcept
The list of zone sizes in the order of their first appearance.
Definition: TRIReader.H:153
bool is_sorted() const noexcept
File read was already in sorted order.
Definition: TRIReader.H:133
const direction noexcept
Definition: Scalar.H:258
TRI (triangle) file reader.
Definition: TRIReader.H:57
List< STLpoint > & points() noexcept
Return full access to the points.
Definition: TRIReader.H:138
label mergePointsMap(labelList &pointMap) const
Calculate merge points mapping, return old to new pointMap.
Definition: TRIReader.C:188
void clear()
Flush all values.
Definition: TRIReader.C:177
A collection of helper functions for reading/writing surface formats.
Namespace for OpenFOAM.