diff --git a/src/FoundationClasses/TKMath/math/math_DoubleTab.hxx b/src/FoundationClasses/TKMath/math/math_DoubleTab.hxx index 91364bc388..ec365ad321 100644 --- a/src/FoundationClasses/TKMath/math/math_DoubleTab.hxx +++ b/src/FoundationClasses/TKMath/math/math_DoubleTab.hxx @@ -100,7 +100,7 @@ public: } //! Copy data to theOther - void Copy(math_DoubleTab& theOther) const { theOther.myArray.Assign(myArray); } + void Copy(math_DoubleTab& theOther) const { theOther.myArray.CopyValues(myArray); } //! Returns true if the internal array is deletable (heap-allocated) bool IsDeletable() const { return myArray.IsDeletable(); } diff --git a/src/FoundationClasses/TKMath/math/math_Matrix.lxx b/src/FoundationClasses/TKMath/math/math_Matrix.lxx index ba88b69da3..11b1199b4e 100644 --- a/src/FoundationClasses/TKMath/math/math_Matrix.lxx +++ b/src/FoundationClasses/TKMath/math/math_Matrix.lxx @@ -695,10 +695,6 @@ inline void math_Matrix::TMultiply(const math_Matrix& TLeft, const math_Matrix& inline math_Matrix& math_Matrix::Initialized(const math_Matrix& Other) { - Standard_DimensionError_Raise_if( - (RowNumber() != Other.RowNumber()) || (ColNumber() != Other.ColNumber()), - "math_Matrix::Initialized() - input matrix has different dimensions"); - (Other.Array).Copy(Array); return *this; } diff --git a/src/FoundationClasses/TKMath/math/math_VectorBase.lxx b/src/FoundationClasses/TKMath/math/math_VectorBase.lxx index c73afc4dd6..364ca38025 100644 --- a/src/FoundationClasses/TKMath/math/math_VectorBase.lxx +++ b/src/FoundationClasses/TKMath/math/math_VectorBase.lxx @@ -607,10 +607,7 @@ template math_VectorBase& math_VectorBase::Initialized( const math_VectorBase& theOther) { - Standard_DimensionError_Raise_if( - Length() != theOther.Length(), - "math_VectorBase::Initialized() - input vector has wrong dimensions"); - memmove(&Array.ChangeFirst(), &theOther.Array.First(), sizeof(TheItemType) * Array.Length()); + Array.CopyValues(theOther.Array); return *this; } diff --git a/src/FoundationClasses/TKernel/GTests/NCollection_Array1_Test.cxx b/src/FoundationClasses/TKernel/GTests/NCollection_Array1_Test.cxx index 8a33dd8692..67799d152d 100644 --- a/src/FoundationClasses/TKernel/GTests/NCollection_Array1_Test.cxx +++ b/src/FoundationClasses/TKernel/GTests/NCollection_Array1_Test.cxx @@ -160,7 +160,6 @@ TEST(NCollection_Array1Test, AssignmentOperator) // Test assignment NCollection_Array1 anArray2(11, 15); anArray2 = anArray1; - anArray2.Resize(1, 5, true); // Resize to match anArray1 // Verify assignment result EXPECT_EQ(anArray1.Length(), anArray2.Length()); @@ -173,6 +172,135 @@ TEST(NCollection_Array1Test, AssignmentOperator) } } +TEST(NCollection_Array1Test, AssignmentOperatorDifferentSize) +{ + NCollection_Array1 anArray1(5, 8); + for (int anIndex = anArray1.Lower(); anIndex <= anArray1.Upper(); ++anIndex) + { + anArray1(anIndex) = anIndex * 10; + } + + NCollection_Array1 anArray2(1, 2); + anArray2 = anArray1; + + EXPECT_EQ(4, anArray2.Length()); + EXPECT_EQ(5, anArray2.Lower()); + EXPECT_EQ(8, anArray2.Upper()); + for (int anIndex = anArray1.Lower(); anIndex <= anArray1.Upper(); ++anIndex) + { + EXPECT_EQ(anArray1(anIndex), anArray2(anIndex)); + } +} + +TEST(NCollection_Array1Test, AssignmentOperatorReusesSameSizeOwnedStorage) +{ + NCollection_Array1 anArray(1, 6); + int* anInitialPointer = &anArray.ChangeFirst(); + + NCollection_Array1 aSource(20, 25); + for (int anIndex = aSource.Lower(); anIndex <= aSource.Upper(); ++anIndex) + { + aSource(anIndex) = anIndex * 10; + } + + anArray = aSource; + + EXPECT_EQ(anInitialPointer, &anArray.ChangeFirst()); + EXPECT_EQ(20, anArray.Lower()); + EXPECT_EQ(25, anArray.Upper()); + for (int anIndex = aSource.Lower(); anIndex <= aSource.Upper(); ++anIndex) + { + EXPECT_EQ(aSource(anIndex), anArray(anIndex)); + } +} + +TEST(NCollection_Array1Test, AssignmentOperatorReusesSameSizeExternalBuffer) +{ + int aBuffer[3] = {0, 0, 0}; + + NCollection_Array1 anArray(aBuffer, 3); + NCollection_Array1 aSource(7, 9); + for (int anIndex = aSource.Lower(); anIndex <= aSource.Upper(); ++anIndex) + { + aSource(anIndex) = anIndex * 10; + } + + anArray = aSource; + + EXPECT_FALSE(anArray.IsDeletable()); + EXPECT_EQ(7, anArray.Lower()); + EXPECT_EQ(9, anArray.Upper()); + EXPECT_EQ(70, aBuffer[0]); + EXPECT_EQ(80, aBuffer[1]); + EXPECT_EQ(90, aBuffer[2]); +} + +TEST(NCollection_Array1Test, AssignmentOperatorDetachesDifferentSizeExternalBuffer) +{ + int aBuffer[3] = {1, 2, 3}; + + NCollection_Array1 anArray(aBuffer, 3); + NCollection_Array1 aSource(7, 10); + for (int anIndex = aSource.Lower(); anIndex <= aSource.Upper(); ++anIndex) + { + aSource(anIndex) = anIndex * 10; + } + + anArray = aSource; + + EXPECT_TRUE(anArray.IsDeletable()); + EXPECT_NE(aBuffer, &anArray.ChangeFirst()); + EXPECT_EQ(7, anArray.Lower()); + EXPECT_EQ(10, anArray.Upper()); + EXPECT_EQ(1, aBuffer[0]); + EXPECT_EQ(2, aBuffer[1]); + EXPECT_EQ(3, aBuffer[2]); + for (int anIndex = aSource.Lower(); anIndex <= aSource.Upper(); ++anIndex) + { + EXPECT_EQ(aSource(anIndex), anArray(anIndex)); + } +} + +TEST(NCollection_Array1Test, AssignmentOperatorEmptySource) +{ + NCollection_Array1 anArray(1, 5); + NCollection_Array1 anEmpty; + + anArray = anEmpty; + + EXPECT_EQ(0, anArray.Length()); + EXPECT_EQ(1, anArray.Lower()); + EXPECT_TRUE(anArray.IsEmpty()); +} + +TEST(NCollection_Array1Test, CopyValuesPreservesBounds) +{ + NCollection_Array1 aSource(1, 5); + for (int anIndex = aSource.Lower(); anIndex <= aSource.Upper(); ++anIndex) + { + aSource(anIndex) = anIndex * 10; + } + + NCollection_Array1 anArray(11, 15); + anArray.CopyValues(aSource); + + EXPECT_EQ(11, anArray.Lower()); + EXPECT_EQ(15, anArray.Upper()); + for (int anIndex = 0; anIndex < anArray.Length(); ++anIndex) + { + EXPECT_EQ(aSource(aSource.Lower() + anIndex), anArray(anArray.Lower() + anIndex)); + } +} + +TEST(NCollection_Array1Test, CopyValuesDifferentSize) +{ + [[maybe_unused]] NCollection_Array1 anArray(1, 5); + [[maybe_unused]] NCollection_Array1 aSource(1, 4); +#ifndef No_Exception + EXPECT_THROW(anArray.CopyValues(aSource), Standard_DimensionMismatch); +#endif +} + TEST(NCollection_Array1Test, Move) { NCollection_Array1 anArray1(1, 5); @@ -186,7 +314,6 @@ TEST(NCollection_Array1Test, Move) // Test Move method NCollection_Array1 anArray2(11, 15); anArray2.Move(anArray1); - anArray2.Resize(1, 5, true); // Resize to match anArray1 // Verify move result EXPECT_EQ(5, anArray2.Length()); diff --git a/src/FoundationClasses/TKernel/GTests/NCollection_Array2_Test.cxx b/src/FoundationClasses/TKernel/GTests/NCollection_Array2_Test.cxx index a28be1b1bc..47d4d977ab 100644 --- a/src/FoundationClasses/TKernel/GTests/NCollection_Array2_Test.cxx +++ b/src/FoundationClasses/TKernel/GTests/NCollection_Array2_Test.cxx @@ -128,20 +128,139 @@ TEST(NCollection_Array2Test, CopyConstructor) TEST(NCollection_Array2Test, AssignmentOperator) { - NCollection_Array2 anArray1(1, 3, 1, 4); - anArray1.Init(123); + NCollection_Array2 anArray1(5, 7, 10, 13); + for (int aRowIter = anArray1.LowerRow(); aRowIter <= anArray1.UpperRow(); ++aRowIter) + { + for (int aColIter = anArray1.LowerCol(); aColIter <= anArray1.UpperCol(); ++aColIter) + { + anArray1(aRowIter, aColIter) = aRowIter * 100 + aColIter; + } + } - NCollection_Array2 anArray2(1, 3, 1, 4); + NCollection_Array2 anArray2(1, 1, 1, 1); anArray2.Init(0); anArray2 = anArray1; // Assign - // Verify data is copied - EXPECT_EQ(123, anArray2(2, 3)); + // Verify dimensions and data are copied + EXPECT_EQ(anArray1.NbRows(), anArray2.NbRows()); + EXPECT_EQ(anArray1.NbColumns(), anArray2.NbColumns()); + EXPECT_EQ(anArray1.LowerRow(), anArray2.LowerRow()); + EXPECT_EQ(anArray1.LowerCol(), anArray2.LowerCol()); + EXPECT_EQ(612, anArray2(6, 12)); // Modify original to ensure it was a deep copy - anArray1.SetValue(2, 3, 999); - EXPECT_EQ(123, anArray2(2, 3)); + anArray1.SetValue(6, 12, 999); + EXPECT_EQ(612, anArray2(6, 12)); +} + +TEST(NCollection_Array2Test, AssignmentOperatorReusesSameSizeOwnedStorage) +{ + NCollection_Array2 anArray(1, 3, 1, 4); + int* anInitialPointer = &anArray.ChangeFirst(); + + NCollection_Array2 aSource(10, 12, 20, 23); + for (int aRowIter = aSource.LowerRow(); aRowIter <= aSource.UpperRow(); ++aRowIter) + { + for (int aColIter = aSource.LowerCol(); aColIter <= aSource.UpperCol(); ++aColIter) + { + aSource(aRowIter, aColIter) = aRowIter * 100 + aColIter; + } + } + + anArray = aSource; + + EXPECT_EQ(anInitialPointer, &anArray.ChangeFirst()); + EXPECT_EQ(10, anArray.LowerRow()); + EXPECT_EQ(12, anArray.UpperRow()); + EXPECT_EQ(20, anArray.LowerCol()); + EXPECT_EQ(23, anArray.UpperCol()); + EXPECT_EQ(1122, anArray(11, 22)); +} + +TEST(NCollection_Array2Test, AssignmentOperatorReusesSameSizeExternalBuffer) +{ + int aBuffer[4] = {0, 0, 0, 0}; + + NCollection_Array2 anArray(aBuffer, 2, 2); + NCollection_Array2 aSource(5, 6, 7, 8); + for (int aRowIter = aSource.LowerRow(); aRowIter <= aSource.UpperRow(); ++aRowIter) + { + for (int aColIter = aSource.LowerCol(); aColIter <= aSource.UpperCol(); ++aColIter) + { + aSource(aRowIter, aColIter) = aRowIter * 100 + aColIter; + } + } + + anArray = aSource; + + EXPECT_FALSE(anArray.IsDeletable()); + EXPECT_EQ(5, anArray.LowerRow()); + EXPECT_EQ(7, anArray.LowerCol()); + EXPECT_EQ(507, aBuffer[0]); + EXPECT_EQ(508, aBuffer[1]); + EXPECT_EQ(607, aBuffer[2]); + EXPECT_EQ(608, aBuffer[3]); +} + +TEST(NCollection_Array2Test, AssignmentOperatorDetachesDifferentSizeExternalBuffer) +{ + int aBuffer[4] = {1, 2, 3, 4}; + + NCollection_Array2 anArray(aBuffer, 2, 2); + NCollection_Array2 aSource(5, 6, 7, 9); + for (int aRowIter = aSource.LowerRow(); aRowIter <= aSource.UpperRow(); ++aRowIter) + { + for (int aColIter = aSource.LowerCol(); aColIter <= aSource.UpperCol(); ++aColIter) + { + aSource(aRowIter, aColIter) = aRowIter * 100 + aColIter; + } + } + + anArray = aSource; + + EXPECT_TRUE(anArray.IsDeletable()); + EXPECT_NE(aBuffer, &anArray.ChangeFirst()); + EXPECT_EQ(2, anArray.NbRows()); + EXPECT_EQ(3, anArray.NbColumns()); + EXPECT_EQ(5, anArray.LowerRow()); + EXPECT_EQ(7, anArray.LowerCol()); + EXPECT_EQ(1, aBuffer[0]); + EXPECT_EQ(2, aBuffer[1]); + EXPECT_EQ(3, aBuffer[2]); + EXPECT_EQ(4, aBuffer[3]); + EXPECT_EQ(608, anArray(6, 8)); +} + +TEST(NCollection_Array2Test, CopyValuesPreservesBounds) +{ + NCollection_Array2 aSource(5, 6, 7, 9); + for (int aRowIter = aSource.LowerRow(); aRowIter <= aSource.UpperRow(); ++aRowIter) + { + for (int aColIter = aSource.LowerCol(); aColIter <= aSource.UpperCol(); ++aColIter) + { + aSource(aRowIter, aColIter) = aRowIter * 100 + aColIter; + } + } + + NCollection_Array2 anArray(1, 2, 1, 3); + anArray.CopyValues(aSource); + + EXPECT_EQ(1, anArray.LowerRow()); + EXPECT_EQ(2, anArray.UpperRow()); + EXPECT_EQ(1, anArray.LowerCol()); + EXPECT_EQ(3, anArray.UpperCol()); + EXPECT_EQ(507, anArray(1, 1)); + EXPECT_EQ(609, anArray(2, 3)); +} + +TEST(NCollection_Array2Test, CopyValuesDifferentDimensions) +{ + [[maybe_unused]] NCollection_Array2 anArray(1, 2, 1, 3); + [[maybe_unused]] NCollection_Array2 aSource(1, 3, 1, 2); +#ifndef No_Exception + EXPECT_THROW(anArray.CopyValues(aSource), Standard_DimensionMismatch); +#endif } TEST(NCollection_Array2Test, MoveConstructor) diff --git a/src/FoundationClasses/TKernel/NCollection/NCollection_Array1.hxx b/src/FoundationClasses/TKernel/NCollection/NCollection_Array1.hxx index 86c014e611..2784b3c001 100644 --- a/src/FoundationClasses/TKernel/NCollection/NCollection_Array1.hxx +++ b/src/FoundationClasses/TKernel/NCollection/NCollection_Array1.hxx @@ -26,6 +26,10 @@ #include #include +#include +#include +#include +#include //! The class NCollection_Array1 represents unidimensional arrays of fixed size known at run time. //! The range of the index is user defined. @@ -232,21 +236,37 @@ public: //! Upper bound int Upper() const noexcept { return myLowerBound + static_cast(mySize) - 1; } - //! Copies data of theOther array to this. - //! This array should be pre-allocated and have the same length as theOther; - //! otherwise exception Standard_DimensionMismatch is thrown. + //! Replaces this array by a copy of theOther array. + //! Bounds and length are copied from theOther. + //! When this array wraps an external (non-owned) buffer: + //! - if theOther has the same length, values are copied in place into the + //! external buffer and ownership is unchanged; + //! - if theOther has a different length, this array detaches from the + //! external buffer and allocates a fresh owned buffer. + //! Use CopyValues() to preserve this array's bounds. NCollection_Array1& Assign(const NCollection_Array1& theOther) { if (&theOther == this) { return *this; } - Standard_DimensionMismatch_Raise_if(mySize != theOther.mySize, "NCollection_Array1::operator="); - for (size_t anInd = 0; anInd < mySize; anInd++) + assign(theOther.myPointer, theOther.mySize, theOther.myLowerBound); + return *this; + } + + //! Copies values from theOther array without changing this array bounds. + //! This array should be pre-allocated and have the same length as theOther; + //! otherwise exception Standard_DimensionMismatch is thrown. + NCollection_Array1& CopyValues(const NCollection_Array1& theOther) + { + if (&theOther == this) { - myPointer[anInd] = theOther.myPointer[anInd]; + return *this; } - // Current implementation disable changing bounds by assigning + Standard_DimensionMismatch_Raise_if(mySize != theOther.mySize, + "NCollection_Array1::CopyValues"); + const size_t aCommonSize = (std::min)(mySize, theOther.mySize); + copyAssign(myPointer, theOther.myPointer, aCommonSize); return *this; } @@ -422,6 +442,15 @@ protected: destroy(myPointer, 0, mySize); } myLowerBound = theNewLower; + if (theNewSize == 0) + { + if (myIsOwner) + myAllocator.deallocate(aPrevPtr, mySize); + myPointer = nullptr; + mySize = 0; + myIsOwner = false; + return; + } if (theToCopyData) { const size_t aMinSize = (std::min)(theNewSize, mySize); @@ -500,11 +529,79 @@ protected: } } - void copyConstruct(const pointer theFrom, const size_t theCount) + void assign(const const_pointer theFrom, const size_t theSize, const int theLower) + { + if (theSize == mySize) + { + copyAssign(myPointer, theFrom, theSize); + myLowerBound = theLower; + return; + } + pointer aNewPointer = nullptr; + if (theSize != 0) + { + aNewPointer = myAllocator.allocate(theSize); + copyConstruct(aNewPointer, theFrom, theSize); + } + + if (myIsOwner) + { + destroy(myPointer, 0, mySize); + myAllocator.deallocate(myPointer, mySize); + } + myLowerBound = theLower; + mySize = theSize; + myPointer = aNewPointer; + myIsOwner = theSize != 0; + } + + template + typename std::enable_if::value, void>::type copyAssign( + pointer theTarget, + const_pointer theFrom, + const size_t theCount) + { + if (theCount != 0) + { + std::memmove(theTarget, theFrom, theCount * sizeof(TheItemType)); + } + } + + template + typename std::enable_if::value, void>::type copyAssign( + pointer theTarget, + const_pointer theFrom, + const size_t theCount) { for (size_t anInd = 0; anInd < theCount; anInd++) { - myAllocator.construct(myPointer + anInd, theFrom[anInd]); + theTarget[anInd] = theFrom[anInd]; + } + } + + void copyConstruct(const pointer theFrom, const size_t theCount) + { + copyConstruct(myPointer, theFrom, theCount); + } + + template + typename std::enable_if::value, void>::type copyConstruct( + pointer theTarget, + const_pointer theFrom, + const size_t theCount) + { + std::uninitialized_copy_n(theFrom, theCount, theTarget); + } + + template + typename std::enable_if::value, void>::type copyConstruct( + pointer theTarget, + const_pointer theFrom, + const size_t theCount) + { + for (size_t anInd = 0; anInd < theCount; anInd++) + { + myAllocator.construct(theTarget + anInd, theFrom[anInd]); } } diff --git a/src/FoundationClasses/TKernel/NCollection/NCollection_Array2.hxx b/src/FoundationClasses/TKernel/NCollection/NCollection_Array2.hxx index a24709135b..42be45e6c4 100644 --- a/src/FoundationClasses/TKernel/NCollection/NCollection_Array2.hxx +++ b/src/FoundationClasses/TKernel/NCollection/NCollection_Array2.hxx @@ -230,7 +230,8 @@ public: myLowerCol = myLowerCol - UpperCol() + theUpperCol; } - //! Assignment + //! Replaces this array by a copy of theOther array. + //! Row and column bounds are copied from theOther. NCollection_Array2& Assign(const NCollection_Array2& theOther) { if (&theOther == this) @@ -238,7 +239,26 @@ public: return *this; } NCollection_Array1::Assign(theOther); - // Current implementation disable changing bounds by assigning + myLowerRow = theOther.myLowerRow; + mySizeRow = theOther.mySizeRow; + myLowerCol = theOther.myLowerCol; + mySizeCol = theOther.mySizeCol; + return *this; + } + + //! Copies values from theOther array without changing this array bounds. + //! This array should be pre-allocated and have the same dimensions as theOther; + //! otherwise exception Standard_DimensionMismatch is thrown. + NCollection_Array2& CopyValues(const NCollection_Array2& theOther) + { + if (&theOther == this) + { + return *this; + } + Standard_DimensionMismatch_Raise_if(mySizeRow != theOther.mySizeRow + || mySizeCol != theOther.mySizeCol, + "NCollection_Array2::CopyValues"); + NCollection_Array1::CopyValues(theOther); return *this; } diff --git a/src/FoundationClasses/TKernel/NCollection/NCollection_KDTree.hxx b/src/FoundationClasses/TKernel/NCollection/NCollection_KDTree.hxx index 620104c3c8..1a0d33f0e0 100644 --- a/src/FoundationClasses/TKernel/NCollection/NCollection_KDTree.hxx +++ b/src/FoundationClasses/TKernel/NCollection/NCollection_KDTree.hxx @@ -488,13 +488,15 @@ public: } //! Copy assignment. - //! Uses copy-and-swap because NCollection_Array1::operator= requires same size. NCollection_KDTree& operator=(const NCollection_KDTree& theOther) { if (this != &theOther) { - NCollection_KDTree aCopy(theOther); - *this = std::move(aCopy); + myPoints = theOther.myPoints; + myIndices = theOther.myIndices; + myRadii = theOther.myRadii; + myMaxRadius = theOther.myMaxRadius; + mySize = theOther.mySize; } return *this; } diff --git a/src/ModelingData/TKG2d/Geom2d/Geom2d_BSplineCurve.cxx b/src/ModelingData/TKG2d/Geom2d/Geom2d_BSplineCurve.cxx index c0287b5c3e..8d2acb8c0d 100644 --- a/src/ModelingData/TKG2d/Geom2d/Geom2d_BSplineCurve.cxx +++ b/src/ModelingData/TKG2d/Geom2d/Geom2d_BSplineCurve.cxx @@ -152,15 +152,15 @@ Geom2d_BSplineCurve::Geom2d_BSplineCurve(const NCollection_Array1& Pol // copy arrays myPoles.Resize(1, Poles.Length(), false); - myPoles.Assign(Poles); + myPoles.CopyValues(Poles); myWeights = BSplCLib::UnitWeights(Poles.Length()); myKnots.Resize(1, Knots.Length(), false); - myKnots.Assign(Knots); + myKnots.CopyValues(Knots); myMults.Resize(1, Mults.Length(), false); - myMults.Assign(Mults); + myMults.CopyValues(Mults); updateKnots(); } @@ -204,11 +204,11 @@ Geom2d_BSplineCurve::Geom2d_BSplineCurve(const NCollection_Array1& Pol // copy arrays myPoles.Resize(1, Poles.Length(), false); - myPoles.Assign(Poles); + myPoles.CopyValues(Poles); if (myRational) { myWeights.Resize(1, Weights.Length(), false); - myWeights.Assign(Weights); + myWeights.CopyValues(Weights); } else { @@ -216,10 +216,10 @@ Geom2d_BSplineCurve::Geom2d_BSplineCurve(const NCollection_Array1& Pol } myKnots.Resize(1, Knots.Length(), false); - myKnots.Assign(Knots); + myKnots.CopyValues(Knots); myMults.Resize(1, Mults.Length(), false); - myMults.Assign(Mults); + myMults.CopyValues(Mults); updateKnots(); } @@ -930,7 +930,7 @@ void Geom2d_BSplineCurve::SetKnot(const int Index, const double K) void Geom2d_BSplineCurve::SetKnots(const NCollection_Array1& K) { CheckCurveData(myPoles, K, myMults, myDeg, myPeriodic); - myKnots = K; + myKnots.CopyValues(K); myMaxDerivInvOk = false; updateKnots(); } diff --git a/src/ModelingData/TKG2d/Geom2d/Geom2d_BezierCurve.cxx b/src/ModelingData/TKG2d/Geom2d/Geom2d_BezierCurve.cxx index 6bef13fcb9..4ea3894072 100644 --- a/src/ModelingData/TKG2d/Geom2d/Geom2d_BezierCurve.cxx +++ b/src/ModelingData/TKG2d/Geom2d/Geom2d_BezierCurve.cxx @@ -710,12 +710,12 @@ void Geom2d_BezierCurve::init(const NCollection_Array1& thePoles, // set fields myPoles.Resize(1, nbpoles, false); - myPoles = thePoles; + myPoles.CopyValues(thePoles); if (theWeights != nullptr) { myWeights.Resize(1, nbpoles, false); - myWeights = *theWeights; + myWeights.CopyValues(*theWeights); myRational = Rational(myWeights); if (!myRational) { diff --git a/src/ModelingData/TKG3d/Geom/Geom_BSplineCurve.cxx b/src/ModelingData/TKG3d/Geom/Geom_BSplineCurve.cxx index a1fb0c8810..6bda409e6c 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_BSplineCurve.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_BSplineCurve.cxx @@ -155,15 +155,15 @@ Geom_BSplineCurve::Geom_BSplineCurve(const NCollection_Array1& Poles, // copy arrays myPoles.Resize(1, Poles.Length(), false); - myPoles.Assign(Poles); + myPoles.CopyValues(Poles); myWeights = BSplCLib::UnitWeights(Poles.Length()); myKnots.Resize(1, Knots.Length(), false); - myKnots.Assign(Knots); + myKnots.CopyValues(Knots); myMults.Resize(1, Mults.Length(), false); - myMults.Assign(Mults); + myMults.CopyValues(Mults); updateKnots(); } @@ -211,11 +211,11 @@ Geom_BSplineCurve::Geom_BSplineCurve(const NCollection_Array1& Poles, // copy arrays myPoles.Resize(1, Poles.Length(), false); - myPoles.Assign(Poles); + myPoles.CopyValues(Poles); if (myRational) { myWeights.Resize(1, Weights.Length(), false); - myWeights.Assign(Weights); + myWeights.CopyValues(Weights); } else { @@ -223,10 +223,10 @@ Geom_BSplineCurve::Geom_BSplineCurve(const NCollection_Array1& Poles, } myKnots.Resize(1, Knots.Length(), false); - myKnots.Assign(Knots); + myKnots.CopyValues(Knots); myMults.Resize(1, Mults.Length(), false); - myMults.Assign(Mults); + myMults.CopyValues(Mults); updateKnots(); } @@ -759,7 +759,7 @@ void Geom_BSplineCurve::SetKnots(const NCollection_Array1& K) { CheckCurveData(myPoles, K, myMults, myDeg, myPeriodic); ClearEvalRepresentation(); - myKnots = K; + myKnots.CopyValues(K); myMaxDerivInvOk = false; updateKnots(); } diff --git a/src/ModelingData/TKG3d/Geom/Geom_BSplineSurface.cxx b/src/ModelingData/TKG3d/Geom/Geom_BSplineSurface.cxx index 3566d5182f..e903865868 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_BSplineSurface.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_BSplineSurface.cxx @@ -205,21 +205,21 @@ Geom_BSplineSurface::Geom_BSplineSurface(const NCollection_Array2& Poles // copy arrays myPoles.Resize(1, Poles.ColLength(), 1, Poles.RowLength(), false); - myPoles.Assign(Poles); + myPoles.CopyValues(Poles); myWeights = BSplSLib::UnitWeights(Poles.ColLength(), Poles.RowLength()); myUKnots.Resize(1, UKnots.Length(), false); - myUKnots.Assign(UKnots); + myUKnots.CopyValues(UKnots); myUMults.Resize(1, UMults.Length(), false); - myUMults.Assign(UMults); + myUMults.CopyValues(UMults); myVKnots.Resize(1, VKnots.Length(), false); - myVKnots.Assign(VKnots); + myVKnots.CopyValues(VKnots); myVMults.Resize(1, VMults.Length(), false); - myVMults.Assign(VMults); + myVMults.CopyValues(VMults); updateUKnots(); updateVKnots(); @@ -284,12 +284,12 @@ Geom_BSplineSurface::Geom_BSplineSurface(const NCollection_Array2& Poles // copy arrays myPoles.Resize(1, Poles.ColLength(), 1, Poles.RowLength(), false); - myPoles.Assign(Poles); + myPoles.CopyValues(Poles); if (myURational || myVRational) { myWeights.Resize(1, Poles.ColLength(), 1, Poles.RowLength(), false); - myWeights.Assign(Weights); + myWeights.CopyValues(Weights); } else { @@ -297,16 +297,16 @@ Geom_BSplineSurface::Geom_BSplineSurface(const NCollection_Array2& Poles } myUKnots.Resize(1, UKnots.Length(), false); - myUKnots.Assign(UKnots); + myUKnots.CopyValues(UKnots); myUMults.Resize(1, UMults.Length(), false); - myUMults.Assign(UMults); + myUMults.CopyValues(UMults); myVKnots.Resize(1, VKnots.Length(), false); - myVKnots.Assign(VKnots); + myVKnots.CopyValues(VKnots); myVMults.Resize(1, VMults.Length(), false); - myVMults.Assign(VMults); + myVMults.CopyValues(VMults); updateUKnots(); updateVKnots(); diff --git a/src/ModelingData/TKG3d/Geom/Geom_BezierCurve.cxx b/src/ModelingData/TKG3d/Geom/Geom_BezierCurve.cxx index 994036558f..c6e4bd3aba 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_BezierCurve.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_BezierCurve.cxx @@ -776,12 +776,12 @@ void Geom_BezierCurve::init(const NCollection_Array1& thePoles, // set fields myPoles.Resize(1, nbpoles, false); - myPoles = thePoles; + myPoles.CopyValues(thePoles); if (theWeights != nullptr) { myWeights.Resize(1, nbpoles, false); - myWeights = *theWeights; + myWeights.CopyValues(*theWeights); myRational = Rational(myWeights); if (!myRational) { diff --git a/src/ModelingData/TKG3d/Geom/Geom_BezierSurface.cxx b/src/ModelingData/TKG3d/Geom/Geom_BezierSurface.cxx index 48749fb04e..6f0145536f 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_BezierSurface.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_BezierSurface.cxx @@ -2052,12 +2052,12 @@ void Geom_BezierSurface::init(const NCollection_Array2& thePoles, int NbVPoles = thePoles.RowLength(); myPoles.Resize(1, NbUPoles, 1, NbVPoles, false); - myPoles = thePoles; + myPoles.CopyValues(thePoles); if (theWeights != nullptr) { myWeights.Resize(1, NbUPoles, 1, NbVPoles, false); - myWeights = *theWeights; + myWeights.CopyValues(*theWeights); Rational(myWeights, myURational, myVRational); if (!(myURational || myVRational)) {