Foundation Classes - Update Array1/2 Assign Operator (#1269)

- Updated `NCollection_Array1/2::Assign()` to copy bounds/size from the source; introduced `CopyValues()` to copy element values while preserving existing bounds.
- Replaced usages of `Assign()` / `operator=` with `CopyValues()` in several `Geom*` classes and math utilities to preserve prior behavior after the `Assign()` semantic change.
- Expanded GTests for `NCollection_Array1/2` to cover assignment behavior (owned/external buffers, size changes) and `CopyValues()` behavior.
This commit is contained in:
Pasukhin Dmitry
2026-05-06 12:13:53 +01:00
committed by GitHub
parent 654d0b07ca
commit d3adc95d96
14 changed files with 423 additions and 65 deletions
@@ -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(); }
@@ -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;
}
@@ -607,10 +607,7 @@ template <typename TheItemType>
math_VectorBase<TheItemType>& math_VectorBase<TheItemType>::Initialized(
const math_VectorBase<TheItemType>& 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;
}
@@ -160,7 +160,6 @@ TEST(NCollection_Array1Test, AssignmentOperator)
// Test assignment
NCollection_Array1<int> 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<int> anArray1(5, 8);
for (int anIndex = anArray1.Lower(); anIndex <= anArray1.Upper(); ++anIndex)
{
anArray1(anIndex) = anIndex * 10;
}
NCollection_Array1<int> 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<int> anArray(1, 6);
int* anInitialPointer = &anArray.ChangeFirst();
NCollection_Array1<int> 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<int> anArray(aBuffer, 3);
NCollection_Array1<int> 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<int> anArray(aBuffer, 3);
NCollection_Array1<int> 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<int> anArray(1, 5);
NCollection_Array1<int> anEmpty;
anArray = anEmpty;
EXPECT_EQ(0, anArray.Length());
EXPECT_EQ(1, anArray.Lower());
EXPECT_TRUE(anArray.IsEmpty());
}
TEST(NCollection_Array1Test, CopyValuesPreservesBounds)
{
NCollection_Array1<int> aSource(1, 5);
for (int anIndex = aSource.Lower(); anIndex <= aSource.Upper(); ++anIndex)
{
aSource(anIndex) = anIndex * 10;
}
NCollection_Array1<int> 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<int> anArray(1, 5);
[[maybe_unused]] NCollection_Array1<int> aSource(1, 4);
#ifndef No_Exception
EXPECT_THROW(anArray.CopyValues(aSource), Standard_DimensionMismatch);
#endif
}
TEST(NCollection_Array1Test, Move)
{
NCollection_Array1<int> anArray1(1, 5);
@@ -186,7 +314,6 @@ TEST(NCollection_Array1Test, Move)
// Test Move method
NCollection_Array1<int> anArray2(11, 15);
anArray2.Move(anArray1);
anArray2.Resize(1, 5, true); // Resize to match anArray1
// Verify move result
EXPECT_EQ(5, anArray2.Length());
@@ -128,20 +128,139 @@ TEST(NCollection_Array2Test, CopyConstructor)
TEST(NCollection_Array2Test, AssignmentOperator)
{
NCollection_Array2<int> anArray1(1, 3, 1, 4);
anArray1.Init(123);
NCollection_Array2<int> 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<int> anArray2(1, 3, 1, 4);
NCollection_Array2<int> 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<int> anArray(1, 3, 1, 4);
int* anInitialPointer = &anArray.ChangeFirst();
NCollection_Array2<int> 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<int> anArray(aBuffer, 2, 2);
NCollection_Array2<int> 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<int> anArray(aBuffer, 2, 2);
NCollection_Array2<int> 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<int> 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<int> 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<int> anArray(1, 2, 1, 3);
[[maybe_unused]] NCollection_Array2<int> aSource(1, 3, 1, 2);
#ifndef No_Exception
EXPECT_THROW(anArray.CopyValues(aSource), Standard_DimensionMismatch);
#endif
}
TEST(NCollection_Array2Test, MoveConstructor)
@@ -26,6 +26,10 @@
#include <NCollection_IndexedIterator.hxx>
#include <algorithm>
#include <cstring>
#include <memory>
#include <type_traits>
#include <utility>
//! 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<int>(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 U = TheItemType>
typename std::enable_if<std::is_trivially_copyable<U>::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 U = TheItemType>
typename std::enable_if<!std::is_trivially_copyable<U>::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 U = TheItemType>
typename std::enable_if<std::is_trivially_copyable<U>::value, void>::type copyConstruct(
pointer theTarget,
const_pointer theFrom,
const size_t theCount)
{
std::uninitialized_copy_n(theFrom, theCount, theTarget);
}
template <typename U = TheItemType>
typename std::enable_if<!std::is_trivially_copyable<U>::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]);
}
}
@@ -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<TheItemType>::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<TheItemType>::CopyValues(theOther);
return *this;
}
@@ -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;
}
@@ -152,15 +152,15 @@ Geom2d_BSplineCurve::Geom2d_BSplineCurve(const NCollection_Array1<gp_Pnt2d>& 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<gp_Pnt2d>& 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<gp_Pnt2d>& 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<double>& K)
{
CheckCurveData(myPoles, K, myMults, myDeg, myPeriodic);
myKnots = K;
myKnots.CopyValues(K);
myMaxDerivInvOk = false;
updateKnots();
}
@@ -710,12 +710,12 @@ void Geom2d_BezierCurve::init(const NCollection_Array1<gp_Pnt2d>& 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)
{
@@ -155,15 +155,15 @@ Geom_BSplineCurve::Geom_BSplineCurve(const NCollection_Array1<gp_Pnt>& 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<gp_Pnt>& 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<gp_Pnt>& 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<double>& K)
{
CheckCurveData(myPoles, K, myMults, myDeg, myPeriodic);
ClearEvalRepresentation();
myKnots = K;
myKnots.CopyValues(K);
myMaxDerivInvOk = false;
updateKnots();
}
@@ -205,21 +205,21 @@ Geom_BSplineSurface::Geom_BSplineSurface(const NCollection_Array2<gp_Pnt>& 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<gp_Pnt>& 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<gp_Pnt>& 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();
@@ -776,12 +776,12 @@ void Geom_BezierCurve::init(const NCollection_Array1<gp_Pnt>& 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)
{
@@ -2052,12 +2052,12 @@ void Geom_BezierSurface::init(const NCollection_Array2<gp_Pnt>& 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))
{