File indexing completed on 2026-08-22 09:14:02
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
0069 public:
0070
0071
0072
0073 inline math_VectorBase(const Standard_Integer theLower, const Standard_Integer theUpper);
0074
0075
0076
0077 inline math_VectorBase(const Standard_Integer theLower,
0078 const Standard_Integer theUpper,
0079 const TheItemType theInitialValue);
0080
0081
0082
0083 inline math_VectorBase(const TheItemType* theTab,
0084 const Standard_Integer theLower,
0085 const Standard_Integer theUpper);
0086
0087
0088 inline math_VectorBase(const gp_XY& Other);
0089
0090
0091 inline math_VectorBase(const gp_XYZ& Other);
0092
0093
0094 void Init(const TheItemType theInitialValue);
0095
0096
0097
0098 inline math_VectorBase(const math_VectorBase& theOther);
0099
0100
0101 inline Standard_Integer Length() const { return Array.Length(); }
0102
0103
0104 inline Standard_Integer Lower() const { return Array.Lower(); }
0105
0106
0107 inline Standard_Integer Upper() const { return Array.Upper(); }
0108
0109
0110 inline Standard_Real Norm() const;
0111
0112
0113 inline Standard_Real Norm2() const;
0114
0115
0116 inline Standard_Integer Max() const;
0117
0118
0119 inline Standard_Integer Min() const;
0120
0121
0122
0123
0124
0125
0126 inline void Normalize();
0127
0128
0129
0130
0131
0132
0133 Standard_NODISCARD inline math_VectorBase Normalized() const;
0134
0135
0136 inline void Invert();
0137
0138
0139 inline math_VectorBase Inverse() const;
0140
0141
0142
0143
0144
0145 inline void Set(const Standard_Integer theI1,
0146 const Standard_Integer theI2,
0147 const math_VectorBase& theV);
0148
0149
0150
0151
0152
0153
0154 inline math_VectorBase Slice(const Standard_Integer theI1, const Standard_Integer theI2) const;
0155
0156
0157 inline void Multiply(const TheItemType theRight);
0158
0159 void operator*=(const TheItemType theRight) { Multiply(theRight); }
0160
0161
0162 Standard_NODISCARD inline math_VectorBase Multiplied(const TheItemType theRight) const;
0163
0164 Standard_NODISCARD math_VectorBase operator*(const TheItemType theRight) const
0165 {
0166 return Multiplied(theRight);
0167 }
0168
0169
0170 Standard_NODISCARD inline math_VectorBase TMultiplied(const TheItemType theRight) const;
0171
0172 friend inline math_VectorBase operator*(const TheItemType theLeft,
0173 const math_VectorBase& theRight)
0174 {
0175 return theRight.Multiplied(theLeft);
0176 }
0177
0178
0179
0180 inline void Divide(const TheItemType theRight);
0181
0182 void operator/=(const TheItemType theRight) { Divide(theRight); }
0183
0184
0185
0186 Standard_NODISCARD inline math_VectorBase Divided(const TheItemType theRight) const;
0187
0188 Standard_NODISCARD math_VectorBase operator/(const TheItemType theRight) const
0189 {
0190 return Divided(theRight);
0191 }
0192
0193
0194
0195
0196
0197
0198 inline void Add(const math_VectorBase& theRight);
0199
0200 void operator+=(const math_VectorBase& theRight) { Add(theRight); }
0201
0202
0203
0204
0205 Standard_NODISCARD inline math_VectorBase Added(const math_VectorBase& theRight) const;
0206
0207 Standard_NODISCARD math_VectorBase operator+(const math_VectorBase& theRight) const
0208 {
0209 return Added(theRight);
0210 }
0211
0212
0213
0214 inline void Multiply(const math_VectorBase& theLeft, const math_Matrix& theRight);
0215
0216
0217
0218 inline void Multiply(const math_Matrix& theLeft, const math_VectorBase& theRight);
0219
0220
0221
0222 inline void TMultiply(const math_Matrix& theTLeft, const math_VectorBase& theRight);
0223
0224
0225
0226 inline void TMultiply(const math_VectorBase& theLeft, const math_Matrix& theTRight);
0227
0228
0229
0230
0231 inline void Add(const math_VectorBase& theLeft, const math_VectorBase& theRight);
0232
0233
0234
0235
0236
0237
0238
0239
0240 inline void Subtract(const math_VectorBase& theLeft, const math_VectorBase& theRight);
0241
0242
0243 const TheItemType& Value(const Standard_Integer theNum) const { return Array(theNum); }
0244
0245
0246 inline TheItemType& Value(const Standard_Integer theNum) { return Array(theNum); }
0247
0248 const TheItemType& operator()(const Standard_Integer theNum) const { return Value(theNum); }
0249
0250 TheItemType& operator()(const Standard_Integer theNum) { return Value(theNum); }
0251
0252
0253
0254 inline math_VectorBase& Initialized(const math_VectorBase& theOther);
0255
0256 math_VectorBase& operator=(const math_VectorBase& theOther) { return Initialized(theOther); }
0257
0258
0259
0260 Standard_NODISCARD inline TheItemType Multiplied(const math_VectorBase& theRight) const;
0261
0262 Standard_NODISCARD inline TheItemType operator*(const math_VectorBase& theRight) const
0263 {
0264 return Multiplied(theRight);
0265 }
0266
0267
0268 Standard_NODISCARD inline math_VectorBase Multiplied(const math_Matrix& theRight) const;
0269
0270 Standard_NODISCARD math_VectorBase operator*(const math_Matrix& theRight) const
0271 {
0272 return Multiplied(theRight);
0273 }
0274
0275
0276 inline math_VectorBase Opposite();
0277
0278 math_VectorBase operator-() { return Opposite(); }
0279
0280
0281
0282 inline void Subtract(const math_VectorBase& theRight);
0283
0284 void operator-=(const math_VectorBase& theRight) { Subtract(theRight); }
0285
0286
0287
0288 Standard_NODISCARD inline math_VectorBase Subtracted(const math_VectorBase& theRight) const;
0289
0290 Standard_NODISCARD math_VectorBase operator-(const math_VectorBase& theRight) const
0291 {
0292 return Subtracted(theRight);
0293 }
0294
0295
0296
0297 inline void Multiply(const TheItemType theLeft, const math_VectorBase& theRight);
0298
0299
0300
0301 inline void Dump(Standard_OStream& theO) const;
0302
0303 friend inline Standard_OStream& operator<<(Standard_OStream& theO, const math_VectorBase& theVec)
0304 {
0305 theVec.Dump(theO);
0306 return theO;
0307 }
0308
0309 friend class math_Matrix;
0310
0311 protected:
0312
0313 inline void SetLower(const Standard_Integer theLower);
0314
0315 private:
0316 std::array<TheItemType, THE_BUFFER_SIZE> myBuffer;
0317 NCollection_Array1<TheItemType> Array;
0318 };
0319
0320 #include <math_VectorBase.lxx>
0321
0322 #endif