Modeling Data, Algorithms - Always-populated weights, direct array access migration, Hermit bug fix (#1058)

Introduce always-populated weight arrays in BSpline/Bezier curve and surface
classes using non-owning views over a static unit-weights buffer. Migrate
~100 callers across the codebase from deprecated copy-out APIs to direct
const-reference array access. Fix a long-standing typo bug in Hermit.cxx.

Infrastructure (BSplCLib, BSplSLib):
- Add BSplCLib::UnitWeights(n) returning a non-owning NCollection_Array1
  view over a compile-time-initialized static array of 2049 ones; falls
  back to heap allocation for larger sizes.
- Add BSplCLib::MaxUnitWeightsSize() (constexpr 2049) and
  BSplCLib::UnitWeightsData() exposing the raw pointer for BSplSLib.
- Add BSplSLib::UnitWeights(nU, nV) returning a non-owning
  NCollection_Array2 view when nU*nV <= 2049, heap-allocated otherwise.

Always-populated myWeights (Geom/Geom2d curve and surface classes):
- myWeights is now always sized to match poles count.
  Non-rational: non-owning view via UnitWeights (zero allocation).
  Rational: owning array with actual weight values.
- Add WeightsArray() returning const NCollection_Array1<double>& (curves)
  or const NCollection_Array2<double>& (surfaces) that is always valid.
- Update all constructors, copy constructors, and restructuring operations
  (IncreaseDegree, InsertKnots, RemoveKnot, Segment, SetPeriodic,
  SetOrigin, SetNotPeriodic, ExchangeUV, etc.) to maintain the invariant.
- SetWeight: copies non-owning view to owned array before mutation when
  transitioning to rational; assigns UnitWeights when becoming non-rational.
- Remove myRational derivation from myWeights.Size() in updateKnots();
  rationality is now tracked explicitly via the myRational flag only.
- Fix Geom2d_BSplineCurve::InsertPoleAfter missing myRational update
  after inserting a weighted pole.
- Fix Geom_BSplineCurve::DumpJson stale myWeights.Size() > 0 guard
  (changed to myRational, matching all other classes).

Caller migration to direct array access (~100 files):
- Replace deprecated copy-out pattern (allocate temp + call Foo(temp))
  with const-reference access for Poles(), Knots(), Multiplicities(),
  UKnots(), VKnots(), UMultiplicities(), VMultiplicities(),
  KnotSequence(), UKnotSequence(), VKnotSequence().
- Replace Weights() null-pointer patterns with WeightsArray() const-ref
  or *Weights() dereference where null check is still appropriate.
- Affected modules: GeomConvert, Geom2dConvert, GeomLib, GeomFill,
  ProjLib, ShapeUpgrade, ShapeCustom, ShapeConstruct, ShapeAnalysis,
  ShapeAlgo, BRepLib, BRepGProp, HLRBRep, ChFi3d, ChFiKPart, BlendFunc,
  FairCurve, IntTools, TopOpeBRepTool, TopOpeBRepBuild, LocOpe,
  BRepOffset, Adaptor3d, GeomAdaptor, Geom2dAdaptor, BndLib, Extrema,
  DrawTrSurf, GeometryTest, GeomliteTest, SWDRAW, QABugs,
  GeomToIGES, IGESToBRep, GeomToStep, StdPrs.

Bug fix in Hermit.cxx (PolyTest, both 3D and 2D overloads):
- Fix typo: "Pole0 < 3" changed to "Pole0 < Pole3" — was comparing
  a double variable against the integer literal 3 instead of the
  variable Pole3 holding the endpoint weight value.
- Fix logic: "if (boucle == 1)" changed to "else if (boucle == 1)"
  to make the boucle==1 and boucle==2 branches mutually exclusive.
- Add explanatory comments on BSplCLib::D1 calls that intentionally
  pass weight values as scalar "poles" to evaluate the weight function.

NCollection_PackedMapAlgo migration (TDataStd, QABugs):
- Replace deprecated member functions (IsSubset, Subtraction, Subtract,
  Unite, Intersect, IsEqual) with NCollection_PackedMapAlgo free functions.

GTests:
- New BSplCLib_Test.cxx: 5 tests for UnitWeights API.
- New BSplSLib_Test.cxx: 5 tests for surface UnitWeights API.
- New Hermit_Test.cxx: 11 tests for Hermit::Solution (3D/2D) and
  Hermit::Solutionbis covering uniform, distinct, high-ratio, reversed,
  symmetric weights and positive-poles invariant.
- Add WeightsArray tests to Geom_BSplineCurve_Test, Geom_BezierCurve_Test,
  Geom_BSplineSurface_Test, Geom_BezierSurface_Test (2 tests each)
  verifying const-ref return, non-owning for non-rational, owning for
  rational.
This commit is contained in:
Pasukhin Dmitry
2026-02-10 18:41:34 +00:00
committed by GitHub
parent 8949fd25f9
commit 964a2c75df
125 changed files with 2024 additions and 1678 deletions
@@ -301,7 +301,7 @@ bool FairCurve_Batten::Compute(const gp_Vec2d& DeltaP1,
}
// Summing
DeltaCurve->Poles(NPoles->ChangeArray1());
NPoles->ChangeArray1() = DeltaCurve->Poles();
for (kk = NPoles->Lower(); kk <= NPoles->Upper(); kk++)
{
NPoles->ChangeValue(kk).ChangeCoord() += Poles->Value(kk).Coord();
@@ -468,13 +468,11 @@ bool FairCurve_Batten::Compute(const gp_Vec2d& DeltaP1,
NewBS->InsertKnots(NKnots->Array1(), NMults->Array1(), 1.e-10);
occ::handle<NCollection_HArray1<gp_Pnt2d>> NewNPoles =
new NCollection_HArray1<gp_Pnt2d>(1, NewBS->NbPoles());
NewBS->Poles(NewNPoles->ChangeArray1());
NewBS->Multiplicities(NMults->ChangeArray1());
NewBS->Knots(NKnots->ChangeArray1());
new NCollection_HArray1<gp_Pnt2d>(NewBS->Poles());
NMults = new NCollection_HArray1<int>(NewBS->Multiplicities());
NKnots = new NCollection_HArray1<double>(NewBS->Knots());
occ::handle<NCollection_HArray1<double>> FKnots =
new NCollection_HArray1<double>(1, NewBS->NbPoles() + Degree + 1);
NewBS->KnotSequence(FKnots->ChangeArray1());
new NCollection_HArray1<double>(NewBS->KnotSequence());
Poles = NewNPoles;
Mults = NMults;
@@ -268,7 +268,7 @@ bool FairCurve_MinimalVariation::Compute(const gp_Vec2d& DeltaP1,
}
// Summing
DeltaCurve->Poles(NPoles->ChangeArray1());
NPoles->ChangeArray1() = DeltaCurve->Poles();
for (kk = NPoles->Lower(); kk <= NPoles->Upper(); kk++)
{
NPoles->ChangeValue(kk).ChangeCoord() += Poles->Value(kk).Coord();
@@ -466,13 +466,11 @@ bool FairCurve_MinimalVariation::Compute(const gp_Vec2d& DeltaP1,
NewBS->InsertKnots(NKnots->Array1(), NMults->Array1(), 1.e-10);
occ::handle<NCollection_HArray1<gp_Pnt2d>> NewNPoles =
new NCollection_HArray1<gp_Pnt2d>(1, NewBS->NbPoles());
NewBS->Poles(NewNPoles->ChangeArray1());
NewBS->Multiplicities(NMults->ChangeArray1());
NewBS->Knots(NKnots->ChangeArray1());
new NCollection_HArray1<gp_Pnt2d>(NewBS->Poles());
NMults = new NCollection_HArray1<int>(NewBS->Multiplicities());
NKnots = new NCollection_HArray1<double>(NewBS->Knots());
occ::handle<NCollection_HArray1<double>> FKnots =
new NCollection_HArray1<double>(1, NewBS->NbPoles() + Degree + 1);
NewBS->KnotSequence(FKnots->ChangeArray1());
new NCollection_HArray1<double>(NewBS->KnotSequence());
Poles = NewNPoles;
Mults = NMults;
@@ -244,14 +244,12 @@ void GeomFill::GetMinimalWeights(const Convert_ParameterisationType TConv,
gp_Circ C(popAx2, 1);
occ::handle<Geom_TrimmedCurve> Sect1 = new Geom_TrimmedCurve(new Geom_Circle(C), 0., MaxAng);
occ::handle<Geom_BSplineCurve> CtoBspl = GeomConvert::CurveToBSplineCurve(Sect1, TConv);
CtoBspl->Weights(Weights);
NCollection_Array1<double> poids(Weights.Lower(), Weights.Upper());
double angle_min = std::max(Precision::PConfusion(), MinAng);
Weights.Assign(CtoBspl->WeightsArray());
double angle_min = std::max(Precision::PConfusion(), MinAng);
occ::handle<Geom_TrimmedCurve> Sect2 = new Geom_TrimmedCurve(new Geom_Circle(C), 0., angle_min);
CtoBspl = GeomConvert::CurveToBSplineCurve(Sect2, TConv);
CtoBspl->Weights(poids);
const NCollection_Array1<double>& poids = CtoBspl->WeightsArray();
for (int ii = Weights.Lower(); ii <= Weights.Upper(); ii++)
{
@@ -133,38 +133,20 @@ static bool Arrange(const occ::handle<Geom_BSplineCurve>& C1,
static int SetSameDistribution(occ::handle<Geom_BSplineCurve>& C1,
occ::handle<Geom_BSplineCurve>& C2)
{
int nbp1 = C1->NbPoles();
int nbk1 = C1->NbKnots();
NCollection_Array1<gp_Pnt> P1(1, nbp1);
NCollection_Array1<double> W1(1, nbp1);
W1.Init(1.);
NCollection_Array1<double> K1(1, nbk1);
NCollection_Array1<int> M1(1, nbk1);
NCollection_Array1<gp_Pnt> P1(C1->Poles());
const NCollection_Array1<double>& W1 = C1->WeightsArray();
NCollection_Array1<double> K1(C1->Knots());
NCollection_Array1<int> M1(C1->Multiplicities());
C1->Poles(P1);
if (C1->IsRational())
C1->Weights(W1);
C1->Knots(K1);
C1->Multiplicities(M1);
int nbp2 = C2->NbPoles();
int nbk2 = C2->NbKnots();
NCollection_Array1<gp_Pnt> P2(1, nbp2);
NCollection_Array1<double> W2(1, nbp2);
W2.Init(1.);
NCollection_Array1<double> K2(1, nbk2);
NCollection_Array1<int> M2(1, nbk2);
C2->Poles(P2);
if (C2->IsRational())
C2->Weights(W2);
C2->Knots(K2);
C2->Multiplicities(M2);
NCollection_Array1<gp_Pnt> P2(C2->Poles());
const NCollection_Array1<double>& W2 = C2->WeightsArray();
NCollection_Array1<double> K2(C2->Knots());
NCollection_Array1<int> M2(C2->Multiplicities());
double K11 = K1(1);
double K12 = K1(nbk1);
double K12 = K1(K1.Upper());
double K21 = K2(1);
double K22 = K2(nbk2);
double K22 = K2(K2.Upper());
if ((K12 - K11) > (K22 - K21))
{
@@ -330,45 +312,18 @@ void GeomFill_BSplineCurves::Init(const occ::handle<Geom_BSplineCurve>& C1,
throw Standard_ConstructionError("GeomFill_BSplineCurves: invalid filling style");
}
NCollection_Array1<gp_Pnt> P1(1, NbUPoles);
NCollection_Array1<gp_Pnt> P2(1, NbVPoles);
NCollection_Array1<gp_Pnt> P3(1, NbUPoles);
NCollection_Array1<gp_Pnt> P4(1, NbVPoles);
CC1->Poles(P1);
CC2->Poles(P2);
CC3->Poles(P3);
CC4->Poles(P4);
const NCollection_Array1<gp_Pnt>& P1 = CC1->Poles();
const NCollection_Array1<gp_Pnt>& P2 = CC2->Poles();
const NCollection_Array1<gp_Pnt>& P3 = CC3->Poles();
const NCollection_Array1<gp_Pnt>& P4 = CC4->Poles();
// Traitement des courbes rationelles
bool isRat = (CC1->IsRational() || CC2->IsRational() || CC3->IsRational() || CC4->IsRational());
NCollection_Array1<double> W1(1, NbUPoles);
NCollection_Array1<double> W3(1, NbUPoles);
NCollection_Array1<double> W2(1, NbVPoles);
NCollection_Array1<double> W4(1, NbVPoles);
W1.Init(1.);
W2.Init(1.);
W3.Init(1.);
W4.Init(1.);
if (isRat)
{
if (CC1->IsRational())
{
CC1->Weights(W1);
}
if (CC2->IsRational())
{
CC2->Weights(W2);
}
if (CC3->IsRational())
{
CC3->Weights(W3);
}
if (CC4->IsRational())
{
CC4->Weights(W4);
}
}
const NCollection_Array1<double>& W1 = CC1->WeightsArray();
const NCollection_Array1<double>& W2 = CC2->WeightsArray();
const NCollection_Array1<double>& W3 = CC3->WeightsArray();
const NCollection_Array1<double>& W4 = CC4->WeightsArray();
GeomFill_Filling Caro;
if (isRat)
@@ -407,17 +362,11 @@ void GeomFill_BSplineCurves::Init(const occ::handle<Geom_BSplineCurve>& C1,
NCollection_Array2<gp_Pnt> Poles(1, NbUPoles, 1, NbVPoles);
// Creation de la surface
int NbUKnot = CC1->NbKnots();
NCollection_Array1<double> UKnots(1, NbUKnot);
NCollection_Array1<int> UMults(1, NbUKnot);
CC1->Knots(UKnots);
CC1->Multiplicities(UMults);
const NCollection_Array1<double>& UKnots = CC1->Knots();
const NCollection_Array1<int>& UMults = CC1->Multiplicities();
int NbVKnot = CC2->NbKnots();
NCollection_Array1<double> VKnots(1, NbVKnot);
NCollection_Array1<int> VMults(1, NbVKnot);
CC2->Knots(VKnots);
CC2->Multiplicities(VMults);
const NCollection_Array1<double>& VKnots = CC2->Knots();
const NCollection_Array1<int>& VMults = CC2->Multiplicities();
Caro.Poles(Poles);
@@ -497,23 +446,18 @@ void GeomFill_BSplineCurves::Init(const occ::handle<Geom_BSplineCurve>& C1,
CC2->IncreaseDegree(DegU);
// Mise en conformite des distributions de noeuds
int NbPoles = SetSameDistribution(CC1, CC2);
NCollection_Array2<gp_Pnt> Poles(1, NbPoles, 1, 2);
NCollection_Array1<gp_Pnt> P1(1, NbPoles);
NCollection_Array1<gp_Pnt> P2(1, NbPoles);
CC1->Poles(P1);
CC2->Poles(P2);
int i;
int NbPoles = SetSameDistribution(CC1, CC2);
NCollection_Array2<gp_Pnt> Poles(1, NbPoles, 1, 2);
const NCollection_Array1<gp_Pnt>& P1 = CC1->Poles();
const NCollection_Array1<gp_Pnt>& P2 = CC2->Poles();
int i;
for (i = 1; i <= NbPoles; i++)
{
Poles(i, 1) = P1(i);
Poles(i, 2) = P2(i);
}
int NbUKnots = CC1->NbKnots();
NCollection_Array1<double> UKnots(1, NbUKnots);
NCollection_Array1<int> UMults(1, NbUKnots);
CC1->Knots(UKnots);
CC1->Multiplicities(UMults);
const NCollection_Array1<double>& UKnots = CC1->Knots();
const NCollection_Array1<int>& UMults = CC1->Multiplicities();
// int NbVKnots = 2;
NCollection_Array1<double> VKnots(1, 2);
NCollection_Array1<int> VMults(1, 2);
@@ -525,27 +469,13 @@ void GeomFill_BSplineCurves::Init(const occ::handle<Geom_BSplineCurve>& C1,
// Traitement des courbes rationelles
if (isRat)
{
NCollection_Array2<double> Weights(1, NbPoles, 1, 2);
NCollection_Array1<double> W1(1, NbPoles);
NCollection_Array1<double> W2(1, NbPoles);
W1.Init(1.);
W2.Init(1.);
if (isRat)
NCollection_Array2<double> Weights(1, NbPoles, 1, 2);
const NCollection_Array1<double>& W1 = CC1->WeightsArray();
const NCollection_Array1<double>& W2 = CC2->WeightsArray();
for (i = 1; i <= NbPoles; i++)
{
if (CC1->IsRational())
{
CC1->Weights(W1);
}
if (CC2->IsRational())
{
CC2->Weights(W2);
}
for (i = 1; i <= NbPoles; i++)
{
Weights(i, 1) = W1(i);
Weights(i, 2) = W2(i);
}
Weights(i, 1) = W1(i);
Weights(i, 2) = W2(i);
}
mySurface = new Geom_BSplineSurface(Poles,
Weights,
@@ -591,41 +521,22 @@ void GeomFill_BSplineCurves::Init(const occ::handle<Geom_BSplineCurve>& C1,
if (!IsOK)
throw Standard_OutOfRange("GeomFill_BSplineCurves: Courbes non jointives");
int NbUPoles = CC1->NbPoles();
int NbVPoles = CC2->NbPoles();
NCollection_Array1<gp_Pnt> P1(1, NbUPoles);
NCollection_Array1<gp_Pnt> P2(1, NbVPoles);
CC1->Poles(P1);
CC2->Poles(P2);
int NbUPoles = CC1->NbPoles();
int NbVPoles = CC2->NbPoles();
const NCollection_Array1<gp_Pnt>& P1 = CC1->Poles();
const NCollection_Array1<gp_Pnt>& P2 = CC2->Poles();
int NbUKnots = CC1->NbKnots();
int NbVKnots = CC2->NbKnots();
NCollection_Array1<double> UKnots(1, NbUKnots);
NCollection_Array1<double> VKnots(1, NbVKnots);
NCollection_Array1<int> UMults(1, NbUKnots);
NCollection_Array1<int> VMults(1, NbVKnots);
CC1->Knots(UKnots);
CC1->Multiplicities(UMults);
CC2->Knots(VKnots);
CC2->Multiplicities(VMults);
NCollection_Array1<double> W1(1, NbUPoles);
NCollection_Array1<double> W2(1, NbVPoles);
W1.Init(1.);
W2.Init(1.);
const NCollection_Array1<double>& UKnots = CC1->Knots();
const NCollection_Array1<int>& UMults = CC1->Multiplicities();
const NCollection_Array1<double>& VKnots = CC2->Knots();
const NCollection_Array1<int>& VMults = CC2->Multiplicities();
GeomFill_Filling Caro;
if (isRat)
{
if (CC1->IsRational())
{
CC1->Weights(W1);
}
if (CC2->IsRational())
{
CC2->Weights(W2);
}
Caro = GeomFill_Curved(P1, P2, W1, W2);
const NCollection_Array1<double>& W1 = CC1->WeightsArray();
const NCollection_Array1<double>& W2 = CC2->WeightsArray();
Caro = GeomFill_Curved(P1, P2, W1, W2);
}
else
{
@@ -225,50 +225,21 @@ void GeomFill_BezierCurves::Init(const occ::handle<Geom_BezierCurve>& C1,
if (CC4->Degree() < DegV)
CC4->Increase(DegV);
NCollection_Array1<gp_Pnt> P1(1, DegU + 1);
NCollection_Array1<gp_Pnt> P3(1, DegU + 1);
NCollection_Array1<gp_Pnt> P2(1, DegV + 1);
NCollection_Array1<gp_Pnt> P4(1, DegV + 1);
CC1->Poles(P1);
CC2->Poles(P2);
CC3->Poles(P3);
CC4->Poles(P4);
const NCollection_Array1<gp_Pnt>& P1 = CC1->Poles();
const NCollection_Array1<gp_Pnt>& P2 = CC2->Poles();
const NCollection_Array1<gp_Pnt>& P3 = CC3->Poles();
const NCollection_Array1<gp_Pnt>& P4 = CC4->Poles();
// Traitement des courbes rationelles
bool isRat = (CC1->IsRational() || CC2->IsRational() || CC3->IsRational() || CC4->IsRational());
NCollection_Array1<double> W1(1, DegU + 1);
NCollection_Array1<double> W3(1, DegU + 1);
NCollection_Array1<double> W2(1, DegV + 1);
NCollection_Array1<double> W4(1, DegV + 1);
W1.Init(1.);
W2.Init(1.);
W3.Init(1.);
W4.Init(1.);
if (isRat)
{
if (CC1->IsRational())
{
CC1->Weights(W1);
}
if (CC2->IsRational())
{
CC2->Weights(W2);
}
if (CC3->IsRational())
{
CC3->Weights(W3);
}
if (CC4->IsRational())
{
CC4->Weights(W4);
}
}
GeomFill_Filling Caro;
if (isRat)
{
NCollection_Array1<double> W1(CC1->WeightsArray());
NCollection_Array1<double> W2(CC2->WeightsArray());
NCollection_Array1<double> W3(CC3->WeightsArray());
NCollection_Array1<double> W4(CC4->WeightsArray());
// Mise en conformite des poids aux coins.
SetSameWeights(W1, W2, W3, W4);
switch (Type)
@@ -369,11 +340,9 @@ void GeomFill_BezierCurves::Init(const occ::handle<Geom_BezierCurve>& C1,
if (CC2->Degree() < DegU)
CC2->Increase(DegU);
NCollection_Array2<gp_Pnt> Poles(1, DegU + 1, 1, 2);
NCollection_Array1<gp_Pnt> P1(1, DegU + 1);
NCollection_Array1<gp_Pnt> P2(1, DegU + 1);
CC1->Poles(P1);
CC2->Poles(P2);
NCollection_Array2<gp_Pnt> Poles(1, DegU + 1, 1, 2);
const NCollection_Array1<gp_Pnt>& P1 = CC1->Poles();
const NCollection_Array1<gp_Pnt>& P2 = CC2->Poles();
int i;
for (i = 1; i <= DegU + 1; i++)
@@ -383,20 +352,9 @@ void GeomFill_BezierCurves::Init(const occ::handle<Geom_BezierCurve>& C1,
}
if (isRat)
{
NCollection_Array1<double> W1(1, DegU + 1);
NCollection_Array1<double> W2(1, DegU + 1);
W1.Init(1.);
W2.Init(1.);
if (CC1->IsRational())
{
CC1->Weights(W1);
}
if (CC2->IsRational())
{
CC2->Weights(W2);
}
NCollection_Array2<double> Weights(1, DegU + 1, 1, 2);
const NCollection_Array1<double>& W1 = CC1->WeightsArray();
const NCollection_Array1<double>& W2 = CC2->WeightsArray();
NCollection_Array2<double> Weights(1, DegU + 1, 1, 2);
for (i = 1; i <= DegU + 1; i++)
{
Weights(i, 1) = W1(i);
@@ -411,9 +369,6 @@ void GeomFill_BezierCurves::Init(const occ::handle<Geom_BezierCurve>& C1,
}
else
{
NCollection_Array1<gp_Pnt> P1(1, Deg1 + 1);
NCollection_Array1<gp_Pnt> P2(1, Deg2 + 1);
constexpr double Eps = Precision::Confusion();
bool IsOK = false;
if (CC1->StartPoint().IsEqual(CC2->StartPoint(), Eps))
@@ -440,26 +395,15 @@ void GeomFill_BezierCurves::Init(const occ::handle<Geom_BezierCurve>& C1,
if (!IsOK)
throw Standard_OutOfRange("GeomFill_BezierCurves: Courbes non jointives");
CC1->Poles(P1);
CC2->Poles(P2);
NCollection_Array1<double> W1(1, Deg1 + 1);
NCollection_Array1<double> W2(1, Deg2 + 1);
W1.Init(1.);
W2.Init(1.);
const NCollection_Array1<gp_Pnt>& P1 = CC1->Poles();
const NCollection_Array1<gp_Pnt>& P2 = CC2->Poles();
GeomFill_Filling Caro;
if (isRat)
{
if (CC1->IsRational())
{
CC1->Weights(W1);
}
if (CC2->IsRational())
{
CC2->Weights(W2);
}
Caro = GeomFill_Curved(P1, P2, W1, W2);
const NCollection_Array1<double>& W1 = CC1->WeightsArray();
const NCollection_Array1<double>& W2 = CC2->WeightsArray();
Caro = GeomFill_Curved(P1, P2, W1, W2);
}
else
{
@@ -208,8 +208,7 @@ static bool FindPlane(const occ::handle<Adaptor3d_Curve>& theC, occ::handle<Geom
}
else
{
TabP = new (NCollection_HArray1<gp_Pnt>)(1, nbp);
GC->Poles(TabP->ChangeArray1());
TabP = new NCollection_HArray1<gp_Pnt>(GC->Poles());
}
}
break;
@@ -225,8 +224,7 @@ static bool FindPlane(const occ::handle<Adaptor3d_Curve>& theC, occ::handle<Geom
}
else
{
TabP = new (NCollection_HArray1<gp_Pnt>)(1, nbp);
GC->Poles(TabP->ChangeArray1());
TabP = new NCollection_HArray1<gp_Pnt>(GC->Poles());
}
}
break;
@@ -59,13 +59,13 @@ bool GeomFill_EvolvedSection::D0(const double U,
{
double val;
int ii, L = Poles.Length();
val = TLaw->Value(U);
myCurve->Poles(Poles);
val = TLaw->Value(U);
Poles = myCurve->Poles();
for (ii = 1; ii <= L; ii++)
{
Poles(ii).ChangeCoord() *= val;
}
myCurve->Weights(Weights);
Weights = myCurve->WeightsArray();
return true;
}
@@ -83,8 +83,8 @@ bool GeomFill_EvolvedSection::D1(const double U,
int ii, L = Poles.Length();
TLaw->D1(U, val, dval);
myCurve->Poles(Poles);
myCurve->Weights(Weights);
Poles = myCurve->Poles();
Weights = myCurve->WeightsArray();
for (ii = 1; ii <= L; ii++)
{
DPoles(ii).SetXYZ(Poles(ii).XYZ());
@@ -110,8 +110,8 @@ bool GeomFill_EvolvedSection::D2(const double U,
double val, dval, d2val;
int ii, L = Poles.Length();
TLaw->D2(U, val, dval, d2val);
myCurve->Poles(Poles);
myCurve->Weights(Weights);
Poles = myCurve->Poles();
Weights = myCurve->WeightsArray();
for (ii = 1; ii <= L; ii++)
{
@@ -172,7 +172,7 @@ void GeomFill_EvolvedSection::SectionShape(int& NbPoles, int& NbKnots, int& Degr
void GeomFill_EvolvedSection::Knots(NCollection_Array1<double>& TKnots) const
{
myCurve->Knots(TKnots);
TKnots = myCurve->Knots();
}
//=======================================================
@@ -180,7 +180,7 @@ void GeomFill_EvolvedSection::Knots(NCollection_Array1<double>& TKnots) const
//=======================================================
void GeomFill_EvolvedSection::Mults(NCollection_Array1<int>& TMults) const
{
myCurve->Multiplicities(TMults);
TMults = myCurve->Multiplicities();
}
//=======================================================
@@ -311,14 +311,7 @@ double GeomFill_EvolvedSection::MaximalSection() const
void GeomFill_EvolvedSection::GetMinimalWeight(NCollection_Array1<double>& Weights) const
{
if (myCurve->IsRational())
{
myCurve->Weights(Weights);
}
else
{
Weights.Init(1);
}
Weights = myCurve->WeightsArray();
}
bool GeomFill_EvolvedSection::IsConstant(double& Error) const
@@ -56,18 +56,16 @@ void GeomFill_Generator::Perform(const double PTol)
KnotsAndMults(UKnots, UMults);
NCollection_Array1<gp_Pnt> Pole(1, NbUPoles);
NCollection_Array1<double> Weight(1, NbUPoles);
for (j = 1; j <= NbVPoles; j++)
{
occ::handle<Geom_BSplineCurve> Cj = occ::down_cast<Geom_BSplineCurve>(mySequence(j));
Cj->Poles(Pole);
Cj->Weights(Weight);
VKnots(j) = (double)(j - 1);
occ::handle<Geom_BSplineCurve> Cj = occ::down_cast<Geom_BSplineCurve>(mySequence(j));
const NCollection_Array1<gp_Pnt>& aPoles = Cj->Poles();
const NCollection_Array1<double>& aWeights = Cj->WeightsArray();
VKnots(j) = (double)(j - 1);
for (i = 1; i <= NbUPoles; i++)
{
Poles(i, j) = Pole(i);
Weights(i, j) = Weight(i);
Poles(i, j) = aPoles(i);
Weights(i, j) = aWeights(i);
}
}
@@ -157,9 +157,7 @@ static void ResultEval(const occ::handle<Geom_BSplineSurface>& surf,
int Cdeg = surf->VDegree(), Cdim = surf->NbUPoles() * gap, NbP = surf->NbVPoles();
// les noeuds plats
int Ksize = NbP + Cdeg + 1;
NCollection_Array1<double> FKnots(1, Ksize);
surf->VKnotSequence(FKnots);
const NCollection_Array1<double>& FKnots = surf->VKnotSequence();
// les poles
int Psize = Cdim * NbP;
@@ -298,11 +296,9 @@ bool GeomFill_NSections::D0(const double V,
{
occ::handle<Geom_BSplineCurve> Curve =
occ::down_cast<Geom_BSplineCurve>(mySurface->VIso(V, false));
NCollection_Array1<gp_Pnt> poles(1, mySurface->NbUPoles());
NCollection_Array1<double> weights(1, mySurface->NbUPoles());
Curve->Poles(poles);
Curve->Weights(weights);
int ii, L = Poles.Length();
const NCollection_Array1<gp_Pnt>& poles = Curve->Poles();
const NCollection_Array1<double>& weights = Curve->WeightsArray();
int ii, L = Poles.Length();
for (ii = 1; ii <= L; ii++)
{
Poles(ii).SetXYZ(poles(ii).XYZ());
@@ -514,8 +510,7 @@ void GeomFill_NSections::ComputeSurface()
curvBS = GeomConvert::CurveToBSplineCurve(curv, Convert_QuasiAngular);
}
NCollection_Array1<double> BSK(1, curvBS->NbKnots());
curvBS->Knots(BSK);
NCollection_Array1<double> BSK(curvBS->Knots());
BSplCLib::Reparametrize(UFirst, ULast, BSK);
curvBS->SetKnots(BSK);
@@ -630,7 +625,7 @@ void GeomFill_NSections::SectionShape(int& NbPoles, int& NbKnots, int& Degree) c
void GeomFill_NSections::Knots(NCollection_Array1<double>& TKnots) const
{
if (!mySurface.IsNull())
mySurface->UKnots(TKnots);
TKnots = mySurface->UKnots();
}
//=======================================================
@@ -639,7 +634,7 @@ void GeomFill_NSections::Knots(NCollection_Array1<double>& TKnots) const
void GeomFill_NSections::Mults(NCollection_Array1<int>& TMults) const
{
if (!mySurface.IsNull())
mySurface->UMultiplicities(TMults);
TMults = mySurface->UMultiplicities();
}
//=======================================================
@@ -802,10 +797,15 @@ void GeomFill_NSections::GetMinimalWeight(NCollection_Array1<double>& Weights) c
if (mySurface->IsURational())
{
int NbU = mySurface->NbUPoles(), NbV = mySurface->NbVPoles();
NCollection_Array2<double> WSurf(1, NbU, 1, NbV);
mySurface->Weights(WSurf);
int i, j;
int NbU = mySurface->NbUPoles(), NbV = mySurface->NbVPoles();
const NCollection_Array2<double>* aWSurfPtr = mySurface->Weights();
if (aWSurfPtr == nullptr)
{
Weights.Init(1);
return;
}
const NCollection_Array2<double>& WSurf = *aWSurfPtr;
int i, j;
for (i = 1; i <= NbU; i++)
{
double min = WSurf(i, 1);
@@ -35,19 +35,15 @@ static void UnifyByInsertingAllKnots(NCollection_Sequence<occ::handle<Geom_Curve
int i;
for (i = 2; i <= theCurves.Length(); i++)
{
occ::handle<Geom_BSplineCurve> Ci = occ::down_cast<Geom_BSplineCurve>(theCurves(i));
NCollection_Array1<double> Ki(1, Ci->NbKnots());
Ci->Knots(Ki);
NCollection_Array1<int> Mi(1, Ci->NbKnots());
Ci->Multiplicities(Mi);
occ::handle<Geom_BSplineCurve> Ci = occ::down_cast<Geom_BSplineCurve>(theCurves(i));
const NCollection_Array1<double>& Ki = Ci->Knots();
const NCollection_Array1<int>& Mi = Ci->Multiplicities();
C->InsertKnots(Ki, Mi, PTol, false);
}
NCollection_Array1<double> NewKnots(1, C->NbKnots());
C->Knots(NewKnots);
NCollection_Array1<int> NewMults(1, C->NbKnots());
C->Multiplicities(NewMults);
const NCollection_Array1<double>& NewKnots = C->Knots();
const NCollection_Array1<int>& NewMults = C->Multiplicities();
for (i = 2; i <= theCurves.Length(); i++)
{
occ::handle<Geom_BSplineCurve> Ci = occ::down_cast<Geom_BSplineCurve>(theCurves(i));
@@ -205,8 +201,7 @@ void GeomFill_Profiler::Perform(const double PTol)
C->IncreaseDegree(myDegree);
NCollection_Array1<double> Knots(1, C->NbKnots());
C->Knots(Knots);
NCollection_Array1<double> Knots(C->Knots());
BSplCLib::Reparametrize(UFirst, ULast, Knots);
C->SetKnots(Knots);
}
@@ -269,7 +264,7 @@ void GeomFill_Profiler::Poles(const int Index, NCollection_Array1<gp_Pnt>& Poles
occ::handle<Geom_BSplineCurve> C = occ::down_cast<Geom_BSplineCurve>(mySequence(Index));
C->Poles(Poles);
Poles = C->Poles();
}
//=================================================================================================
@@ -285,7 +280,7 @@ void GeomFill_Profiler::Weights(const int Index, NCollection_Array1<double>& Wei
occ::handle<Geom_BSplineCurve> C = occ::down_cast<Geom_BSplineCurve>(mySequence(Index));
C->Weights(Weights);
Weights = C->WeightsArray();
}
//=================================================================================================
@@ -316,6 +311,6 @@ void GeomFill_Profiler::KnotsAndMults(NCollection_Array1<double>& Knots,
occ::handle<Geom_BSplineCurve> C = occ::down_cast<Geom_BSplineCurve>(mySequence(1));
C->Knots(Knots);
C->Multiplicities(Mults);
Knots = C->Knots();
Mults = C->Multiplicities();
}
@@ -63,14 +63,14 @@ void GeomFill_SectionGenerator::GetShape(int& NbPoles,
void GeomFill_SectionGenerator::Knots(NCollection_Array1<double>& TKnots) const
{
(occ::down_cast<Geom_BSplineCurve>(mySequence(1)))->Knots(TKnots);
TKnots = (occ::down_cast<Geom_BSplineCurve>(mySequence(1)))->Knots();
}
//=================================================================================================
void GeomFill_SectionGenerator::Mults(NCollection_Array1<int>& TMults) const
{
(occ::down_cast<Geom_BSplineCurve>(mySequence(1)))->Multiplicities(TMults);
TMults = (occ::down_cast<Geom_BSplineCurve>(mySequence(1)))->Multiplicities();
}
//=================================================================================================
@@ -97,8 +97,8 @@ void GeomFill_SectionGenerator::Section(const int P,
{
occ::handle<Geom_BSplineCurve> C = occ::down_cast<Geom_BSplineCurve>(mySequence(P));
C->Poles(Poles);
C->Weights(Weigths);
Poles = C->Poles();
Weigths = C->WeightsArray();
}
//=================================================================================================
@@ -399,7 +399,7 @@ void GeomFill_SweepSectionGenerator::Knots(NCollection_Array1<double>& TKnots) c
*/
if (myType != 0)
{
myFirstSect->Knots(TKnots);
TKnots = myFirstSect->Knots();
}
else
{
@@ -422,7 +422,7 @@ void GeomFill_SweepSectionGenerator::Mults(NCollection_Array1<int>& TMults) cons
*/
if (myType != 0)
{
myFirstSect->Multiplicities(TMults);
TMults = myFirstSect->Multiplicities();
}
else
{
@@ -524,8 +524,8 @@ void GeomFill_SweepSectionGenerator::Section(const int P,
{
if (myType != 0)
{
myFirstSect->Poles(Poles);
myFirstSect->Weights(Weigths);
Poles = myFirstSect->Poles();
Weigths = myFirstSect->WeightsArray();
gp_Trsf cumulTR;
if (P > 1)
{
@@ -630,8 +630,8 @@ void GeomFill_SweepSectionGenerator::Section(const int P,
else
BS = GeomConvert::CurveToBSplineCurve(CT, Convert_QuasiAngular);
BS->Poles(Poles);
BS->Weights(Weigths);
Poles = BS->Poles();
Weigths = BS->WeightsArray();
}
}
}
@@ -58,8 +58,8 @@ bool GeomFill_UniformSection::D0(const double,
NCollection_Array1<gp_Pnt>& Poles,
NCollection_Array1<double>& Weights)
{
myCurve->Poles(Poles);
myCurve->Weights(Weights);
Poles = myCurve->Poles();
Weights = myCurve->WeightsArray();
return true;
}
@@ -73,8 +73,8 @@ bool GeomFill_UniformSection::D1(const double,
NCollection_Array1<double>& Weights,
NCollection_Array1<double>& DWeights)
{
myCurve->Poles(Poles);
myCurve->Weights(Weights);
Poles = myCurve->Poles();
Weights = myCurve->WeightsArray();
gp_Vec V0(0, 0, 0);
DPoles.Init(V0);
DWeights.Init(0);
@@ -93,8 +93,8 @@ bool GeomFill_UniformSection::D2(const double,
NCollection_Array1<double>& DWeights,
NCollection_Array1<double>& D2Weights)
{
myCurve->Poles(Poles);
myCurve->Weights(Weights);
Poles = myCurve->Poles();
Weights = myCurve->WeightsArray();
gp_Vec V0(0, 0, 0);
DPoles.Init(V0);
DWeights.Init(0);
@@ -109,21 +109,23 @@ bool GeomFill_UniformSection::D2(const double,
//=======================================================
occ::handle<Geom_BSplineSurface> GeomFill_UniformSection::BSplineSurface() const
{
int ii, NbPoles = myCurve->NbPoles();
NCollection_Array2<gp_Pnt> Poles(1, NbPoles, 1, 2);
NCollection_Array1<double> UKnots(1, myCurve->NbKnots()), VKnots(1, 2);
NCollection_Array1<int> UMults(1, myCurve->NbKnots()), VMults(1, 2);
int ii, NbPoles = myCurve->NbPoles();
NCollection_Array2<gp_Pnt> Poles(1, NbPoles, 1, 2);
const NCollection_Array1<double>& CurKnots = myCurve->Knots();
NCollection_Array1<double> UKnots(CurKnots);
NCollection_Array1<double> VKnots(1, 2);
const NCollection_Array1<int>& CurMults = myCurve->Multiplicities();
NCollection_Array1<int> UMults(CurMults);
NCollection_Array1<int> VMults(1, 2);
for (ii = 1; ii <= NbPoles; ii++)
{
Poles(ii, 1) = Poles(ii, 2) = myCurve->Pole(ii);
}
myCurve->Knots(UKnots);
VKnots(1) = First;
VKnots(2) = Last;
myCurve->Multiplicities(UMults);
VMults.Init(2);
occ::handle<Geom_BSplineSurface> BS = new (Geom_BSplineSurface)(Poles,
@@ -150,7 +152,7 @@ void GeomFill_UniformSection::SectionShape(int& NbPoles, int& NbKnots, int& Degr
void GeomFill_UniformSection::Knots(NCollection_Array1<double>& TKnots) const
{
myCurve->Knots(TKnots);
TKnots = myCurve->Knots();
}
//=======================================================
@@ -158,7 +160,7 @@ void GeomFill_UniformSection::Knots(NCollection_Array1<double>& TKnots) const
//=======================================================
void GeomFill_UniformSection::Mults(NCollection_Array1<int>& TMults) const
{
myCurve->Multiplicities(TMults);
TMults = myCurve->Multiplicities();
}
//=======================================================
@@ -276,14 +278,7 @@ double GeomFill_UniformSection::MaximalSection() const
void GeomFill_UniformSection::GetMinimalWeight(NCollection_Array1<double>& Weights) const
{
if (myCurve->IsRational())
{
myCurve->Weights(Weights);
}
else
{
Weights.Init(1);
}
Weights = myCurve->WeightsArray();
}
bool GeomFill_UniformSection::IsConstant(double& Error) const
@@ -1182,8 +1182,7 @@ void GeomInt_IntSS::BuildPCurves(const double theFirst,
|| (theLast - theCurve2d->LastParameter() > Precision::PConfusion()))
{
occ::handle<Geom2d_BSplineCurve> aBspl = occ::down_cast<Geom2d_BSplineCurve>(theCurve2d);
NCollection_Array1<double> aKnots(1, aBspl->NbKnots());
aBspl->Knots(aKnots);
NCollection_Array1<double> aKnots(aBspl->Knots());
BSplCLib::Reparametrize(theFirst, theLast, aKnots);
aBspl->SetKnots(aKnots);
}