b311480e |
1 | // Created by: CKY / Contract Toubro-Larsen |
2 | // Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
3 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
7fd59977 |
6 | // |
d5f74e42 |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
7fd59977 |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
b311480e |
15 | |
16 | //-------------------------------------------------------------------- |
7fd59977 |
17 | //-------------------------------------------------------------------- |
18 | |
7fd59977 |
19 | #include <gp_GTrsf.hxx> |
42cf5bc1 |
20 | #include <gp_Pnt.hxx> |
21 | #include <IGESGeom_BSplineSurface.hxx> |
22 | #include <Standard_DimensionMismatch.hxx> |
23 | #include <Standard_OutOfRange.hxx> |
24 | #include <Standard_Type.hxx> |
7fd59977 |
25 | |
92efcf78 |
26 | IMPLEMENT_STANDARD_RTTIEXT(IGESGeom_BSplineSurface,IGESData_IGESEntity) |
27 | |
b311480e |
28 | IGESGeom_BSplineSurface::IGESGeom_BSplineSurface () { } |
7fd59977 |
29 | |
30 | |
31 | void IGESGeom_BSplineSurface::Init |
32 | (const Standard_Integer anIndexU, |
33 | const Standard_Integer anIndexV, const Standard_Integer aDegU, |
34 | const Standard_Integer aDegV, const Standard_Boolean aCloseU, |
35 | const Standard_Boolean aCloseV, const Standard_Boolean aPolynom, |
36 | const Standard_Boolean aPeriodU, const Standard_Boolean aPeriodV, |
37 | const Handle(TColStd_HArray1OfReal)& allKnotsU, |
38 | const Handle(TColStd_HArray1OfReal)& allKnotsV, |
39 | const Handle(TColStd_HArray2OfReal)& allWeights, |
40 | const Handle(TColgp_HArray2OfXYZ)& allPoles, |
41 | const Standard_Real aUmin, const Standard_Real aUmax, |
42 | const Standard_Real aVmin, const Standard_Real aVmax) |
43 | { |
44 | if (allWeights->RowLength() != allPoles->RowLength() || |
45 | allWeights->ColLength() != allPoles->ColLength()) |
9775fa61 |
46 | throw Standard_DimensionMismatch("IGESGeom_BSplineSurface : Init"); |
7fd59977 |
47 | if (allKnotsU->Lower() != -aDegU || allKnotsV->Lower() != -aDegV || |
48 | allKnotsU->Upper() != anIndexU+1 || allKnotsV->Upper() != anIndexV+1 || |
49 | allWeights->LowerRow() != 0 || allWeights->LowerCol() != 0 || |
50 | allPoles->LowerRow() != 0 || allPoles->LowerCol() != 0 || |
51 | allPoles->UpperRow() != anIndexU || allPoles->UpperCol() != anIndexV) |
9775fa61 |
52 | throw Standard_DimensionMismatch("IGESGeom_BSplineSurface : Init"); |
7fd59977 |
53 | |
54 | theIndexU = anIndexU; |
55 | theIndexV = anIndexV; |
56 | theDegreeU = aDegU; |
57 | theDegreeV = aDegV; |
58 | isClosedU = aCloseU; |
59 | isClosedV = aCloseV; |
60 | isPolynomial = aPolynom; |
61 | isPeriodicU = aPeriodU; |
62 | isPeriodicV = aPeriodV; |
63 | theKnotsU = allKnotsU; |
64 | theKnotsV = allKnotsV; |
65 | theWeights = allWeights; |
66 | thePoles = allPoles; |
67 | theUmin = aUmin; |
68 | theUmax = aUmax; |
69 | theVmin = aVmin; |
70 | theVmax = aVmax; |
71 | InitTypeAndForm(128,FormNumber()); |
72 | // FormNumber precises the shape 0-9 |
73 | } |
74 | |
75 | void IGESGeom_BSplineSurface::SetFormNumber (const Standard_Integer form) |
76 | { |
9775fa61 |
77 | if (form < 0 || form > 9) throw Standard_OutOfRange("IGESGeom_BSplineSurface : SetFormNumber"); |
7fd59977 |
78 | InitTypeAndForm(128,form); |
79 | } |
80 | |
81 | Standard_Integer IGESGeom_BSplineSurface::UpperIndexU () const |
82 | { |
83 | return theIndexU; |
84 | } |
85 | |
86 | Standard_Integer IGESGeom_BSplineSurface::UpperIndexV () const |
87 | { |
88 | return theIndexV; |
89 | } |
90 | |
91 | Standard_Integer IGESGeom_BSplineSurface::DegreeU () const |
92 | { |
93 | return theDegreeU; |
94 | } |
95 | |
96 | Standard_Integer IGESGeom_BSplineSurface::DegreeV () const |
97 | { |
98 | return theDegreeV; |
99 | } |
100 | |
101 | Standard_Boolean IGESGeom_BSplineSurface::IsClosedU () const |
102 | { |
103 | return isClosedU; |
104 | } |
105 | |
106 | Standard_Boolean IGESGeom_BSplineSurface::IsClosedV () const |
107 | { |
108 | return isClosedV; |
109 | } |
110 | |
111 | Standard_Boolean IGESGeom_BSplineSurface::IsPolynomial |
112 | (const Standard_Boolean flag) const |
113 | { |
114 | if (flag) return isPolynomial; |
115 | Standard_Integer i,j; |
116 | Standard_Real w0 = theWeights->Value(0,0); |
fa920fb1 |
117 | /*CR23377 |
118 | * Following fix is needed to address Rational surface with non-unitary weights at last index |
119 | * Limit for indices are changed from theIndexV-->theIndexV+1 (=NbPolesV()) |
120 | * theIndexU--> theIndexU+1 (=NbPolesU()) |
121 | */ |
122 | for ( j = 0; j < (theIndexV+1); j ++) |
123 | for (i = 0; i < (theIndexU+1); i ++) |
7fd59977 |
124 | if (Abs(theWeights->Value(i,j) - w0) > 1.e-10) return Standard_False; |
125 | return Standard_True; |
126 | } |
127 | |
128 | Standard_Boolean IGESGeom_BSplineSurface::IsPeriodicU () const |
129 | { |
130 | return isPeriodicU; |
131 | } |
132 | |
133 | Standard_Boolean IGESGeom_BSplineSurface::IsPeriodicV () const |
134 | { |
135 | return isPeriodicV; |
136 | } |
137 | |
138 | Standard_Integer IGESGeom_BSplineSurface::NbKnotsU () const |
139 | { |
140 | return theKnotsU->Length(); |
141 | } |
142 | |
143 | Standard_Integer IGESGeom_BSplineSurface::NbKnotsV () const |
144 | { |
145 | return theKnotsV->Length(); |
146 | } |
147 | |
148 | Standard_Real IGESGeom_BSplineSurface::KnotU |
149 | (const Standard_Integer anIndex) const |
150 | { |
151 | return theKnotsU->Value(anIndex); |
152 | } |
153 | |
154 | Standard_Real IGESGeom_BSplineSurface::KnotV |
155 | (const Standard_Integer anIndex) const |
156 | { |
157 | return theKnotsV->Value(anIndex); |
158 | } |
159 | |
160 | Standard_Integer IGESGeom_BSplineSurface::NbPolesU () const |
161 | { |
162 | return theIndexU+1; |
163 | } |
164 | |
165 | Standard_Integer IGESGeom_BSplineSurface::NbPolesV () const |
166 | { |
167 | return theIndexV+1; |
168 | } |
169 | |
170 | Standard_Real IGESGeom_BSplineSurface::Weight |
171 | (const Standard_Integer anIndex1, const Standard_Integer anIndex2) const |
172 | { |
173 | return theWeights->Value(anIndex1, anIndex2); |
174 | } |
175 | |
176 | gp_Pnt IGESGeom_BSplineSurface::Pole |
177 | (const Standard_Integer anIndex1, const Standard_Integer anIndex2) const |
178 | { |
179 | gp_XYZ tempXYZ = thePoles->Value(anIndex1,anIndex2); |
180 | // Reversal of the order of indices since the poles are |
181 | // stored in the array like that. See ReadOwnParams() |
182 | gp_Pnt Pole(tempXYZ); |
183 | return Pole; |
184 | } |
185 | |
186 | gp_Pnt IGESGeom_BSplineSurface::TransformedPole |
187 | (const Standard_Integer anIndex1, const Standard_Integer anIndex2) const |
188 | { |
189 | gp_XYZ tempXYZ = thePoles->Value(anIndex1, anIndex2); |
190 | // Reversal of the order of indices since the poles are |
191 | // stored in the array like that. See ReadOwnParams() |
192 | if (HasTransf()) Location().Transforms(tempXYZ); |
193 | gp_Pnt Pole(tempXYZ); |
194 | return Pole; |
195 | } |
196 | |
197 | Standard_Real IGESGeom_BSplineSurface::UMin () const |
198 | { |
199 | return theUmin; |
200 | } |
201 | |
202 | Standard_Real IGESGeom_BSplineSurface::UMax () const |
203 | { |
204 | return theUmax; |
205 | } |
206 | |
207 | Standard_Real IGESGeom_BSplineSurface::VMin () const |
208 | { |
209 | return theVmin; |
210 | } |
211 | |
212 | Standard_Real IGESGeom_BSplineSurface::VMax () const |
213 | { |
214 | return theVmax; |
215 | } |