![]() |
http://www.sim.no http://www.coin3d.org |
00001 #ifndef COIN_SBBOX2S_H 00002 #define COIN_SBBOX2S_H 00003 00004 /**************************************************************************\ 00005 * 00006 * This file is part of the Coin 3D visualization library. 00007 * Copyright (C) 1998-2007 by Systems in Motion. All rights reserved. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU General Public License 00011 * ("GPL") version 2 as published by the Free Software Foundation. 00012 * See the file LICENSE.GPL at the root directory of this source 00013 * distribution for additional information about the GNU GPL. 00014 * 00015 * For using Coin with software that can not be combined with the GNU 00016 * GPL, and for taking advantage of the additional benefits of our 00017 * support services, please contact Systems in Motion about acquiring 00018 * a Coin Professional Edition License. 00019 * 00020 * See http://www.coin3d.org/ for more information. 00021 * 00022 * Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY. 00023 * http://www.sim.no/ sales@sim.no coin-support@coin3d.org 00024 * 00025 \**************************************************************************/ 00026 00027 #include <Inventor/SbVec2s.h> 00028 #include <Inventor/SbVec2f.h> 00029 00030 class SbBox2i32; 00031 class SbBox2f; 00032 class SbBox2d; 00033 00034 class COIN_DLL_API SbBox2s { 00035 public: 00036 SbBox2s(void); 00037 SbBox2s(short xmin, short ymin, short xmax, short ymax); 00038 SbBox2s(const SbVec2s & boxmin, const SbVec2s & boxmax); 00039 explicit SbBox2s(const SbBox2i32 & box) { setBounds(box); } 00040 explicit SbBox2s(const SbBox2f & box) { setBounds(box); } 00041 explicit SbBox2s(const SbBox2d & box) { setBounds(box); } 00042 ~SbBox2s(void); 00043 00044 void setBounds(short xmin, short ymin, short xmax, short ymax); 00045 void setBounds(const SbVec2s & boxmin, const SbVec2s & boxmax); 00046 SbBox2s & setBounds(const SbBox2i32 & box); 00047 SbBox2s & setBounds(const SbBox2f & box); 00048 SbBox2s & setBounds(const SbBox2d & box); 00049 00050 void getBounds(short & xmin, short & ymin, short & xmax, short & ymax) const; 00051 void getBounds(SbVec2s & boxmin, SbVec2s & boxmax) const; 00052 00053 const SbVec2s & getMin(void) const; 00054 SbVec2s & getMin(void) { return minpt; } 00055 const SbVec2s & getMax(void) const; 00056 SbVec2s & getMax(void) { return maxpt; } 00057 00058 void extendBy(const SbVec2s & point); 00059 void extendBy(const SbBox2s & box); 00060 void makeEmpty(void); 00061 SbBool isEmpty(void) const { return (maxpt[0] < minpt[0]); } 00062 SbBool hasArea(void) const; 00063 00064 SbBool intersect(const SbVec2s & point) const; 00065 SbBool intersect(const SbBox2s & box) const; 00066 00067 SbVec2f getCenter(void) const { return SbVec2f((minpt[0] + maxpt[0]) * 0.5f, (minpt[1] + maxpt[1]) * 0.5f); } 00068 00069 void getOrigin(short & originX, short & originY) const; 00070 void getSize(short & sizeX, short & sizeY) const; 00071 float getAspectRatio(void) const; 00072 friend COIN_DLL_API int operator ==(const SbBox2s & b1, const SbBox2s & b2); 00073 friend COIN_DLL_API int operator !=(const SbBox2s & b1, const SbBox2s & b2); 00074 00075 private: 00076 SbVec2s minpt, maxpt; 00077 00078 short width(void) const; 00079 short height(void) const; 00080 }; 00081 00082 COIN_DLL_API int operator ==(const SbBox2s & b1, const SbBox2s & b2); 00083 COIN_DLL_API int operator !=(const SbBox2s & b1, const SbBox2s & b2); 00084 00085 #endif // !COIN_SBBOX2S_H
Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.
Generated on Mon Feb 28 2011 10:11:52 for Coin by Doxygen. 1.7.3