OBJstream.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) 2012-2015 OpenFOAM Foundation
9 Copyright (C) 2017-2021 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::OBJstream
29
30Description
31 OFstream that keeps track of vertices
32
33SourceFiles
34 OBJstream.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef OBJstream_H
39#define OBJstream_H
40
41#include "OFstream.H"
42#include "point.H"
43#include "edge.H"
44#include "face.H"
45#include "triPointRef.H"
46
47// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48
49namespace Foam
50{
51
52// Forward Declarations
53class treeBoundBox;
54
55/*---------------------------------------------------------------------------*\
56 Class OBJstream Declaration
57\*---------------------------------------------------------------------------*/
59class OBJstream
60:
61 public OFstream
62{
63 // Private Data
64
65 bool startOfLine_;
66
67 label nVertices_;
68
69
70 // Private Member Functions
71
72 void writeAndCheck(const char c);
73
74public:
75
76 //- Declare type-name (with debug switch)
77 ClassName("OBJstream");
78
79
80 // Constructors
81
82 //- Construct from pathname
83 explicit OBJstream
84 (
85 const fileName& pathname,
86 IOstreamOption streamOpt = IOstreamOption()
87 );
88
89 //- Construct from pathname
91 (
92 const fileName& pathname,
96 )
97 :
98 OBJstream(pathname, IOstreamOption(fmt, ver, cmp))
99 {}
100
101
102 //- Destructor
103 ~OBJstream() = default;
104
105
106 // Member Functions
107
108 // Access
109
110 //- Return the number of vertices written
111 label nVertices() const
112 {
113 return nVertices_;
114 }
115
116
117 // Ostream implementation
118
119 //- Inherit write from Ostream
120 using Ostream::write;
121
122 //- Write character
123 virtual Ostream& write(const char c);
124
125 //- Write character string
126 virtual Ostream& write(const char* str);
127
128 //- Write word
129 virtual Ostream& write(const word& str);
130
131 //- Write string
132 virtual Ostream& write(const string& str);
133
134 //- Write std::string surrounded by quotes.
135 // Optional write without quotes.
136 virtual Ostream& writeQuoted
137 (
138 const std::string& str,
139 const bool quoted=true
140 );
141
142
143 // Direct write functionality
144
145 //- Write point
146 Ostream& write(const point& pt);
147
148 //- Write point and vector normal ('vn')
149 Ostream& write(const point& pt, const vector& n);
150
151 //- Write edge as points and line
152 Ostream& write(const edge& e, const UList<point>& points);
153
154 //- Write line
155 Ostream& write(const linePointRef& ln);
156
157 //- Write line with points and vector normals ('vn')
159 (
160 const linePointRef& ln,
161 const vector& n0,
162 const vector& n1
163 );
164
165 //- Write triangle as points and lines/filled-polygon
166 Ostream& write(const triPointRef& f, const bool lines = true);
167
168 //- Write face as points and lines/filled-polygon
170 (
171 const face& f,
172 const UList<point>& points,
173 const bool lines = true
174 );
175
176 //- Write patch faces as points and lines/filled-polygon
178 (
179 const UList<face>& faces,
180 const pointField& points,
181 const bool lines = true
182 );
183
184 //- Write edges as points and lines.
185 // Optionally eliminate unused points.
187 (
188 const UList<edge>& edges,
189 const UList<point>& points,
190 const bool compact = false
191 );
192
193 //- Write tree-bounding box as lines/filled-polygons
195 (
196 const treeBoundBox& bb,
197 const bool lines = true
198 );
199};
200
201
202// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203
204} // End namespace Foam
205
206// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207
208#endif
209
210// ************************************************************************* //
label n
Representation of a major/minor version number.
The IOstreamOption is a simple container for options an IOstream can normally have.
streamFormat
Data format (ascii | binary)
compressionType
Compression treatment (UNCOMPRESSED | COMPRESSED)
@ UNCOMPRESSED
compression = false
static const versionNumber currentVersion
The current version number (2.0)
OFstream that keeps track of vertices.
Definition: OBJstream.H:61
~OBJstream()=default
Destructor.
label nVertices() const
Return the number of vertices written.
Definition: OBJstream.H:110
virtual Ostream & writeQuoted(const std::string &str, const bool quoted=true)
Write std::string surrounded by quotes.
Definition: OBJstream.C:108
ClassName("OBJstream")
Declare type-name (with debug switch)
OBJstream(const fileName &pathname, IOstreamOption::streamFormat fmt, IOstreamOption::versionNumber ver=IOstreamOption::currentVersion, IOstreamOption::compressionType cmp=IOstreamOption::UNCOMPRESSED)
Construct from pathname.
Definition: OBJstream.H:90
Output to file stream, using an OSstream.
Definition: OFstream.H:57
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:66
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
A class for handling file names.
Definition: fileName.H:76
virtual bool write()
Write the output fields.
A line primitive.
Definition: line.H:68
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:89
A triangle primitive used to calculate face normals and swept volumes.
Definition: triangle.H:80
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition: className.H:67
const pointField & points
Namespace for OpenFOAM.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: MSwindows.C:933
runTime write()
labelList f(nPoints)
volScalarField & e
Definition: createFields.H:11