![]() |
http://www.sim.no http://www.coin3d.org |
00001 #ifndef COIN_SBBOX3I32_H 00002 #define COIN_SBBOX3I32_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/SbVec3i32.h> 00028 #include <Inventor/SbVec3f.h> 00029 00030 class SbBox3s; 00031 class SbBox3f; 00032 class SbBox3d; 00033 class SbMatrix; 00034 00035 class COIN_DLL_API SbBox3i32 { 00036 public: 00037 SbBox3i32(void) { makeEmpty(); } 00038 SbBox3i32(int32_t xmin, int32_t ymin, int32_t zmin, int32_t xmax, int32_t ymax, int32_t zmax) 00039 : minpt(xmin, ymin, zmin), maxpt(xmax, ymax, zmax) { } 00040 SbBox3i32(const SbVec3i32 & minpoint, const SbVec3i32 & maxpoint) 00041 : minpt(minpoint), maxpt(maxpoint) { } 00042 explicit SbBox3i32(const SbBox3s & box) { setBounds(box); } 00043 explicit SbBox3i32(const SbBox3f & box) { setBounds(box); } 00044 explicit SbBox3i32(const SbBox3d & box) { setBounds(box); } 00045 00046 SbBox3i32 & setBounds(int32_t xmin, int32_t ymin, int32_t zmin, int32_t xmax, int32_t ymax, int32_t zmax) 00047 { minpt.setValue(xmin, ymin, zmin); maxpt.setValue(xmax, ymax, zmax); return *this; } 00048 SbBox3i32 & setBounds(const SbVec3i32 & minpoint, const SbVec3i32 & maxpoint) 00049 { minpt = minpoint; maxpt = maxpoint; return *this; } 00050 SbBox3i32 & setBounds(const SbBox3s & box); 00051 SbBox3i32 & setBounds(const SbBox3f & box); 00052 SbBox3i32 & setBounds(const SbBox3d & box); 00053 00054 void getBounds(int32_t & xmin, int32_t & ymin, int32_t & zmin, int32_t & xmax, int32_t & ymax, int32_t & zmax) const 00055 { minpt.getValue(xmin, ymin, zmin); maxpt.getValue(xmax, ymax, zmax); } 00056 void getBounds(SbVec3i32 & minpoint, SbVec3i32 & maxpoint) const 00057 { minpoint = minpt; maxpoint = maxpt; } 00058 00059 const SbVec3i32 & getMin(void) const { return minpt; } 00060 SbVec3i32 & getMin(void) { return minpt; } 00061 const SbVec3i32 & getMax(void) const { return maxpt; } 00062 SbVec3i32 & getMax(void) { return maxpt; } 00063 00064 void extendBy(const SbVec3i32 & pt); 00065 void extendBy(const SbBox3i32 & bb); 00066 void extendBy(const SbVec3f & pt); 00067 void transform(const SbMatrix & m); 00068 void makeEmpty(void); 00069 SbBool isEmpty(void) const { return (maxpt[0] < minpt[0]); } 00070 SbBool hasVolume(void) const 00071 { return ((maxpt[0] > minpt[0]) && (maxpt[1] > minpt[1]) && (maxpt[2] > minpt[2])); } 00072 float getVolume(void) const 00073 { int32_t dx = 0, dy = 0, dz = 0; getSize(dx, dy, dz); return (float(dx) * float(dy) * float(dz)); } 00074 00075 SbBool intersect(const SbVec3i32 & pt) const; 00076 SbBool intersect(const SbBox3i32 & bb) const; 00077 SbBool intersect(const SbVec3f & pt) const; 00078 00079 SbBool outside(const SbMatrix & MVP, int & cullBits) const; 00080 SbVec3f getClosestPoint(const SbVec3f & pt) const; 00081 00082 SbVec3f getCenter(void) const { return SbVec3f(minpt + maxpt) * 0.5f; } 00083 void getOrigin(int32_t & originX, int32_t & originY, int32_t & originZ) const 00084 { minpt.getValue(originX, originY, originZ); } 00085 void getSize(int32_t & sizeX, int32_t & sizeY, int32_t sizeZ) const 00086 { if (isEmpty()) { sizeX = sizeY = sizeZ = 0; } 00087 else { sizeX = maxpt[0] - minpt[0]; sizeY = maxpt[1] - minpt[1]; sizeZ = maxpt[2] - minpt[2]; } } 00088 00089 void getSpan(const SbVec3f & direction, float & dmin, float & dmax) const; 00090 00091 protected: 00092 SbVec3i32 minpt, maxpt; 00093 00094 }; // SbBox3i32 00095 00096 COIN_DLL_API inline int operator == (const SbBox3i32 & b1, const SbBox3i32 & b2) 00097 { 00098 return ((b1.getMin() == b2.getMin()) && (b1.getMax() == b2.getMax())); 00099 } 00100 00101 COIN_DLL_API inline int operator != (const SbBox3i32 & b1, const SbBox3i32 & b2) 00102 { 00103 return !(b1 == b2); 00104 } 00105 00106 #endif // !COIN_SBBOX3I32_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