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
@@ -2152,16 +2152,13 @@ void ComputeGridPoints(const BRepAdaptor_Surface& theSurf,
const double theTolerance,
IntTools_SurfaceRangeLocalizeData& theSurfaceData)
{
int i;
int j;
int k;
int aNbSamples[2] = {theSurf.UDegree(), theSurf.VDegree()};
int aNbKnots[2] = {theSurf.NbUKnots(), theSurf.NbVKnots()};
NCollection_Array1<double> aKnotsU(1, aNbKnots[0]);
NCollection_Array1<double> aKnotsV(1, aNbKnots[1]);
theBsplSurf->UKnots(aKnotsU);
theBsplSurf->VKnots(aKnotsV);
int i;
int j;
int k;
int aNbSamples[2] = {theSurf.UDegree(), theSurf.VDegree()};
int aNbKnots[2] = {theSurf.NbUKnots(), theSurf.NbVKnots()};
const NCollection_Array1<double>& aKnotsU = theBsplSurf->UKnots();
const NCollection_Array1<double>& aKnotsV = theBsplSurf->VKnots();
int iLmI;
int iMin[2] = {-1, -1};
@@ -275,8 +275,7 @@ void IntTools_TopolTool::ComputeSamplePoints()
if (nbsu > 10 || nbsv > 10)
{
NCollection_Array2<gp_Pnt> array2(1, myS->NbUPoles(), 1, myS->NbVPoles());
myS->Bezier()->Poles(array2);
const NCollection_Array2<gp_Pnt>& array2 = myS->Bezier()->Poles();
Analyse(array2, nbsu, nbsv);
}
@@ -298,8 +297,7 @@ void IntTools_TopolTool::ComputeSamplePoints()
if (nbsu > 10 || nbsv > 10)
{
NCollection_Array2<gp_Pnt> array2(1, myS->NbUPoles(), 1, myS->NbVPoles());
myS->BSpline()->Poles(array2);
const NCollection_Array2<gp_Pnt>& array2 = myS->BSpline()->Poles();
Analyse(array2, nbsu, nbsv);
}
if (nbsu < 10)
@@ -109,8 +109,7 @@ static occ::handle<Geom_BSplineCurve> EdgeToBSpline(const TopoDS_Edge& theEdge)
aBSCurve->Transform(aLoc.Transformation());
// reparameterize to [0,1]
NCollection_Array1<double> aKnots(1, aBSCurve->NbKnots());
aBSCurve->Knots(aKnots);
NCollection_Array1<double> aKnots(aBSCurve->Knots());
BSplCLib::Reparametrize(0., 1., aKnots);
aBSCurve->SetKnots(aKnots);
}
@@ -1285,9 +1285,8 @@ bool SameSupport(const TopoDS_Edge& E1, const TopoDS_Edge& E2)
return false;
}
NCollection_Array1<gp_Pnt> P1(1, nbpoles), P2(1, nbpoles);
B1->Poles(P1);
B2->Poles(P2);
const NCollection_Array1<gp_Pnt>& P1 = B1->Poles();
const NCollection_Array1<gp_Pnt>& P2 = B2->Poles();
double tol3d = BRep_Tool::Tolerance(E1);
for (int p = 1; p <= nbpoles; p++)
@@ -1298,13 +1297,11 @@ bool SameSupport(const TopoDS_Edge& E1, const TopoDS_Edge& E2)
}
}
NCollection_Array1<double> K1(1, nbknots), K2(1, nbknots);
B1->Knots(K1);
B2->Knots(K2);
const NCollection_Array1<double>& K1 = B1->Knots();
const NCollection_Array1<double>& K2 = B2->Knots();
NCollection_Array1<int> M1(1, nbknots), M2(1, nbknots);
B1->Multiplicities(M1);
B2->Multiplicities(M2);
const NCollection_Array1<int>& M1 = B1->Multiplicities();
const NCollection_Array1<int>& M2 = B2->Multiplicities();
for (int k = 1; k <= nbknots; k++)
{
@@ -1335,9 +1332,8 @@ bool SameSupport(const TopoDS_Edge& E1, const TopoDS_Edge& E2)
if (B1->IsRational())
{
NCollection_Array1<double> W1(1, nbpoles), W2(1, nbpoles);
B1->Weights(W1);
B2->Weights(W2);
const NCollection_Array1<double>& W1 = B1->WeightsArray();
const NCollection_Array1<double>& W2 = B2->WeightsArray();
for (int w = 1; w <= nbpoles; w++)
{
@@ -1360,9 +1356,8 @@ bool SameSupport(const TopoDS_Edge& E1, const TopoDS_Edge& E2)
return false;
}
NCollection_Array1<gp_Pnt> P1(1, nbpoles), P2(1, nbpoles);
B1->Poles(P1);
B2->Poles(P2);
const NCollection_Array1<gp_Pnt>& P1 = B1->Poles();
const NCollection_Array1<gp_Pnt>& P2 = B2->Poles();
for (int p = 1; p <= nbpoles; p++)
{
@@ -1389,9 +1384,8 @@ bool SameSupport(const TopoDS_Edge& E1, const TopoDS_Edge& E2)
if (B1->IsRational())
{
NCollection_Array1<double> W1(1, nbpoles), W2(1, nbpoles);
B1->Weights(W1);
B2->Weights(W2);
const NCollection_Array1<double>& W1 = B1->WeightsArray();
const NCollection_Array1<double>& W2 = B2->WeightsArray();
for (int w = 1; w <= nbpoles; w++)
{
@@ -344,20 +344,16 @@ bool TopOpeBRepTool_CurveTool::MakeCurves(const double parmi
// std::cout <<"nbpol = " << nbpol << std::endl;
if (nbpol > 100)
{
NCollection_Array1<gp_Pnt> PolC3D(1, nbpol);
NCollection_Array1<gp_Pnt2d> PolPC1(1, nbpol);
NCollection_Array1<gp_Pnt2d> PolPC2(1, nbpol);
NCollection_Array1<bool> IsValid(1, nbpol);
const NCollection_Array1<gp_Pnt>& PolC3D = HC3D->Poles();
NCollection_Array1<gp_Pnt2d> aDummyPnt2d;
const NCollection_Array1<gp_Pnt2d>& PolPC1 = CompPC1 ? HPC1->Poles() : aDummyPnt2d;
const NCollection_Array1<gp_Pnt2d>& PolPC2 = CompPC2 ? HPC2->Poles() : aDummyPnt2d;
NCollection_Array1<bool> IsValid(1, nbpol);
IsValid.Init(true);
double tol = std::max(1.e-10, 100. * tol3d * tol3d); // tol *= tol; - square distance
double tl2d = tol * (tol2d * tol2d) / (tol3d * tol3d);
double def = tol;
double def2d = tol2d;
HC3D->Poles(PolC3D);
if (CompPC1)
HPC1->Poles(PolPC1);
if (CompPC2)
HPC2->Poles(PolPC2);
int ip = 1, NbPol = 1;
double d, d1, d2;
@@ -529,11 +525,10 @@ bool TopOpeBRepTool_CurveTool::MakeCurves(const double parmi
int degmax = 8;
Approx_ParametrizationType parametrization = Approx_ChordLength;
int npol = HC3D->NbPoles();
NCollection_Array1<gp_Pnt> Polc3d(1, npol);
NCollection_Array1<double> par(1, npol);
HC3D->Poles(Polc3d);
gp_Pnt P = Polc3d(1);
int npol = HC3D->NbPoles();
const NCollection_Array1<gp_Pnt>& Polc3d = HC3D->Poles();
NCollection_Array1<double> par(1, npol);
gp_Pnt P = Polc3d(1);
bool IsBad = false;
int ip;
@@ -745,9 +745,8 @@ bool TopOpeBRepTool_FuseEdges::SameSupport(const TopoDS_Edge& E1, const TopoDS_E
return false;
}
NCollection_Array1<gp_Pnt> P1(1, nbpoles), P2(1, nbpoles);
B1->Poles(P1);
B2->Poles(P2);
const NCollection_Array1<gp_Pnt>& P1 = B1->Poles();
const NCollection_Array1<gp_Pnt>& P2 = B2->Poles();
double tol3d = BRep_Tool::Tolerance(E1);
for (int p = 1; p <= nbpoles; p++)
@@ -758,13 +757,11 @@ bool TopOpeBRepTool_FuseEdges::SameSupport(const TopoDS_Edge& E1, const TopoDS_E
}
}
NCollection_Array1<double> K1(1, nbknots), K2(1, nbknots);
B1->Knots(K1);
B2->Knots(K2);
const NCollection_Array1<double>& K1 = B1->Knots();
const NCollection_Array1<double>& K2 = B2->Knots();
NCollection_Array1<int> M1(1, nbknots), M2(1, nbknots);
B1->Multiplicities(M1);
B2->Multiplicities(M2);
const NCollection_Array1<int>& M1 = B1->Multiplicities();
const NCollection_Array1<int>& M2 = B2->Multiplicities();
for (int k = 1; k <= nbknots; k++)
{
@@ -795,9 +792,8 @@ bool TopOpeBRepTool_FuseEdges::SameSupport(const TopoDS_Edge& E1, const TopoDS_E
if (B1->IsRational())
{
NCollection_Array1<double> W1(1, nbpoles), W2(1, nbpoles);
B1->Weights(W1);
B2->Weights(W2);
const NCollection_Array1<double>& W1 = B1->WeightsArray();
const NCollection_Array1<double>& W2 = B2->WeightsArray();
for (int w = 1; w <= nbpoles; w++)
{
@@ -828,9 +824,8 @@ bool TopOpeBRepTool_FuseEdges::SameSupport(const TopoDS_Edge& E1, const TopoDS_E
return false;
}
NCollection_Array1<gp_Pnt> P1(1, nbpoles), P2(1, nbpoles);
B1->Poles(P1);
B2->Poles(P2);
const NCollection_Array1<gp_Pnt>& P1 = B1->Poles();
const NCollection_Array1<gp_Pnt>& P2 = B2->Poles();
for (int p = 1; p <= nbpoles; p++)
{
@@ -857,9 +852,8 @@ bool TopOpeBRepTool_FuseEdges::SameSupport(const TopoDS_Edge& E1, const TopoDS_E
if (B1->IsRational())
{
NCollection_Array1<double> W1(1, nbpoles), W2(1, nbpoles);
B1->Weights(W1);
B2->Weights(W2);
const NCollection_Array1<double>& W1 = B1->WeightsArray();
const NCollection_Array1<double>& W2 = B2->WeightsArray();
for (int w = 1; w <= nbpoles; w++)
{
@@ -980,8 +974,7 @@ bool TopOpeBRepTool_FuseEdges::UpdatePCurve(const TopoDS_Edge&
|| std::abs(last - el) > Precision::PConfusion())
{
occ::handle<Geom2d_BSplineCurve> bc = occ::down_cast<Geom2d_BSplineCurve>(Curv2d);
NCollection_Array1<double> Knots(1, bc->NbKnots());
bc->Knots(Knots);
NCollection_Array1<double> Knots(bc->Knots());
BSplCLib::Reparametrize(ef, el, Knots);
bc->SetKnots(Knots);
}
@@ -253,9 +253,8 @@ void LocOpe_FindEdges::Set(const TopoDS_Shape& FFrom, const TopoDS_Shape& FTo)
if (IsSame)
{
NCollection_Array1<gp_Pnt> Pf(1, nbpoles), Pt(1, nbpoles);
Bf->Poles(Pf);
Bt->Poles(Pt);
const NCollection_Array1<gp_Pnt>& Pf = Bf->Poles();
const NCollection_Array1<gp_Pnt>& Pt = Bt->Poles();
double tol3d = BRep_Tool::Tolerance(edgt);
for (int p = 1; p <= nbpoles; p++)
@@ -269,13 +268,11 @@ void LocOpe_FindEdges::Set(const TopoDS_Shape& FFrom, const TopoDS_Shape& FTo)
if (IsSame)
{
NCollection_Array1<double> Kf(1, nbknots), Kt(1, nbknots);
Bf->Knots(Kf);
Bt->Knots(Kt);
const NCollection_Array1<double>& Kf = Bf->Knots();
const NCollection_Array1<double>& Kt = Bt->Knots();
NCollection_Array1<int> Mf(1, nbknots), Mt(1, nbknots);
Bf->Multiplicities(Mf);
Bt->Multiplicities(Mt);
const NCollection_Array1<int>& Mf = Bf->Multiplicities();
const NCollection_Array1<int>& Mt = Bt->Multiplicities();
for (int k = 1; k <= nbknots; k++)
{
@@ -308,9 +305,8 @@ void LocOpe_FindEdges::Set(const TopoDS_Shape& FFrom, const TopoDS_Shape& FTo)
if (IsSame && Bf->IsRational())
{
NCollection_Array1<double> Wf(1, nbpoles), Wt(1, nbpoles);
Bf->Weights(Wf);
Bt->Weights(Wt);
const NCollection_Array1<double>& Wf = Bf->WeightsArray();
const NCollection_Array1<double>& Wt = Bt->WeightsArray();
for (int w = 1; w <= nbpoles; w++)
{
@@ -350,9 +346,8 @@ void LocOpe_FindEdges::Set(const TopoDS_Shape& FFrom, const TopoDS_Shape& FTo)
if (IsSame)
{
NCollection_Array1<gp_Pnt> Pf(1, nbpoles), Pt(1, nbpoles);
Bf->Poles(Pf);
Bt->Poles(Pt);
const NCollection_Array1<gp_Pnt>& Pf = Bf->Poles();
const NCollection_Array1<gp_Pnt>& Pt = Bt->Poles();
for (int p = 1; p <= nbpoles; p++)
{
@@ -382,9 +377,8 @@ void LocOpe_FindEdges::Set(const TopoDS_Shape& FFrom, const TopoDS_Shape& FTo)
if (IsSame && Bf->IsRational())
{
NCollection_Array1<double> Wf(1, nbpoles), Wt(1, nbpoles);
Bf->Weights(Wf);
Bt->Weights(Wt);
const NCollection_Array1<double>& Wf = Bf->WeightsArray();
const NCollection_Array1<double>& Wt = Bt->WeightsArray();
for (int w = 1; w <= nbpoles; w++)
{
@@ -358,9 +358,7 @@ const NCollection_Sequence<occ::handle<Geom_Curve>>& LocOpe_Pipe::Curves(
{
C->Segment(p1, p2);
}
int Nbkn = C->NbKnots();
NCollection_Array1<double> Tkn(1, Nbkn);
C->Knots(Tkn);
NCollection_Array1<double> Tkn(C->Knots());
BSplCLib::Reparametrize(seq.Length(), seq.Length() + 1, Tkn);
C->SetKnots(Tkn);
seq.Append(C);
@@ -487,9 +485,7 @@ occ::handle<Geom_Curve> LocOpe_Pipe::BarycCurve()
{
C->Segment(p1, p2);
}
int Nbkn = C->NbKnots();
NCollection_Array1<double> Tkn(1, Nbkn);
C->Knots(Tkn);
NCollection_Array1<double> Tkn(C->Knots());
BSplCLib::Reparametrize(seq.Length(), seq.Length() + 1, Tkn);
C->SetKnots(Tkn);
seq.Append(C);
@@ -113,15 +113,13 @@ void BlendFunc::GetMinimalWeights(const BlendFunc_SectionShape SShape,
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);
CtoBspl = GeomConvert::CurveToBSplineCurve(Sect2, TConv);
const NCollection_Array1<double>& poids = CtoBspl->WeightsArray();
for (int ii = Weights.Lower(); ii <= Weights.Upper(); ii++)
{
@@ -1325,13 +1325,10 @@ void ChFi3d_ReparamPcurv(const double Uf, const double Ul, occ::handle<Geom2d_Cu
if (std::abs(Uf - pc->FirstParameter()) > Precision::PConfusion()
|| std::abs(Ul - pc->LastParameter()) > Precision::PConfusion())
{
NCollection_Array1<gp_Pnt2d> pol(1, pc->NbPoles());
pc->Poles(pol);
NCollection_Array1<double> kn(1, pc->NbKnots());
pc->Knots(kn);
NCollection_Array1<int> mu(1, pc->NbKnots());
pc->Multiplicities(mu);
int deg = pc->Degree();
const NCollection_Array1<gp_Pnt2d>& pol = pc->Poles();
NCollection_Array1<double> kn(pc->Knots());
const NCollection_Array1<int>& mu = pc->Multiplicities();
int deg = pc->Degree();
BSplCLib::Reparametrize(Uf, Ul, kn);
pc = new Geom2d_BSplineCurve(pol, kn, mu, deg);
}
@@ -4736,8 +4733,7 @@ Standard_EXPORT void ChFi3d_PerformElSpine(occ::handle<ChFiDS_ElSpine>& HES,
// valide des aretes du chemin.
BSpline = Concat.BSplineCurve();
// There is a reparametrisation to maximally connect the abscissas of edges.
NCollection_Array1<double> BSNoeuds(1, BSpline->NbKnots());
BSpline->Knots(BSNoeuds);
NCollection_Array1<double> BSNoeuds(BSpline->Knots());
BSplCLib::Reparametrize(Wrefdeb, Wreffin, BSNoeuds);
BSpline->SetKnots(BSNoeuds);
//
@@ -286,8 +286,7 @@ static TopoDS_Edge MakeOffsetEdge(const TopoDS_Edge& theEdge,
std::abs(LastDiff) > ParTol)
{
occ::handle<Geom_BSplineCurve> BsplCurve = occ::down_cast<Geom_BSplineCurve>(IntCurve);
NCollection_Array1<double> aKnots(1, BsplCurve->NbKnots());
BsplCurve->Knots(aKnots);
NCollection_Array1<double> aKnots(BsplCurve->Knots());
BSplCLib::Reparametrize(aBAcurve.FirstParameter(), aBAcurve.LastParameter(), aKnots);
BsplCurve->SetKnots(aKnots);
if (aBAcurve.IsPeriodic() && !BsplCurve->IsPeriodic())
@@ -616,8 +616,7 @@ void ChFi3d_FilBuilder::PerformTwoCorner(const int Index)
std::max(parCP1, parCP2),
tol2d);
}
NCollection_Array1<double> kk(1, PCurveOnPiv->NbKnots());
PCurveOnPiv->Knots(kk);
NCollection_Array1<double> kk(PCurveOnPiv->Knots());
BSplCLib::Reparametrize(0., 1., kk);
PCurveOnPiv->SetKnots(kk);
if (pcfalenvers)
@@ -90,40 +90,30 @@ void ChFiKPart_ProjPC(const GeomAdaptor_Curve& Cg,
}
break;
case GeomAbs_BezierCurve: {
occ::handle<Geom2d_BezierCurve> BezProjc = Projc.Bezier();
NCollection_Array1<gp_Pnt2d> TP(1, BezProjc->NbPoles());
occ::handle<Geom2d_BezierCurve> BezProjc = Projc.Bezier();
const NCollection_Array1<gp_Pnt2d>& TP = BezProjc->Poles();
if (BezProjc->IsRational())
{
NCollection_Array1<double> TW(1, BezProjc->NbPoles());
BezProjc->Poles(TP);
BezProjc->Weights(TW);
Pcurv = new Geom2d_BezierCurve(TP, TW);
Pcurv = new Geom2d_BezierCurve(TP, BezProjc->WeightsArray());
}
else
{
BezProjc->Poles(TP);
Pcurv = new Geom2d_BezierCurve(TP);
}
}
break;
case GeomAbs_BSplineCurve: {
occ::handle<Geom2d_BSplineCurve> BspProjc = Projc.BSpline();
NCollection_Array1<gp_Pnt2d> TP(1, BspProjc->NbPoles());
NCollection_Array1<double> TK(1, BspProjc->NbKnots());
NCollection_Array1<int> TM(1, BspProjc->NbKnots());
occ::handle<Geom2d_BSplineCurve> BspProjc = Projc.BSpline();
const NCollection_Array1<gp_Pnt2d>& TP = BspProjc->Poles();
const NCollection_Array1<double>& TK = BspProjc->Knots();
const NCollection_Array1<int>& TM = BspProjc->Multiplicities();
BspProjc->Knots(TK);
BspProjc->Multiplicities(TM);
if (BspProjc->IsRational())
{
NCollection_Array1<double> TW(1, BspProjc->NbPoles());
BspProjc->Poles(TP);
BspProjc->Weights(TW);
Pcurv = new Geom2d_BSplineCurve(TP, TW, TK, TM, BspProjc->Degree());
Pcurv = new Geom2d_BSplineCurve(TP, BspProjc->WeightsArray(), TK, TM, BspProjc->Degree());
}
else
{
BspProjc->Poles(TP);
Pcurv = new Geom2d_BSplineCurve(TP, TK, TM, BspProjc->Degree());
}
}
@@ -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);
}
@@ -97,11 +97,8 @@ TopoDS_Edge HLRBRep::MakeEdge(const HLRBRep_Curve& ec, const double U1, const do
{
theCurve->Segment(sta, end);
NCollection_Array1<gp_Pnt2d> Poles(1, theCurve->NbPoles());
NCollection_Array1<double> knots(1, theCurve->NbKnots());
NCollection_Array1<int> mults(1, theCurve->NbKnots());
//-- ec.KnotsAndMultiplicities(knots,mults);
theCurve->Knots(knots);
theCurve->Multiplicities(mults);
NCollection_Array1<double> knots(theCurve->Knots());
NCollection_Array1<int> mults(theCurve->Multiplicities());
if (theCurve->IsRational())
{
NCollection_Array1<double> Weights(1, theCurve->NbPoles());
@@ -51,9 +51,19 @@ int HLRBRep_BCurveTool::NbSamples(const BRepAdaptor_Curve& C, const double U0, c
void HLRBRep_BCurveTool::Poles(const BRepAdaptor_Curve& C, NCollection_Array1<gp_Pnt>& T)
{
if (C.GetType() == GeomAbs_BezierCurve)
C.Bezier()->Poles(T);
{
occ::handle<Geom_BezierCurve> aBez = C.Bezier();
const NCollection_Array1<gp_Pnt>& aSrcPoles = aBez->Poles();
for (int i = T.Lower(); i <= T.Upper(); i++)
T(i) = aSrcPoles(i);
}
else if (C.GetType() == GeomAbs_BSplineCurve)
C.BSpline()->Poles(T);
{
occ::handle<Geom_BSplineCurve> aBSpl = C.BSpline();
const NCollection_Array1<gp_Pnt>& aSrcPoles = aBSpl->Poles();
for (int i = T.Lower(); i <= T.Upper(); i++)
T(i) = aSrcPoles(i);
}
}
//=================================================================================================
@@ -64,15 +74,23 @@ void HLRBRep_BCurveTool::PolesAndWeights(const BRepAdaptor_Curve& C,
{
if (C.GetType() == GeomAbs_BezierCurve)
{
const occ::handle<Geom_BezierCurve> HB = C.Bezier();
HB->Poles(T);
HB->Weights(W);
const occ::handle<Geom_BezierCurve> HB = C.Bezier();
const NCollection_Array1<gp_Pnt>& aSrcPoles = HB->Poles();
const NCollection_Array1<double>& aSrcWeights = HB->WeightsArray();
for (int i = T.Lower(); i <= T.Upper(); i++)
T(i) = aSrcPoles(i);
for (int i = W.Lower(); i <= W.Upper(); i++)
W(i) = aSrcWeights(i);
}
else if (C.GetType() == GeomAbs_BSplineCurve)
{
const occ::handle<Geom_BSplineCurve> HB = C.BSpline();
HB->Poles(T);
HB->Weights(W);
const occ::handle<Geom_BSplineCurve> HB = C.BSpline();
const NCollection_Array1<gp_Pnt>& aSrcPoles = HB->Poles();
const NCollection_Array1<double>& aSrcWeights = HB->WeightsArray();
for (int i = T.Lower(); i <= T.Upper(); i++)
T(i) = aSrcPoles(i);
for (int i = W.Lower(); i <= W.Upper(); i++)
W(i) = aSrcWeights(i);
}
}
@@ -468,11 +468,17 @@ void HLRBRep_Curve::Poles(NCollection_Array1<gp_Pnt2d>& TP) const
//-- HLRBRep_BCurveTool::Poles(myCurve,TP3);
if (HLRBRep_BCurveTool::GetType(myCurve) == GeomAbs_BSplineCurve)
{
(HLRBRep_BCurveTool::BSpline(myCurve))->Poles(TP3);
occ::handle<Geom_BSplineCurve> aBSpl = HLRBRep_BCurveTool::BSpline(myCurve);
const NCollection_Array1<gp_Pnt>& aSrcPoles = aBSpl->Poles();
for (int i = i1; i <= i2; i++)
TP3(i) = aSrcPoles(i);
}
else
{
(HLRBRep_BCurveTool::Bezier(myCurve))->Poles(TP3);
occ::handle<Geom_BezierCurve> aBez = HLRBRep_BCurveTool::Bezier(myCurve);
const NCollection_Array1<gp_Pnt>& aSrcPoles = aBez->Poles();
for (int i = i1; i <= i2; i++)
TP3(i) = aSrcPoles(i);
}
for (int i = i1; i <= i2; i++)
{
@@ -490,7 +496,9 @@ void HLRBRep_Curve::Poles(const occ::handle<Geom_BSplineCurve>& aCurve,
int i2 = TP.Upper();
NCollection_Array1<gp_Pnt> TP3(i1, i2);
//-- HLRBRep_BCurveTool::Poles(myCurve,TP3);
aCurve->Poles(TP3);
const NCollection_Array1<gp_Pnt>& aSrcPoles = aCurve->Poles();
for (int i = i1; i <= i2; i++)
TP3(i) = aSrcPoles(i);
for (int i = i1; i <= i2; i++)
{
@@ -511,17 +519,23 @@ void HLRBRep_Curve::PolesAndWeights(NCollection_Array1<gp_Pnt2d>& TP,
if (HLRBRep_BCurveTool::GetType(myCurve) == GeomAbs_BSplineCurve)
{
occ::handle<Geom_BSplineCurve> HB = (HLRBRep_BCurveTool::BSpline(myCurve));
HB->Poles(TP3);
HB->Weights(TW);
//-- (HLRBRep_BCurveTool::BSpline(myCurve))->PolesAndWeights(TP3,TW);
occ::handle<Geom_BSplineCurve> HB = (HLRBRep_BCurveTool::BSpline(myCurve));
const NCollection_Array1<gp_Pnt>& aSrcPoles = HB->Poles();
const NCollection_Array1<double>& aSrcWeights = HB->WeightsArray();
for (int i = i1; i <= i2; i++)
TP3(i) = aSrcPoles(i);
for (int i = i1; i <= i2; i++)
TW(i) = aSrcWeights(i);
}
else
{
occ::handle<Geom_BezierCurve> HB = (HLRBRep_BCurveTool::Bezier(myCurve));
HB->Poles(TP3);
HB->Weights(TW);
//-- (HLRBRep_BCurveTool::Bezier(myCurve))->PolesAndWeights(TP3,TW);
occ::handle<Geom_BezierCurve> HB = (HLRBRep_BCurveTool::Bezier(myCurve));
const NCollection_Array1<gp_Pnt>& aSrcPoles = HB->Poles();
const NCollection_Array1<double>& aSrcWeights = HB->WeightsArray();
for (int i = i1; i <= i2; i++)
TP3(i) = aSrcPoles(i);
for (int i = i1; i <= i2; i++)
TW(i) = aSrcWeights(i);
}
for (int i = i1; i <= i2; i++)
{
@@ -541,9 +555,12 @@ void HLRBRep_Curve::PolesAndWeights(const occ::handle<Geom_BSplineCurve>& aCurve
NCollection_Array1<gp_Pnt> TP3(i1, i2);
//-- HLRBRep_BCurveTool::PolesAndWeights(myCurve,TP3,TW);
aCurve->Poles(TP3);
aCurve->Weights(TW);
//-- (HLRBRep_BCurveTool::BSpline(myCurve))->PolesAndWeights(TP3,TW);
const NCollection_Array1<gp_Pnt>& aSrcPoles = aCurve->Poles();
const NCollection_Array1<double>& aSrcWeights = aCurve->WeightsArray();
for (int i = i1; i <= i2; i++)
TP3(i) = aSrcPoles(i);
for (int i = i1; i <= i2; i++)
TW(i) = aSrcWeights(i);
for (int i = i1; i <= i2; i++)
{
@@ -558,8 +575,10 @@ void HLRBRep_Curve::Knots(NCollection_Array1<double>& kn) const
{
if (HLRBRep_BCurveTool::GetType(myCurve) == GeomAbs_BSplineCurve)
{
occ::handle<Geom_BSplineCurve> HB = (HLRBRep_BCurveTool::BSpline(myCurve));
HB->Knots(kn);
occ::handle<Geom_BSplineCurve> aBSpl = HLRBRep_BCurveTool::BSpline(myCurve);
const NCollection_Array1<double>& aSrcKnots = aBSpl->Knots();
for (int i = kn.Lower(); i <= kn.Upper(); i++)
kn(i) = aSrcKnots(i);
}
}
@@ -569,7 +588,9 @@ void HLRBRep_Curve::Multiplicities(NCollection_Array1<int>& mu) const
{
if (HLRBRep_BCurveTool::GetType(myCurve) == GeomAbs_BSplineCurve)
{
occ::handle<Geom_BSplineCurve> HB = (HLRBRep_BCurveTool::BSpline(myCurve));
HB->Multiplicities(mu);
occ::handle<Geom_BSplineCurve> aBSpl = HLRBRep_BCurveTool::BSpline(myCurve);
const NCollection_Array1<int>& aSrcMults = aBSpl->Multiplicities();
for (int i = mu.Lower(); i <= mu.Upper(); i++)
mu(i) = aSrcMults(i);
}
}
@@ -183,22 +183,26 @@ bool HLRBRep_Surface::IsSide(const double tolF, const double toler) const
{
if (myProj->Perspective())
return false;
int nu = HLRBRep_BSurfaceTool::NbUPoles(mySurf);
int nv = HLRBRep_BSurfaceTool::NbVPoles(mySurf);
NCollection_Array2<gp_Pnt> Pnt(1, nu, 1, nv);
HLRBRep_BSurfaceTool::Bezier(mySurf)->Poles(Pnt);
int nu = HLRBRep_BSurfaceTool::NbUPoles(mySurf);
int nv = HLRBRep_BSurfaceTool::NbVPoles(mySurf);
NCollection_Array2<gp_Pnt> Pnt(1, nu, 1, nv);
const NCollection_Array2<gp_Pnt>& aSrcPoles = HLRBRep_BSurfaceTool::Bezier(mySurf)->Poles();
for (int iu = 1; iu <= nu; iu++)
for (int iv = 1; iv <= nv; iv++)
Pnt(iu, iv) = aSrcPoles(iu, iv);
return SideRowsOfPoles(tolF, nu, nv, Pnt);
}
else if (myType == GeomAbs_BSplineSurface)
{
if (myProj->Perspective())
return false;
int nu = HLRBRep_BSurfaceTool::NbUPoles(mySurf);
int nv = HLRBRep_BSurfaceTool::NbVPoles(mySurf);
NCollection_Array2<gp_Pnt> Pnt(1, nu, 1, nv);
NCollection_Array2<double> W(1, nu, 1, nv);
HLRBRep_BSurfaceTool::BSpline(mySurf)->Poles(Pnt);
HLRBRep_BSurfaceTool::BSpline(mySurf)->Weights(W);
int nu = HLRBRep_BSurfaceTool::NbUPoles(mySurf);
int nv = HLRBRep_BSurfaceTool::NbVPoles(mySurf);
NCollection_Array2<gp_Pnt> Pnt(1, nu, 1, nv);
const NCollection_Array2<gp_Pnt>& aSrcPoles = HLRBRep_BSurfaceTool::BSpline(mySurf)->Poles();
for (int iu = 1; iu <= nu; iu++)
for (int iv = 1; iv <= nv; iv++)
Pnt(iu, iv) = aSrcPoles(iu, iv);
return SideRowsOfPoles(tolF, nu, nv, Pnt);
}
else
@@ -1043,9 +1043,8 @@ static bool ExtendPCurve(const occ::handle<Geom2d_Curve>& aPCurve,
occ::handle<Geom2d_BezierCurve> aBezier = occ::down_cast<Geom2d_BezierCurve>(NewPCurve);
if (aBezier->NbPoles() == 2)
{
NCollection_Array1<gp_Pnt2d> thePoles(1, 2);
aBezier->Poles(thePoles);
gp_Vec2d aVec(thePoles(1), thePoles(2));
const NCollection_Array1<gp_Pnt2d>& thePoles = aBezier->Poles();
gp_Vec2d aVec(thePoles(1), thePoles(2));
NewPCurve = new Geom2d_Line(thePoles(1), aVec);
return true;
}
@@ -1055,9 +1054,8 @@ static bool ExtendPCurve(const occ::handle<Geom2d_Curve>& aPCurve,
occ::handle<Geom2d_BSplineCurve> aBSpline = occ::down_cast<Geom2d_BSplineCurve>(NewPCurve);
if (aBSpline->NbKnots() == 2 && aBSpline->NbPoles() == 2)
{
NCollection_Array1<gp_Pnt2d> thePoles(1, 2);
aBSpline->Poles(thePoles);
gp_Vec2d aVec(thePoles(1), thePoles(2));
const NCollection_Array1<gp_Pnt2d>& thePoles = aBSpline->Poles();
gp_Vec2d aVec(thePoles(1), thePoles(2));
NewPCurve = new Geom2d_Line(thePoles(1), aVec);
return true;
}
@@ -1124,8 +1124,7 @@ static occ::handle<Geom_BSplineCurve> EdgeToBSpline(const TopoDS_Edge& theEdge)
aBSCurve->Transform(aLoc.Transformation());
// reparameterize to [0,1]
NCollection_Array1<double> aKnots(1, aBSCurve->NbKnots());
aBSCurve->Knots(aKnots);
NCollection_Array1<double> aKnots(aBSCurve->Knots());
BSplCLib::Reparametrize(0., 1., aKnots);
aBSCurve->SetKnots(aKnots);
}
@@ -132,20 +132,12 @@ void ShapeAlgo_AlgoContainer::ApproxBSplineCurve(
// on detecte d`eventuelles cassures par la multiplicite des poles.
// Puis on approxime chaque "partie" de BSpline
int NbKnots = bspline->NbKnots();
int NbPoles = bspline->NbPoles();
NCollection_Array1<gp_Pnt> Poles(1, NbPoles);
NCollection_Array1<double> Weigs(1, NbPoles);
Weigs.Init(1.);
NCollection_Array1<double> Knots(1, NbKnots);
NCollection_Array1<int> Mults(1, NbKnots);
bspline->Poles(Poles);
if (bspline->IsRational())
bspline->Weights(Weigs);
bspline->Knots(Knots);
bspline->Multiplicities(Mults);
int deg = bspline->Degree();
int NbPoles = bspline->NbPoles();
const NCollection_Array1<gp_Pnt>& Poles = bspline->Poles();
const NCollection_Array1<double>& Weigs = bspline->WeightsArray();
const NCollection_Array1<double>& Knots = bspline->Knots();
const NCollection_Array1<int>& Mults = bspline->Multiplicities();
int deg = bspline->Degree();
int jpole = 1;
int j, PoleIndex, I1;
@@ -163,7 +155,7 @@ void ShapeAlgo_AlgoContainer::ApproxBSplineCurve(
{
NCollection_Array1<gp_Pnt> newPoles(1, jpole);
NCollection_Array1<double> newWeigs(1, jpole);
Weigs.Init(1.);
newWeigs.Init(1.);
int NbNew = jpole - deg + 1;
NCollection_Array1<double> newKnots(1, NbNew);
NCollection_Array1<int> newMults(1, NbNew);
@@ -206,10 +198,9 @@ void ShapeAlgo_AlgoContainer::ApproxBSplineCurve(
jpole = mycurve->NbPoles();
if (jpole > 2)
{
NCollection_Array1<gp_Pnt> newP(1, jpole);
mycurve->Poles(newP);
occ::handle<IntSurf_LineOn2S> R = new IntSurf_LineOn2S();
double u1, v1, u2, v2;
const NCollection_Array1<gp_Pnt>& newP = mycurve->Poles();
occ::handle<IntSurf_LineOn2S> R = new IntSurf_LineOn2S();
double u1, v1, u2, v2;
u1 = v1 = 0.;
u2 = v2 = 1.;
for (j = 1; j <= jpole; j++)
@@ -277,20 +268,12 @@ void ShapeAlgo_AlgoContainer::ApproxBSplineCurve(
// Puis on approxime chaque "partie" de BSpline et on reconstruit
// une BSpline = somme des BSplines traitees
int NbKnots = bspline->NbKnots();
int NbPoles = bspline->NbPoles();
NCollection_Array1<gp_Pnt2d> Poles(1, NbPoles);
NCollection_Array1<double> Weigs(1, NbPoles);
Weigs.Init(1.);
NCollection_Array1<double> Knots(1, NbKnots);
NCollection_Array1<int> Mults(1, NbKnots);
bspline->Poles(Poles);
if (bspline->IsRational())
bspline->Weights(Weigs);
bspline->Knots(Knots);
bspline->Multiplicities(Mults);
int deg = bspline->Degree();
int NbPoles = bspline->NbPoles();
const NCollection_Array1<gp_Pnt2d>& Poles = bspline->Poles();
const NCollection_Array1<double>& Weigs = bspline->WeightsArray();
const NCollection_Array1<double>& Knots = bspline->Knots();
const NCollection_Array1<int>& Mults = bspline->Multiplicities();
int deg = bspline->Degree();
int jpole = 1;
int j, PoleIndex, I1;
@@ -308,7 +291,7 @@ void ShapeAlgo_AlgoContainer::ApproxBSplineCurve(
{
NCollection_Array1<gp_Pnt2d> newPoles(1, jpole);
NCollection_Array1<double> newWeigs(1, jpole);
Weigs.Init(1.);
newWeigs.Init(1.);
int NbNew = jpole - deg + 1;
NCollection_Array1<double> newKnots(1, NbNew);
NCollection_Array1<int> newMults(1, NbNew);
@@ -351,11 +334,10 @@ void ShapeAlgo_AlgoContainer::ApproxBSplineCurve(
jpole = mycurve->NbPoles();
if (jpole > 10)
{
NCollection_Array1<gp_Pnt> P(1, jpole);
NCollection_Array1<gp_Pnt2d> newP(1, jpole);
mycurve->Poles(newP);
occ::handle<IntSurf_LineOn2S> R = new IntSurf_LineOn2S();
double u2, v2;
NCollection_Array1<gp_Pnt> P(1, jpole);
const NCollection_Array1<gp_Pnt2d>& newP = mycurve->Poles();
occ::handle<IntSurf_LineOn2S> R = new IntSurf_LineOn2S();
double u2, v2;
u2 = v2 = 1.;
for (j = 1; j <= jpole; j++)
{
@@ -750,11 +750,12 @@ bool ShapeAnalysis_CheckSmallFace::CheckPin(const TopoDS_Face& F, int& whatrow,
if (nbu == 0 || nbv == 0)
return false;
NCollection_Array2<gp_Pnt> allpoles(1, nbu, 1, nbv);
const NCollection_Array2<gp_Pnt>* allpolesPtr = nullptr;
if (!bs.IsNull())
bs->Poles(allpoles);
allpolesPtr = &bs->Poles();
if (!bz.IsNull())
bz->Poles(allpoles);
allpolesPtr = &bz->Poles();
const NCollection_Array2<gp_Pnt>& allpoles = *allpolesPtr;
// Check each natural bound if it is a singularity (i.e. a pin)
@@ -1007,21 +1007,16 @@ static void AppendControlPoles(NCollection_Sequence<gp_Pnt>& seq,
}
else if (curve->IsKind(STANDARD_TYPE(Geom_BSplineCurve)))
{
// DeclareAndCast(Geom_BSplineCurve, BSpline, curve);
occ::handle<Geom_BSplineCurve> BSpline = occ::down_cast<Geom_BSplineCurve>(curve);
NCollection_Array1<gp_Pnt> Poles(1, BSpline->NbPoles());
BSpline->Poles(Poles);
for (int i = 1; i <= BSpline->NbPoles(); i++)
occ::handle<Geom_BSplineCurve> BSpline = occ::down_cast<Geom_BSplineCurve>(curve);
const NCollection_Array1<gp_Pnt>& Poles = BSpline->Poles();
for (int i = 1; i <= Poles.Length(); i++)
seq.Append(Poles(i));
}
else if (curve->IsKind(STANDARD_TYPE(Geom_BezierCurve)))
{
// DeclareAndCast(Geom_BezierCurve, Bezier, curve);
// occ::handle<Geom_BezierCurve> Bezier = occ::down_cast<Geom_BezierCurve>(curve);
occ::handle<Geom_BezierCurve> Bezier = occ::down_cast<Geom_BezierCurve>(curve);
NCollection_Array1<gp_Pnt> Poles(1, Bezier->NbPoles());
Bezier->Poles(Poles);
for (int i = 1; i <= Bezier->NbPoles(); i++)
occ::handle<Geom_BezierCurve> Bezier = occ::down_cast<Geom_BezierCurve>(curve);
const NCollection_Array1<gp_Pnt>& Poles = Bezier->Poles();
for (int i = 1; i <= Poles.Length(); i++)
seq.Append(Poles(i));
}
}
@@ -1151,20 +1146,14 @@ bool ShapeAnalysis_Curve::IsPlanar(const occ::handle<Geom_Curve>& curve,
if (curve->IsKind(STANDARD_TYPE(Geom_BSplineCurve)))
{
// DeclareAndCast(Geom_BSplineCurve, BSpline, curve);
occ::handle<Geom_BSplineCurve> BSpline = occ::down_cast<Geom_BSplineCurve>(curve);
NCollection_Array1<gp_Pnt> Poles(1, BSpline->NbPoles());
BSpline->Poles(Poles);
return IsPlanar(Poles, Normal, precision);
return IsPlanar(BSpline->Poles(), Normal, precision);
}
if (curve->IsKind(STANDARD_TYPE(Geom_BezierCurve)))
{
// DeclareAndCast(Geom_BezierCurve, Bezier, curve);
occ::handle<Geom_BezierCurve> Bezier = occ::down_cast<Geom_BezierCurve>(curve);
NCollection_Array1<gp_Pnt> Poles(1, Bezier->NbPoles());
Bezier->Poles(Poles);
return IsPlanar(Poles, Normal, precision);
return IsPlanar(Bezier->Poles(), Normal, precision);
}
if (curve->IsKind(STANDARD_TYPE(ShapeExtend_ComplexCurve)))
@@ -186,17 +186,11 @@ occ::handle<Geom_BSplineSurface> ShapeConstruct::ConvertSurfaceToBSpline(
shiftF.SetTranslation(extr->Value(UF, 0), extr->Value(UF, VF));
shiftL.SetTranslation(extr->Value(UF, 0), extr->Value(UF, VL));
int nbPoles = bspl->NbPoles();
NCollection_Array1<gp_Pnt> poles(1, nbPoles);
NCollection_Array1<double> weights(1, nbPoles);
int nbKnots = bspl->NbKnots();
NCollection_Array1<double> knots(1, nbKnots);
NCollection_Array1<int> mults(1, nbKnots);
bspl->Poles(poles);
bspl->Knots(knots);
bspl->Multiplicities(mults);
bspl->Weights(weights);
int nbPoles = bspl->NbPoles();
const NCollection_Array1<gp_Pnt>& poles = bspl->Poles();
const NCollection_Array1<double>& weights = bspl->WeightsArray();
const NCollection_Array1<double>& knots = bspl->Knots();
const NCollection_Array1<int>& mults = bspl->Multiplicities();
NCollection_Array2<gp_Pnt> resPoles(1, nbPoles, 1, 2);
NCollection_Array2<double> resWeigth(1, nbPoles, 1, 2);
@@ -2082,22 +2082,18 @@ occ::handle<Geom2d_Curve> ShapeConstruct_ProjectCurveOnSurface::approximatePCurv
GeomAPI_PointsToBSpline appr(points3d, params, 1, 10, GeomAbs_C1, theTolerance2d);
const occ::handle<Geom_BSplineCurve>& crv3d = appr.Curve();
const int NbPoles = crv3d->NbPoles();
NCollection_Array1<gp_Pnt> poles3d(1, NbPoles);
NCollection_Array1<gp_Pnt2d> poles2d(1, NbPoles);
crv3d->Poles(poles3d);
const int NbPoles = crv3d->NbPoles();
const NCollection_Array1<gp_Pnt>& poles3d = crv3d->Poles();
NCollection_Array1<gp_Pnt2d> poles2d(1, NbPoles);
for (int i = 1; i <= NbPoles; i++)
{
poles2d(i).SetCoord(poles3d(i).X(), poles3d(i).Y());
}
NCollection_Array1<double> weights(1, NbPoles);
NCollection_Array1<int> multiplicities(1, crv3d->NbKnots());
NCollection_Array1<double> knots(1, crv3d->NbKnots());
crv3d->Knots(knots);
crv3d->Weights(weights);
crv3d->Multiplicities(multiplicities);
const NCollection_Array1<double>& weights = crv3d->WeightsArray();
const NCollection_Array1<double>& knots = crv3d->Knots();
const NCollection_Array1<int>& multiplicities = crv3d->Multiplicities();
aC2D = new Geom2d_BSplineCurve(poles2d,
weights,
@@ -436,18 +436,12 @@ static void ConvertExtrusion(const occ::handle<Geom_Curve>& C, /*const gp_Dir& d
const double VL,
occ::handle<Geom_Surface>& bspline)
{
occ::handle<Geom_BSplineCurve> bspl = occ::down_cast<Geom_BSplineCurve>(C);
int nbPoles = bspl->NbPoles();
NCollection_Array1<gp_Pnt> poles(1, nbPoles);
NCollection_Array1<double> weights(1, nbPoles);
int nbKnots = bspl->NbKnots();
NCollection_Array1<double> knots(1, nbKnots);
NCollection_Array1<int> mults(1, nbKnots);
bspl->Poles(poles);
bspl->Knots(knots);
bspl->Multiplicities(mults);
bspl->Weights(weights);
occ::handle<Geom_BSplineCurve> bspl = occ::down_cast<Geom_BSplineCurve>(C);
int nbPoles = bspl->NbPoles();
const NCollection_Array1<gp_Pnt>& poles = bspl->Poles();
const NCollection_Array1<double>& weights = bspl->WeightsArray();
const NCollection_Array1<double>& knots = bspl->Knots();
const NCollection_Array1<int>& mults = bspl->Multiplicities();
NCollection_Array2<gp_Pnt> resPoles(1, nbPoles, 1, 2);
NCollection_Array2<double> resWeigth(1, nbPoles, 1, 2);
@@ -639,16 +633,12 @@ bool ShapeCustom_BSplineRestriction::ConvertSurface(const occ::handle<Geom_Surfa
}
if (aSurf->IsKind(STANDARD_TYPE(Geom_BezierSurface)) && myParameters->ConvertBezierSurf())
{
occ::handle<Geom_BezierSurface> bezier = occ::down_cast<Geom_BezierSurface>(aSurf);
int nbUPoles = bezier->NbUPoles();
int nbVPoles = bezier->NbVPoles();
int uDegree = bezier->UDegree();
int vDegree = bezier->VDegree();
NCollection_Array2<gp_Pnt> aPoles(1, nbUPoles, 1, nbVPoles);
NCollection_Array2<double> aWeights(1, nbUPoles, 1, nbVPoles);
bezier->Poles(aPoles);
bezier->Weights(aWeights);
NCollection_Array1<double> uKnots(1, 2), vKnots(1, 2);
occ::handle<Geom_BezierSurface> bezier = occ::down_cast<Geom_BezierSurface>(aSurf);
int uDegree = bezier->UDegree();
int vDegree = bezier->VDegree();
const NCollection_Array2<gp_Pnt>& aPoles = bezier->Poles();
const NCollection_Array2<double>& aWeights = bezier->WeightsArray();
NCollection_Array1<double> uKnots(1, 2), vKnots(1, 2);
uKnots(1) = 0;
uKnots(2) = 1;
vKnots(1) = 0;
@@ -805,19 +795,15 @@ bool ShapeCustom_BSplineRestriction::ConvertSurface(const occ::handle<Geom_Surfa
mySurfaceError = std::max(mySurfaceError, anApprox.MaxError());
if (std::abs(ShiftU) > Precision::PConfusion())
{
int nb = Bsc->NbUKnots();
NCollection_Array1<double> uknots(1, nb);
Bsc->UKnots(uknots);
for (int j = 1; j <= nb; j++)
NCollection_Array1<double> uknots(Bsc->UKnots());
for (int j = 1; j <= uknots.Length(); j++)
uknots(j) += ShiftU;
Bsc->SetUKnots(uknots);
}
if (std::abs(ShiftV) > Precision::PConfusion())
{
int nb = Bsc->NbVKnots();
NCollection_Array1<double> vknots(1, nb);
Bsc->VKnots(vknots);
for (int j = 1; j <= nb; j++)
NCollection_Array1<double> vknots(Bsc->VKnots());
for (int j = 1; j <= vknots.Length(); j++)
vknots(j) += ShiftV;
Bsc->SetVKnots(vknots);
}
@@ -1043,10 +1029,8 @@ bool ShapeCustom_BSplineRestriction::ConvertCurve(const occ::handle<Geom_Curve>&
double Shift = First - aBSpline->FirstParameter();
if (std::abs(Shift) > Precision::PConfusion())
{
int nbKnots = aBSpline->NbKnots();
NCollection_Array1<double> newKnots(1, nbKnots);
aBSpline->Knots(newKnots);
for (int i = 1; i <= nbKnots; i++)
NCollection_Array1<double> newKnots(aBSpline->Knots());
for (int i = 1; i <= newKnots.Length(); i++)
newKnots(i) += Shift;
aBSpline->SetKnots(newKnots);
}
@@ -1417,10 +1401,8 @@ bool ShapeCustom_BSplineRestriction::ConvertCurve2d(const occ::handle<Geom2d_Cur
double Shift = First - aBSpline2d->FirstParameter();
if (std::abs(Shift) > Precision::PConfusion())
{
int nbKnots = aBSpline2d->NbKnots();
NCollection_Array1<double> newKnots(1, nbKnots);
aBSpline2d->Knots(newKnots);
for (int i = 1; i <= nbKnots; i++)
NCollection_Array1<double> newKnots(aBSpline2d->Knots());
for (int i = 1; i <= newKnots.Length(); i++)
newKnots(i) += Shift;
aBSpline2d->SetKnots(newKnots);
}
@@ -60,17 +60,11 @@ occ::handle<Geom_Curve> ShapeCustom_Curve::ConvertToPeriodic(const bool substi
if (BSpl->Multiplicity(1) == BSpl->Degree() + 1
&& BSpl->Multiplicity(BSpl->NbKnots()) == BSpl->Degree() + 1)
{
int nbPoles = BSpl->NbPoles();
NCollection_Array1<gp_Pnt> oldPoles(1, nbPoles);
NCollection_Array1<double> oldWeights(1, nbPoles);
int nbKnots = BSpl->NbKnots();
NCollection_Array1<double> oldKnots(1, nbKnots);
NCollection_Array1<int> oldMults(1, nbKnots);
BSpl->Poles(oldPoles);
BSpl->Weights(oldWeights);
BSpl->Knots(oldKnots);
BSpl->Multiplicities(oldMults);
const NCollection_Array1<gp_Pnt>& oldPoles = BSpl->Poles();
const NCollection_Array1<double>& oldWeights = BSpl->WeightsArray();
int nbKnots = BSpl->NbKnots();
const NCollection_Array1<double>& oldKnots = BSpl->Knots();
const NCollection_Array1<int>& oldMults = BSpl->Multiplicities();
NCollection_Array1<double> newKnots(1, nbKnots + 2);
NCollection_Array1<int> newMults(1, nbKnots + 2);
@@ -115,10 +115,7 @@ occ::handle<Geom2d_Line> ShapeCustom_Curve2d::ConvertToLine2d(
occ::handle<Geom2d_BSplineCurve> bsc = occ::down_cast<Geom2d_BSplineCurve>(theCurve);
if (!bsc.IsNull())
{
int nbPoles = bsc->NbPoles();
NCollection_Array1<gp_Pnt2d> Poles(1, nbPoles);
bsc->Poles(Poles);
if (!ShapeCustom_Curve2d::IsLinear(Poles, theTolerance, theDeviation))
if (!ShapeCustom_Curve2d::IsLinear(bsc->Poles(), theTolerance, theDeviation))
return aLine2d; // non
gp_Lin2d alin = GetLine(P1, P2, c1, cf, cl);
aLine2d = new Geom2d_Line(alin);
@@ -128,10 +125,7 @@ occ::handle<Geom2d_Line> ShapeCustom_Curve2d::ConvertToLine2d(
occ::handle<Geom2d_BezierCurve> bzc = occ::down_cast<Geom2d_BezierCurve>(theCurve);
if (!bzc.IsNull())
{
int nbPoles = bzc->NbPoles();
NCollection_Array1<gp_Pnt2d> Poles(1, nbPoles);
bzc->Poles(Poles);
if (!ShapeCustom_Curve2d::IsLinear(Poles, theTolerance, theDeviation))
if (!ShapeCustom_Curve2d::IsLinear(bzc->Poles(), theTolerance, theDeviation))
return aLine2d; // non
gp_Lin2d alin = GetLine(P1, P2, c1, cf, cl);
aLine2d = new Geom2d_Line(alin);
@@ -454,23 +454,13 @@ occ::handle<Geom_Surface> ShapeCustom_Surface::ConvertToPeriodic(const bool su
if (BSpl->UMultiplicity(1) == BSpl->UDegree() + 1
&& BSpl->UMultiplicity(BSpl->NbUKnots()) == BSpl->UDegree() + 1)
{
int nbUPoles = BSpl->NbUPoles();
int nbVPoles = BSpl->NbVPoles();
NCollection_Array2<gp_Pnt> oldPoles(1, nbUPoles, 1, nbVPoles);
NCollection_Array2<double> oldWeights(1, nbUPoles, 1, nbVPoles);
int nbUKnots = BSpl->NbUKnots();
int nbVKnots = BSpl->NbVKnots();
NCollection_Array1<double> oldUKnots(1, nbUKnots);
NCollection_Array1<double> oldVKnots(1, nbVKnots);
NCollection_Array1<int> oldUMults(1, nbUKnots);
NCollection_Array1<int> oldVMults(1, nbVKnots);
BSpl->Poles(oldPoles);
BSpl->Weights(oldWeights);
BSpl->UKnots(oldUKnots);
BSpl->VKnots(oldVKnots);
BSpl->UMultiplicities(oldUMults);
BSpl->VMultiplicities(oldVMults);
const NCollection_Array2<gp_Pnt>& oldPoles = BSpl->Poles();
const NCollection_Array2<double>& oldWeights = BSpl->WeightsArray();
int nbUKnots = BSpl->NbUKnots();
const NCollection_Array1<double>& oldUKnots = BSpl->UKnots();
const NCollection_Array1<double>& oldVKnots = BSpl->VKnots();
const NCollection_Array1<int>& oldUMults = BSpl->UMultiplicities();
const NCollection_Array1<int>& oldVMults = BSpl->VMultiplicities();
NCollection_Array1<double> newUKnots(1, nbUKnots + 2);
NCollection_Array1<int> newUMults(1, nbUKnots + 2);
@@ -515,23 +505,13 @@ occ::handle<Geom_Surface> ShapeCustom_Surface::ConvertToPeriodic(const bool su
if (BSpl->VMultiplicity(1) == BSpl->VDegree() + 1
&& BSpl->VMultiplicity(BSpl->NbVKnots()) == BSpl->VDegree() + 1)
{
int nbUPoles = BSpl->NbUPoles();
int nbVPoles = BSpl->NbVPoles();
NCollection_Array2<gp_Pnt> oldPoles(1, nbUPoles, 1, nbVPoles);
NCollection_Array2<double> oldWeights(1, nbUPoles, 1, nbVPoles);
int nbUKnots = BSpl->NbUKnots();
int nbVKnots = BSpl->NbVKnots();
NCollection_Array1<double> oldUKnots(1, nbUKnots);
NCollection_Array1<double> oldVKnots(1, nbVKnots);
NCollection_Array1<int> oldUMults(1, nbUKnots);
NCollection_Array1<int> oldVMults(1, nbVKnots);
BSpl->Poles(oldPoles);
BSpl->Weights(oldWeights);
BSpl->UKnots(oldUKnots);
BSpl->VKnots(oldVKnots);
BSpl->UMultiplicities(oldUMults);
BSpl->VMultiplicities(oldVMults);
const NCollection_Array2<gp_Pnt>& oldPoles = BSpl->Poles();
const NCollection_Array2<double>& oldWeights = BSpl->WeightsArray();
int nbVKnots = BSpl->NbVKnots();
const NCollection_Array1<double>& oldUKnots = BSpl->UKnots();
const NCollection_Array1<double>& oldVKnots = BSpl->VKnots();
const NCollection_Array1<int>& oldUMults = BSpl->UMultiplicities();
const NCollection_Array1<int>& oldVMults = BSpl->VMultiplicities();
NCollection_Array1<double> newVKnots(1, nbVKnots + 2);
NCollection_Array1<int> newVMults(1, nbVKnots + 2);
@@ -386,8 +386,7 @@ void ShapeFix_EdgeProjAux::Init2d(const double preci)
// Try to reparametrize (CASE dxf read bug25899)
occ::handle<Geom2d_BSplineCurve> aBspl =
occ::down_cast<Geom2d_BSplineCurve>(theCurve2d->Copy());
NCollection_Array1<double> aNewKnots(1, aBspl->NbKnots());
aBspl->Knots(aNewKnots);
NCollection_Array1<double> aNewKnots(aBspl->Knots());
BSplCLib::Reparametrize(cf, cl, aNewKnots);
aBspl->SetKnots(aNewKnots);
theCurve2d = aBspl;
@@ -47,23 +47,12 @@ bool ShapeUpgrade::C0BSplineToSequenceOfC1BSplineCurve(
seqBS = new NCollection_HSequence<occ::handle<Geom_BoundedCurve>>;
BS->SetNotPeriodic(); // to have equation NbPoles = NbKnots with Multiplicities - degree - 1
int deg = BS->Degree();
int NbKnots = BS->NbKnots();
int NbPoles = BS->NbPoles();
NCollection_Array1<gp_Pnt> Poles(1, NbPoles);
NCollection_Array1<double> Weights(1, NbPoles);
NCollection_Array1<double> Knots(1, NbKnots);
NCollection_Array1<int> Mults(1, NbKnots);
NCollection_Array1<double> KnotSequence(1, NbPoles + deg + 1);
BS->Poles(Poles);
if (BS->IsRational())
BS->Weights(Weights);
else
Weights.Init(1.);
BS->Knots(Knots);
BS->Multiplicities(Mults);
BS->KnotSequence(KnotSequence);
int deg = BS->Degree();
const NCollection_Array1<gp_Pnt>& Poles = BS->Poles();
const NCollection_Array1<double>& Weights = BS->WeightsArray();
const NCollection_Array1<double>& Knots = BS->Knots();
const NCollection_Array1<int>& Mults = BS->Multiplicities();
const NCollection_Array1<double>& KnotSequence = BS->KnotSequence();
int StartKnotIndex, EndKnotIndex, j;
@@ -78,8 +67,8 @@ bool ShapeUpgrade::C0BSplineToSequenceOfC1BSplineCurve(
int EndFlatIndex = BSplCLib::FlatIndex(deg, EndKnotIndex, Mults, false);
EndFlatIndex -= Mults(EndKnotIndex) - 1;
NCollection_Array1<double> TempKnots(1, NbKnots);
NCollection_Array1<int> TempMults(1, NbKnots);
NCollection_Array1<double> TempKnots(1, Knots.Length());
NCollection_Array1<int> TempMults(1, Knots.Length());
TempMults.Init(1);
int TempKnotIndex = 1;
TempKnots(TempKnotIndex) = KnotSequence(StartFlatIndex - deg);
@@ -130,21 +119,12 @@ bool ShapeUpgrade::C0BSplineToSequenceOfC1BSplineCurve(
static occ::handle<Geom_BSplineCurve> BSplineCurve2dTo3d(const occ::handle<Geom2d_BSplineCurve>& BS)
{
int deg = BS->Degree();
int NbKnots = BS->NbKnots();
int NbPoles = BS->NbPoles();
NCollection_Array1<gp_Pnt2d> Poles2d(1, NbPoles);
NCollection_Array1<double> Weights(1, NbPoles);
NCollection_Array1<double> Knots(1, NbKnots);
NCollection_Array1<int> Mults(1, NbKnots);
BS->Poles(Poles2d);
if (BS->IsRational())
BS->Weights(Weights);
else
Weights.Init(1);
BS->Knots(Knots);
BS->Multiplicities(Mults);
int deg = BS->Degree();
int NbPoles = BS->NbPoles();
const NCollection_Array1<gp_Pnt2d>& Poles2d = BS->Poles();
const NCollection_Array1<double>& Weights = BS->WeightsArray();
const NCollection_Array1<double>& Knots = BS->Knots();
const NCollection_Array1<int>& Mults = BS->Multiplicities();
NCollection_Array1<gp_Pnt> Poles3d(1, NbPoles);
for (int i = 1; i <= NbPoles; i++)
@@ -157,21 +137,12 @@ static occ::handle<Geom_BSplineCurve> BSplineCurve2dTo3d(const occ::handle<Geom2
static occ::handle<Geom2d_BSplineCurve> BSplineCurve3dTo2d(const occ::handle<Geom_BSplineCurve>& BS)
{
int deg = BS->Degree();
int NbKnots = BS->NbKnots();
int NbPoles = BS->NbPoles();
NCollection_Array1<gp_Pnt> Poles3d(1, NbPoles);
NCollection_Array1<double> Weights(1, NbPoles);
NCollection_Array1<double> Knots(1, NbKnots);
NCollection_Array1<int> Mults(1, NbKnots);
BS->Poles(Poles3d);
if (BS->IsRational())
BS->Weights(Weights);
else
Weights.Init(1);
BS->Knots(Knots);
BS->Multiplicities(Mults);
int deg = BS->Degree();
int NbPoles = BS->NbPoles();
const NCollection_Array1<gp_Pnt>& Poles3d = BS->Poles();
const NCollection_Array1<double>& Weights = BS->WeightsArray();
const NCollection_Array1<double>& Knots = BS->Knots();
const NCollection_Array1<int>& Mults = BS->Multiplicities();
NCollection_Array1<gp_Pnt2d> Poles2d(1, NbPoles);
for (int i = 1; i <= NbPoles; i++)
@@ -409,11 +409,10 @@ void ShapeUpgrade_ConvertSurfaceToBezierBasis::Compute(const bool Segment)
int i; // svv #1
for (i = 1; i <= nbCurves; i++)
{
occ::handle<Geom_BezierCurve> bez = occ::down_cast<Geom_BezierCurve>(curves->Value(i));
int nbPoles = bez->NbPoles();
NCollection_Array1<gp_Pnt> poles(1, nbPoles);
bez->Poles(poles);
NCollection_Array2<gp_Pnt> resPoles(1, nbPoles, 1, 2);
occ::handle<Geom_BezierCurve> bez = occ::down_cast<Geom_BezierCurve>(curves->Value(i));
int nbPoles = bez->NbPoles();
const NCollection_Array1<gp_Pnt>& poles = bez->Poles();
NCollection_Array2<gp_Pnt> resPoles(1, nbPoles, 1, 2);
for (int j = 1; j <= nbPoles; j++)
{
resPoles(j, 1) = poles(j).Transformed(shiftF);
@@ -1956,8 +1956,7 @@ void ShapeUpgrade_UnifySameDomain::UnionPCurves(const NCollection_Sequence<TopoD
new Geom2d_TrimmedCurve(ResPCurves(ii), ResFirsts(ii), ResLasts(ii));
occ::handle<Geom2d_BSplineCurve> aBSplinePCurve =
Geom2dConvert::CurveToBSplineCurve(aTrPCurve);
NCollection_Array1<double> aKnots(1, aBSplinePCurve->NbKnots());
aBSplinePCurve->Knots(aKnots);
NCollection_Array1<double> aKnots(aBSplinePCurve->Knots());
BSplCLib::Reparametrize(aFirst3d, aLast3d, aKnots);
aBSplinePCurve->SetKnots(aKnots);
ResPCurves(ii) = aBSplinePCurve;
@@ -2005,8 +2004,7 @@ void ShapeUpgrade_UnifySameDomain::UnionPCurves(const NCollection_Sequence<TopoD
new Geom2d_TrimmedCurve(ResPCurves(ii), ResFirsts(ii), ResLasts(ii));
occ::handle<Geom2d_BSplineCurve> aBSplinePCurve =
Geom2dConvert::CurveToBSplineCurve(aTrPCurve);
NCollection_Array1<double> aKnots(1, aBSplinePCurve->NbKnots());
aBSplinePCurve->Knots(aKnots);
NCollection_Array1<double> aKnots(aBSplinePCurve->Knots());
BSplCLib::Reparametrize(aFirst3d, aLast3d, aKnots);
aBSplinePCurve->SetKnots(aKnots);
ResPCurves(ii) = aBSplinePCurve;
@@ -345,9 +345,13 @@ void BRepGProp_Face::UKnots(NCollection_Array1<double>& Knots) const
Knots(3) = M_PI * 4.0 / 3.0;
Knots(4) = M_PI * 6.0 / 3.0;
break;
case GeomAbs_BSplineSurface:
(*((occ::handle<Geom_BSplineSurface>*)&((mySurface.Surface()).Surface())))->UKnots(Knots);
break;
case GeomAbs_BSplineSurface: {
const NCollection_Array1<double>& aSrcKnots =
(*((occ::handle<Geom_BSplineSurface>*)&((mySurface.Surface()).Surface())))->UKnots();
for (int i = Knots.Lower(); i <= Knots.Upper(); i++)
Knots(i) = aSrcKnots(i);
}
break;
default:
Knots(1) = mySurface.FirstUParameter();
Knots(2) = mySurface.LastUParameter();
@@ -378,9 +382,13 @@ void BRepGProp_Face::VKnots(NCollection_Array1<double>& Knots) const
Knots(3) = M_PI * 4.0 / 3.0;
Knots(4) = M_PI * 6.0 / 3.0;
break;
case GeomAbs_BSplineSurface:
(*((occ::handle<Geom_BSplineSurface>*)&((mySurface.Surface()).Surface())))->VKnots(Knots);
break;
case GeomAbs_BSplineSurface: {
const NCollection_Array1<double>& aSrcKnots =
(*((occ::handle<Geom_BSplineSurface>*)&((mySurface.Surface()).Surface())))->VKnots();
for (int i = Knots.Lower(); i <= Knots.Upper(); i++)
Knots(i) = aSrcKnots(i);
}
break;
default:
Knots(1) = mySurface.FirstUParameter();
Knots(2) = mySurface.LastUParameter();
@@ -493,9 +501,13 @@ void BRepGProp_Face::LKnots(NCollection_Array1<double>& Knots) const
Knots(1) = myCurve.FirstParameter();
Knots(2) = myCurve.LastParameter();
break;
case GeomAbs_BSplineCurve:
(*((occ::handle<Geom2d_BSplineCurve>*)&(myCurve.Curve())))->Knots(Knots);
break;
case GeomAbs_BSplineCurve: {
const NCollection_Array1<double>& aSrcKnots =
(*((occ::handle<Geom2d_BSplineCurve>*)&(myCurve.Curve())))->Knots();
for (int i = Knots.Lower(); i <= Knots.Upper(); i++)
Knots(i) = aSrcKnots(i);
}
break;
default:
Knots(1) = myCurve.FirstParameter();
Knots(2) = myCurve.LastParameter();
@@ -606,13 +618,10 @@ static void GetCurveKnots(const double theMin,
if (isSBSpline)
{
occ::handle<Geom2d_BSplineCurve> aCrv;
int aNbKnots;
occ::handle<NCollection_HArray1<double>> aCrvKnots;
aCrv = occ::down_cast<Geom2d_BSplineCurve>(theCurve.Curve());
aNbKnots = aCrv->NbKnots();
aCrvKnots = new NCollection_HArray1<double>(1, aNbKnots);
aCrv->Knots(aCrvKnots->ChangeArray1());
aCrvKnots = new NCollection_HArray1<double>(aCrv->Knots());
GetRealKnots(theMin, theMax, aCrvKnots, theKnots);
}
else
@@ -649,7 +658,6 @@ void BRepGProp_Face::GetUKnots(const double theUMin
{
// Using span decomposition for BSpline.
occ::handle<NCollection_HArray1<double>> aKnots;
int aNbKnots;
if (isSBSpline)
{
@@ -658,9 +666,7 @@ void BRepGProp_Face::GetUKnots(const double theUMin
occ::handle<Geom_BSplineSurface> aBSplSurf;
aBSplSurf = occ::down_cast<Geom_BSplineSurface>(aSurf);
aNbKnots = aBSplSurf->NbUKnots();
aKnots = new NCollection_HArray1<double>(1, aNbKnots);
aBSplSurf->UKnots(aKnots->ChangeArray1());
aKnots = new NCollection_HArray1<double>(aBSplSurf->UKnots());
}
else
{
@@ -672,9 +678,7 @@ void BRepGProp_Face::GetUKnots(const double theUMin
aCurve.Load(occ::down_cast<Geom_SurfaceOfLinearExtrusion>(aSurf)->BasisCurve());
aBSplCurve = aCurve.BSpline();
aNbKnots = aBSplCurve->NbKnots();
aKnots = new NCollection_HArray1<double>(1, aNbKnots);
aBSplCurve->Knots(aKnots->ChangeArray1());
aKnots = new NCollection_HArray1<double>(aBSplCurve->Knots());
}
// Compute number of knots inside theUMin and theUMax.
@@ -701,16 +705,13 @@ void BRepGProp_Face::GetTKnots(const double theTMin
{
// Using span decomposition for BSpline.
occ::handle<NCollection_HArray1<double>> aSurfKnots;
int aNbKnots;
// Get V knots of BSpline surface.
occ::handle<Geom_Surface> aSurf = mySurface.Surface().Surface();
occ::handle<Geom_BSplineSurface> aBSplSurf;
aBSplSurf = occ::down_cast<Geom_BSplineSurface>(aSurf);
aNbKnots = aBSplSurf->NbVKnots();
aSurfKnots = new NCollection_HArray1<double>(1, aNbKnots);
aBSplSurf->VKnots(aSurfKnots->ChangeArray1());
aSurfKnots = new NCollection_HArray1<double>(aBSplSurf->VKnots());
// occ::handle<NCollection_HArray1<double>> aCurveKnots;
@@ -1348,8 +1348,7 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge,
|| std::abs(OriginPoint.Y() - NewOriginPoint.Y()) > Precision::PConfusion())
{
NCollection_Array1<double> Knotbs2d(1, bs2d->NbKnots());
bs2d->Knots(Knotbs2d);
NCollection_Array1<double> Knotbs2d(bs2d->Knots());
for (int Index = 1; Index <= bs2d->NbKnots(); Index++)
{
@@ -1375,11 +1374,10 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge,
double Tol2dbail = std::min(UResbail, VResbail);
bs2d->D0(bs2d->FirstParameter(), OriginPoint);
int nbp = bs2d->NbPoles();
NCollection_Array1<gp_Pnt2d> poles(1, nbp);
bs2d->Poles(poles);
gp_Pnt2d p = poles(1), p1;
double d = Precision::Infinite();
int nbp = bs2d->NbPoles();
const NCollection_Array1<gp_Pnt2d>& poles = bs2d->Poles();
gp_Pnt2d p = poles(1), p1;
double d = Precision::Infinite();
for (int ip = 2; ip <= nbp; ip++)
{
p1 = poles(ip);
@@ -1400,8 +1398,7 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge,
|| std::abs(OriginPoint.Y() - NewOriginPoint.Y()) > Precision::PConfusion())
{
NCollection_Array1<double> Knotbs2d(1, bs2d->NbKnots());
bs2d->Knots(Knotbs2d);
const NCollection_Array1<double>& Knotbs2d = bs2d->Knots();
for (int Index = 1; Index <= bs2d->NbKnots(); Index++)
{
@@ -1431,9 +1428,7 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge,
{
if (repar)
{
int NbKnots = bs2d->NbKnots();
NCollection_Array1<double> Knots(1, NbKnots);
bs2d->Knots(Knots);
NCollection_Array1<double> Knots(bs2d->Knots());
// BSplCLib::Reparametrize(f3d,l3d,Knots);
BSplCLib::Reparametrize(fC0, lC0, Knots);
bs2d->SetKnots(Knots);
@@ -1463,13 +1458,12 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge,
if (cont > GeomAbs_C0 && error > std::max(1.e-3, theTolerance))
{
int NbKnots = bs2d->NbKnots();
NCollection_Array1<double> Knots(1, NbKnots);
bs2d->Knots(Knots);
double critratio = 10.;
double dtprev = Knots(2) - Knots(1), dtratio = 1.;
double dtmin = dtprev;
double dtcur;
int NbKnots = bs2d->NbKnots();
const NCollection_Array1<double>& Knots = bs2d->Knots();
double critratio = 10.;
double dtprev = Knots(2) - Knots(1), dtratio = 1.;
double dtmin = dtprev;
double dtcur;
for (int j = 2; j < NbKnots; j++)
{
dtcur = Knots(j + 1) - Knots(j);
@@ -1522,9 +1516,7 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge,
if (std::abs(bs2d->FirstParameter() - fC0) > TolSameRange
|| std::abs(bs2d->LastParameter() - lC0) > TolSameRange)
{
int NbKnots = bs2d->NbKnots();
NCollection_Array1<double> Knots(1, NbKnots);
bs2d->Knots(Knots);
NCollection_Array1<double> Knots(bs2d->Knots());
// BSplCLib::Reparametrize(f3d,l3d,Knots);
BSplCLib::Reparametrize(fC0, lC0, Knots);
bs2d->SetKnots(Knots);
@@ -76,12 +76,9 @@ static void BCSmoothing(occ::handle<Geom_BSplineCurve>& theC,
{
int aNbKnots = theC->NbKnots();
NCollection_Array1<int> aMults(1, aNbKnots);
NCollection_Array1<double> aKnots(1, aNbKnots);
theC->Multiplicities(aMults);
theC->Knots(aKnots);
int i, m = theC->Degree();
NCollection_Array1<int> aMults(theC->Multiplicities());
NCollection_Array1<double> aKnots(theC->Knots());
int i, m = theC->Degree();
m = m - theCont;
if (m < 1)
@@ -912,9 +909,8 @@ bool BRepLib_FuseEdges::SameSupport(const TopoDS_Edge& E1, const TopoDS_Edge& E2
return false;
}
NCollection_Array1<gp_Pnt> P1(1, nbpoles), P2(1, nbpoles);
B1->Poles(P1);
B2->Poles(P2);
const NCollection_Array1<gp_Pnt>& P1 = B1->Poles();
const NCollection_Array1<gp_Pnt>& P2 = B2->Poles();
double tol3d = BRep_Tool::Tolerance(E1);
for (int p = 1; p <= nbpoles; p++)
@@ -925,13 +921,11 @@ bool BRepLib_FuseEdges::SameSupport(const TopoDS_Edge& E1, const TopoDS_Edge& E2
}
}
NCollection_Array1<double> K1(1, nbknots), K2(1, nbknots);
B1->Knots(K1);
B2->Knots(K2);
const NCollection_Array1<double>& K1 = B1->Knots();
const NCollection_Array1<double>& K2 = B2->Knots();
NCollection_Array1<int> M1(1, nbknots), M2(1, nbknots);
B1->Multiplicities(M1);
B2->Multiplicities(M2);
const NCollection_Array1<int>& M1 = B1->Multiplicities();
const NCollection_Array1<int>& M2 = B2->Multiplicities();
for (int k = 1; k <= nbknots; k++)
{
@@ -962,9 +956,8 @@ bool BRepLib_FuseEdges::SameSupport(const TopoDS_Edge& E1, const TopoDS_Edge& E2
if (B1->IsRational())
{
NCollection_Array1<double> W1(1, nbpoles), W2(1, nbpoles);
B1->Weights(W1);
B2->Weights(W2);
const NCollection_Array1<double>& W1 = B1->WeightsArray();
const NCollection_Array1<double>& W2 = B2->WeightsArray();
for (int w = 1; w <= nbpoles; w++)
{
@@ -995,9 +988,8 @@ bool BRepLib_FuseEdges::SameSupport(const TopoDS_Edge& E1, const TopoDS_Edge& E2
return false;
}
NCollection_Array1<gp_Pnt> P1(1, nbpoles), P2(1, nbpoles);
B1->Poles(P1);
B2->Poles(P2);
const NCollection_Array1<gp_Pnt>& P1 = B1->Poles();
const NCollection_Array1<gp_Pnt>& P2 = B2->Poles();
for (int p = 1; p <= nbpoles; p++)
{
@@ -1024,9 +1016,8 @@ bool BRepLib_FuseEdges::SameSupport(const TopoDS_Edge& E1, const TopoDS_Edge& E2
if (B1->IsRational())
{
NCollection_Array1<double> W1(1, nbpoles), W2(1, nbpoles);
B1->Weights(W1);
B2->Weights(W2);
const NCollection_Array1<double>& W1 = B1->WeightsArray();
const NCollection_Array1<double>& W2 = B2->WeightsArray();
for (int w = 1; w <= nbpoles; w++)
{
@@ -1147,8 +1138,7 @@ bool BRepLib_FuseEdges::UpdatePCurve(const TopoDS_Edge& theOl
|| std::abs(last - el) > Precision::PConfusion())
{
occ::handle<Geom2d_BSplineCurve> bc = occ::down_cast<Geom2d_BSplineCurve>(Curv2d);
NCollection_Array1<double> Knots(1, bc->NbKnots());
bc->Knots(Knots);
NCollection_Array1<double> Knots(bc->Knots());
BSplCLib::Reparametrize(ef, el, Knots);
bc->SetKnots(Knots);
}
@@ -465,11 +465,10 @@ void BRepTopAdaptor_TopolTool::ComputeSamplePoints()
{
if (typS == GeomAbs_BSplineSurface)
{
const occ::handle<Geom_BSplineSurface>& Bspl = myS->BSpline();
int nbup = Bspl->NbUPoles();
int nbvp = Bspl->NbVPoles();
NCollection_Array2<gp_Pnt> array2(1, nbup, 1, nbvp);
Bspl->Poles(array2);
const occ::handle<Geom_BSplineSurface>& Bspl = myS->BSpline();
int nbup = Bspl->NbUPoles();
int nbvp = Bspl->NbVPoles();
const NCollection_Array2<gp_Pnt>& array2 = Bspl->Poles();
Analyse(array2, nbup, nbvp, myNbSamplesU, myNbSamplesV);
nbsu = myNbSamplesU;
nbsv = myNbSamplesV;
@@ -477,11 +476,10 @@ void BRepTopAdaptor_TopolTool::ComputeSamplePoints()
}
else if (typS == GeomAbs_BezierSurface)
{
const occ::handle<Geom_BezierSurface>& Bez = myS->Bezier();
int nbup = Bez->NbUPoles();
int nbvp = Bez->NbVPoles();
NCollection_Array2<gp_Pnt> array2(1, nbup, 1, nbvp);
Bez->Poles(array2);
const occ::handle<Geom_BezierSurface>& Bez = myS->Bezier();
int nbup = Bez->NbUPoles();
int nbvp = Bez->NbVPoles();
const NCollection_Array2<gp_Pnt>& array2 = Bez->Poles();
Analyse(array2, nbup, nbvp, myNbSamplesU, myNbSamplesV);
nbsu = myNbSamplesU;
nbsv = myNbSamplesV;