VAPoR  0.1
Box.h
Go to the documentation of this file.
1 //************************************************************************
2 // *
3 // Copyright (C) 2011 *
4 // University Corporation for Atmospheric Research *
5 // All Rights Reserved *
6 // *
7 //************************************************************************/
8 //
9 // File: Box.h
10 //
11 // Author: Alan Norton
12 // National Center for Atmospheric Research
13 // PO 3000, Boulder, Colorado
14 //
15 // Date: April 2011
16 //
17 // Description: Defines the Box class
18 // This supports control of a 2D or 3D box-shaped region that can be
19 // rotated and changed over time.
20 //
21 #ifndef BOX_H
22 #define BOX_H
23 
24 namespace VAPoR {
25 #include <vapor/ParamsBase.h>
33 
34 class PARAMS_API Box : public ParamsBase {
35 public:
36 
37  Box();
38  static ParamsBase* CreateDefaultInstance() {return new Box();}
39 
44  int GetUserExtents(double extents[6], size_t timestep);
50  int GetUserExtents(float extents[6], size_t timestep);
56 
57  int GetLocalExtents(double extents[6], int timestep = -1);
63  int GetLocalExtents(float extents[6], int timestep = -1);
69  const vector<double>& GetLocalExtents() {
70  const vector<double> localExtents(6,0.);
71  return GetRootNode()->GetElementDouble(_extentsTag,localExtents);
72  }
78  int SetLocalExtents(const vector<double>& extents, int timestep = -1);
84  int SetLocalExtents(const double extents[6], int timestep = -1);
90  int SetLocalExtents(const float extents[6], int timestep = -1);
91 
95  const vector<double>& GetAngles(){
96  const vector<double> defaultAngles(3,0.);
97  return GetRootNode()->GetElementDouble(Box::_anglesTag,defaultAngles);
98  }
102  int GetAngles(double ang[3]){
103  const vector<double> defaultAngles(3,0.);
104  const vector<double>& angles = GetRootNode()->GetElementDouble(Box::_anglesTag,defaultAngles);
105  if (angles.size() != 3) return -1;
106  for (int i = 0; i<3;i++) ang[i]=angles[i];
107  return 0;
108  }
112  int GetAngles(float ang[3]){
113  const vector<double> defaultAngles(3,0.);
114  const vector<double>& angles = GetRootNode()->GetElementDouble(Box::_anglesTag,defaultAngles);
115  if (angles.size() != 3) return -1;
116  for (int i = 0; i<3;i++) ang[i]=(float)angles[i];
117  return 0;
118  }
122  int SetAngles(const double angles[3]){
123  vector<double> ang;
124  for (int i = 0; i<3;i++) ang.push_back(angles[i]);
125  return GetRootNode()->SetElementDouble(_anglesTag, ang);
126  }
130  int SetAngles(const float angles[3]){
131  vector<double> angl;
132  for (int i = 0; i<3;i++) angl.push_back((double)angles[i]);
133  return GetRootNode()->SetElementDouble(_anglesTag, angl);
134  }
137  void SetAngles(const vector<double>& vals){
138  GetRootNode()->SetElementDouble(_anglesTag, vals);
139  }
146  const vector<long>& GetTimes() {
147  const vector<long> defaultTimes(1,0);
148  return( GetRootNode()->GetElementLong(Box::_timesTag,defaultTimes));
149  }
155  void SetTimes(const vector<long>& times) { GetRootNode()->SetElementLong(Box::_timesTag, times);}
159  void Trim(int numTimes = 1){
160  if (numTimes > GetTimes().size()) return;
161  vector<long> times = GetTimes();
162  times.resize(numTimes);
163  GetRootNode()->SetElementLong(Box::_timesTag,times);
164  vector<double> exts;
165  vector<double>defaultExts(6,0.);
166  exts = GetRootNode()->GetElementDouble(Box::_extentsTag,defaultExts);
167  GetRootNode()->SetElementDouble(Box::_extentsTag, exts);
168  }
169  static const string _boxTag;
170  static const string _anglesTag;
171  static const string _extentsTag;
172  static const string _timesTag;
173 
174 
175 };
176 };
177 #endif
178 
179 
#define PARAMS_API
Definition: common.h:63
void Trim(int numTimes=1)
Definition: Box.h:159
3D or 2D box with options for orientation angles and extents changing in time. Intended to be used in...
Definition: Box.h:34
void SetTimes(const vector< long > &times)
Definition: Box.h:155
int SetAngles(const double angles[3])
Definition: Box.h:122
const vector< long > & GetTimes()
Definition: Box.h:146
static const string _boxTag
Definition: Box.h:169
static ParamsBase * CreateDefaultInstance()
Definition: Box.h:38
const vector< double > & GetLocalExtents()
Definition: Box.h:69
Nodes with state in Xml tree representation.
Definition: ParamsBase.h:57
int SetAngles(const float angles[3])
Definition: Box.h:130
int GetAngles(float ang[3])
Definition: Box.h:112
static const string _extentsTag
Definition: Box.h:171
void SetAngles(const vector< double > &vals)
Definition: Box.h:137
int GetAngles(double ang[3])
Definition: Box.h:102
static const string _timesTag
Definition: Box.h:172
static const string _anglesTag
Definition: Box.h:170
const vector< double > & GetAngles()
Definition: Box.h:95