-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathGridPicture.cpp
103 lines (87 loc) · 3.07 KB
/
GridPicture.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// -------------------------------------------------------------------
// GridPicture.cpp
// -------------------------------------------------------------------
#include "GridPicture.H"
#include "GlobalUtilities.H"
#ifdef BL_USE_NEW_HFILES
#include <climits>
#include <cfloat>
#else
#include <limits.h>
#include <float.h>
#endif
// -------------------------------------------------------------------
GridPicture::GridPicture() {
}
// -------------------------------------------------------------------
void GridPicture::GridPictureInit(int level,
int rratio, int scale, int picSizeH, int picSizeV,
const Box &overlapbox,
const Box &boxWithData, int slicedir)
{
sliceDir = slicedir;
refRatio = rratio;
currentScale = scale;
pictureSizeH = picSizeH;
pictureSizeV = picSizeV;
overlapBox = overlapbox;
BL_ASSERT(overlapBox.sameSize(boxWithData));
imageBox = overlapBox;
imageBox.refine(refRatio * currentScale);
if(sliceDir == ZDIR) {
dataSizeH = boxWithData.length(XDIR);
dataSizeV = boxWithData.length(YDIR);
} else if(sliceDir == YDIR) {
dataSizeV = boxWithData.length(ZDIR);
dataSizeH = boxWithData.length(XDIR);
} else {
dataSizeH = boxWithData.length(YDIR);
dataSizeV = boxWithData.length(ZDIR);
}
imageSizeH = dataSizeH * refRatio * currentScale;
imageSizeV = dataSizeV * refRatio * currentScale;
} // end GridPictureInit
// -------------------------------------------------------------------
GridPicture::~GridPicture() {
}
// -------------------------------------------------------------------
void GridPicture::ChangeScale(int newScale, int picSizeH, int picSizeV) {
currentScale = newScale;
imageBox = overlapBox;
imageBox.refine(refRatio * currentScale);
// use datasize instead of imageBox.length() for node centered boxes
imageSizeH = dataSizeH * refRatio * currentScale;
imageSizeV = dataSizeV * refRatio * currentScale;
pictureSizeH = picSizeH;
pictureSizeV = picSizeV;
}
// -------------------------------------------------------------------
int GridPicture::HPositionInPicture() {
int endLoc;
if(sliceDir == ZDIR) {
endLoc = imageBox.smallEnd()[XDIR];
} else if(sliceDir == YDIR) {
endLoc = imageBox.smallEnd()[XDIR];
} else {
endLoc = imageBox.smallEnd()[YDIR];
}
return (endLoc - ((int) imageSizeH % refRatio));
}
// -------------------------------------------------------------------
int GridPicture::VPositionInPicture() {
int endLoc, nodeAdjustment;
if(sliceDir == ZDIR) {
endLoc = imageBox.bigEnd()[YDIR];
nodeAdjustment = imageBox.type()[YDIR] * (currentScale - 1) * refRatio;
} else if(sliceDir == YDIR) {
endLoc = imageBox.bigEnd()[ZDIR];
nodeAdjustment = imageBox.type()[ZDIR] * (currentScale - 1) * refRatio;
} else {
endLoc = imageBox.bigEnd()[ZDIR];
nodeAdjustment = imageBox.type()[ZDIR] * (currentScale - 1) * refRatio;
}
return ((pictureSizeV-1) - endLoc - ((int) imageSizeV % refRatio) -
nodeAdjustment);
}
// -------------------------------------------------------------------
// -------------------------------------------------------------------