36 #include <Inventor/SbVec2s.h>
37 #include <Inventor/SbVec2f.h>
46 SbBox2s(
short xmin,
short ymin,
short xmax,
short ymax)
47 : minpt(xmin, ymin), maxpt(xmax, ymax) { }
49 : minpt(minpoint), maxpt(maxpoint) { }
50 explicit SbBox2s(
const SbBox2i32 & box) { setBounds(box); }
54 SbBox2s & setBounds(
short xmin,
short ymin,
short xmax,
short ymax)
55 { minpt.setValue(xmin, ymin); maxpt.setValue(xmax, ymax);
return *
this; }
57 { minpt = minpoint; maxpt = maxpoint;
return *
this; }
58 SbBox2s & setBounds(
const SbBox2i32 & box);
62 void getBounds(
short & xmin,
short & ymin,
short & xmax,
short & ymax)
const
63 { minpt.getValue(xmin, ymin); maxpt.getValue(xmax, ymax); }
65 { minpoint = minpt; maxpoint = maxpt; }
68 SbVec2s & getMin(
void) {
return minpt; }
70 SbVec2s & getMax(
void) {
return maxpt; }
72 void extendBy(
const SbVec2s & point);
73 void extendBy(
const SbBox2s & box);
75 SbBool isEmpty(
void)
const {
return (maxpt[0] < minpt[0]); }
76 SbBool hasArea(
void)
const {
return ((maxpt[0] > minpt[0]) && (maxpt[1] > minpt[1])); }
78 SbBool intersect(
const SbVec2s & point)
const;
79 SbBool intersect(
const SbBox2s & box)
const;
81 SbVec2f getCenter(
void)
const {
return SbVec2f((minpt[0] + maxpt[0]) * 0.5f, (minpt[1] + maxpt[1]) * 0.5f); }
82 void getOrigin(
short & originX,
short & originY)
const
83 { minpt.getValue(originX, originY); }
84 void getSize(
short & sizeX,
short & sizeY)
const
85 {
if (isEmpty()) { sizeX = sizeY = 0; }
86 else { sizeX = maxpt[0] - minpt[0]; sizeY = maxpt[1] - minpt[1]; } }
89 this->getSize(v[0], v[1]);
93 float getAspectRatio(
void)
const
94 { SbDividerChk(
"SbBox2s::getAspectRatio()", maxpt[1] - minpt[1]);
95 return (
float(maxpt[0] - minpt[0]) /
float(maxpt[1] - minpt[1])); }
110 #endif // !COIN_SBBOX2S_H