curve.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 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::curve
26 
27 Description
28  A single curve in a graph.
29 
30 SourceFiles
31  curve.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef curve_H
36 #define curve_H
37 
38 #include "string.H"
39 #include "primitiveFields.H"
40 #include "autoPtr.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 // Forward declaration of friend functions and operators
48 
49 class curve;
50 Ostream& operator<<(Ostream&, const curve&);
51 
52 
53 /*---------------------------------------------------------------------------*\
54  Class curve Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 class curve
58 :
59  public scalarField
60 {
61 
62 public:
63 
64  //- The style (line, symbol, etc) of a curve
65  class curveStyle
66  {
67 
68  public:
69 
70  //- Enumeration definitions
71  enum curveStyleNo
72  {
78  };
79 
80 
81  private:
82 
83  // Private Data
84 
85  curveStyleNo CurveStyleNo;
86 
87 
88  public:
89 
90 
91  // Constructors
92 
93  //- Construct given a curveStyleNo
94  curveStyle(const curveStyleNo csn)
95  :
96  CurveStyleNo(csn)
97  {}
98 
99  //- Construct from Istream
100  curveStyle(Istream& is)
101  :
102  CurveStyleNo(curveStyleNo(readInt(is)))
103  {}
104 
105 
106  // Ostream operator
108  friend Ostream& operator<<(Ostream& os, const curveStyle& cs)
109  {
110  os << int(cs.CurveStyleNo);
111  return os;
112  }
113  };
114 
115 
116 private:
117 
118  // Private Data
119 
120  string name_;
121  curveStyle style_;
122 
123 
124 public:
125 
126  // Constructors
127 
128  //- Construct as interpolation of an existing curve
129  // curve(const curve&, const label);
130 
131  //- Construct from name, style and size
132  curve
133  (
134  const string& name,
135  const curveStyle& style,
136  const label l
137  );
138 
139  //- Construct from the components
140  curve
141  (
142  const string&,
143  const curveStyle&,
144  const scalarField& y
145  );
147  autoPtr<curve> clone() const
148  {
149  return autoPtr<curve>(new curve(*this));
150  }
151 
152 
153  // Member Functions
154 
155  // Access
157  const string& name() const
158  {
159  return name_;
160  }
162  const curveStyle& style() const
163  {
164  return style_;
165  }
166 
167 
168  // Friend Functions
169 
170  //- Gradient of the curve
171  // friend curve grad(const curve&);
172 
173 
174  // Ostream operator
175 
176  friend Ostream& operator<<(Ostream&, const curve&);
177 };
178 
179 
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 
182 } // End namespace Foam
183 
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 
186 #endif
187 
188 // ************************************************************************* //
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
int readInt(Istream &)
Definition: intIO.C:31
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
scalar y
The style (line, symbol, etc) of a curve.
Definition: curve.H:64
curve(const string &name, const curveStyle &style, const label l)
Construct as interpolation of an existing curve.
Definition: curve.C:32
A single curve in a graph.
Definition: curve.H:56
curveStyleNo
Enumeration definitions.
Definition: curve.H:70
curveStyle(const curveStyleNo csn)
Construct given a curveStyleNo.
Definition: curve.H:93
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
friend Ostream & operator<<(Ostream &os, const curveStyle &cs)
Definition: curve.H:107
Specialisations of Field<T> for scalar, vector and tensor.
const curveStyle & style() const
Definition: curve.H:161
Ostream & operator<<(Ostream &, const ensightPart &)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Namespace for OpenFOAM.
const string & name() const
Definition: curve.H:156
autoPtr< curve > clone() const
Definition: curve.H:146