// Created on: 1991-08-26
// Created by: JCV
// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
// Modifed RLE Aug 93 - Complete rewrite
// xab 21-Mar-95 implemented cache mecanism
// pmn 07-10-96 : Correction de DN dans le cas rationnal.
// pmn 06-02-97 : Correction des poids dans RationalDerivative. (PRO700)
-#include <BSplSLib.ixx>
-#include <PLib.hxx>
-#include <NCollection_LocalArray.hxx>
#include <BSplCLib.hxx>
-#include <TColgp_Array2OfXYZ.hxx>
+#include <BSplSLib.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Vec.hxx>
+#include <math_Matrix.hxx>
+#include <NCollection_LocalArray.hxx>
+#include <PLib.hxx>
+#include <Standard_ConstructionError.hxx>
+#include <Standard_NotImplemented.hxx>
#include <TColgp_Array1OfXYZ.hxx>
+#include <TColgp_Array2OfXYZ.hxx>
#include <TColStd_HArray1OfInteger.hxx>
-#include <Standard_NotImplemented.hxx>
-#include <Standard_ConstructionError.hxx>
-#include <math_Matrix.hxx>
// for null derivatives
static Standard_Real BSplSLib_zero[3] = {0.0, 0.0, 0.0};
-#ifdef WNT
-#define M_SQRT2 1.4142135623730950488016887
-#endif
//=======================================================================
//struct : BSplCLib_DataContainer
{
BSplSLib_DataContainer (Standard_Integer UDegree, Standard_Integer VDegree)
{
+ (void)UDegree; (void)VDegree; // just to avoid compiler warning in Release mode
Standard_OutOfRange_Raise_if (UDegree > BSplCLib::MaxDegree() ||
VDegree > BSplCLib::MaxDegree() || BSplCLib::MaxDegree() > 25,
"BSplSLib: bspline degree is greater than maximum supported");
const Standard_Boolean UPer,
const Standard_Boolean VPer,
const TColgp_Array2OfPnt& Poles,
- const TColStd_Array2OfReal& Weights,
+ const TColStd_Array2OfReal* Weights,
const TColStd_Array1OfReal& UKnots,
const TColStd_Array1OfReal& VKnots,
- const TColStd_Array1OfInteger& UMults,
- const TColStd_Array1OfInteger& VMults,
+ const TColStd_Array1OfInteger* UMults,
+ const TColStd_Array1OfInteger* VMults,
Standard_Real& u1, // first parameter to use
Standard_Real& u2, // second parameter to use
Standard_Integer& d1, // first degree
BSplCLib::BuildKnots(UDegree,uindex,UPer,UKnots,UMults,*dc.knots1);
BSplCLib::BuildKnots(VDegree,vindex,VPer,VKnots,VMults,*dc.knots2);
- if (&UMults == NULL)
+ if (UMults == NULL)
uindex -= UKLower + UDegree;
else
- uindex = BSplCLib::PoleIndex(UDegree,uindex,UPer,UMults);
+ uindex = BSplCLib::PoleIndex(UDegree,uindex,UPer,*UMults);
- if (&VMults == NULL)
+ if (VMults == NULL)
vindex -= VKLower + VDegree;
else
- vindex = BSplCLib::PoleIndex(VDegree,vindex,VPer,VMults);
+ vindex = BSplCLib::PoleIndex(VDegree,vindex,VPer,*VMults);
// get the poles
Standard_Integer i,j,ip,jp;
if(ip < PLowerRow) ip = PUpperRow;
if(jp < PLowerCol) jp = PUpperCol;
- w = Weights.Value(ip,jp);
+ w = Weights->Value(ip,jp);
Standard_Real eps = Epsilon(w);
Standard_Real dw;
for (j = 0; j <= VDegree && !rational; j++)
{
- dw = Weights.Value(ip,jp) - w;
+ dw = Weights->Value(ip,jp) - w;
if (dw < 0)
dw = - dw;
for (j = 0; j <= d2; j++)
{
const gp_Pnt& P = Poles .Value(ip,jp);
- pole[3] = w = Weights.Value(ip,jp);
+ pole[3] = w = Weights->Value(ip,jp);
pole[0] = P.X() * w;
pole[1] = P.Y() * w;
pole[2] = P.Z() * w;
BSplCLib::BuildKnots(UDegree,uindex,UPer,UKnots,UMults,*dc.knots2);
BSplCLib::BuildKnots(VDegree,vindex,VPer,VKnots,VMults,*dc.knots1);
- if (&UMults == NULL)
+ if (UMults == NULL)
uindex -= UKLower + UDegree;
else
- uindex = BSplCLib::PoleIndex(UDegree,uindex,UPer,UMults);
+ uindex = BSplCLib::PoleIndex(UDegree,uindex,UPer,*UMults);
- if (&VMults == NULL)
+ if (VMults == NULL)
vindex -= VKLower + VDegree;
else
- vindex = BSplCLib::PoleIndex(VDegree,vindex,VPer,VMults);
+ vindex = BSplCLib::PoleIndex(VDegree,vindex,VPer,*VMults);
// get the poles
Standard_Integer i,j,ip,jp;
if(jp < PLowerCol)
jp = PUpperCol;
- w = Weights.Value(ip,jp);
+ w = Weights->Value(ip,jp);
Standard_Real eps = Epsilon(w);
Standard_Real dw;
for (j = 0; j <= VDegree && !rational; j++)
{
- dw = Weights.Value(ip,jp) - w;
+ dw = Weights->Value(ip,jp) - w;
if (dw < 0) dw = - dw;
rational = dw > eps;
for (j = 0; j <= d2; j++)
{
const gp_Pnt& P = Poles.Value(ip,jp);
- pole[3] = w = Weights.Value(ip,jp);
+ pole[3] = w = Weights->Value(ip,jp);
pole[0] = P.X() * w;
pole[1] = P.Y() * w;
pole[2] = P.Z() * w;
if(ip < PLowerRow)
ip = PUpperRow;
+ if(ip > PUpperRow)
+ ip = PLowerRow;
+
for (j = 0; j <= d2; j++)
{
const gp_Pnt& P = Poles.Value(ip,jp);
const Standard_Integer UIndex,
const Standard_Integer VIndex,
const TColgp_Array2OfPnt& Poles,
- const TColStd_Array2OfReal& Weights,
+ const TColStd_Array2OfReal* Weights,
const TColStd_Array1OfReal& UKnots,
const TColStd_Array1OfReal& VKnots,
- const TColStd_Array1OfInteger& UMults,
- const TColStd_Array1OfInteger& VMults,
+ const TColStd_Array1OfInteger* UMults,
+ const TColStd_Array1OfInteger* VMults,
const Standard_Integer UDegree,
const Standard_Integer VDegree,
const Standard_Boolean URat,
const Standard_Integer UIndex,
const Standard_Integer VIndex,
const TColgp_Array2OfPnt& Poles,
- const TColStd_Array2OfReal& Weights,
+ const TColStd_Array2OfReal* Weights,
const TColStd_Array1OfReal& UKnots,
const TColStd_Array1OfReal& VKnots,
- const TColStd_Array1OfInteger& UMults,
- const TColStd_Array1OfInteger& VMults,
+ const TColStd_Array1OfInteger* UMults,
+ const TColStd_Array1OfInteger* VMults,
const Standard_Integer UDegree,
const Standard_Integer VDegree,
const Standard_Boolean URat,
const Standard_Integer UIndex,
const Standard_Integer VIndex,
const TColgp_Array2OfPnt& Poles,
- const TColStd_Array2OfReal& Weights,
+ const TColStd_Array2OfReal* Weights,
const TColStd_Array1OfReal& UKnots,
const TColStd_Array1OfReal& VKnots,
- const TColStd_Array1OfInteger& UMults,
- const TColStd_Array1OfInteger& VMults,
+ const TColStd_Array1OfInteger* UMults,
+ const TColStd_Array1OfInteger* VMults,
const Standard_Integer UDegree,
const Standard_Integer VDegree,
const Standard_Boolean URat,
const Standard_Integer UIndex,
const Standard_Integer VIndex,
const TColgp_Array2OfPnt& Poles,
- const TColStd_Array2OfReal& Weights,
+ const TColStd_Array2OfReal* Weights,
const TColStd_Array1OfReal& UKnots,
const TColStd_Array1OfReal& VKnots,
- const TColStd_Array1OfInteger& UMults,
- const TColStd_Array1OfInteger& VMults,
+ const TColStd_Array1OfInteger* UMults,
+ const TColStd_Array1OfInteger* VMults,
const Standard_Integer UDegree,
const Standard_Integer VDegree,
const Standard_Boolean URat,
const Standard_Integer UIndex,
const Standard_Integer VIndex,
const TColgp_Array2OfPnt& Poles,
- const TColStd_Array2OfReal& Weights,
+ const TColStd_Array2OfReal* Weights,
const TColStd_Array1OfReal& UKnots,
const TColStd_Array1OfReal& VKnots,
- const TColStd_Array1OfInteger& UMults,
- const TColStd_Array1OfInteger& VMults,
+ const TColStd_Array1OfInteger* UMults,
+ const TColStd_Array1OfInteger* VMults,
const Standard_Integer UDegree,
const Standard_Integer VDegree,
const Standard_Boolean URat,
const Standard_Integer UIndex,
const Standard_Integer VIndex,
const TColgp_Array2OfPnt& Poles,
- const TColStd_Array2OfReal& Weights,
+ const TColStd_Array2OfReal* Weights,
const TColStd_Array1OfReal& UKnots,
const TColStd_Array1OfReal& VKnots,
- const TColStd_Array1OfInteger& UMults,
- const TColStd_Array1OfInteger& VMults,
+ const TColStd_Array1OfInteger* UMults,
+ const TColStd_Array1OfInteger* VMults,
const Standard_Integer UDegree,
const Standard_Integer VDegree,
const Standard_Boolean URat,
const Standard_Integer UIndex,
const Standard_Integer VIndex,
const TColgp_Array2OfPnt& Poles,
- const TColStd_Array2OfReal& Weights,
+ const TColStd_Array2OfReal* Weights,
const TColStd_Array1OfReal& UKnots,
const TColStd_Array1OfReal& VKnots,
- const TColStd_Array1OfInteger& UMults,
- const TColStd_Array1OfInteger& VMults,
+ const TColStd_Array1OfInteger* UMults,
+ const TColStd_Array1OfInteger* VMults,
const Standard_Integer UDegree,
const Standard_Integer VDegree,
const Standard_Boolean URat,
void BSplSLib::Iso(const Standard_Real Param,
const Standard_Boolean IsU,
const TColgp_Array2OfPnt& Poles,
- const TColStd_Array2OfReal& Weights,
+ const TColStd_Array2OfReal* Weights,
const TColStd_Array1OfReal& Knots,
- const TColStd_Array1OfInteger& Mults,
+ const TColStd_Array1OfInteger* Mults,
const Standard_Integer Degree,
const Standard_Boolean Periodic,
TColgp_Array1OfPnt& CPoles,
- TColStd_Array1OfReal& CWeights)
+ TColStd_Array1OfReal* CWeights)
{
Standard_Integer index = 0;
Standard_Real u = Param;
- Standard_Boolean rational = &Weights != NULL;
+ Standard_Boolean rational = Weights != NULL;
Standard_Integer dim = rational ? 4 : 3;
// compute local knots
NCollection_LocalArray<Standard_Real> locknots1 (2*Degree);
BSplCLib::LocateParameter(Degree,Knots,Mults,u,Periodic,index,u);
BSplCLib::BuildKnots(Degree,index,Periodic,Knots,Mults,*locknots1);
- if (&Mults == NULL)
+ if (Mults == NULL)
index -= Knots.Lower() + Degree;
else
- index = BSplCLib::PoleIndex(Degree,index,Periodic,Mults);
+ index = BSplCLib::PoleIndex(Degree,index,Periodic,*Mults);
// copy the local poles
const gp_Pnt& P = IsU ? Poles(index,j) : Poles(j,index);
if (rational) {
- pole[3] = w = IsU ? Weights(index,j) : Weights(j,index);
+ pole[3] = w = IsU ? (*Weights)(index,j) : (*Weights)(j,index);
pole[0] = P.X() * w;
pole[1] = P.Y() * w;
pole[2] = P.Z() * w;
for (i = CPoles.Lower(); i <= CPoles.Upper(); i++) {
gp_Pnt& P = CPoles(i);
if (rational) {
- CWeights(i) = w = pole[3];
+ (*CWeights)(i) = w = pole[3];
P.SetX( pole[0] / w);
P.SetY( pole[1] / w);
P.SetZ( pole[2] / w);
}
// if the input is not rational but weights are wanted
- if (!rational && (&CWeights != NULL)) {
+ if (!rational && (CWeights != NULL)) {
- for (i = CWeights.Lower(); i <= CWeights.Upper(); i++)
- CWeights(i) = 1.;
+ for (i = CWeights->Lower(); i <= CWeights->Upper(); i++)
+ (*CWeights)(i) = 1.;
}
}
const Standard_Integer Degree,
const Standard_Boolean Periodic,
const TColgp_Array2OfPnt& Poles,
- const TColStd_Array2OfReal& Weights,
+ const TColStd_Array2OfReal* Weights,
const TColStd_Array1OfReal& Knots,
const TColStd_Array1OfInteger& Mults,
const TColStd_Array1OfReal& AddKnots,
- const TColStd_Array1OfInteger& AddMults,
+ const TColStd_Array1OfInteger* AddMults,
TColgp_Array2OfPnt& NewPoles,
- TColStd_Array2OfReal& NewWeights,
+ TColStd_Array2OfReal* NewWeights,
TColStd_Array1OfReal& NewKnots,
TColStd_Array1OfInteger& NewMults,
const Standard_Real Epsilon,
const Standard_Boolean Add )
{
- Standard_Boolean rational = &Weights != NULL;
+ Standard_Boolean rational = Weights != NULL;
Standard_Integer dim = 3;
if (rational) dim++;
TColStd_Array1OfReal
newpoles( 1, dim*NewPoles.RowLength()*NewPoles.ColLength());
- if (rational) SetPoles(Poles,Weights,poles,UDirection);
+ if (rational) SetPoles(Poles,*Weights,poles,UDirection);
else SetPoles(Poles,poles,UDirection);
if (UDirection) {
AddKnots,AddMults,newpoles,NewKnots,NewMults,
Epsilon,Add);
- if (rational) GetPoles(newpoles,NewPoles,NewWeights,UDirection);
+ if (rational) GetPoles(newpoles,NewPoles,*NewWeights,UDirection);
else GetPoles(newpoles,NewPoles,UDirection);
}
const Standard_Integer Degree,
const Standard_Boolean Periodic,
const TColgp_Array2OfPnt& Poles,
- const TColStd_Array2OfReal& Weights,
+ const TColStd_Array2OfReal* Weights,
const TColStd_Array1OfReal& Knots,
const TColStd_Array1OfInteger& Mults,
TColgp_Array2OfPnt& NewPoles,
- TColStd_Array2OfReal& NewWeights,
+ TColStd_Array2OfReal* NewWeights,
TColStd_Array1OfReal& NewKnots,
TColStd_Array1OfInteger& NewMults,
const Standard_Real Tolerance)
{
- Standard_Boolean rational = &Weights != NULL;
+ Standard_Boolean rational = Weights != NULL;
Standard_Integer dim = 3;
if (rational) dim++;
TColStd_Array1OfReal
newpoles( 1, dim*NewPoles.RowLength()*NewPoles.ColLength());
- if (rational) SetPoles(Poles,Weights,poles,UDirection);
+ if (rational) SetPoles(Poles,*Weights,poles,UDirection);
else SetPoles(Poles,poles,UDirection);
if (UDirection) {
Tolerance))
return Standard_False;
- if (rational) GetPoles(newpoles,NewPoles,NewWeights,UDirection);
+ if (rational) GetPoles(newpoles,NewPoles,*NewWeights,UDirection);
else GetPoles(newpoles,NewPoles,UDirection);
return Standard_True;
}
const Standard_Integer NewDegree,
const Standard_Boolean Periodic,
const TColgp_Array2OfPnt& Poles,
- const TColStd_Array2OfReal& Weights,
+ const TColStd_Array2OfReal* Weights,
const TColStd_Array1OfReal& Knots,
const TColStd_Array1OfInteger& Mults,
TColgp_Array2OfPnt& NewPoles,
- TColStd_Array2OfReal& NewWeights,
+ TColStd_Array2OfReal* NewWeights,
TColStd_Array1OfReal& NewKnots,
TColStd_Array1OfInteger& NewMults)
{
- Standard_Boolean rational = &Weights != NULL;
+ Standard_Boolean rational = Weights != NULL;
Standard_Integer dim = 3;
if (rational) dim++;
TColStd_Array1OfReal
newpoles( 1, dim*NewPoles.RowLength()*NewPoles.ColLength());
- if (rational) SetPoles(Poles,Weights,poles,UDirection);
+ if (rational) SetPoles(Poles,*Weights,poles,UDirection);
else SetPoles(Poles,poles,UDirection);
if (UDirection) {
BSplCLib::IncreaseDegree(Degree,NewDegree,Periodic,dim,poles,Knots,Mults,
newpoles,NewKnots,NewMults);
- if (rational) GetPoles(newpoles,NewPoles,NewWeights,UDirection);
+ if (rational) GetPoles(newpoles,NewPoles,*NewWeights,UDirection);
else GetPoles(newpoles,NewPoles,UDirection);
}
const TColStd_Array1OfInteger& Mults,
const TColStd_Array1OfReal& Knots,
const TColgp_Array2OfPnt& Poles,
- const TColStd_Array2OfReal& Weights,
+ const TColStd_Array2OfReal* Weights,
TColStd_Array1OfInteger& NewMults,
TColStd_Array1OfReal& NewKnots,
TColgp_Array2OfPnt& NewPoles,
- TColStd_Array2OfReal& NewWeights)
+ TColStd_Array2OfReal* NewWeights)
{
- Standard_Boolean rational = &Weights != NULL;
+ Standard_Boolean rational = Weights != NULL;
Standard_Integer dim = 3;
if (rational) dim++;
TColStd_Array1OfReal
newpoles( 1, dim*NewPoles.RowLength()*NewPoles.ColLength());
- if (rational) SetPoles(Poles,Weights,poles,UDirection);
+ if (rational) SetPoles(Poles,*Weights,poles,UDirection);
else SetPoles(Poles,poles,UDirection);
if (UDirection) {
BSplCLib::Unperiodize(Degree, dim, Mults, Knots, poles,
NewMults, NewKnots, newpoles);
- if (rational) GetPoles(newpoles,NewPoles,NewWeights,UDirection);
+ if (rational) GetPoles(newpoles,NewPoles,*NewWeights,UDirection);
else GetPoles(newpoles,NewPoles,UDirection);
}
const TColStd_Array1OfReal& UFlatKnots,
const TColStd_Array1OfReal& VFlatKnots,
const TColgp_Array2OfPnt& Poles,
- const TColStd_Array2OfReal& Weights,
+ const TColStd_Array2OfReal* Weights,
TColgp_Array2OfPnt& CachePoles,
- TColStd_Array2OfReal& CacheWeights)
+ TColStd_Array2OfReal* CacheWeights)
{
Standard_Boolean rational,rational_u,rational_v,flag_u_or_v;
Standard_Integer kk,d1,d1p1,d2,d2p1,ii,jj,iii,jjj,Index;
Standard_Real u1,min_degree_domain,max_degree_domain,f,factor[2],u2;
- if (&Weights != NULL)
+ if (Weights != NULL)
rational_u = rational_v = Standard_True;
else
rational_u = rational_v = Standard_False;
P.SetX( f * dc.poles[Index]); Index++;
P.SetY( f * dc.poles[Index]); Index++;
P.SetZ( f * dc.poles[Index]); Index++;
- CacheWeights(iii ,jjj) = f * dc.poles[Index] ;
+ (*CacheWeights)(iii ,jjj) = f * dc.poles[Index] ;
factor[1] *= min_degree_domain / (Standard_Real) (jjj) ;
}
factor[0] *= max_degree_domain / (Standard_Real) (iii) ;
}
factor[0] *= max_degree_domain / (Standard_Real) (iii) ;
}
- if (&Weights != NULL) {
+ if (Weights != NULL) {
//
// means that PrepareEval did found out that the surface was
// locally polynomial but since the surface is constructed
for (ii = 1 ; ii <= d2p1 ; ii++) {
for (jj = 1 ; jj <= d1p1 ; jj++) {
- CacheWeights(ii,jj) = 0.0e0 ;
+ (*CacheWeights)(ii,jj) = 0.0e0 ;
}
}
- CacheWeights(1,1) = 1.0e0 ;
+ (*CacheWeights)(1,1) = 1.0e0 ;
+ }
+ }
+}
+
+void BSplSLib::BuildCache(const Standard_Real theU,
+ const Standard_Real theV,
+ const Standard_Real theUSpanDomain,
+ const Standard_Real theVSpanDomain,
+ const Standard_Boolean theUPeriodicFlag,
+ const Standard_Boolean theVPeriodicFlag,
+ const Standard_Integer theUDegree,
+ const Standard_Integer theVDegree,
+ const Standard_Integer theUIndex,
+ const Standard_Integer theVIndex,
+ const TColStd_Array1OfReal& theUFlatKnots,
+ const TColStd_Array1OfReal& theVFlatKnots,
+ const TColgp_Array2OfPnt& thePoles,
+ const TColStd_Array2OfReal* theWeights,
+ TColStd_Array2OfReal& theCacheArray)
+{
+ Standard_Boolean flag_u_or_v;
+ Standard_Integer d1, d2;
+ Standard_Real u1, u2;
+ Standard_Boolean isRationalOnParam = (theWeights != NULL);
+ Standard_Boolean isRational;
+
+ BSplSLib_DataContainer dc(theUDegree, theVDegree);
+ flag_u_or_v =
+ PrepareEval(theU, theV, theUIndex, theVIndex, theUDegree, theVDegree,
+ isRationalOnParam, isRationalOnParam,
+ theUPeriodicFlag, theVPeriodicFlag,
+ thePoles, theWeights,
+ theUFlatKnots, theVFlatKnots,
+ (BSplCLib::NoMults()), (BSplCLib::NoMults()),
+ u1, u2, d1, d2, isRational, dc);
+
+ Standard_Integer d2p1 = d2 + 1;
+ Standard_Integer aDimension = isRational ? 4 : 3;
+ Standard_Integer aCacheShift = // helps to store weights when PrepareEval did not found that the surface is locally polynomial
+ (isRationalOnParam && !isRational) ? aDimension + 1 : aDimension;
+
+ Standard_Real aDomains[2];
+ // aDomains[0] corresponds to variable with minimal degree
+ // aDomains[1] corresponds to variable with maximal degree
+ if (flag_u_or_v)
+ {
+ aDomains[0] = theUSpanDomain;
+ aDomains[1] = theVSpanDomain;
+ }
+ else
+ {
+ aDomains[0] = theVSpanDomain;
+ aDomains[1] = theUSpanDomain;
+ }
+
+ BSplCLib::Bohm(u1, d1, d1, *dc.knots1, aDimension * d2p1, *dc.poles);
+ for (Standard_Integer kk = 0; kk <= d1 ; kk++)
+ BSplCLib::Bohm(u2, d2, d2, *dc.knots2, aDimension, *(dc.poles + kk * aDimension * d2p1));
+
+ Standard_Real* aCache = (Standard_Real *) &(theCacheArray(theCacheArray.LowerRow(), theCacheArray.LowerCol()));
+ Standard_Real* aPolyCoeffs = dc.poles;
+
+ Standard_Real aFactors[2];
+ // aFactors[0] corresponds to variable with minimal degree
+ // aFactors[1] corresponds to variable with maximal degree
+ aFactors[1] = 1.0;
+ Standard_Integer aRow, aCol, i;
+ Standard_Real aCoeff;
+ for (aRow = 0; aRow <= d2; aRow++)
+ {
+ aFactors[0] = 1.0;
+ for (aCol = 0; aCol <= d1; aCol++)
+ {
+ aPolyCoeffs = dc.poles + (aCol * d2p1 + aRow) * aDimension;
+ aCoeff = aFactors[0] * aFactors[1];
+ for (i = 0; i < aDimension; i++)
+ aCache[i] = aPolyCoeffs[i] * aCoeff;
+ aCache += aCacheShift;
+ aFactors[0] *= aDomains[0] / (aCol + 1);
}
+ aFactors[1] *= aDomains[1] / (aRow + 1);
+ }
+
+ // Fill the weights for the surface which is not locally polynomial
+ if (aCacheShift > aDimension)
+ {
+ aCache = (Standard_Real *) &(theCacheArray(theCacheArray.LowerRow(), theCacheArray.LowerCol()));
+ aCache += aCacheShift - 1;
+ for (aRow = 0; aRow <= d2; aRow++)
+ for (aCol = 0; aCol <= d1; aCol++)
+ {
+ *aCache = 0.0;
+ aCache += aCacheShift;
+ }
+ theCacheArray.SetValue(theCacheArray.LowerRow(), theCacheArray.LowerCol() + aCacheShift - 1, 1.0);
}
}
+
//=======================================================================
//function : CacheD0
//purpose : Evaluates the polynomial cache of the Bspline Curve
const Standard_Real USpanLenght,
const Standard_Real VSpanLenght,
const TColgp_Array2OfPnt& PolesArray,
- const TColStd_Array2OfReal& WeightsArray,
+ const TColStd_Array2OfReal* WeightsArray,
gp_Pnt& aPoint)
{
//
(min_degree << 1) + min_degree,
locpoles[0],
myPoint[0]) ;
- if (&WeightsArray != NULL) {
+ if (WeightsArray != NULL) {
dimension = min_degree + 1 ;
+ const TColStd_Array2OfReal& refWeights = *WeightsArray;
Standard_Real *
WArray = (Standard_Real *)
- &WeightsArray(WeightsArray.LowerCol(),WeightsArray.LowerRow()) ;
+ &refWeights(refWeights.LowerCol(),refWeights.LowerRow()) ;
PLib::NoDerivativeEvalPolynomial(new_parameter[0],
max_degree,
dimension,
const Standard_Real USpanLenght,
const Standard_Real VSpanLenght,
const TColgp_Array2OfPnt& PolesArray,
- const TColStd_Array2OfReal& WeightsArray,
+ const TColStd_Array2OfReal* WeightsArray,
gp_Pnt& aPoint,
gp_Vec& aVecU,
gp_Vec& aVecV)
// the coefficients
//
//
- if (&WeightsArray != NULL) {
+ if (WeightsArray != NULL) {
local_poles_array [0][0][0] = 0.0e0 ;
local_poles_array [0][0][1] = 0.0e0 ;
locpoles[dimension],
local_poles_array[1][0][0]) ;
- if (&WeightsArray != NULL) {
+ if (WeightsArray != NULL) {
dimension = min_degree + 1 ;
+ const TColStd_Array2OfReal& refWeights = *WeightsArray;
Standard_Real *
WArray = (Standard_Real *)
- &WeightsArray(WeightsArray.LowerCol(),WeightsArray.LowerRow()) ;
+ &refWeights(refWeights.LowerCol(),refWeights.LowerRow()) ;
PLib::EvalPolynomial(new_parameter[0],
1,
max_degree,
const Standard_Real USpanLenght,
const Standard_Real VSpanLenght,
const TColgp_Array2OfPnt& PolesArray,
- const TColStd_Array2OfReal& WeightsArray,
+ const TColStd_Array2OfReal* WeightsArray,
gp_Pnt& aPoint,
gp_Vec& aVecU,
gp_Vec& aVecV,
// the coefficients
//
//
- if (&WeightsArray != NULL) {
+ if (WeightsArray != NULL) {
local_poles_and_weights_array[0][0][0] = 0.0e0 ;
local_poles_and_weights_array[0][0][1] = 0.0e0 ;
locpoles[dimension + dimension],
local_poles_array[2][0][0]) ;
- if (&WeightsArray != NULL) {
+ if (WeightsArray != NULL) {
dimension = min_degree + 1 ;
+ const TColStd_Array2OfReal& refWeights = *WeightsArray;
Standard_Real *
WArray = (Standard_Real *)
- &WeightsArray(WeightsArray.LowerCol(),WeightsArray.LowerRow()) ;
+ &refWeights(refWeights.LowerCol(),refWeights.LowerRow()) ;
PLib::EvalPolynomial(new_parameter[0],
MinIndMax,
max_degree,
Standard_Integer UFirstNonZeroBsplineIndex;
math_Matrix UBSplineBasis(1, 1,
1, UDegree+1);
- Standard_Integer ErrorCod1 = BSplCLib::EvalBsplineBasis(1,
- 0,
+ Standard_Integer ErrorCod1 = BSplCLib::EvalBsplineBasis(0,
UDegree+1,
UFlatKnots,
U,
Standard_Integer VFirstNonZeroBsplineIndex;
math_Matrix VBSplineBasis(1, 1,
1, VDegree+1);
- Standard_Integer ErrorCod2 = BSplCLib::EvalBsplineBasis(1,
- 0,
+ Standard_Integer ErrorCod2 = BSplCLib::EvalBsplineBasis(0,
VDegree+1,
VFlatKnots,
V,
//=======================================================================
void BSplSLib::Resolution(const TColgp_Array2OfPnt& Poles,
- const TColStd_Array2OfReal& Weights,
+ const TColStd_Array2OfReal* Weights,
const TColStd_Array1OfReal& UKnots,
const TColStd_Array1OfReal& VKnots,
const TColStd_Array1OfInteger& UMults,
PColLength = Poles.ColLength();
if (URational || VRational) {
Standard_Integer Wsize = PRowLength * PColLength;
- const Standard_Real * WG = &Weights(Weights.LowerRow(),Weights.LowerCol());
+ const TColStd_Array2OfReal& refWights = *Weights;
+ const Standard_Real * WG = &refWights(refWights.LowerRow(), refWights.LowerCol());
min_weights = WG[0];
for (ii = 1 ; ii < Wsize ; ii++) {
upper[1] = jj + VD2 + 1;
if (upper[1] > num_poles[1]) upper[1] = num_poles[1];
const gp_Pnt& Pij = Poles .Value(ii_index,jj_index);
- Wij = Weights.Value(ii_index,jj_index);
+ Wij = Weights->Value(ii_index,jj_index);
const gp_Pnt& Pmj = Poles .Value(ii_minus,jj_index);
- Wmj = Weights.Value(ii_minus,jj_index);
+ Wmj = Weights->Value(ii_minus,jj_index);
Xij = Pij.X();
Yij = Pij.Y();
Zij = Pij.Z();
upper[1] = jj + UD2 + 1;
if (upper[1] > num_poles[0]) upper[1] = num_poles[0];
const gp_Pnt& Pji = Poles .Value(jj_index,ii_index);
- Wji = Weights.Value(jj_index,ii_index);
+ Wji = Weights->Value(jj_index,ii_index);
const gp_Pnt& Pjm = Poles .Value(jj_index,ii_minus);
- Wjm = Weights.Value(jj_index,ii_minus);
+ Wjm = Weights->Value(jj_index,ii_minus);
Xji = Pji.X();
Yji = Pji.Y();
Zji = Pji.Z();
}
else {
UTolerance=VTolerance=0.0;
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout<<"ElSLib.cxx : maxderivative = 0.0 "<<endl;
#endif
}
const Standard_Integer VBSplineDegree,
const TColStd_Array1OfReal& UBSplineKnots,
const TColStd_Array1OfReal& VBSplineKnots,
- const TColStd_Array1OfInteger & UMults,
- const TColStd_Array1OfInteger & VMults,
+ const TColStd_Array1OfInteger * UMults,
+ const TColStd_Array1OfInteger * VMults,
const TColgp_Array2OfPnt& Poles,
- const TColStd_Array2OfReal& Weights,
+ const TColStd_Array2OfReal* Weights,
const TColStd_Array1OfReal& UFlatKnots,
const TColStd_Array1OfReal& VFlatKnots,
const Standard_Integer UNewDegree,