VAPOR3 3.9.4
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#include <vapor/ParamsBase.h>
25#include <vapor/Grid.h>
26
27namespace VAPoR {
28
35
39class PARAMS_API Box : public ParamsBase {
40public:
41 enum Orientation { XY = 0, XZ = 1, YZ = 2, XYZ = 3 };
42
44 //
45 Box(ParamsBase::StateSave *ssave, string name = Box::GetClassType());
46
48 //
50
51 virtual ~Box();
52
62 //
63 virtual void SetExtents(const vector<double> &minExt, const vector<double> &maxExt);
64 virtual void SetExtents(const VAPoR::CoordType &minExt, const VAPoR::CoordType &maxExt);
65
80 //
81 void GetExtents(vector<double> &minExt, vector<double> &maxExt) const;
82 void GetExtents(VAPoR::CoordType &minExt, VAPoR::CoordType &maxExt) const;
83
89 //
90 bool IsPlanar() const;
91
100 //
101 void SetPlanar(bool value);
102
112 //
113 int GetOrientation() const { return GetValueLong(Box::m_orientationTag, XY); }
114
121 //
122 void SetOrientation(long value) { SetValueLong(Box::m_orientationTag, "Set box orientation", (long)value); }
123
124#if 0
130 int GetStretchedLocalExtents(double extents[6], int timestep = -1);
131
137 vector<double> GetLocalExtents() const
138 {
139 const vector<double> localExtents(6, 0);
140 return GetValueDoubleVec(_extentsTag, localExtents);
141 }
142
148 void SetLocalExtents(const vector<double>& extents, int timestep = -1);
149
150 void SetLocalExtents(
151 const vector<double>& minExt, const vector<double>& maxExt,
152 int timestep = -1
153 ) {
154 VAssert(minExt.size() == maxExt.size() && minExt.size() == 3);
155 vector <double> extents = minExt;
156 extents.insert(extents.end(), maxExt.begin(), maxExt.end());
157 SetLocalExtents(extents, timestep);
158 }
159
165 void SetLocalExtents(const double extents[6], int timestep = -1);
166
172 void SetLocalExtents(const float extents[6], int timestep = -1);
173#endif
174
175#if 0
181 void SetStretchedLocalExtents(const double extents[6], int timestep = -1);
182#endif
183
187 vector<double> GetAngles() const
188 {
189 const vector<double> defaultAngles(3, 0.);
190 return GetValueDoubleVec(Box::m_anglesTag, defaultAngles);
191 }
192
193#if 0
197 void GetAngles(double ang[3]){
198 const vector<double> angv = GetAngles();
199 for (int i=0; i<3; i++) ang[i] = angv[i];
200 }
201
205 void GetAngles(float ang[3]){
206 const vector<double> angv = GetAngles();
207 for (int i=0; i<3; i++) ang[i] = angv[i];
208 }
209#endif
210
214 void SetAngles(const double angles[3])
215 {
216 vector<double> ang;
217 for (int i = 0; i < 3; i++) ang.push_back(angles[i]);
218 SetValueDoubleVec(m_anglesTag, "change box angles", ang);
219 }
220
224 void SetAngles(const float angles[3])
225 {
226 vector<double> angl;
227 for (int i = 0; i < 3; i++) angl.push_back((double)angles[i]);
228 SetValueDoubleVec(m_anglesTag, "change box angles", angl);
229 }
230
233 void SetAngles(const vector<double> &vals) { SetValueDoubleVec(m_anglesTag, "Change box angles", vals); }
234#if 0
241 const vector<long> GetTimes() {
242 return( GetValueLongVec(Box::_timesTag));
243 }
249 void SetTimes(const vector<long>& times) {
250 SetValueLongVec(Box::_timesTag, "Change box times",times);
251 }
252
253 void buildLocalCoordTransform(
254 double transformMatrix[12], double extraThickness,
255 int timestep, double rotation = 0., int axis= -1
256 ) const;
257#endif
258
259 // Get static string identifier for this params class
260 //
261 static string GetClassType() { return ("BoxParams"); }
262
263private:
264#if 0
271 void calcContainingBoxExtents(
272 double extents[6], bool rotated = false
273 ) const {
274
275 if (!rotated) GetLocalExtents(extents,-1);
276 else calcRotatedBoxExtents(extents);
277
278 }
279
283 void calcRotatedBoxExtents(double extents[6]) const;
284
291 void calcContainingStretchedBoxExtents(
292 double extents[6], bool rotated = false
293 ) const {
294
295 VAssert( ! rotated);
296 if (!rotated) GetStretchedLocalExtents(extents,-1);
297 //else calcRotatedStretchedBoxExtents(extents);
298
299 }
300
301
305 void calcRotatedStretchedBoxExtents(
306 vector <double> stretchFactors, double extents[6]
307 ) const;
308
309
310 //Used only by params with rotated boxes:
311 bool cropToBox(const double boxExts[6]);
312 bool intersectRotatedBox(double boxexts[6], double pointFound[3], double probeCoords[2]);
313 bool fitToBox(const double boxExts[6]);
314 void setBoxToExtents(const double extents[6]);
315 int interceptBox(const double boxExts[6], double intercept[6][3]);
316
317 void getRotatedVoxelExtents(string varname, float voxdims[2], int numRefinements);
318
319
320 void rotateAndRenormalize(int axis, double rotVal);
322
323
324 void convertThetaPhiPsi(
325 double *newTheta, double* newPhi, double* newPsi,
326 int axis, double rotation
327 ) const;
328
329 //Not part of public API
330 void calcLocalBoxCorners(
331 double corners[8][3], float extraThickness, int timestep,
332 double rotation = 0., int axis = -1
333 ) const ;
334
335#endif
336
337public:
338 static const string m_anglesTag;
339 static const string m_extentsTag;
340 static const string m_planarTag;
341 static const string m_orientationTag;
342};
343}; // namespace VAPoR
344#endif
#define VAssert(expr)
Definition: VAssert.h:9
3D or 2D box with options for orientation angles .
Definition: Box.h:39
virtual void SetExtents(const VAPoR::CoordType &minExt, const VAPoR::CoordType &maxExt)
void GetExtents(vector< double > &minExt, vector< double > &maxExt) const
void SetOrientation(long value)
Definition: Box.h:122
Box(ParamsBase::StateSave *ssave, string name=Box::GetClassType())
Create a Box object from scratch.
void SetAngles(const vector< double > &vals)
Definition: Box.h:233
virtual ~Box()
void SetPlanar(bool value)
static string GetClassType()
Definition: Box.h:261
Box(ParamsBase::StateSave *ssave, XmlNode *node)
Create a Box object from an existing XmlNode tree.
virtual void SetExtents(const vector< double > &minExt, const vector< double > &maxExt)
static const string m_planarTag
Definition: Box.h:340
void GetExtents(VAPoR::CoordType &minExt, VAPoR::CoordType &maxExt) const
Orientation
Definition: Box.h:41
int GetOrientation() const
Definition: Box.h:113
static const string m_extentsTag
Definition: Box.h:339
bool IsPlanar() const
static const string m_anglesTag
Definition: Box.h:338
vector< double > GetAngles() const
Definition: Box.h:187
static const string m_orientationTag
Definition: Box.h:341
void SetAngles(const double angles[3])
Definition: Box.h:214
void SetAngles(const float angles[3])
Definition: Box.h:224
State capture class.
Definition: ParamsBase.h:62
Nodes with state in Xml tree representation.
Definition: ParamsBase.h:50
An Xml tree.
Definition: XmlNode.h:49
#define PARAMS_API
Definition: common.h:77
std::array< double, 3 > CoordType
Type for specifying floating point coordinates.
Definition: Grid.h:23