VAPoR  3.0.0
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 
26 #include <vapor/ParamsBase.h>
27 
43 class PARAMS_API Box : public ParamsBase {
44 public:
45 
46  Box();
47  virtual ~Box() {}
48 
49 
54  int GetUserExtents(double extents[6], size_t timestep);
59  int GetUserExtents(vector<double> minExts, vector<double>maxExts, size_t timestep);
65  int GetUserExtents(float extents[6], size_t timestep);
71 
72  int GetLocalExtents(double extents[6], int timestep = -1);
78  int GetLocalExtents(float extents[6], int timestep = -1);
84  int GetStretchedLocalExtents(double extents[6], int timestep = -1);
90  const vector<double> GetLocalExtents() {
91  const vector<double> localExtents(6,0.);
92  return GetValueDoubleVec(_extentsTag,localExtents);
93  }
100  int SetLocalExtents(const vector<double>& extents, Params* p, int timestep = -1);
107  int SetLocalExtents(const double extents[6], Params* p, int timestep = -1);
114  int SetLocalExtents(const float extents[6], Params* p, int timestep = -1);
121  int SetStretchedLocalExtents(const double extents[6], Params* p, int timestep = -1);
122 
126  const vector<double> GetAngles(){
127  const vector<double> defaultAngles(3,0.);
128  return GetValueDoubleVec(Box::_anglesTag,defaultAngles);
129  }
133  int GetAngles(double ang[3]){
134  const vector<double> defaultAngles(3,0.);
135  const vector<double> angles = GetValueDoubleVec(Box::_anglesTag,defaultAngles);
136  if (angles.size() != 3) return -1;
137  for (int i = 0; i<3;i++) ang[i]=angles[i];
138  return 0;
139  }
143  int GetAngles(float ang[3]){
144  const vector<double> defaultAngles(3,0.);
145  const vector<double> angles = GetValueDoubleVec(Box::_anglesTag,defaultAngles);
146  if (angles.size() != 3) return -1;
147  for (int i = 0; i<3;i++) ang[i]=(float)angles[i];
148  return 0;
149  }
154  int SetAngles(const double angles[3], Params* p){
155  vector<double> ang;
156  for (int i = 0; i<3;i++) ang.push_back(angles[i]);
157  return SetValueDouble(_anglesTag, "change box angles",ang,p);
158  }
163  int SetAngles(const float angles[3], Params* p){
164  vector<double> angl;
165  for (int i = 0; i<3;i++) angl.push_back((double)angles[i]);
166  return SetValueDouble(_anglesTag, "change box angles",angl,p);
167  }
171  void SetAngles(const vector<double>& vals, Params* p){
172  SetValueDouble(_anglesTag, "Change box angles",vals, p);
173  }
180  const vector<long> GetTimes() {
181  const vector<long> defaultTimes(1,0);
182  return( GetValueLongVec(Box::_timesTag,defaultTimes));
183  }
190  void SetTimes(const vector<long>& times, Params* p) {
191  SetValueLong(Box::_timesTag, "Change box times",times, p);
192  }
193 
198  void Trim(Params* p,int numTimes = 1);
199 
203  bool IsPlanar() {return GetValueLong(Box::_planarTag) != 0;}
204 
209  void SetPlanar(bool value, Params* p){
210  SetValueLong(Box::_planarTag, "Set box planar value", (long)value, p);
211  }
216  return GetValueLong(Box::_orientationTag);
217  }
222  void SetOrientation(long value, Params* p){
223  SetValueLong(Box::_orientationTag, "Set box orientation", (long)value, p);
224  }
225 
229 
232  static ParamsBase* CreateDefaultInstance() {return new Box();}
233 
240  void calcContainingBoxExtents(double extents[6], bool rotated = false) {
241  if (!rotated) GetLocalExtents(extents,-1);
242  else calcRotatedBoxExtents(extents);
243  }
250  void calcContainingStretchedBoxExtents(double extents[6], bool rotated = false) {
251  if (!rotated) GetStretchedLocalExtents(extents,-1);
252  else calcRotatedStretchedBoxExtents(extents);
253  }
254 
258  void calcRotatedBoxExtents(double extents[6]);
259 
263  void calcRotatedStretchedBoxExtents(double extents[6]);
264 
265 
266  //Used only by params with rotated boxes:
267  bool cropToBox(const double boxExts[6], Params* p);
268  bool intersectRotatedBox(double boxexts[6], double pointFound[3], double probeCoords[2]);
269  bool fitToBox(const double boxExts[6], Params* p);
270  void setBoxToExtents(const double extents[6], Params* pParams);
271  int interceptBox(const double boxExts[6], double intercept[6][3]);
272  void getRotatedVoxelExtents(string varname, float voxdims[2], int numRefinements);
273  void rotateAndRenormalize(int axis, double rotVal, Params* p);
275 
276 #ifndef DOXYGEN_SKIP_THIS
277  void buildLocalCoordTransform(double transformMatrix[12], double extraThickness, int timestep, double rotation = 0., int axis= -1);
278  void convertThetaPhiPsi(double *newTheta, double* newPhi, double* newPsi, int axis, double rotation);
279  //Not part of public API
280  void calcLocalBoxCorners(double corners[8][3], float extraThickness, int timestep, double rotation = 0., int axis = -1);
281 
282  static const string _boxTag;
283  static const string _anglesTag;
284  static const string _extentsTag;
285  static const string _timesTag;
286  static const string _planarTag;
287  static const string _orientationTag;
288 #endif //DOXYGEN_SKIP_THIS
289 };
290 };
291 #endif
292 
293 
3D or 2D box with options for orientation angles and extents changing in time. Intended to be used in...
Definition: Box.h:43
void SetAngles(const vector< double > &vals, Params *p)
Definition: Box.h:171
A pure virtual class for managing parameters used in visualization.
Definition: params.h:129
void SetOrientation(long value, Params *p)
Definition: Box.h:222
int GetOrientation()
Definition: Box.h:215
void calcContainingBoxExtents(double extents[6], bool rotated=false)
Definition: Box.h:240
static ParamsBase * CreateDefaultInstance()
Definition: Box.h:232
bool IsPlanar()
Definition: Box.h:203
void SetTimes(const vector< long > &times, Params *p)
Definition: Box.h:190
Nodes with state in Xml tree representation.
Definition: ParamsBase.h:90
void calcContainingStretchedBoxExtents(double extents[6], bool rotated=false)
Definition: Box.h:250
int GetAngles(float ang[3])
Definition: Box.h:143
void SetPlanar(bool value, Params *p)
Definition: Box.h:209
const vector< double > GetAngles()
Definition: Box.h:126
const vector< double > GetLocalExtents()
Definition: Box.h:90
const vector< long > GetTimes()
Definition: Box.h:180
int SetAngles(const float angles[3], Params *p)
Definition: Box.h:163
#define PARAMS_API
int GetAngles(double ang[3])
Definition: Box.h:133
Definition: DC.h:10
int SetAngles(const double angles[3], Params *p)
Definition: Box.h:154
virtual ~Box()
Definition: Box.h:47