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