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 | Copyright (C) 2012-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::OBJstream
26 
27 Description
28  OFstream which keeps track of vertices
29 
30 SourceFiles
31  OBJstream.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef OBJstream_H
36 #define OBJstream_H
37 
38 #include "OFstream.H"
39 #include "point.H"
40 #include "edge.H"
41 #include "face.H"
42 #include "triPointRef.H"
43 #include "linePointRef.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class OBJstream Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 class OBJstream
55 :
56  public OFstream
57 {
58  // Private data
59 
60  bool startOfLine_;
61 
62  label nVertices_;
63 
64 
65  // Private Member Functions
66 
67  void writeAndCheck(const char);
68 
69 public:
70 
71  // Declare name of the class and its debug switch
72  ClassName("OBJstream");
73 
74 
75  // Constructors
76 
77  //- Construct from pathname
78  OBJstream
79  (
80  const fileName& pathname,
84  );
85 
86 
87  //- Destructor
88  ~OBJstream();
89 
90 
91  // Member functions
92 
93  // Access
94 
95  //- Return the number of vertices written
96  label nVertices() const
97  {
98  return nVertices_;
99  }
100 
101 
102  // Ostream implementation
103 
104  //- Inherit write from Ostream
105  using Ostream::write;
106 
107  //- Write character
108  virtual Ostream& write(const char);
109 
110  //- Write character string
111  virtual Ostream& write(const char*);
112 
113  //- Write word
114  virtual Ostream& write(const word&);
115 
116  virtual Ostream& write(const string&);
117 
118  //- Write std::string surrounded by quotes.
119  // Optional write without quotes.
120  virtual Ostream& writeQuoted
121  (
122  const std::string&,
123  const bool quoted=true
124  );
125 
126 
127  // Direct write functionality
128 
129  //- Write point
130  Ostream& write(const point&);
131 
132  //- Write point and vector normal ('vn')
133  Ostream& write(const point&, const vector&);
134 
135  //- Write edge as points with line
136  Ostream& write(const edge&, const UList<point>&);
137 
138  //- Write line
139  Ostream& write(const linePointRef&);
140 
141  //- Write line with points and vector normals ('vn')
142  Ostream& write
143  (
144  const linePointRef&,
145  const vector& n0,
146  const vector& n1
147  );
148 
149  //- Write triangle as points with lines or filled polygon
150  Ostream& write(const triPointRef&, const bool lines = true);
151 
152  //- Write face as points with lines or filled polygon
153  Ostream& write
154  (
155  const face&,
156  const UList<point>&,
157  const bool lines = true
158  );
159 
160  //- Write patch as points and faces with lines or filled polygons
161  Ostream& write
162  (
163  const faceList&,
164  const pointField&,
165  const bool lines = true
166  );
167 
168 };
169 
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 } // End namespace Foam
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 #endif
178 
179 // ************************************************************************* //
A triangle primitive used to calculate face normals and swept volumes.
Definition: triangle.H:58
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A line primitive.
Definition: line.H:56
A class for handling file names.
Definition: fileName.H:69
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
Output to file stream.
Definition: OFstream.H:82
versionNumber version() const
Return the stream version.
Definition: IOstream.H:399
virtual Ostream & write(const char)
Write character.
Definition: OBJstream.C:82
ClassName("OBJstream")
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:58
A class for handling words, derived from string.
Definition: word.H:59
streamFormat
Enumeration for the format of data in the stream.
Definition: IOstream.H:86
streamFormat format() const
Return current stream format.
Definition: IOstream.H:377
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:61
compressionType
Enumeration for the format of data in the stream.
Definition: IOstream.H:193
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
OFstream which keeps track of vertices.
Definition: OBJstream.H:53
OBJstream(const fileName &pathname, streamFormat format=ASCII, versionNumber version=currentVersion, compressionType compression=UNCOMPRESSED)
Construct from pathname.
Definition: OBJstream.C:61
compressionType compression() const
Return the stream compression.
Definition: IOstream.H:416
static const versionNumber currentVersion
Current version number.
Definition: IOstream.H:206
Version number type.
Definition: IOstream.H:96
~OBJstream()
Destructor.
Definition: OBJstream.C:76
virtual Ostream & write(const token &)=0
Write next token to stream.
virtual Ostream & writeQuoted(const std::string &, const bool quoted=true)
Write std::string surrounded by quotes.
Definition: OBJstream.C:150
label nVertices() const
Return the number of vertices written.
Definition: OBJstream.H:95
Namespace for OpenFOAM.