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

SbVec2i32.h
00001 #ifndef COIN_SBVEC2I32_H
00002 #define COIN_SBVEC2I32_H
00003 
00004 /**************************************************************************\
00005  *
00006  *  This file is part of the Coin 3D visualization library.
00007  *  Copyright (C) by Kongsberg Oil & Gas Technologies.
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 Kongsberg Oil & Gas Technologies
00018  *  about acquiring a Coin Professional Edition License.
00019  *
00020  *  See http://www.coin3d.org/ for more information.
00021  *
00022  *  Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
00023  *  http://www.sim.no/  sales@sim.no  coin-support@coin3d.org
00024  *
00025 \**************************************************************************/
00026 
00027 #include <stdio.h>
00028 
00029 #include <Inventor/SbBasic.h>
00030 #include <Inventor/system/inttypes.h>
00031 #ifndef NDEBUG
00032 #include <Inventor/errors/SoDebugError.h>
00033 #endif // !NDEBUG
00034 
00035 class SbVec2ui32;
00036 class SbVec2b;
00037 class SbVec2s;
00038 class SbVec2f;
00039 class SbVec2d;
00040 
00041 class COIN_DLL_API SbVec2i32 {
00042 public:
00043   SbVec2i32(void) { }
00044   SbVec2i32(const int32_t v[2]) { vec[0] = v[0]; vec[1] = v[1]; }
00045   SbVec2i32(int32_t x, int32_t y) { vec[0] = x; vec[1] = y; }
00046   explicit SbVec2i32(const SbVec2ui32 & v) { setValue(v); }
00047   explicit SbVec2i32(const SbVec2b & v) { setValue(v); }
00048   explicit SbVec2i32(const SbVec2s & v) { setValue(v); }
00049   explicit SbVec2i32(const SbVec2f & v) { setValue(v); }
00050   explicit SbVec2i32(const SbVec2d & v) { setValue(v); }
00051 
00052   SbVec2i32 & setValue(const int32_t v[2]) { vec[0] = v[0]; vec[1] = v[1]; return *this; }
00053   SbVec2i32 & setValue(int32_t x, int32_t y) { vec[0] = x; vec[1] = y; return *this; }
00054   SbVec2i32 & setValue(const SbVec2ui32 & v);
00055   SbVec2i32 & setValue(const SbVec2b & v);
00056   SbVec2i32 & setValue(const SbVec2s & v);
00057   SbVec2i32 & setValue(const SbVec2f & v);
00058   SbVec2i32 & setValue(const SbVec2d & v);
00059 
00060   const int32_t * getValue(void) const { return vec; }
00061   void getValue(int32_t & x, int32_t & y) const { x = vec[0]; y = vec[1]; }
00062 
00063   int32_t & operator [] (const int i) { return vec[i]; }
00064   const int32_t & operator [] (const int i) const { return vec[i]; }
00065 
00066   int32_t dot(const SbVec2i32 & v) const { return vec[0] * v[0] + vec[1] * v[1]; }
00067   void negate(void) { vec[0] = -vec[0]; vec[1] = -vec[1]; }
00068 
00069   SbVec2i32 & operator *= (int d) { vec[0] *= d; vec[1] *= d; return *this; }
00070   SbVec2i32 & operator *= (double d);
00071   SbVec2i32 & operator /= (int d) { SbDividerChk("SbVec2i32::operator/=(int)", d); vec[0] /= d; vec[1] /= d; return *this; }
00072   SbVec2i32 & operator /= (double d) { SbDividerChk("SbVec2i32::operator/=(double)", d); return operator *= (1.0 / d); }
00073   SbVec2i32 & operator += (const SbVec2i32 & v) { vec[0] += v[0]; vec[1] += v[1]; return *this; }
00074   SbVec2i32 & operator -= (const SbVec2i32 & v) { vec[0] -= v[0]; vec[1] -= v[1]; return *this; }
00075   SbVec2i32 operator - (void) const { return SbVec2i32(-vec[0], -vec[1]); }
00076 
00077   void print(FILE * fp) const;
00078 
00079 protected:
00080   int32_t vec[2];
00081 
00082 }; // SbVec2i32
00083 
00084 COIN_DLL_API inline SbVec2i32 operator * (const SbVec2i32 & v, int d) {
00085   SbVec2i32 val(v); val *= d; return val;
00086 }
00087 
00088 COIN_DLL_API inline SbVec2i32 operator * (const SbVec2i32 & v, double d) {
00089   SbVec2i32 val(v); val *= d; return val;
00090 }
00091 
00092 COIN_DLL_API inline SbVec2i32 operator * (int d, const SbVec2i32 & v) {
00093   SbVec2i32 val(v); val *= d; return val;
00094 }
00095 
00096 COIN_DLL_API inline SbVec2i32 operator * (double d, const SbVec2i32 & v) {
00097   SbVec2i32 val(v); val *= d; return val;
00098 }
00099 
00100 COIN_DLL_API inline SbVec2i32 operator / (const SbVec2i32 & v, int d) {
00101   SbDividerChk("operator/(SbVec2i32,int)", d);
00102   SbVec2i32 val(v); val /= d; return val;
00103 }
00104 
00105 COIN_DLL_API inline SbVec2i32 operator / (const SbVec2i32 & v, double d) {
00106   SbDividerChk("operator/(SbVec2i32,double)", d);
00107   SbVec2i32 val(v); val /= d; return val;
00108 }
00109 
00110 COIN_DLL_API inline SbVec2i32 operator + (const SbVec2i32 & v1, const SbVec2i32 & v2) {
00111   SbVec2i32 v(v1); v += v2; return v;
00112 }
00113 
00114 COIN_DLL_API inline SbVec2i32 operator - (const SbVec2i32 & v1, const SbVec2i32 & v2) {
00115   SbVec2i32 v(v1); v -= v2; return v;
00116 }
00117 
00118 COIN_DLL_API inline int operator == (const SbVec2i32 & v1, const SbVec2i32 & v2) {
00119   return ((v1[0] == v2[0]) && (v1[1] == v2[1]));
00120 }
00121 
00122 COIN_DLL_API inline int operator != (const SbVec2i32& v1, const SbVec2i32& v2) {
00123   return !(v1 == v2);
00124 }
00125 
00126 #endif // !COIN_SBVEC2I32_H

Copyright © 1998-2010 by Kongsberg Oil & Gas Technologies. All rights reserved.

Generated for Coin by Doxygen 1.7.5.1.