1 // Created on: 1997-05-13
2 // Created by: Stagiaire Francois DUMONT
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <BSplSLib.hxx>
19 #include <Geom_BSplineSurface.hxx>
20 #include <GeomLib_DenominatorMultiplier.hxx>
23 #include <math_Matrix.hxx>
24 #include <Standard_ConstructionError.hxx>
25 #include <Standard_OutOfRange.hxx>
26 #include <TColgp_Array2OfPnt.hxx>
27 #include <TColStd_Array1OfInteger.hxx>
28 #include <TColStd_Array1OfReal.hxx>
29 #include <TColStd_Array2OfReal.hxx>
31 //=======================================================================
32 //function :GeomLib_DenominatorMultiplier
34 //=======================================================================
35 GeomLib_DenominatorMultiplier::GeomLib_DenominatorMultiplier
36 (const Handle(Geom_BSplineSurface) & Surface,
37 const TColStd_Array1OfReal & KnotVector):mySurface(Surface),
38 myKnotFlatVector(1,KnotVector.Length())
40 for (i=1;i<=KnotVector.Length();i++)
41 myKnotFlatVector.SetValue(i,KnotVector(i));
44 //=======================================================================
46 //purpose : give the value of a(UParameter,VParameter)
47 //=======================================================================
49 Standard_Real GeomLib_DenominatorMultiplier::Value(const Standard_Real UParameter,
50 const Standard_Real VParameter)const
52 {Standard_Real Dumaxv,Duminv,dDduumaxv,dDduuminv,
57 TColgp_Array2OfPnt surface_poles(1,mySurface->NbUPoles(),
58 1,mySurface->NbVPoles()) ;
59 TColStd_Array2OfReal surface_weights(1,mySurface->NbUPoles(),
60 1,mySurface->NbVPoles()) ;
61 TColStd_Array1OfReal surface_u_knots(1,mySurface->NbUKnots()) ;
62 TColStd_Array1OfInteger surface_u_mults(1,mySurface->NbUKnots()) ;
64 TColStd_Array1OfReal surface_v_knots(1,mySurface->NbVKnots()) ;
65 TColStd_Array1OfInteger surface_v_mults(1,mySurface->NbVKnots()) ;
66 Standard_Integer udegree,vdegree;
68 mySurface->UKnots(surface_u_knots) ;
69 mySurface->UMultiplicities(surface_u_mults) ;
70 mySurface->Poles(surface_poles) ;
71 mySurface->Weights(surface_weights) ;
72 mySurface->VKnots(surface_v_knots) ;
73 mySurface->VMultiplicities(surface_v_mults) ;
74 udegree=mySurface->UDegree();
75 vdegree=mySurface->VDegree();
77 BSplSLib::HomogeneousD1(mySurface->UKnot(mySurface->LastUKnotIndex()),VParameter,
81 surface_u_knots,surface_v_knots,
82 &surface_u_mults,&surface_v_mults,
84 mySurface->IsURational(),mySurface->IsVRational(),
85 mySurface->IsUPeriodic(),mySurface->IsVPeriodic(),
90 BSplSLib::HomogeneousD1(mySurface->UKnot(1),VParameter,
94 surface_u_knots,surface_v_knots,
95 &surface_u_mults,&surface_v_mults,
97 mySurface->IsURational(),mySurface->IsVRational(),
98 mySurface->IsUPeriodic(),mySurface->IsVPeriodic(),
104 math_Matrix BSplineBasisDeriv(1,2,1,4,0.0);
105 Standard_Real B1prim0,Bprelastprim1,
106 lambda=(mySurface->Weight(1,1)/mySurface->Weight(mySurface->NbUPoles(),1));
107 Standard_Integer index,i;
109 BSplCLib::EvalBsplineBasis(1,
116 B1prim0=BSplineBasisDeriv(2,2);
118 BSplCLib::EvalBsplineBasis(1,
125 Bprelastprim1=BSplineBasisDeriv(2,3);
127 math_Matrix BSplineBasisValue(1,1,1,4,0.0);
128 BSplCLib::EvalBsplineBasis(1,
136 TColStd_Array1OfReal value(0,5);
137 TColStd_Array1OfReal Polesenv(0,5); //poles of a(u,v)
142 Polesenv(1)=Duminv-dDduuminv/B1prim0;
143 Polesenv(4)=lambda*lambda*(Dumaxv-dDduumaxv/Bprelastprim1);
144 Polesenv(5)=lambda*lambda*Dumaxv;
146 if (myKnotFlatVector.Length()==8){
147 value(0)=BSplineBasisValue(1,1); //values of the basic functions
148 value(1)=BSplineBasisValue(1,2);
151 value(4)=BSplineBasisValue(1,3);
152 value(5)=BSplineBasisValue(1,4);
154 if (myKnotFlatVector.Length()==9){
156 value(0)=BSplineBasisValue(1,1);
157 value(1)=BSplineBasisValue(1,2);
158 value(2)=BSplineBasisValue(1,3);
160 value(4)=BSplineBasisValue(1,4);
165 value(1)=BSplineBasisValue(1,1);
166 value(2)=BSplineBasisValue(1,2);
168 value(4)=BSplineBasisValue(1,3);
169 value(5)=BSplineBasisValue(1,4);
171 Polesenv(2)=(0.5*(Polesenv(0)+Polesenv(5)));
173 if (myKnotFlatVector.Length()==10){
175 value(0)=BSplineBasisValue(1,1);
176 value(1)=BSplineBasisValue(1,2);
177 value(2)=BSplineBasisValue(1,3);
178 value(3)=BSplineBasisValue(1,4);
184 value(1)=BSplineBasisValue(1,1);
185 value(2)=BSplineBasisValue(1,2);
186 value(3)=BSplineBasisValue(1,3);
187 value(4)=BSplineBasisValue(1,4);
193 value(2)=BSplineBasisValue(1,1);
194 value(3)=BSplineBasisValue(1,2);
195 value(4)=BSplineBasisValue(1,3);
196 value(5)=BSplineBasisValue(1,4);
198 Polesenv(2)=(0.5*(Polesenv(0)+Polesenv(5)));
199 Polesenv(3)=Polesenv(2);
202 Buv+=Polesenv(i)*value(i);