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,
115 B1prim0=BSplineBasisDeriv(2,2);
117 BSplCLib::EvalBsplineBasis(1,
123 Bprelastprim1=BSplineBasisDeriv(2,3);
125 math_Matrix BSplineBasisValue(1,1,1,4,0.0);
126 BSplCLib::EvalBsplineBasis(0,
133 TColStd_Array1OfReal value(0,5);
134 TColStd_Array1OfReal Polesenv(0,5); //poles of a(u,v)
139 Polesenv(1)=Duminv-dDduuminv/B1prim0;
140 Polesenv(4)=lambda*lambda*(Dumaxv-dDduumaxv/Bprelastprim1);
141 Polesenv(5)=lambda*lambda*Dumaxv;
143 if (myKnotFlatVector.Length()==8){
144 value(0)=BSplineBasisValue(1,1); //values of the basic functions
145 value(1)=BSplineBasisValue(1,2);
148 value(4)=BSplineBasisValue(1,3);
149 value(5)=BSplineBasisValue(1,4);
151 if (myKnotFlatVector.Length()==9){
153 value(0)=BSplineBasisValue(1,1);
154 value(1)=BSplineBasisValue(1,2);
155 value(2)=BSplineBasisValue(1,3);
157 value(4)=BSplineBasisValue(1,4);
162 value(1)=BSplineBasisValue(1,1);
163 value(2)=BSplineBasisValue(1,2);
165 value(4)=BSplineBasisValue(1,3);
166 value(5)=BSplineBasisValue(1,4);
168 Polesenv(2)=(0.5*(Polesenv(0)+Polesenv(5)));
170 if (myKnotFlatVector.Length()==10){
172 value(0)=BSplineBasisValue(1,1);
173 value(1)=BSplineBasisValue(1,2);
174 value(2)=BSplineBasisValue(1,3);
175 value(3)=BSplineBasisValue(1,4);
181 value(1)=BSplineBasisValue(1,1);
182 value(2)=BSplineBasisValue(1,2);
183 value(3)=BSplineBasisValue(1,3);
184 value(4)=BSplineBasisValue(1,4);
190 value(2)=BSplineBasisValue(1,1);
191 value(3)=BSplineBasisValue(1,2);
192 value(4)=BSplineBasisValue(1,3);
193 value(5)=BSplineBasisValue(1,4);
195 Polesenv(2)=(0.5*(Polesenv(0)+Polesenv(5)));
196 Polesenv(3)=Polesenv(2);
199 Buv+=Polesenv(i)*value(i);