Tulip  4.8.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
VectorCast.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 ///@cond DOXYGEN_HIDDEN
20 
21 //@TLPGEOLICENCE#
22 
23 #ifndef _TLP_VECTORCAST_H
24 #define _TLP_VECTORCAST_H
25 
26 #include <cassert>
27 #include <tulip/Vector.h>
28 
29 #define TEMPLATEVECTORCAST template <typename Obj, unsigned int SIZE, typename TYPE >
30 
31 #define VECTORCAST tlp::VectorCast<Obj, SIZE, TYPE>
32 
33 namespace tlp {
34 /**
35  * @ingroup Structures
36  * \brief class for mathematical vector
37  *
38  * Enables to create a Vector of Obj with a
39  * fixed size and provides Mathematical operation. Mathematical
40  * operators must be defined for Obj. Out of bound accesses are only checked
41  * in debug mode.
42  *
43  * \author : David Auber auber@tulip-software.org
44  * \version 0.0.1 24/01/2003
45  */
46 TEMPLATEVECTORCAST
47 class TLP_SCOPE VectorCast : public Vector<Obj,SIZE> {
48 public:
49  VectorCast() {}
50  inline explicit VectorCast(const tlp::Vector<float,3> &v):Vector<Obj,SIZE>(v) {
51  }
52 
53  inline TYPE & operator*=(const Obj obj) {
54  return (TYPE &)this->Vector<Obj,SIZE>::operator*=(obj);
55  }
56  inline TYPE & operator*=(const Vector<Obj,SIZE> &vec) {
57  return (TYPE &)this->Vector<Obj,SIZE>::operator*=(vec);
58  }
59  inline TYPE & operator/=(const Obj obj) {
60  return (TYPE &)this->Vector<Obj,SIZE>::operator/=(obj);
61  }
62  inline TYPE & operator/=(const Vector<Obj,SIZE> &vec) {
63  return (TYPE &)this->Vector<Obj,SIZE>::operator/=(vec);
64  }
65  inline TYPE & operator+=(const Obj obj) {
66  return (TYPE &)this->Vector<Obj,SIZE>::operator+=(obj);
67  }
68  inline TYPE & operator+=(const Vector<Obj,SIZE> &vec) {
69  return (TYPE &)this->Vector<Obj,SIZE>::operator+=(vec);
70  }
71  inline TYPE & operator-=(const Obj obj) {
72  return (TYPE &)this->Vector<Obj,SIZE>::operator-=(obj);
73  }
74  inline TYPE & operator-=(const Vector<Obj,SIZE> &vec) {
75  return (TYPE &)this->Vector<Obj,SIZE>::operator-=(vec);
76  }
77  inline TYPE & operator^=(const Vector<Obj,SIZE> &vec) {
78  return (TYPE &)this->Vector<Obj,SIZE>::operator^=(vec);
79  }
80  inline TYPE & fill(const Obj obj) {
81  return (TYPE &)this->Vector<Obj,SIZE>::fill(obj);
82  }
83 
84  inline TYPE operator*(const Vector<Obj,SIZE> &v) const {
85  return VECTORCAST(*this)*=v;
86  }
87  inline TYPE operator*(const Obj v) const {
88  return VECTORCAST(*this)*=v;
89  }
90  inline TYPE operator+(const Vector<Obj,SIZE> &v) const {
91  return VECTORCAST(*this)+=v;
92  }
93  inline TYPE operator+(const Obj v) const {
94  return VECTORCAST(*this)+=v;
95  }
96  inline TYPE operator-(const Vector<Obj,SIZE> &v) const {
97  return VECTORCAST(*this)-=v;
98  }
99  inline TYPE operator-(const Obj v)const {
100  return VECTORCAST(*this)-=v;
101  }
102  inline TYPE operator/(const Vector<Obj,SIZE> &v) const {
103  return VECTORCAST(*this)/=v;
104  }
105  inline TYPE operator/(const Obj v) const {
106  return VECTORCAST(*this)/=v;
107  }
108  inline TYPE operator^(const Vector<Obj,SIZE> &v) const {
109  return VECTORCAST(*this)^=v;
110  }
111 
112 };
113 
114 
115 
116 
117 }
118 
119 #endif
120 ///@endcond