File indexing completed on 2025-01-18 10:04:15
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef _math_VectorBase_HeaderFile
0016 #define _math_VectorBase_HeaderFile
0017
0018 #include <NCollection_Array1.hxx>
0019 #include <gp_XY.hxx>
0020 #include <gp_XYZ.hxx>
0021
0022
0023 #ifdef Opposite
0024 #undef Opposite
0025 #endif
0026
0027 #include <math_Matrix.hxx>
0028
0029 #include <array>
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059 template<typename TheItemType>
0060 class math_VectorBase
0061 {
0062 static const int THE_BUFFER_SIZE = 32;
0063
0064 public:
0065
0066 DEFINE_STANDARD_ALLOC;
0067 DEFINE_NCOLLECTION_ALLOC;
0068 public:
0069
0070
0071
0072 inline math_VectorBase(const Standard_Integer theLower, const Standard_Integer theUpper);
0073
0074
0075
0076 inline math_VectorBase(const Standard_Integer theLower, const Standard_Integer theUpper, const TheItemType theInitialValue);
0077
0078
0079
0080 inline math_VectorBase(const TheItemType* theTab, const Standard_Integer theLower, const Standard_Integer theUpper);
0081
0082
0083 inline math_VectorBase(const gp_XY& Other);
0084
0085
0086 inline math_VectorBase(const gp_XYZ& Other);
0087
0088
0089 void Init(const TheItemType theInitialValue);
0090
0091
0092
0093 inline math_VectorBase(const math_VectorBase& theOther);
0094
0095
0096 inline Standard_Integer Length() const
0097 {
0098 return Array.Length();
0099 }
0100
0101
0102 inline Standard_Integer Lower() const
0103 {
0104 return Array.Lower();
0105 }
0106
0107
0108 inline Standard_Integer Upper() const
0109 {
0110 return Array.Upper();
0111 }
0112
0113
0114 inline Standard_Real Norm() const;
0115
0116
0117 inline Standard_Real Norm2() const;
0118
0119
0120 inline Standard_Integer Max() const;
0121
0122
0123 inline Standard_Integer Min() const;
0124
0125
0126
0127
0128
0129
0130 inline void Normalize();
0131
0132
0133
0134
0135
0136
0137 Standard_NODISCARD inline math_VectorBase Normalized() const;
0138
0139
0140 inline void Invert();
0141
0142
0143 inline math_VectorBase Inverse() const;
0144
0145
0146
0147
0148 inline void Set(const Standard_Integer theI1, const Standard_Integer theI2, const math_VectorBase& theV);
0149
0150
0151
0152
0153
0154
0155 inline math_VectorBase Slice(const Standard_Integer theI1, const Standard_Integer theI2) const;
0156
0157
0158 inline void Multiply(const TheItemType theRight);
0159
0160 void operator *=(const TheItemType theRight)
0161 {
0162 Multiply(theRight);
0163 }
0164
0165
0166 Standard_NODISCARD inline math_VectorBase Multiplied(const TheItemType theRight) const;
0167
0168 Standard_NODISCARD math_VectorBase operator*(const TheItemType theRight) const
0169 {
0170 return Multiplied(theRight);
0171 }
0172
0173
0174 Standard_NODISCARD inline math_VectorBase TMultiplied(const TheItemType theRight) const;
0175
0176 friend inline math_VectorBase operator* (const TheItemType theLeft, const math_VectorBase& theRight)
0177 {
0178 return theRight.Multiplied(theLeft);
0179 }
0180
0181
0182
0183 inline void Divide(const TheItemType theRight);
0184
0185 void operator /=(const TheItemType theRight)
0186 {
0187 Divide(theRight);
0188 }
0189
0190
0191
0192 Standard_NODISCARD inline math_VectorBase Divided(const TheItemType theRight) const;
0193
0194 Standard_NODISCARD math_VectorBase operator/(const TheItemType theRight) const
0195 {
0196 return Divided(theRight);
0197 }
0198
0199
0200
0201
0202
0203
0204 inline void Add(const math_VectorBase& theRight);
0205
0206 void operator +=(const math_VectorBase& theRight)
0207 {
0208 Add(theRight);
0209 }
0210
0211
0212
0213
0214 Standard_NODISCARD inline math_VectorBase Added(const math_VectorBase& theRight) const;
0215
0216 Standard_NODISCARD math_VectorBase operator+(const math_VectorBase& theRight) const
0217 {
0218 return Added(theRight);
0219 }
0220
0221
0222
0223 inline void Multiply(const math_VectorBase& theLeft, const math_Matrix& theRight);
0224
0225
0226
0227 inline void Multiply(const math_Matrix& theLeft, const math_VectorBase& theRight);
0228
0229
0230
0231 inline void TMultiply(const math_Matrix& theTLeft, const math_VectorBase& theRight);
0232
0233
0234
0235 inline void TMultiply(const math_VectorBase& theLeft, const math_Matrix& theTRight);
0236
0237
0238
0239
0240 inline void Add(const math_VectorBase& theLeft, const math_VectorBase& theRight);
0241
0242
0243
0244
0245
0246
0247
0248
0249 inline void Subtract(const math_VectorBase& theLeft, const math_VectorBase& theRight);
0250
0251
0252 const TheItemType& Value(const Standard_Integer theNum) const
0253 {
0254 return Array(theNum);
0255 }
0256
0257
0258 inline TheItemType& Value(const Standard_Integer theNum)
0259 {
0260 return Array(theNum);
0261 }
0262
0263 const TheItemType& operator()(const Standard_Integer theNum) const
0264 {
0265 return Value(theNum);
0266 }
0267
0268 TheItemType& operator()(const Standard_Integer theNum)
0269 {
0270 return Value(theNum);
0271 }
0272
0273
0274
0275 inline math_VectorBase& Initialized(const math_VectorBase& theOther);
0276
0277 math_VectorBase& operator=(const math_VectorBase& theOther)
0278 {
0279 return Initialized(theOther);
0280 }
0281
0282
0283
0284 Standard_NODISCARD inline TheItemType Multiplied(const math_VectorBase& theRight) const;
0285 Standard_NODISCARD inline TheItemType operator*(const math_VectorBase& theRight) const
0286 {
0287 return Multiplied(theRight);
0288 }
0289
0290
0291 Standard_NODISCARD inline math_VectorBase Multiplied(const math_Matrix& theRight) const;
0292
0293 Standard_NODISCARD math_VectorBase operator*(const math_Matrix& theRight) const
0294 {
0295 return Multiplied(theRight);
0296 }
0297
0298
0299 inline math_VectorBase Opposite();
0300
0301 math_VectorBase operator-()
0302 {
0303 return Opposite();
0304 }
0305
0306
0307
0308 inline void Subtract(const math_VectorBase& theRight);
0309
0310 void operator-=(const math_VectorBase& theRight)
0311 {
0312 Subtract(theRight);
0313 }
0314
0315
0316
0317 Standard_NODISCARD inline math_VectorBase Subtracted(const math_VectorBase& theRight) const;
0318
0319 Standard_NODISCARD math_VectorBase operator-(const math_VectorBase& theRight) const
0320 {
0321 return Subtracted(theRight);
0322 }
0323
0324
0325
0326 inline void Multiply(const TheItemType theLeft, const math_VectorBase& theRight);
0327
0328
0329
0330 inline void Dump(Standard_OStream& theO) const;
0331
0332 friend inline Standard_OStream& operator<<(Standard_OStream& theO, const math_VectorBase& theVec)
0333 {
0334 theVec.Dump(theO);
0335 return theO;
0336 }
0337
0338 friend class math_Matrix;
0339
0340 protected:
0341
0342
0343 inline void SetLower(const Standard_Integer theLower);
0344
0345 private:
0346 std::array<TheItemType, THE_BUFFER_SIZE> myBuffer;
0347 NCollection_Array1<TheItemType> Array;
0348 };
0349
0350 #include <math_VectorBase.lxx>
0351
0352 #endif