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-2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::fileFormats::TRIReader
29
30Description
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
39SourceFiles
40 TRIReader.C
41
42\*---------------------------------------------------------------------------*/
43
44#ifndef TRIReader_H
45#define TRIReader_H
46
47#include "STLpoint.H"
48#include "labelList.H"
49#include "surfaceFormatsCore.H"
50
51// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52
53namespace Foam
54{
55namespace fileFormats
56{
57
58/*---------------------------------------------------------------------------*\
59 Class fileFormats::TRIReader Declaration
60\*---------------------------------------------------------------------------*/
62class TRIReader
63:
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
88public:
89
90 // Constructors
91
92 //- Read from file, filling in the information
93 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 sorted
116 bool sorted() const
117 {
118 return sorted_;
119 }
120
121 //- Return full access to the points
123 {
124 return points_;
125 }
126
127 //- Return full access to the zones
129 {
130 return zoneIds_;
131 }
132
133 //- The list of solid names in the order of their first appearance
135 {
136 return names_;
137 }
138
139 //- The list of zone sizes in the order of their first appearance
141 {
142 return sizes_;
143 }
144};
145
146
147// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148
149} // End namespace fileFormats
150} // End namespace Foam
151
152// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153
154#endif
155
156// ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
TRI (triangle) file reader.
Definition: TRIReader.H:64
label mergePointsMap(labelList &pointMap) const
Calculate merge points mapping, return old to new pointMap.
Definition: TRIReader.C:195
bool sorted() const
File read was already sorted.
Definition: TRIReader.H:115
~TRIReader()=default
Destructor.
List< STLpoint > & points()
Return full access to the points.
Definition: TRIReader.H:121
void clear()
Flush all values.
Definition: TRIReader.C:184
List< label > & sizes()
The list of zone sizes in the order of their first appearance.
Definition: TRIReader.H:139
List< word > & names()
The list of solid names in the order of their first appearance.
Definition: TRIReader.H:133
List< label > & zoneIds()
Return full access to the zones.
Definition: TRIReader.H:127
A collection of helper functions for reading/writing surface formats.
A class for handling file names.
Definition: fileName.H:76
Namespace for OpenFOAM.