Coin Logo http://www.sim.no
http://www.coin3d.org

SbBox2s.h
1 #ifndef COIN_SBBOX2S_H
2 #define COIN_SBBOX2S_H
3 
4 /**************************************************************************\
5  *
6  * This file is part of the Coin 3D visualization library.
7  * Copyright (C) 1998-2007 by Systems in Motion. All rights reserved.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * ("GPL") version 2 as published by the Free Software Foundation.
12  * See the file LICENSE.GPL at the root directory of this source
13  * distribution for additional information about the GNU GPL.
14  *
15  * For using Coin with software that can not be combined with the GNU
16  * GPL, and for taking advantage of the additional benefits of our
17  * support services, please contact Systems in Motion about acquiring
18  * a Coin Professional Edition License.
19  *
20  * See http://www.coin3d.org/ for more information.
21  *
22  * Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
23  * http://www.sim.no/ sales@sim.no coin-support@coin3d.org
24  *
25 \**************************************************************************/
26 
27 #include <Inventor/SbVec2s.h>
28 #include <Inventor/SbVec2f.h>
29 
30 class SbBox2i32;
31 class SbBox2f;
32 class SbBox2d;
33 
34 class COIN_DLL_API SbBox2s {
35 public:
36  SbBox2s(void);
37  SbBox2s(short xmin, short ymin, short xmax, short ymax);
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); }
42  ~SbBox2s(void);
43 
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);
49 
50  void getBounds(short & xmin, short & ymin, short & xmax, short & ymax) const;
51  void getBounds(SbVec2s & boxmin, SbVec2s & boxmax) const;
52 
53  const SbVec2s & getMin(void) const;
54  SbVec2s & getMin(void) { return minpt; }
55  const SbVec2s & getMax(void) const;
56  SbVec2s & getMax(void) { return maxpt; }
57 
58  void extendBy(const SbVec2s & point);
59  void extendBy(const SbBox2s & box);
60  void makeEmpty(void);
61  SbBool isEmpty(void) const { return (maxpt[0] < minpt[0]); }
62  SbBool hasArea(void) const;
63 
64  SbBool intersect(const SbVec2s & point) const;
65  SbBool intersect(const SbBox2s & box) const;
66 
67  SbVec2f getCenter(void) const { return SbVec2f((minpt[0] + maxpt[0]) * 0.5f, (minpt[1] + maxpt[1]) * 0.5f); }
68 
69  void getOrigin(short & originX, short & originY) const;
70  void getSize(short & sizeX, short & sizeY) const;
71  float getAspectRatio(void) const;
72  friend COIN_DLL_API int operator ==(const SbBox2s & b1, const SbBox2s & b2);
73  friend COIN_DLL_API int operator !=(const SbBox2s & b1, const SbBox2s & b2);
74 
75 private:
76  SbVec2s minpt, maxpt;
77 
78  short width(void) const;
79  short height(void) const;
80 };
81 
82 COIN_DLL_API int operator ==(const SbBox2s & b1, const SbBox2s & b2);
83 COIN_DLL_API int operator !=(const SbBox2s & b1, const SbBox2s & b2);
84 
85 #endif // !COIN_SBBOX2S_H
SbBox2s::getMax
const SbVec2s & getMax(void) const
Definition: SbBox2s.cpp:234
SbBox2s
The SbBox2s class is a 2 dimensional box with short integer coordinates.
Definition: SbBox2s.h:34
SbBox2i32::getMin
const SbVec2i32 & getMin(void) const
Definition: SbBox2i32.h:58
SbBox2i32::isEmpty
SbBool isEmpty(void) const
Definition: SbBox2i32.h:66
SbVec2f
The SbVec2f class is a 2 dimensional vector with floating point coordinates.
Definition: SbVec2f.h:36
SbBox2s::getMin
SbVec2s & getMin(void)
Definition: SbBox2s.h:54
SbBox2s::makeEmpty
void makeEmpty(void)
Definition: SbBox2s.cpp:179
SbBox2s::getSize
void getSize(short &sizeX, short &sizeY) const
Definition: SbBox2s.cpp:397
SbBox2d::getMin
const SbVec2d & getMin(void) const
Definition: SbBox2d.cpp:158
SbBox2i32::getMax
const SbVec2i32 & getMax(void) const
Definition: SbBox2i32.h:60
SbBox2s::isEmpty
SbBool isEmpty(void) const
Definition: SbBox2s.h:61
SoDebugError::postWarning
static void postWarning(const char *const source, const char *const format,...)
Definition: SoDebugError.cpp:324
SbBox2d
The SbBox2d class is a 2 dimensional box with double precision corner coordinates.
Definition: SbBox2d.h:33
SbVec2s::setValue
SbVec2s & setValue(const short v[2])
Definition: SbVec2s.cpp:174
SbBox2s::setBounds
void setBounds(short xmin, short ymin, short xmax, short ymax)
Definition: SbBox2s.cpp:316
SbBox2f::getMax
const SbVec2f & getMax(void) const
Definition: SbBox2f.cpp:174
SbBox2s::getCenter
SbVec2f getCenter(void) const
Definition: SbBox2s.h:67
SbBox2s::SbBox2s
SbBox2s(void)
Definition: SbBox2s.cpp:52
SbBox2s::hasArea
SbBool hasArea(void) const
Definition: SbBox2s.cpp:203
SbVec2s
The SbVec2s class is a 2 dimensional vector with short integer coordinates.
Definition: SbVec2s.h:37
SbBox2s::getAspectRatio
float getAspectRatio(void) const
Definition: SbBox2s.cpp:413
SbBox2f::isEmpty
SbBool isEmpty(void) const
Definition: SbBox2f.cpp:131
SbBox2s::SbBox2s
SbBox2s(const SbBox2d &box)
Definition: SbBox2s.h:41
SbBox2s::getOrigin
void getOrigin(short &originX, short &originY) const
Definition: SbBox2s.cpp:387
SbBox2i32::operator!=
int operator!=(const SbBox2i32 &b1, const SbBox2i32 &b2)
Definition: SbBox2i32.h:91
SbBox2s::getMin
const SbVec2s & getMin(void) const
Definition: SbBox2s.cpp:215
SbBox2d::isEmpty
SbBool isEmpty(void) const
Definition: SbBox2d.cpp:136
SbBox2s::getMax
SbVec2s & getMax(void)
Definition: SbBox2s.h:56
SbBox2f
The SbBox2f class is a 2 dimensional box with floating point corner coordinates.
Definition: SbBox2f.h:33
SbBox2s::getBounds
void getBounds(short &xmin, short &ymin, short &xmax, short &ymax) const
Definition: SbBox2s.cpp:353
SbBox2s::SbBox2s
SbBox2s(const SbBox2i32 &box)
Definition: SbBox2s.h:39
SbBox2i32
The SbBox2i32 class is a 2 dimensional box with int32_t coordinates.
Definition: SbBox2i32.h:34
SbBox2s::SbBox2s
SbBox2s(const SbBox2f &box)
Definition: SbBox2s.h:40
SbBox2s::intersect
SbBool intersect(const SbVec2s &point) const
Definition: SbBox2s.cpp:286
SbBox2d::getMax
const SbVec2d & getMax(void) const
Definition: SbBox2d.cpp:177
SbBox2i32::operator==
int operator==(const SbBox2i32 &b1, const SbBox2i32 &b2)
Definition: SbBox2i32.h:87
SbBox2f::getMin
const SbVec2f & getMin(void) const
Definition: SbBox2f.cpp:153
SbBox2s::~SbBox2s
~SbBox2s(void)
Definition: SbBox2s.cpp:82
SbBox2s::extendBy
void extendBy(const SbVec2s &point)
Definition: SbBox2s.cpp:254

Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.

Generated on Wed Jul 24 2019 for Coin by Doxygen. 1.8.17