EPANET  3.0
EPANET Development Project
curve.h
Go to the documentation of this file.
1 /* EPANET 3
2  *
3  * Copyright (c) 2016 Open Water Analytics
4  * Licensed under the terms of the MIT License (see the LICENSE file for details).
5  *
6  */
7 
10 
11 #ifndef CURVE_H_
12 #define CURVE_H_
13 
14 #include "Elements/element.h"
15 
16 #include <string>
17 #include <iostream>
18 #include <vector>
19 
26 
27 // NOTE: Curve data are stored in the user's original units.
28 //-----------------------------------------------------------------------------
29 
30 class Curve: public Element
31 {
32  public:
33 
34  // Curve type enumeration
35  enum CurveType {UNKNOWN, PUMP, EFFICIENCY, VOLUME, HEADLOSS};
36 
37  // Names of curve types
38  static const char* CurveTypeWords[];
39 
40  // Constructor/Destructor
41  Curve(std::string name_);
42  ~Curve();
43 
44  // Data provider methods
45  void setType(int curveType);
46  void addData(double x, double y);
47 
48  // Data retrieval methods
49  int size();
50  int curveType();
51  double x(int index);
52  double y(int index);
53  void findSegment(double xseg, double& slope, double& intercept);
54  double getYofX(double x);
55  double getXofY(double y);
56 
57  private:
58  CurveType type;
59  std::vector<double> xData;
60  std::vector<double> yData;
61 };
62 
63 //-----------------------------------------------------------------------------
64 // Inline Functions
65 //-----------------------------------------------------------------------------
66 inline void Curve::setType(int curveType)
67  { type = (CurveType)curveType; }
68 
69 inline void Curve::addData(double x, double y)
70  { xData.push_back(x); yData.push_back(y);}
71 
72 inline int Curve::size() { return xData.size(); }
73 
74 inline int Curve::curveType() { return (int)type; }
75 
76 inline double Curve::x(int i) { return xData.at(i); }
77 
78 inline double Curve::y(int i) { return yData.at(i); }
79 
80 #endif
Abstract parent class for all pipe network components.
Definition: element.h:19
Describes the Element class.
int index
index in array of elements
Definition: element.h:29
An ordered collection of x,y data pairs.
Definition: curve.h:30