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

SbVec3i32.h

00001 #ifndef COIN_SBVEC3I32_H
00002 #define COIN_SBVEC3I32_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 SbVec3ui32;
00034 class SbVec3b;
00035 class SbVec3s;
00036 class SbVec3f;
00037 class SbVec3d;
00038 
00039 class COIN_DLL_API SbVec3i32 {
00040 public:
00041   SbVec3i32(void) { }
00042   SbVec3i32(const int32_t v[3]) { vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2]; }
00043   SbVec3i32(int32_t x, int32_t y, int32_t z) { vec[0] = x; vec[1] = y; vec[2] = z; }
00044   explicit SbVec3i32(const SbVec3ui32 & v) { setValue(v); }
00045   explicit SbVec3i32(const SbVec3b & v) { setValue(v); }
00046   explicit SbVec3i32(const SbVec3s & v) { setValue(v); }
00047   explicit SbVec3i32(const SbVec3f & v) { setValue(v); }
00048   explicit SbVec3i32(const SbVec3d & v) { setValue(v); }
00049 
00050   SbVec3i32 & setValue(const int32_t v[3]) { vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2]; return *this; }
00051   SbVec3i32 & setValue(int32_t x, int32_t y, int32_t z) { vec[0] = x; vec[1] = y; vec[2] = z; return *this; }
00052   SbVec3i32 & setValue(const SbVec3ui32 & v);
00053   SbVec3i32 & setValue(const SbVec3b & v);
00054   SbVec3i32 & setValue(const SbVec3s & v);
00055   SbVec3i32 & setValue(const SbVec3f & v);
00056   SbVec3i32 & setValue(const SbVec3d & v);
00057 
00058   const int32_t * getValue(void) const { return vec; }
00059   void getValue(int32_t & x, int32_t & y, int32_t & z) const { x = vec[0]; y = vec[1]; z = vec[2]; }
00060 
00061   int32_t & operator [] (int i) { return vec[i]; }
00062   const int32_t & operator [] (int i) const { return vec[i]; }
00063 
00064   int32_t dot(const SbVec3i32 & v) const { return vec[0] * v[0] + vec[1] * v[1] + vec[2] * v[2]; }
00065   void negate(void) { vec[0] = -vec[0]; vec[1] = -vec[1]; vec[2] = -vec[2]; }
00066 
00067   SbVec3i32 & operator *= (int d) { vec[0] *= d; vec[1] *= d; vec[2] *= d; return *this; }
00068   SbVec3i32 & operator *= (double d);
00069   SbVec3i32 & operator /= (int d) { SbDividerChk("SbVec3i32::operator/=(int)", d); vec[0] /= d; vec[1] /= d; vec[2] /= d; return *this; }
00070   SbVec3i32 & operator /= (double d) { SbDividerChk("SbVec3i32::operator/=(double)", d); return operator *= (1.0 / d); }
00071   SbVec3i32 & operator += (const SbVec3i32 & v) { vec[0] += v[0]; vec[1] += v[1]; vec[2] += v[2]; return *this; }
00072   SbVec3i32 & operator -= (const SbVec3i32 & v) { vec[0] -= v[0]; vec[1] -= v[1]; vec[2] -= v[2]; return *this; }
00073   SbVec3i32 operator - (void) const { return SbVec3i32(-vec[0], -vec[1], -vec[2]); }
00074 
00075 protected:
00076   int32_t vec[3];
00077 
00078 }; // SbVec3i32
00079 
00080 COIN_DLL_API inline SbVec3i32 operator * (const SbVec3i32 & v, int d) {
00081   SbVec3i32 val(v); val *= d; return val;
00082 }
00083 
00084 COIN_DLL_API inline SbVec3i32 operator * (const SbVec3i32 & v, double d) {
00085   SbVec3i32 val(v); val *= d; return val;
00086 }
00087 
00088 COIN_DLL_API inline SbVec3i32 operator * (int d, const SbVec3i32 & v) {
00089   SbVec3i32 val(v); val *= d; return val;
00090 }
00091 
00092 COIN_DLL_API inline SbVec3i32 operator * (double d, const SbVec3i32 & v) {
00093   SbVec3i32 val(v); val *= d; return val;
00094 }
00095 
00096 COIN_DLL_API inline SbVec3i32 operator / (const SbVec3i32 & v, int d) {
00097   SbDividerChk("operator/(SbVec3i32,int)", d); 
00098   SbVec3i32 val(v); val /= d; return val;
00099 }
00100 
00101 COIN_DLL_API inline SbVec3i32 operator / (const SbVec3i32 & v, double d) {
00102   SbDividerChk("operator/(SbVec3i32,double)", d); 
00103   SbVec3i32 val(v); val /= d; return val;
00104 }
00105 
00106 COIN_DLL_API inline SbVec3i32 operator + (const SbVec3i32 & v1, const SbVec3i32 & v2) {
00107   SbVec3i32 v(v1); v += v2; return v;
00108 }
00109 
00110 COIN_DLL_API inline SbVec3i32 operator - (const SbVec3i32 & v1, const SbVec3i32 & v2) {
00111   SbVec3i32 v(v1); v -= v2; return v;
00112 }
00113 
00114 COIN_DLL_API inline int operator == (const SbVec3i32 & v1, const SbVec3i32 & v2) {
00115   return ((v1[0] == v2[0]) && (v1[1] == v2[1]) && (v1[2] == v2[2]));
00116 }
00117 
00118 COIN_DLL_API inline int operator != (const SbVec3i32 & v1, const SbVec3i32 & v2) {
00119   return !(v1 == v2);
00120 }
00121 
00122 #endif // !COIN_SBVEC3I32_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