![]() |
Tulip
4.6.0
Better Visualization Through Research
|
00001 /* 00002 * 00003 * This file is part of Tulip (www.tulip-software.org) 00004 * 00005 * Authors: David Auber and the Tulip development Team 00006 * from LaBRI, University of Bordeaux 00007 * 00008 * Tulip is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License 00010 * as published by the Free Software Foundation, either version 3 00011 * of the License, or (at your option) any later version. 00012 * 00013 * Tulip is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 * See the GNU General Public License for more details. 00017 * 00018 */ 00019 ///@cond DOXYGEN_HIDDEN 00020 00021 //@TLPGEOLICENCE# 00022 00023 #ifndef _TLP_VECTORCAST_H 00024 #define _TLP_VECTORCAST_H 00025 00026 #include <cassert> 00027 #include <tulip/Vector.h> 00028 00029 #define TEMPLATEVECTORCAST template <typename Obj, unsigned int SIZE, typename TYPE > 00030 00031 #define VECTORCAST tlp::VectorCast<Obj, SIZE, TYPE> 00032 00033 namespace tlp { 00034 /** 00035 * @ingroup Structures 00036 * \brief class for mathematical vector 00037 * 00038 * Enables to create a Vector of Obj with a 00039 * fixed size and provides Mathematical operation. Mathematical 00040 * operators must be defined for Obj. Out of bound accesses are only checked 00041 * in debug mode. 00042 * 00043 * \author : David Auber auber@tulip-software.org 00044 * \version 0.0.1 24/01/2003 00045 */ 00046 TEMPLATEVECTORCAST 00047 class TLP_SCOPE VectorCast : public Vector<Obj,SIZE> { 00048 public: 00049 VectorCast() {} 00050 inline explicit VectorCast(const tlp::Vector<float,3> &v):Vector<Obj,SIZE>(v) { 00051 } 00052 00053 inline TYPE & operator*=(const Obj obj) { 00054 return (TYPE &)this->Vector<Obj,SIZE>::operator*=(obj); 00055 } 00056 inline TYPE & operator*=(const Vector<Obj,SIZE> &vec) { 00057 return (TYPE &)this->Vector<Obj,SIZE>::operator*=(vec); 00058 } 00059 inline TYPE & operator/=(const Obj obj) { 00060 return (TYPE &)this->Vector<Obj,SIZE>::operator/=(obj); 00061 } 00062 inline TYPE & operator/=(const Vector<Obj,SIZE> &vec) { 00063 return (TYPE &)this->Vector<Obj,SIZE>::operator/=(vec); 00064 } 00065 inline TYPE & operator+=(const Obj obj) { 00066 return (TYPE &)this->Vector<Obj,SIZE>::operator+=(obj); 00067 } 00068 inline TYPE & operator+=(const Vector<Obj,SIZE> &vec) { 00069 return (TYPE &)this->Vector<Obj,SIZE>::operator+=(vec); 00070 } 00071 inline TYPE & operator-=(const Obj obj) { 00072 return (TYPE &)this->Vector<Obj,SIZE>::operator-=(obj); 00073 } 00074 inline TYPE & operator-=(const Vector<Obj,SIZE> &vec) { 00075 return (TYPE &)this->Vector<Obj,SIZE>::operator-=(vec); 00076 } 00077 inline TYPE & operator^=(const Vector<Obj,SIZE> &vec) { 00078 return (TYPE &)this->Vector<Obj,SIZE>::operator^=(vec); 00079 } 00080 inline TYPE & fill(const Obj obj) { 00081 return (TYPE &)this->Vector<Obj,SIZE>::fill(obj); 00082 } 00083 00084 inline TYPE operator*(const Vector<Obj,SIZE> &v) const { 00085 return VECTORCAST(*this)*=v; 00086 } 00087 inline TYPE operator*(const Obj v) const { 00088 return VECTORCAST(*this)*=v; 00089 } 00090 inline TYPE operator+(const Vector<Obj,SIZE> &v) const { 00091 return VECTORCAST(*this)+=v; 00092 } 00093 inline TYPE operator+(const Obj v) const { 00094 return VECTORCAST(*this)+=v; 00095 } 00096 inline TYPE operator-(const Vector<Obj,SIZE> &v) const { 00097 return VECTORCAST(*this)-=v; 00098 } 00099 inline TYPE operator-(const Obj v)const { 00100 return VECTORCAST(*this)-=v; 00101 } 00102 inline TYPE operator/(const Vector<Obj,SIZE> &v) const { 00103 return VECTORCAST(*this)/=v; 00104 } 00105 inline TYPE operator/(const Obj v) const { 00106 return VECTORCAST(*this)/=v; 00107 } 00108 inline TYPE operator^(const Vector<Obj,SIZE> &v) const { 00109 return VECTORCAST(*this)^=v; 00110 } 00111 00112 }; 00113 00114 00115 00116 00117 } 00118 00119 #endif 00120 ///@endcond