27 #include <Inventor/SbVec2s.h>
28 #include <Inventor/SbVec2f.h>
37 SbBox2s(
short xmin,
short ymin,
short xmax,
short ymax)
38 : minpt(xmin, ymin), maxpt(xmax, ymax) { }
40 : minpt(minpoint), maxpt(maxpoint) { }
41 explicit SbBox2s(
const SbBox2i32 & box) { setBounds(box); }
45 SbBox2s & setBounds(
short xmin,
short ymin,
short xmax,
short ymax)
46 { minpt.setValue(xmin, ymin); maxpt.setValue(xmax, ymax);
return *
this; }
48 { minpt = minpoint; maxpt = maxpoint;
return *
this; }
49 SbBox2s & setBounds(
const SbBox2i32 & box);
53 void getBounds(
short & xmin,
short & ymin,
short & xmax,
short & ymax)
const
54 { minpt.getValue(xmin, ymin); maxpt.getValue(xmax, ymax); }
56 { minpoint = minpt; maxpoint = maxpt; }
59 SbVec2s & getMin(
void) {
return minpt; }
61 SbVec2s & getMax(
void) {
return maxpt; }
63 void extendBy(
const SbVec2s & point);
64 void extendBy(
const SbBox2s & box);
66 SbBool isEmpty(
void)
const {
return (maxpt[0] < minpt[0]); }
67 SbBool hasArea(
void)
const {
return ((maxpt[0] > minpt[0]) && (maxpt[1] > minpt[1])); }
69 SbBool intersect(
const SbVec2s & point)
const;
70 SbBool intersect(
const SbBox2s & box)
const;
72 SbVec2f getCenter(
void)
const {
return SbVec2f((minpt[0] + maxpt[0]) * 0.5f, (minpt[1] + maxpt[1]) * 0.5f); }
73 void getOrigin(
short & originX,
short & originY)
const
74 { minpt.getValue(originX, originY); }
75 void getSize(
short & sizeX,
short & sizeY)
const
76 {
if (isEmpty()) { sizeX = sizeY = 0; }
77 else { sizeX = maxpt[0] - minpt[0]; sizeY = maxpt[1] - minpt[1]; } }
78 float getAspectRatio(
void)
const
79 { SbDividerChk(
"SbBox2s::getAspectRatio()", maxpt[1] - minpt[1]);
80 return (
float(maxpt[0] - minpt[0]) /
float(maxpt[1] - minpt[1])); }
95 #endif // !COIN_SBBOX2S_H