File indexing completed on 2026-09-22 08:59:07
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef _Poly_ArrayOfUVNodes_HeaderFile
0015 #define _Poly_ArrayOfUVNodes_HeaderFile
0016
0017 #include <NCollection_AliasedArray.hxx>
0018 #include <gp_Pnt2d.hxx>
0019 #include <NCollection_Vec2.hxx>
0020 #include <Standard_Macro.hxx>
0021
0022
0023 class Poly_ArrayOfUVNodes : public NCollection_AliasedArray<>
0024 {
0025 public:
0026
0027 Poly_ArrayOfUVNodes()
0028 : NCollection_AliasedArray((int)sizeof(gp_Pnt2d))
0029 {
0030
0031 }
0032
0033
0034 Poly_ArrayOfUVNodes(int theLength)
0035 : NCollection_AliasedArray((int)sizeof(gp_Pnt2d), theLength)
0036 {
0037
0038 }
0039
0040
0041 Standard_EXPORT Poly_ArrayOfUVNodes(const Poly_ArrayOfUVNodes& theOther);
0042
0043
0044 Poly_ArrayOfUVNodes(const gp_Pnt2d& theBegin, int theLength)
0045 : NCollection_AliasedArray(theBegin, theLength)
0046 {
0047
0048 }
0049
0050
0051 Poly_ArrayOfUVNodes(const NCollection_Vec2<float>& theBegin, int theLength)
0052 : NCollection_AliasedArray(theBegin, theLength)
0053 {
0054
0055 }
0056
0057
0058 Standard_EXPORT ~Poly_ArrayOfUVNodes();
0059
0060
0061 bool IsDoublePrecision() const { return myStride == (int)sizeof(gp_Pnt2d); }
0062
0063
0064
0065 void SetDoublePrecision(bool theIsDouble)
0066 {
0067 if (myData != nullptr)
0068 {
0069 throw Standard_ProgramError(
0070 "Poly_ArrayOfUVNodes::SetDoublePrecision() should be called before allocation");
0071 }
0072 myStride = int(theIsDouble ? sizeof(gp_Pnt2d) : sizeof(NCollection_Vec2<float>));
0073 }
0074
0075
0076
0077
0078
0079 Standard_EXPORT Poly_ArrayOfUVNodes& Assign(const Poly_ArrayOfUVNodes& theOther);
0080
0081
0082 Poly_ArrayOfUVNodes& Move(Poly_ArrayOfUVNodes& theOther)
0083 {
0084 NCollection_AliasedArray::Move(theOther);
0085 return *this;
0086 }
0087
0088
0089 Poly_ArrayOfUVNodes& operator=(const Poly_ArrayOfUVNodes& theOther) { return Assign(theOther); }
0090
0091
0092 Poly_ArrayOfUVNodes(Poly_ArrayOfUVNodes&& theOther) noexcept
0093 : NCollection_AliasedArray(std::move(theOther))
0094 {
0095
0096 }
0097
0098
0099 Poly_ArrayOfUVNodes& operator=(Poly_ArrayOfUVNodes&& theOther) noexcept { return Move(theOther); }
0100
0101 public:
0102
0103 inline gp_Pnt2d Value(int theIndex) const;
0104 inline gp_Pnt2d Value(const size_t theIndex) const;
0105
0106
0107 inline void SetValue(int theIndex, const gp_Pnt2d& theValue);
0108 inline void SetValue(const size_t theIndex, const gp_Pnt2d& theValue);
0109
0110
0111 gp_Pnt2d operator[](int theIndex) const { return Value(theIndex); }
0112 };
0113
0114
0115
0116 inline gp_Pnt2d Poly_ArrayOfUVNodes::Value(int theIndex) const
0117 {
0118 if (myStride == (int)sizeof(gp_Pnt2d))
0119 {
0120 return NCollection_AliasedArray::Value<gp_Pnt2d>(theIndex);
0121 }
0122 else
0123 {
0124 const NCollection_Vec2<float>& aVec2 =
0125 NCollection_AliasedArray::Value<NCollection_Vec2<float>>(theIndex);
0126 return gp_Pnt2d(aVec2.x(), aVec2.y());
0127 }
0128 }
0129
0130
0131
0132 inline gp_Pnt2d Poly_ArrayOfUVNodes::Value(const size_t theIndex) const
0133 {
0134 Standard_OutOfRange_Raise_if(theIndex >= static_cast<size_t>(mySize),
0135 "Poly_ArrayOfUVNodes::Value(), out of range index");
0136 return Value(static_cast<int>(theIndex));
0137 }
0138
0139
0140
0141 inline void Poly_ArrayOfUVNodes::SetValue(int theIndex, const gp_Pnt2d& theValue)
0142 {
0143 if (myStride == (int)sizeof(gp_Pnt2d))
0144 {
0145 NCollection_AliasedArray::ChangeValue<gp_Pnt2d>(theIndex) = theValue;
0146 }
0147 else
0148 {
0149 NCollection_Vec2<float>& aVec2 =
0150 NCollection_AliasedArray::ChangeValue<NCollection_Vec2<float>>(theIndex);
0151 aVec2.SetValues((float)theValue.X(), (float)theValue.Y());
0152 }
0153 }
0154
0155
0156
0157 inline void Poly_ArrayOfUVNodes::SetValue(const size_t theIndex, const gp_Pnt2d& theValue)
0158 {
0159 Standard_OutOfRange_Raise_if(theIndex >= static_cast<size_t>(mySize),
0160 "Poly_ArrayOfUVNodes::SetValue(), out of range index");
0161 SetValue(static_cast<int>(theIndex), theValue);
0162 }
0163
0164 #endif