4
4
/**************************************************************************\
6
6
* This file is part of the Coin 3D visualization library.
7
* Copyright (C) 1998-2006 by Systems in Motion. All rights reserved.
7
* Copyright (C) 1998-2007 by Systems in Motion. All rights reserved.
9
9
* This library is free software; you can redistribute it and/or
10
10
* modify it under the terms of the GNU General Public License
25
25
\**************************************************************************/
27
#include <Inventor/SbBasic.h>
28
27
#include <Inventor/SbVec2s.h>
28
#include <Inventor/SbVec2f.h>
30
34
class COIN_DLL_API SbBox2s {
33
37
SbBox2s(short xmin, short ymin, short xmax, short ymax);
34
38
SbBox2s(const SbVec2s & boxmin, const SbVec2s & boxmax);
39
explicit SbBox2s(const SbBox2i32 & box) { setBounds(box); }
40
explicit SbBox2s(const SbBox2f & box) { setBounds(box); }
41
explicit SbBox2s(const SbBox2d & box) { setBounds(box); }
44
void setBounds(short xmin, short ymin, short xmax, short ymax);
45
void setBounds(const SbVec2s & boxmin, const SbVec2s & boxmax);
46
SbBox2s & setBounds(const SbBox2i32 & box);
47
SbBox2s & setBounds(const SbBox2f & box);
48
SbBox2s & setBounds(const SbBox2d & box);
50
void getBounds(short & xmin, short & ymin, short & xmax, short & ymax) const;
51
void getBounds(SbVec2s & boxmin, SbVec2s & boxmax) const;
37
53
const SbVec2s & getMin(void) const;
54
SbVec2s & getMin(void) { return minpt; }
38
55
const SbVec2s & getMax(void) const;
56
SbVec2s & getMax(void) { return maxpt; }
39
58
void extendBy(const SbVec2s & point);
40
59
void extendBy(const SbBox2s & box);
61
SbBool isEmpty(void) const { return (maxpt[0] < minpt[0]); }
62
SbBool hasArea(void) const;
41
64
SbBool intersect(const SbVec2s & point) const;
42
65
SbBool intersect(const SbBox2s & box) const;
43
void setBounds(short xmin, short ymin, short xmax, short ymax);
44
void setBounds(const SbVec2s & boxmin, const SbVec2s & boxmax);
45
void getBounds(short & xmin, short & ymin, short & xmax, short & ymax) const;
46
void getBounds(SbVec2s & boxmin, SbVec2s & boxmax) const;
67
SbVec2f getCenter(void) const { return SbVec2f((minpt[0] + maxpt[0]) * 0.5f, (minpt[1] + maxpt[1]) * 0.5f); }
47
69
void getOrigin(short & originX, short & originY) const;
48
70
void getSize(short & sizeX, short & sizeY) const;
49
71
float getAspectRatio(void) const;
51
72
friend COIN_DLL_API int operator ==(const SbBox2s & b1, const SbBox2s & b2);
52
73
friend COIN_DLL_API int operator !=(const SbBox2s & b1, const SbBox2s & b2);