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