![]() |
http://www.sim.no http://www.coin3d.org |
00001 #ifndef COIN_SBVEC3US_H 00002 #define COIN_SBVEC3US_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/SbBasic.h> 00028 #include <Inventor/system/inttypes.h> 00029 #ifndef NDEBUG 00030 #include <Inventor/errors/SoDebugError.h> 00031 #endif // !NDEBUG 00032 00033 class SbVec3s; 00034 class SbVec3ub; 00035 class SbVec3ui32; 00036 00037 class COIN_DLL_API SbVec3us { 00038 public: 00039 SbVec3us(void) { } 00040 SbVec3us(const unsigned short v[3]) { vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2]; } 00041 SbVec3us(unsigned short x, unsigned short y, unsigned short z) { vec[0] = x; vec[1] = y; vec[2] = z; } 00042 explicit SbVec3us(const SbVec3s & v) { setValue(v); } 00043 explicit SbVec3us(const SbVec3ub & v) { setValue(v); } 00044 explicit SbVec3us(const SbVec3ui32 & v) { setValue(v); } 00045 00046 SbVec3us & setValue(const unsigned short v[3]) { vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2]; return *this; } 00047 SbVec3us & setValue(unsigned short x, unsigned short y, unsigned short z) { vec[0] = x; vec[1] = y; vec[2] = z; return *this; } 00048 SbVec3us & setValue(const SbVec3s & v); 00049 SbVec3us & setValue(const SbVec3ub & v); 00050 SbVec3us & setValue(const SbVec3ui32 & v); 00051 00052 const unsigned short * getValue(void) const { return vec; } 00053 void getValue(unsigned short & x, unsigned short & y, unsigned short & z) const { x = vec[0]; y = vec[1]; z = vec[2]; } 00054 00055 unsigned short & operator [] (int i) { return vec[i]; } 00056 const unsigned short & operator [] (int i) const { return vec[i]; } 00057 00058 int32_t dot(const SbVec3us & v) const { return vec[0] * v[0] + vec[1] * v[1] + vec[2] * v[2]; } 00059 void negate(void); 00060 00061 SbVec3us & operator *= (int d) { vec[0] *= d; vec[1] *= d; vec[2] *= d; return *this; } 00062 SbVec3us & operator *= (double d); 00063 SbVec3us & operator /= (int d) { SbDividerChk("SbVec3us::operator/=(int)", d); vec[0] /= d; vec[1] /= d; vec[2] /= d; return *this; } 00064 SbVec3us & operator /= (double d) { SbDividerChk("SbVec3us::operator/=(double)", d); return operator *= (1.0 / d); } 00065 SbVec3us & operator += (const SbVec3us & v) { vec[0] += v[0]; vec[1] += v[1]; vec[2] += v[2]; return *this; } 00066 SbVec3us & operator -= (const SbVec3us & v) { vec[0] -= v[0]; vec[1] -= v[1]; vec[2] -= v[2]; return *this; } 00067 SbVec3us operator - (void) const { SbVec3us v(*this); v.negate(); return v; } 00068 00069 protected: 00070 unsigned short vec[3]; 00071 00072 }; // SbVec3us 00073 00074 COIN_DLL_API inline SbVec3us operator * (const SbVec3us & v, int d) { 00075 SbVec3us val(v); val *= d; return val; 00076 } 00077 00078 COIN_DLL_API inline SbVec3us operator * (const SbVec3us & v, double d) { 00079 SbVec3us val(v); val *= d; return val; 00080 } 00081 00082 COIN_DLL_API inline SbVec3us operator * (int d, const SbVec3us & v) { 00083 SbVec3us val(v); val *= d; return val; 00084 } 00085 00086 COIN_DLL_API inline SbVec3us operator * (double d, const SbVec3us & v) { 00087 SbVec3us val(v); val *= d; return val; 00088 } 00089 00090 COIN_DLL_API inline SbVec3us operator / (const SbVec3us & v, int d) { 00091 SbDividerChk("operator/(SbVec3us,int)", d); 00092 SbVec3us val(v); val /= d; return val; 00093 } 00094 00095 COIN_DLL_API inline SbVec3us operator / (const SbVec3us & v, double d) { 00096 SbDividerChk("operator/(SbVec3us,double)", d); 00097 SbVec3us val(v); val /= d; return val; 00098 } 00099 00100 COIN_DLL_API inline SbVec3us operator + (const SbVec3us & v1, const SbVec3us & v2) { 00101 SbVec3us v(v1); v += v2; return v; 00102 } 00103 00104 COIN_DLL_API inline SbVec3us operator - (const SbVec3us & v1, const SbVec3us & v2) { 00105 SbVec3us v(v1); v -= v2; return v; 00106 } 00107 00108 COIN_DLL_API inline int operator == (const SbVec3us & v1, const SbVec3us & v2) { 00109 return ((v1[0] == v2[0]) && (v1[1] == v2[1]) && (v1[2] == v2[2])); 00110 } 00111 00112 COIN_DLL_API inline int operator != (const SbVec3us & v1, const SbVec3us & v2) { 00113 return !(v1 == v2); 00114 } 00115 00116 #endif // !COIN_SBVEC3US_H
Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.
Generated on Mon Feb 23 16:33:10 2009 for Coin by Doxygen. 1.5.8