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

SbBox3s.h

00001 #ifndef COIN_SBBOX3S_H
00002 #define COIN_SBBOX3S_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/SbVec3s.h>
00028 #include <Inventor/SbVec3f.h>
00029 
00030 class SbBox3i32;
00031 class SbBox3f;
00032 class SbBox3d;
00033 
00034 class COIN_DLL_API SbBox3s {
00035 public:
00036   SbBox3s(void);
00037   SbBox3s(short xmin, short ymin, short zmin, short xmax, short ymax, short zmax);
00038   SbBox3s(const SbVec3s & minvec, const SbVec3s & maxvec);
00039   explicit SbBox3s(const SbBox3i32 & box) { setBounds(box); }
00040   explicit SbBox3s(const SbBox3f & box) { setBounds(box); }
00041   explicit SbBox3s(const SbBox3d & box) { setBounds(box); }
00042   ~SbBox3s(void);
00043 
00044   void setBounds(short xmin, short ymin, short zmin, short xmax, short ymax, short zmax);
00045   void setBounds(const SbVec3s & minvec, const SbVec3s & maxvec);
00046   SbBox3s & setBounds(const SbBox3i32 & box);
00047   SbBox3s & setBounds(const SbBox3f & box);
00048   SbBox3s & setBounds(const SbBox3d & box);
00049 
00050   const SbVec3s & getMin(void) const;
00051   SbVec3s & getMin(void) { return minpt; }
00052   const SbVec3s & getMax(void) const;
00053   SbVec3s & getMax(void) { return maxpt; }
00054 
00055   void extendBy(const SbVec3s & point);
00056   void extendBy(const SbBox3s & box);
00057   void makeEmpty(void);
00058   SbBool isEmpty(void) const { return (maxpt[0] < minpt[0]); }
00059   SbBool hasVolume(void) const
00060     { return ((maxpt[0] > minpt[0]) && (maxpt[1] > minpt[1]) && (maxpt[2] > minpt[2])); }
00061   int getVolume(void) const
00062     { short dx = 0, dy = 0, dz = 0; getSize(dx, dy, dz); return (dx * dy * dz); }
00063 
00064   SbBool intersect(const SbVec3s & point) const;
00065   SbBool intersect(const SbBox3s & box) const;
00066   void getBounds(short & xmin, short & ymin, 
00067                  short & zmin, short & xmax, 
00068                  short & ymax, short & zmax) const;
00069   void getBounds(SbVec3s & minvec, SbVec3s & maxvec) const;
00070 
00071   SbVec3f getCenter(void) const
00072     { return SbVec3f((minpt[0]+maxpt[0])*0.5f, (minpt[1]+maxpt[1])*0.5f, (minpt[2]+maxpt[2])*0.5f); }
00073   void getOrigin(short & originX, short & originY, short & originZ) const;
00074   void getSize(short & sizeX, short & sizeY, short & sizeZ) const;
00075 
00076   friend COIN_DLL_API int operator ==(const SbBox3s & b1, const SbBox3s & b2);
00077   friend COIN_DLL_API int operator !=(const SbBox3s & b1, const SbBox3s & b2);
00078 
00079 private:
00080   SbVec3s minpt, maxpt;
00081 
00082   short width(void) const;
00083   short height(void) const;
00084   short depth(void) const;
00085   SbBool hasArea(void) const;
00086 };
00087 
00088 COIN_DLL_API int operator ==(const SbBox3s & b1, const SbBox3s & b2);
00089 COIN_DLL_API int operator !=(const SbBox3s & b1, const SbBox3s & b2);
00090 
00091 #endif // !COIN_SBBOX3S_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