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