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, |
110 | 1, |
111 | 4, |
112 | myKnotFlatVector, |
113 | 0.0, |
114 | index, |
115 | BSplineBasisDeriv); |
116 | B1prim0=BSplineBasisDeriv(2,2); |
117 | |
118 | BSplCLib::EvalBsplineBasis(1, |
119 | 1, |
120 | 4, |
121 | myKnotFlatVector, |
122 | 1.0, |
123 | index, |
124 | BSplineBasisDeriv); |
125 | Bprelastprim1=BSplineBasisDeriv(2,3); |
126 | |
127 | math_Matrix BSplineBasisValue(1,1,1,4,0.0); |
128 | BSplCLib::EvalBsplineBasis(1, |
129 | 0, |
130 | 4, |
131 | myKnotFlatVector, |
132 | UParameter, |
133 | index, |
134 | BSplineBasisValue); |
135 | |
136 | TColStd_Array1OfReal value(0,5); |
137 | TColStd_Array1OfReal Polesenv(0,5); //poles of a(u,v) |
138 | |
139 | for (i=0;i<=5;i++) |
140 | Polesenv(i)=0.0; |
141 | Polesenv(0)=Duminv; |
142 | Polesenv(1)=Duminv-dDduuminv/B1prim0; |
143 | Polesenv(4)=lambda*lambda*(Dumaxv-dDduumaxv/Bprelastprim1); |
144 | Polesenv(5)=lambda*lambda*Dumaxv; |
145 | |
146 | if (myKnotFlatVector.Length()==8){ |
147 | value(0)=BSplineBasisValue(1,1); //values of the basic functions |
148 | value(1)=BSplineBasisValue(1,2); |
149 | value(2)=0.0; |
150 | value(3)=0.0; |
151 | value(4)=BSplineBasisValue(1,3); |
152 | value(5)=BSplineBasisValue(1,4); |
153 | } |
154 | if (myKnotFlatVector.Length()==9){ |
155 | if (index==1){ |
156 | value(0)=BSplineBasisValue(1,1); |
157 | value(1)=BSplineBasisValue(1,2); |
158 | value(2)=BSplineBasisValue(1,3); |
159 | value(3)=0.0; |
160 | value(4)=BSplineBasisValue(1,4); |
161 | value(5)=0.0; |
162 | } |
163 | else{ |
164 | value(0)=0.0; |
165 | value(1)=BSplineBasisValue(1,1); |
166 | value(2)=BSplineBasisValue(1,2); |
167 | value(3)=0.0; |
168 | value(4)=BSplineBasisValue(1,3); |
169 | value(5)=BSplineBasisValue(1,4); |
170 | } |
171 | Polesenv(2)=(0.5*(Polesenv(0)+Polesenv(5))); |
172 | } |
173 | if (myKnotFlatVector.Length()==10){ |
174 | if (index==1){ |
175 | value(0)=BSplineBasisValue(1,1); |
176 | value(1)=BSplineBasisValue(1,2); |
177 | value(2)=BSplineBasisValue(1,3); |
178 | value(3)=BSplineBasisValue(1,4); |
179 | value(4)=0.0; |
180 | value(5)=0.0; |
181 | } |
182 | if (index==2){ |
183 | value(0)=0.0; |
184 | value(1)=BSplineBasisValue(1,1); |
185 | value(2)=BSplineBasisValue(1,2); |
186 | value(3)=BSplineBasisValue(1,3); |
187 | value(4)=BSplineBasisValue(1,4); |
188 | value(5)=0.0; |
189 | } |
190 | if (index==3){ |
191 | value(0)=0.0; |
192 | value(1)=0.0; |
193 | value(2)=BSplineBasisValue(1,1); |
194 | value(3)=BSplineBasisValue(1,2); |
195 | value(4)=BSplineBasisValue(1,3); |
196 | value(5)=BSplineBasisValue(1,4); |
197 | } |
198 | Polesenv(2)=(0.5*(Polesenv(0)+Polesenv(5))); |
199 | Polesenv(3)=Polesenv(2); |
200 | } |
201 | for (i=0;i<=5;i++) |
202 | Buv+=Polesenv(i)*value(i); |
203 | return Buv; |
204 | } |
205 | |
206 | |
207 | |
208 | |