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

SbBox2f.h
1 #ifndef COIN_SBBOX2F_H
2 #define COIN_SBBOX2F_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/SbVec2f.h>
28 
29 class SbBox2d;
30 class SbBox2s;
31 class SbBox2i32;
32 
33 class COIN_DLL_API SbBox2f {
34 public:
35  SbBox2f(void);
36  SbBox2f(float xmin, float ymin, float xmax, float ymax);
37  SbBox2f(const SbVec2f & min, const SbVec2f & max);
38  explicit SbBox2f(const SbBox2d & box) { setBounds(box); }
39  explicit SbBox2f(const SbBox2s & box) { setBounds(box); }
40  explicit SbBox2f(const SbBox2i32 & box) { setBounds(box); }
41  ~SbBox2f(void);
42 
43  void setBounds(float xmin, float ymin, float xmax, float ymax);
44  void setBounds(const SbVec2f & min, const SbVec2f & max);
45  SbBox2f & setBounds(const SbBox2d & box);
46  SbBox2f & setBounds(const SbBox2s & box);
47  SbBox2f & setBounds(const SbBox2i32 & box);
48 
49  void getBounds(float & xmin, float & ymin, float & xmax, float & ymax) const;
50  void getBounds(SbVec2f & min, SbVec2f & max) const;
51 
52  const SbVec2f & getMin(void) const;
53  SbVec2f & getMin(void) { return minpt; }
54  const SbVec2f & getMax(void) const;
55  SbVec2f & getMax(void) { return maxpt; }
56 
57  void extendBy(const SbVec2f & point);
58  void extendBy(const SbBox2f & box);
59  void makeEmpty(void);
60  SbBool isEmpty(void) const;
61  SbBool hasArea(void) const;
62 
63  SbBool intersect(const SbVec2f & point) const;
64  SbBool intersect(const SbBox2f & box) const;
65  SbVec2f getClosestPoint(const SbVec2f & p) const;
66 
67  SbVec2f getCenter(void) const;
68  void getOrigin(float & x0, float & y0) const;
69  void getSize(float & w, float & h) const;
70  float getAspectRatio(void) const;
71 
72  friend COIN_DLL_API int operator ==(const SbBox2f & b1, const SbBox2f & b2);
73  friend COIN_DLL_API int operator !=(const SbBox2f & b1, const SbBox2f & b2);
74 
75 private:
76  SbVec2f minpt, maxpt;
77 
78  float width(void) const;
79  float height(void) const;
80 };
81 
82 COIN_DLL_API int operator ==(const SbBox2f & b1, const SbBox2f & b2);
83 COIN_DLL_API int operator !=(const SbBox2f & b1, const SbBox2f & b2);
84 
85 #endif // !COIN_SBBOX2F_H
The SbBox2d class is a 2 dimensional box with double precision corner coordinates.
Definition: SbBox2d.h:33
The SbBox2f class is a 2 dimensional box with floating point corner coordinates.
Definition: SbBox2f.h:33
SbVec2f & getMax(void)
Definition: SbBox2f.h:55
SbBox2f(const SbBox2i32 &box)
Definition: SbBox2f.h:40
SbBox2f(const SbBox2s &box)
Definition: SbBox2f.h:39
SbBox2f(const SbBox2d &box)
Definition: SbBox2f.h:38
SbVec2f & getMin(void)
Definition: SbBox2f.h:53
The SbBox2i32 class is a 2 dimensional box with int32_t coordinates.
Definition: SbBox2i32.h:34
The SbBox2s class is a 2 dimensional box with short integer coordinates.
Definition: SbBox2s.h:34
int operator==(const SbBox2s &b1, const SbBox2s &b2)
Definition: SbBox2s.cpp:432
int operator!=(const SbBox2s &b1, const SbBox2s &b2)
Definition: SbBox2s.cpp:443
The SbVec2f class is a 2 dimensional vector with floating point coordinates.
Definition: SbVec2f.h:36

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

Generated on Wed Jul 21 2021 for Coin by Doxygen. 1.9.1