mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-09-04 19:57:55 +08:00
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:
@@ -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))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user