1 // Created on: 1993-09-28
2 // Created by: Bruno DUMORTIER
3 // Copyright (c) 1993-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 <GeomFill_Curved.hxx>
21 #include <Standard_NotImplemented.hxx>
22 #include <TColgp_HArray2OfPnt.hxx>
23 #include <TColStd_Array1OfReal.hxx>
24 #include <TColStd_HArray2OfReal.hxx>
26 //=======================================================================
27 //function : GeomFill_Curved
29 //=======================================================================
30 GeomFill_Curved::GeomFill_Curved()
35 //=======================================================================
36 //function : GeomFill_Curved
38 //=======================================================================
40 GeomFill_Curved::GeomFill_Curved(const TColgp_Array1OfPnt& P1,
41 const TColgp_Array1OfPnt& P2,
42 const TColgp_Array1OfPnt& P3,
43 const TColgp_Array1OfPnt& P4)
49 //=======================================================================
50 //function : GeomFill_Curved
52 //=======================================================================
54 GeomFill_Curved::GeomFill_Curved(const TColgp_Array1OfPnt& P1,
55 const TColgp_Array1OfPnt& P2,
56 const TColgp_Array1OfPnt& P3,
57 const TColgp_Array1OfPnt& P4,
58 const TColStd_Array1OfReal& W1,
59 const TColStd_Array1OfReal& W2,
60 const TColStd_Array1OfReal& W3,
61 const TColStd_Array1OfReal& W4)
63 Init(P1, P2, P3, P4, W1, W2, W3, W4);
66 //=======================================================================
67 //function : GeomFill_Curved
69 //=======================================================================
71 GeomFill_Curved::GeomFill_Curved(const TColgp_Array1OfPnt& P1,
72 const TColgp_Array1OfPnt& P2)
78 //=======================================================================
79 //function : GeomFill_Curved
81 //=======================================================================
83 GeomFill_Curved::GeomFill_Curved(const TColgp_Array1OfPnt& P1,
84 const TColgp_Array1OfPnt& P2,
85 const TColStd_Array1OfReal& W1,
86 const TColStd_Array1OfReal& W2)
92 //=======================================================================
95 //=======================================================================
97 void GeomFill_Curved::Init(const TColgp_Array1OfPnt& P1,
98 const TColgp_Array1OfPnt& P2,
99 const TColgp_Array1OfPnt& P3,
100 const TColgp_Array1OfPnt& P4)
102 Standard_DomainError_Raise_if
103 ( P1.Length() != P3.Length() || P2.Length() != P4.Length()," ");
105 Standard_Integer NPolU = P1.Length();
106 Standard_Integer NPolV = P2.Length();
108 IsRational = Standard_False;
110 Standard_Real NU = NPolU - 1;
111 Standard_Real NV = NPolV - 1;
112 myPoles = new TColgp_HArray2OfPnt( 1, NPolU, 1, NPolV);
114 // The boundaries are not modified
115 Standard_Integer i,j,k;
116 for ( i=1; i<=NPolU; i++) {
117 myPoles->SetValue( i, 1 , P1(i));
118 myPoles->SetValue( i, NPolV, P3(i));
120 Standard_Real PU,PU1,PV,PV1;
122 for ( j=2; j<=NPolV-1; j++) {
127 myPoles->SetValue( 1 , j, P4(j));
128 myPoles->SetValue( NPolU, j, P2(j));
130 for ( i=2; i<=NPolU-1; i++) {
136 for (k=1; k<=3; k++) {
138 PV1 * P1(i).Coord(k) + PV * P3(i).Coord(k) +
139 PU * P2(j).Coord(k) + PU1 * P4(j).Coord(k) );
141 myPoles->SetValue(i,j,P);
147 //=======================================================================
150 //=======================================================================
152 void GeomFill_Curved::Init(const TColgp_Array1OfPnt& P1,
153 const TColgp_Array1OfPnt& P2,
154 const TColgp_Array1OfPnt& P3,
155 const TColgp_Array1OfPnt& P4,
156 const TColStd_Array1OfReal& W1,
157 const TColStd_Array1OfReal& W2,
158 const TColStd_Array1OfReal& W3,
159 const TColStd_Array1OfReal& W4)
161 Standard_DomainError_Raise_if
162 ( W1.Length() != W3.Length() || W2.Length() != W4.Length()," ");
163 Standard_DomainError_Raise_if
164 ( W1.Length() != P1.Length() ||
165 W2.Length() != P2.Length() ||
166 W3.Length() != P3.Length() ||
167 W4.Length() != P4.Length() , " ");
170 IsRational = Standard_True;
172 Standard_Integer NPolU = W1.Length();
173 Standard_Integer NPolV = W2.Length();
175 Standard_Real NU = NPolU - 1;
176 Standard_Real NV = NPolV - 1;
177 myWeights = new TColStd_HArray2OfReal( 1, NPolU, 1, NPolV);
179 // The boundaries are not modified
180 Standard_Integer i,j;
181 for ( i=1; i<=NPolU; i++) {
182 myWeights->SetValue( i, 1 , W1(i));
183 myWeights->SetValue( i, NPolV, W3(i));
185 Standard_Real PU,PU1,PV,PV1;
187 for ( j=2; j<=NPolV-1; j++) {
192 myWeights->SetValue( 1 , j, W4(j));
193 myWeights->SetValue( NPolU, j, W2(j));
195 for ( i=2; i<=NPolU-1; i++) {
200 Standard_Real W = PV1 * W1(i) + PV * W3(i) +
201 PU * W2(j) + PU1 * W4(j) ;
202 myWeights->SetValue(i,j,W);
208 //=======================================================================
211 //=======================================================================
213 void GeomFill_Curved::Init(const TColgp_Array1OfPnt& P1,
214 const TColgp_Array1OfPnt& P2)
216 Standard_Integer NPolU = P1.Length();
217 Standard_Integer NPolV = P2.Length();
219 IsRational = Standard_False;
221 myPoles = new TColgp_HArray2OfPnt( 1, NPolU, 1, NPolV);
223 Standard_Integer i,j;
225 for ( j=1; j<=NPolV; j++) {
226 gp_Vec Tra(P2(1),P2(j));
227 for ( i=1; i<=NPolU; i++) {
228 myPoles->SetValue( i, j, P1(i).Translated(Tra));
234 //=======================================================================
237 //=======================================================================
239 void GeomFill_Curved::Init(const TColgp_Array1OfPnt& P1,
240 const TColgp_Array1OfPnt& P2,
241 const TColStd_Array1OfReal& W1,
242 const TColStd_Array1OfReal& W2)
245 IsRational = Standard_True;
247 //Initialisation des poids.
248 Standard_Integer NPolU = W1.Length();
249 Standard_Integer NPolV = W2.Length();
251 myWeights = new TColStd_HArray2OfReal( 1, NPolU, 1, NPolV);
252 for (Standard_Integer j=1; j<=NPolV; j++) {
253 Standard_Real Factor = W2(j)/W1(1);
254 for (Standard_Integer i=1; i<=NPolU; i++) {
255 myWeights->SetValue(i,j,W1(i)*Factor);