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-2018 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  curveStyleNo CurveStyleNo;
85 
86 
87  public:
88 
89 
90  // Constructors
91 
92  //- Construct given a curveStyleNo
93  curveStyle(const curveStyleNo csn)
94  :
95  CurveStyleNo(csn)
96  {}
97 
98  //- Construct from Istream
99  curveStyle(Istream& is)
100  :
101  CurveStyleNo(curveStyleNo(readInt(is)))
102  {}
103 
104 
105  // Ostream operator
107  friend Ostream& operator<<(Ostream& os, const curveStyle& cs)
108  {
109  os << int(cs.CurveStyleNo);
110  return os;
111  }
112  };
113 
114 
115 private:
116 
117  // private data
118 
119  string name_;
120  curveStyle style_;
121 
122 
123 public:
124 
125  // Constructors
126 
127  //- Construct as interpolation of an existing curve
128  // curve(const curve&, const label);
129 
130  //- Construct from name, style and size
131  curve
132  (
133  const string& name,
134  const curveStyle& style,
135  const label l
136  );
137 
138  //- Construct from the components
139  curve
140  (
141  const string&,
142  const curveStyle&,
143  const scalarField& y
144  );
146  autoPtr<curve> clone() const
147  {
148  return autoPtr<curve>(new curve(*this));
149  }
150 
151 
152  // Member functions
153 
154  // Access
156  const string& name() const
157  {
158  return name_;
159  }
161  const curveStyle& style() const
162  {
163  return style_;
164  }
165 
166 
167  // Friend functions
168 
169  //- Gradient of the curve
170  // friend curve grad(const curve&);
171 
172 
173  // Ostream operator
174 
175  friend Ostream& operator<<(Ostream&, const curve&);
176 };
177 
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 } // End namespace Foam
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 #endif
186 
187 // ************************************************************************* //
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:92
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:106
Specialisations of Field<T> for scalar, vector and tensor.
const curveStyle & style() const
Definition: curve.H:160
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:155
autoPtr< curve > clone() const
Definition: curve.H:145