b311480e |
1 | // Created on: 1997-05-13 |
2 | // Created by: Stagiaire Francois DUMONT |
3 | // Copyright (c) 1997-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
42cf5bc1 |
17 | |
18 | #include <BSplSLib.hxx> |
19 | #include <Geom_BSplineSurface.hxx> |
20 | #include <GeomLib_DenominatorMultiplier.hxx> |
7fd59977 |
21 | #include <gp_Pnt.hxx> |
22 | #include <gp_Vec.hxx> |
42cf5bc1 |
23 | #include <math_Matrix.hxx> |
24 | #include <Standard_ConstructionError.hxx> |
25 | #include <Standard_OutOfRange.hxx> |
7fd59977 |
26 | #include <TColgp_Array2OfPnt.hxx> |
7fd59977 |
27 | #include <TColStd_Array1OfInteger.hxx> |
42cf5bc1 |
28 | #include <TColStd_Array1OfReal.hxx> |
29 | #include <TColStd_Array2OfReal.hxx> |
7fd59977 |
30 | |
31 | //======================================================================= |
32 | //function :GeomLib_DenominatorMultiplier |
33 | //purpose : |
34 | //======================================================================= |
7fd59977 |
35 | GeomLib_DenominatorMultiplier::GeomLib_DenominatorMultiplier |
36 | (const Handle(Geom_BSplineSurface) & Surface, |
37 | const TColStd_Array1OfReal & KnotVector):mySurface(Surface), |
38 | myKnotFlatVector(1,KnotVector.Length()) |
39 | {Standard_Integer i; |
40 | for (i=1;i<=KnotVector.Length();i++) |
41 | myKnotFlatVector.SetValue(i,KnotVector(i)); |
42 | } |
43 | |
44 | //======================================================================= |
45 | //function : value |
46 | //purpose : give the value of a(UParameter,VParameter) |
47 | //======================================================================= |
48 | |
49 | Standard_Real GeomLib_DenominatorMultiplier::Value(const Standard_Real UParameter, |
50 | const Standard_Real VParameter)const |
51 | |
52 | {Standard_Real Dumaxv,Duminv,dDduumaxv,dDduuminv, |
53 | Dv,Buv=0.0; |
54 | // gp_Pnt HermPnt; |
55 | gp_Pnt N; |
56 | gp_Vec Nu,Nv; |
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()) ; |
63 | |
64 | TColStd_Array1OfReal surface_v_knots(1,mySurface->NbVKnots()) ; |
65 | TColStd_Array1OfInteger surface_v_mults(1,mySurface->NbVKnots()) ; |
66 | Standard_Integer udegree,vdegree; |
67 | |
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(); |
76 | |
77 | BSplSLib::HomogeneousD1(mySurface->UKnot(mySurface->LastUKnotIndex()),VParameter, |
78 | 0,0, |
79 | surface_poles, |
0e14656b |
80 | &surface_weights, |
7fd59977 |
81 | surface_u_knots,surface_v_knots, |
0e14656b |
82 | &surface_u_mults,&surface_v_mults, |
7fd59977 |
83 | udegree,vdegree, |
84 | mySurface->IsURational(),mySurface->IsVRational(), |
85 | mySurface->IsUPeriodic(),mySurface->IsVPeriodic(), |
86 | N,Nu,Nv, |
87 | Dumaxv, |
88 | dDduumaxv, |
89 | Dv); |
90 | BSplSLib::HomogeneousD1(mySurface->UKnot(1),VParameter, |
91 | 0,0, |
92 | surface_poles, |
0e14656b |
93 | &surface_weights, |
7fd59977 |
94 | surface_u_knots,surface_v_knots, |
0e14656b |
95 | &surface_u_mults,&surface_v_mults, |
7fd59977 |
96 | udegree,vdegree, |
97 | mySurface->IsURational(),mySurface->IsVRational(), |
98 | mySurface->IsUPeriodic(),mySurface->IsVPeriodic(), |
99 | N,Nu,Nv, |
100 | Duminv, |
101 | dDduuminv, |
102 | Dv); |
103 | |
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; |
108 | |
109 | BSplCLib::EvalBsplineBasis(1, |
7fd59977 |
110 | 4, |
111 | myKnotFlatVector, |
112 | 0.0, |
113 | index, |
114 | BSplineBasisDeriv); |
115 | B1prim0=BSplineBasisDeriv(2,2); |
116 | |
117 | BSplCLib::EvalBsplineBasis(1, |
7fd59977 |
118 | 4, |
119 | myKnotFlatVector, |
120 | 1.0, |
121 | index, |
122 | BSplineBasisDeriv); |
123 | Bprelastprim1=BSplineBasisDeriv(2,3); |
124 | |
125 | math_Matrix BSplineBasisValue(1,1,1,4,0.0); |
6143f12f |
126 | BSplCLib::EvalBsplineBasis(0, |
7fd59977 |
127 | 4, |
128 | myKnotFlatVector, |
129 | UParameter, |
130 | index, |
131 | BSplineBasisValue); |
132 | |
133 | TColStd_Array1OfReal value(0,5); |
134 | TColStd_Array1OfReal Polesenv(0,5); //poles of a(u,v) |
135 | |
136 | for (i=0;i<=5;i++) |
137 | Polesenv(i)=0.0; |
138 | Polesenv(0)=Duminv; |
139 | Polesenv(1)=Duminv-dDduuminv/B1prim0; |
140 | Polesenv(4)=lambda*lambda*(Dumaxv-dDduumaxv/Bprelastprim1); |
141 | Polesenv(5)=lambda*lambda*Dumaxv; |
142 | |
143 | if (myKnotFlatVector.Length()==8){ |
144 | value(0)=BSplineBasisValue(1,1); //values of the basic functions |
145 | value(1)=BSplineBasisValue(1,2); |
146 | value(2)=0.0; |
147 | value(3)=0.0; |
148 | value(4)=BSplineBasisValue(1,3); |
149 | value(5)=BSplineBasisValue(1,4); |
150 | } |
151 | if (myKnotFlatVector.Length()==9){ |
152 | if (index==1){ |
153 | value(0)=BSplineBasisValue(1,1); |
154 | value(1)=BSplineBasisValue(1,2); |
155 | value(2)=BSplineBasisValue(1,3); |
156 | value(3)=0.0; |
157 | value(4)=BSplineBasisValue(1,4); |
158 | value(5)=0.0; |
159 | } |
160 | else{ |
161 | value(0)=0.0; |
162 | value(1)=BSplineBasisValue(1,1); |
163 | value(2)=BSplineBasisValue(1,2); |
164 | value(3)=0.0; |
165 | value(4)=BSplineBasisValue(1,3); |
166 | value(5)=BSplineBasisValue(1,4); |
167 | } |
168 | Polesenv(2)=(0.5*(Polesenv(0)+Polesenv(5))); |
169 | } |
170 | if (myKnotFlatVector.Length()==10){ |
171 | if (index==1){ |
172 | value(0)=BSplineBasisValue(1,1); |
173 | value(1)=BSplineBasisValue(1,2); |
174 | value(2)=BSplineBasisValue(1,3); |
175 | value(3)=BSplineBasisValue(1,4); |
176 | value(4)=0.0; |
177 | value(5)=0.0; |
178 | } |
179 | if (index==2){ |
180 | value(0)=0.0; |
181 | value(1)=BSplineBasisValue(1,1); |
182 | value(2)=BSplineBasisValue(1,2); |
183 | value(3)=BSplineBasisValue(1,3); |
184 | value(4)=BSplineBasisValue(1,4); |
185 | value(5)=0.0; |
186 | } |
187 | if (index==3){ |
188 | value(0)=0.0; |
189 | value(1)=0.0; |
190 | value(2)=BSplineBasisValue(1,1); |
191 | value(3)=BSplineBasisValue(1,2); |
192 | value(4)=BSplineBasisValue(1,3); |
193 | value(5)=BSplineBasisValue(1,4); |
194 | } |
195 | Polesenv(2)=(0.5*(Polesenv(0)+Polesenv(5))); |
196 | Polesenv(3)=Polesenv(2); |
197 | } |
198 | for (i=0;i<=5;i++) |
199 | Buv+=Polesenv(i)*value(i); |
200 | return Buv; |
201 | } |
202 | |
203 | |
204 | |
205 | |