b311480e |
1 | // Created on: 1998-03-16 |
2 | // Created by: Pierre BARRAS |
3 | // Copyright (c) 1998-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | // gka 30.04.99 S4137: extended for all types of surfaces |
22 | |
23 | #include <ShapeUpgrade_SplitSurface.ixx> |
24 | #include <ShapeUpgrade.hxx> |
25 | #include <Geom_BSplineSurface.hxx> |
26 | #include <Geom_RectangularTrimmedSurface.hxx> |
27 | #include <TColGeom_HArray2OfSurface.hxx> |
28 | #include <TColStd_HSequenceOfReal.hxx> |
29 | #include <Precision.hxx> |
30 | #include <Geom_SurfaceOfRevolution.hxx> |
31 | #include <Geom_SurfaceOfLinearExtrusion.hxx> |
32 | #include <Geom_RectangularTrimmedSurface.hxx> |
33 | #include <Geom_OffsetSurface.hxx> |
34 | #include <ShapeUpgrade_SplitCurve3d.hxx> |
35 | #include <TColGeom_HArray1OfCurve.hxx> |
36 | #include <gp_Ax1.hxx> |
37 | #include <Standard_ErrorHandler.hxx> |
38 | #include <Standard_Failure.hxx> |
39 | #include <ShapeExtend.hxx> |
40 | #include <Geom_BezierSurface.hxx> |
41 | #include <TColStd_Array1OfReal.hxx> |
42 | |
43 | //======================================================================= |
44 | //function : ShapeUpgrade_SplitSurface |
45 | //purpose : |
46 | //======================================================================= |
47 | |
48 | ShapeUpgrade_SplitSurface::ShapeUpgrade_SplitSurface() : myStatus(0) |
49 | { |
50 | } |
51 | |
52 | //======================================================================= |
53 | //function : Init |
54 | //purpose : |
55 | //======================================================================= |
56 | |
57 | void ShapeUpgrade_SplitSurface::Init(const Handle(Geom_Surface)& S) |
58 | { |
59 | myStatus = ShapeExtend::EncodeStatus (ShapeExtend_OK); |
60 | |
61 | myUSplitValues = new TColStd_HSequenceOfReal(); |
62 | myVSplitValues = new TColStd_HSequenceOfReal(); |
63 | mySurface = S; |
64 | myResSurfaces = new ShapeExtend_CompositeSurface(); |
65 | myNbResultingRow =1; |
66 | myNbResultingCol =1; |
67 | Standard_Real U1,U2,V1,V2; |
68 | mySurface->Bounds(U1,U2,V1,V2); |
69 | |
70 | myUSplitValues->Append(U1); |
71 | myUSplitValues->Append(U2); |
72 | |
73 | myVSplitValues->Append(V1); |
74 | myVSplitValues->Append(V2); |
75 | } |
76 | |
77 | //======================================================================= |
78 | //function : Init |
79 | //purpose : |
80 | //======================================================================= |
81 | |
82 | void ShapeUpgrade_SplitSurface::Init(const Handle(Geom_Surface)& S, const Standard_Real UFirst,const Standard_Real ULast, |
83 | const Standard_Real VFirst, const Standard_Real VLast) |
84 | { |
85 | myStatus = ShapeExtend::EncodeStatus (ShapeExtend_OK); |
86 | |
87 | mySurface = S; |
88 | myResSurfaces = new ShapeExtend_CompositeSurface(); |
89 | myUSplitValues = new TColStd_HSequenceOfReal(); |
90 | myVSplitValues = new TColStd_HSequenceOfReal(); |
91 | |
92 | myNbResultingRow =1; |
93 | myNbResultingCol =1; |
94 | |
95 | Standard_Real U1,U2,V1,V2; |
96 | mySurface->Bounds(U1,U2,V1,V2); |
97 | Standard_Real precision = Precision::PConfusion(); |
98 | if ( mySurface->IsUPeriodic() && |
99 | ULast - UFirst <= U2 - U1 + precision ) { U1 = UFirst; U2 = U1 + mySurface->UPeriod(); } |
100 | if ( mySurface->IsVPeriodic() && |
101 | VLast - VFirst <= V2 - V1 + precision ) { V1 = VFirst; V2 = V1 + mySurface->VPeriod(); } |
102 | Standard_Real UF,UL,VF,VL; |
103 | if( UFirst > U2-precision || |
104 | ULast < U1-precision ) { |
105 | UF =U1; UL = U2; |
106 | } |
107 | else { |
108 | UF = Max(U1,UFirst); |
109 | UL = Min(U2,ULast); |
110 | } |
111 | if( VFirst > V2-precision || |
112 | VLast < V1-precision ) { |
113 | VF =V1; VL = V2; |
114 | } |
115 | else { |
116 | VF = Max(V1,VFirst); |
117 | VL = Min(V2,VLast); |
118 | } |
119 | |
120 | if(UL-UF < precision) { |
121 | Standard_Real p2 = precision/2.; |
122 | UF-= p2; |
123 | UL+= p2; |
124 | } |
125 | if(VL-VF < precision) { |
126 | Standard_Real p2 = precision/2.; |
127 | VF-= p2; |
128 | VL+= p2; |
129 | } |
130 | |
131 | myUSplitValues->Append(UF); |
132 | myUSplitValues->Append(UL); |
133 | myVSplitValues->Append(VF); |
134 | myVSplitValues->Append(VL); |
135 | } |
136 | |
137 | //======================================================================= |
138 | //function : SetSplitValues |
139 | //purpose : |
140 | //======================================================================= |
141 | |
142 | void ShapeUpgrade_SplitSurface::SetUSplitValues(const Handle(TColStd_HSequenceOfReal)& UValues) |
143 | { |
144 | if(UValues.IsNull()) return; |
145 | Standard_Real precision = Precision::PConfusion(); |
146 | Standard_Real UFirst = myUSplitValues->Value(1), |
147 | ULast = myUSplitValues->Value(myUSplitValues->Length()); |
148 | Standard_Integer i =1; |
149 | Standard_Integer len = UValues->Length(); |
150 | |
151 | for(Standard_Integer ku =2; ku <= myUSplitValues->Length();ku++) { |
152 | ULast = myUSplitValues->Value(ku); |
153 | for(; i <= len; i++) { |
154 | if( (UFirst + precision) >= UValues->Value(i)) continue; |
155 | if((ULast - precision) <= UValues->Value(i)) break; |
156 | myUSplitValues->InsertBefore(ku++,UValues->Value(i)); |
157 | } |
158 | UFirst = ULast; |
159 | } |
160 | } |
161 | |
162 | //======================================================================= |
163 | //function : SetSplitVValues |
164 | //purpose : |
165 | //======================================================================= |
166 | |
167 | void ShapeUpgrade_SplitSurface::SetVSplitValues(const Handle(TColStd_HSequenceOfReal)& VValues) |
168 | { |
169 | if(VValues.IsNull()) return; |
170 | Standard_Real precision = Precision::PConfusion(); |
171 | Standard_Real VFirst = myVSplitValues->Value(1), |
172 | VLast = myVSplitValues->Value(myVSplitValues->Length()); |
173 | Standard_Integer i =1; |
174 | Standard_Integer len = VValues->Length(); |
175 | for(Standard_Integer kv =2; kv <= myVSplitValues->Length();kv++) { |
176 | VLast = myVSplitValues->Value(kv); |
177 | for(; i <= len; i++) { |
178 | if( (VFirst + precision) >= VValues->Value(i)) continue; |
179 | if((VLast - precision) <= VValues->Value(i)) break; |
180 | myVSplitValues->InsertBefore(kv++,VValues->Value(i)); |
181 | } |
182 | VFirst = VLast; |
183 | } |
184 | } |
185 | |
186 | //======================================================================= |
187 | //function : Build |
188 | //purpose : |
189 | //======================================================================= |
190 | |
191 | void ShapeUpgrade_SplitSurface::Build(const Standard_Boolean Segment) |
192 | { |
193 | |
194 | Standard_Real UFirst = myUSplitValues->Value(1); |
195 | Standard_Real ULast = myUSplitValues->Value(myUSplitValues->Length()); |
196 | Standard_Real VFirst = myVSplitValues->Value(1); |
197 | Standard_Real VLast = myVSplitValues->Value(myVSplitValues->Length()); |
198 | |
199 | if(myUSplitValues->Length() > 2 || myVSplitValues->Length() > 2) |
200 | myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE1); |
201 | |
202 | Standard_Real U1,U2,V1,V2; |
203 | mySurface->Bounds(U1, U2, V1, V2); |
204 | if (mySurface->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) { |
205 | Handle(Geom_SurfaceOfRevolution) Surface = Handle(Geom_SurfaceOfRevolution)::DownCast(mySurface); |
206 | Handle(Geom_Curve) BasCurve = Surface->BasisCurve(); |
207 | ShapeUpgrade_SplitCurve3d spc; |
208 | spc.Init(BasCurve,VFirst,VLast); |
209 | spc.SetSplitValues(myVSplitValues); |
210 | spc.Build(Segment); |
211 | Handle(TColGeom_HArray2OfSurface) Surfaces; |
212 | myNbResultingCol = spc.GetCurves()->Length(); |
213 | if(myUSplitValues->Length()> 2) { |
214 | myNbResultingRow = myUSplitValues->Length() -1; |
215 | Surfaces = new TColGeom_HArray2OfSurface(1, myNbResultingRow,1,myNbResultingCol); |
216 | for(Standard_Integer nc =1; nc <= myNbResultingCol; nc++) { |
217 | Handle(Geom_SurfaceOfRevolution) NewSurfaceRev = |
218 | new Geom_SurfaceOfRevolution(spc.GetCurves()->Value(nc),Surface->Axis()); |
219 | Standard_Real U1p,U2p,V1p,V2p; |
220 | NewSurfaceRev->Bounds(U1p,U2p,V1p,V2p); |
221 | for(Standard_Integer nc1 =1; nc1 <= myNbResultingRow; nc1++) { |
222 | Handle(Geom_RectangularTrimmedSurface) NewSurf = |
223 | new Geom_RectangularTrimmedSurface ( NewSurfaceRev, myUSplitValues->Value(nc1), |
224 | myUSplitValues->Value(nc1+1), V1p, V2p ); |
225 | Surfaces->SetValue(nc1,nc,NewSurf); |
226 | } |
227 | } |
228 | } |
229 | else { |
230 | Surfaces = new TColGeom_HArray2OfSurface(1,1,1,myNbResultingCol); |
231 | |
232 | for(Standard_Integer nc =1; nc <= spc.GetCurves()->Length(); nc++) { |
233 | Handle(Geom_SurfaceOfRevolution) NewSurfaceRev = |
234 | new Geom_SurfaceOfRevolution ( spc.GetCurves()->Value(nc), Surface->Axis() ); |
235 | NewSurfaceRev->Bounds(U1, U2, V1, V2); |
236 | if( UFirst == U1 && ULast == U2) |
237 | Surfaces ->SetValue(1,nc,NewSurfaceRev); |
238 | else { |
239 | Handle(Geom_RectangularTrimmedSurface) NewSurf = new Geom_RectangularTrimmedSurface |
240 | (NewSurfaceRev,UFirst,ULast,V1,V2); //pdn correction for main seq |
241 | Surfaces ->SetValue(1,nc,NewSurf); |
242 | } |
243 | } |
244 | } |
245 | myResSurfaces->Init(Surfaces); |
246 | myResSurfaces->SetUFirstValue ( myUSplitValues->Sequence().First() ); |
247 | myResSurfaces->SetVFirstValue ( myVSplitValues->Sequence().First() ); |
248 | if ( spc.Status ( ShapeExtend_DONE1 ) ) |
249 | myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE1 ); |
250 | if ( spc.Status ( ShapeExtend_DONE2 ) ) |
251 | myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE2 ); |
252 | if ( spc.Status ( ShapeExtend_DONE3 ) ) |
253 | myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE3 ); |
254 | return; |
255 | } |
256 | |
257 | if (mySurface->IsKind(STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion))) { |
258 | Handle(Geom_SurfaceOfLinearExtrusion) Surface = Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(mySurface); |
259 | Handle(Geom_Curve) BasCurve = Surface->BasisCurve(); |
260 | ShapeUpgrade_SplitCurve3d spc; |
261 | spc.Init(BasCurve,UFirst,ULast); |
262 | spc.SetSplitValues(myUSplitValues); |
263 | spc.Build(Segment); |
264 | myNbResultingRow = spc.GetCurves()->Length(); |
265 | Handle(TColGeom_HArray2OfSurface) Surfaces; |
266 | if(myVSplitValues->Length() > 2) { |
267 | myNbResultingCol = myVSplitValues->Length() - 1; |
268 | Surfaces = new TColGeom_HArray2OfSurface(1,myNbResultingRow,1,myNbResultingCol); |
269 | for(Standard_Integer nc1 =1; nc1 <= myNbResultingRow; nc1++) { |
270 | Handle(Geom_SurfaceOfLinearExtrusion) NewSurfaceEx = new Geom_SurfaceOfLinearExtrusion(spc.GetCurves()->Value(nc1), |
271 | Surface->Direction()); |
272 | Standard_Real U1p,U2p,V1p,V2p; |
273 | NewSurfaceEx->Bounds(U1p,U2p,V1p,V2p); |
274 | for(Standard_Integer nc2 =1; nc2 <= myNbResultingCol; nc2++) { |
275 | Handle(Geom_RectangularTrimmedSurface) NewSurf = new Geom_RectangularTrimmedSurface |
276 | (NewSurfaceEx,U1p,U2p,myVSplitValues->Value(nc2),myVSplitValues->Value(nc2+1)); |
277 | Surfaces ->SetValue(nc1,nc2,NewSurf); |
278 | } |
279 | } |
280 | } |
281 | else { |
282 | Surfaces = new TColGeom_HArray2OfSurface(1,myNbResultingRow,1,1); |
283 | |
284 | for(Standard_Integer nc1 =1; nc1 <= myNbResultingRow; nc1++) { |
285 | Handle(Geom_SurfaceOfLinearExtrusion) NewSurfaceEx = new Geom_SurfaceOfLinearExtrusion(spc.GetCurves()->Value(nc1),Surface->Direction()); |
286 | NewSurfaceEx->Bounds(U1,U2,V1,V2); |
287 | if(VFirst == V1 && VLast == V2) |
288 | Surfaces -> SetValue(nc1,1,NewSurfaceEx); |
289 | else { |
290 | Handle(Geom_RectangularTrimmedSurface) NewSurf = new Geom_RectangularTrimmedSurface |
291 | (NewSurfaceEx,Max(U1,UFirst),Min(ULast,U2),Max(VFirst,V1),Min(VLast,V2)); |
292 | Surfaces ->SetValue(nc1,1,NewSurf); |
293 | } |
294 | } |
295 | } |
296 | myResSurfaces->Init(Surfaces); |
297 | myResSurfaces->SetUFirstValue ( myUSplitValues->Sequence().First() ); |
298 | myResSurfaces->SetVFirstValue ( myVSplitValues->Sequence().First() ); |
299 | if ( spc.Status ( ShapeExtend_DONE1 ) ) |
300 | myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE1 ); |
301 | if ( spc.Status ( ShapeExtend_DONE2 ) ) |
302 | myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE2 ); |
303 | if ( spc.Status ( ShapeExtend_DONE3 ) ) |
304 | myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE3 ); |
305 | return; |
306 | } |
307 | |
308 | if (mySurface->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) { |
309 | Handle(Geom_RectangularTrimmedSurface) tmp = Handle(Geom_RectangularTrimmedSurface)::DownCast (mySurface); |
310 | Handle(Geom_Surface) theSurf = tmp->BasisSurface(); |
311 | ShapeUpgrade_SplitSurface sps; |
312 | sps.Init(theSurf,UFirst,ULast,VFirst,VLast); |
313 | sps.SetUSplitValues(myUSplitValues); |
314 | sps.SetVSplitValues(myVSplitValues); |
315 | sps.myStatus = myStatus; |
316 | sps.Build(Segment); |
317 | myStatus |= sps.myStatus; |
318 | myResSurfaces = sps.myResSurfaces; |
319 | return; |
320 | } |
321 | else if (mySurface->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) { |
322 | Handle(Geom_OffsetSurface) tmp = Handle(Geom_OffsetSurface)::DownCast (mySurface); |
323 | Handle(Geom_Surface) theSurf = tmp->BasisSurface(); |
324 | ShapeUpgrade_SplitSurface sps; |
325 | sps.Init(theSurf,UFirst,ULast,VFirst,VLast); |
326 | sps.SetUSplitValues(myUSplitValues); |
327 | sps.SetVSplitValues(myVSplitValues); |
328 | sps.myStatus = myStatus; |
329 | sps.Build(Segment); |
330 | Handle(TColGeom_HArray2OfSurface) Patches = new TColGeom_HArray2OfSurface |
331 | (1,sps.ResSurfaces()->NbUPatches(),1,sps.ResSurfaces()->NbVPatches()); |
332 | for(Standard_Integer i1 = 1; i1 <= sps.ResSurfaces()->NbUPatches(); i1++) { |
333 | for(Standard_Integer j1 = 1 ; j1 <= sps.ResSurfaces()->NbVPatches(); j1++) { |
334 | Handle(Geom_OffsetSurface) NewOffSur = new Geom_OffsetSurface(sps.ResSurfaces()->Patch(i1,j1),tmp->Offset()); |
335 | Patches->SetValue(i1,j1,NewOffSur); |
336 | } |
337 | } |
338 | myResSurfaces->Init(Patches); |
339 | myResSurfaces->SetUFirstValue ( myUSplitValues->Sequence().First() ); |
340 | myResSurfaces->SetVFirstValue ( myVSplitValues->Sequence().First() ); |
341 | myStatus |= sps.myStatus; |
342 | return; |
343 | } |
344 | |
345 | // splitting the surfaces: |
346 | myNbResultingRow = myUSplitValues->Length() -1; |
347 | myNbResultingCol = myVSplitValues->Length() -1; |
348 | Handle(TColGeom_HArray2OfSurface) Surfaces =new TColGeom_HArray2OfSurface(1,myNbResultingRow,1,myNbResultingCol); |
349 | Standard_Boolean isBSpline = mySurface->IsKind(STANDARD_TYPE(Geom_BSplineSurface)); |
350 | Standard_Boolean isBezier = mySurface->IsKind(STANDARD_TYPE(Geom_BezierSurface)); |
351 | |
352 | // Standard_Real U1,U2,V1,V2; |
353 | // U1=UFirst; |
354 | // U2 = ULast; |
355 | // V1 = VFirst; |
356 | // V2 = VLast; |
357 | |
358 | if(myNbResultingRow == 1 && myNbResultingCol == 1) { |
359 | mySurface->Bounds(U1, U2, V1, V2); |
360 | Standard_Boolean filled = Standard_True; |
361 | if ( Abs ( U1 - UFirst ) < Precision::PConfusion() && |
362 | Abs ( U2 - ULast ) < Precision::PConfusion() && |
363 | Abs ( V1 - VFirst ) < Precision::PConfusion() && |
364 | Abs ( V2 - VLast ) < Precision::PConfusion() ) |
365 | Surfaces->SetValue(1,1,mySurface); |
366 | else if ( ! Segment || ! mySurface->IsKind (STANDARD_TYPE (Geom_BSplineSurface) ) || |
367 | ! Status ( ShapeExtend_DONE2 ) ) { |
368 | //pdn copying of surface |
369 | Handle(Geom_Surface) tmp = Handle(Geom_Surface)::DownCast(mySurface->Copy()); |
370 | Handle(Geom_RectangularTrimmedSurface) Surf= |
371 | new Geom_RectangularTrimmedSurface(tmp,UFirst,ULast,VFirst,VLast); |
372 | Surfaces->SetValue(1,1,Surf); |
373 | } |
374 | else filled = Standard_False; |
375 | if ( filled ) { |
376 | myResSurfaces->Init(Surfaces); |
377 | myResSurfaces->SetUFirstValue ( myUSplitValues->Sequence().First() ); |
378 | myResSurfaces->SetVFirstValue ( myVSplitValues->Sequence().First() ); |
379 | return; |
380 | } |
381 | } |
382 | if (mySurface->IsKind (STANDARD_TYPE (Geom_BSplineSurface))) { |
383 | Handle(Geom_BSplineSurface) BsSurface = Handle(Geom_BSplineSurface)::DownCast(mySurface->Copy()); |
384 | Standard_Integer FirstInd =BsSurface->FirstUKnotIndex(), |
385 | LastInd = BsSurface->LastUKnotIndex(); |
386 | Standard_Integer j = FirstInd; |
387 | for(Standard_Integer ii =1 ; ii <= myUSplitValues->Length(); ii++) { |
388 | Standard_Real spval = myUSplitValues->Value(ii); |
389 | for(; j <=LastInd;j++) { |
390 | if( spval > BsSurface->UKnot(j) + Precision::PConfusion()) continue; |
391 | if( spval < BsSurface->UKnot(j) - Precision::PConfusion()) break; |
392 | myUSplitValues->ChangeValue(ii) = BsSurface->UKnot(j); |
393 | } |
394 | if(j == LastInd) break; |
395 | } |
396 | FirstInd =BsSurface->FirstVKnotIndex(), |
397 | LastInd = BsSurface->LastVKnotIndex(); |
398 | j = FirstInd; |
399 | for(Standard_Integer ii1 =1 ; ii1 <= myVSplitValues->Length(); ii1++) { |
400 | Standard_Real spval = myVSplitValues->Value(ii1); |
401 | for(; j <=LastInd;j++) { |
402 | if( spval > BsSurface->VKnot(j) + Precision::PConfusion()) continue; |
403 | if( spval < BsSurface->VKnot(j) - Precision::PConfusion()) break; |
404 | myVSplitValues->ChangeValue(ii1) =BsSurface->VKnot(j); |
405 | } |
406 | if(j == LastInd) break; |
407 | } |
408 | } |
409 | U1 = myUSplitValues->Value(1); |
410 | V1 = myVSplitValues->Value(1); |
411 | for(Standard_Integer irow = 2; irow <= myUSplitValues->Length(); irow++) { |
412 | U2 = myUSplitValues->Value(irow); |
413 | for(Standard_Integer icol = 2; icol <= myVSplitValues->Length(); icol++) { |
414 | V2 = myVSplitValues->Value(icol); |
415 | // if (ShapeUpgrade::Debug()) { |
416 | // cout<<".. bounds ="<<U1 <<","<<U2 <<","<<V1 <<","<<V2 <<endl; |
417 | // cout<<".. -> pos ="<<irow <<","<<icol<<endl; |
418 | // } |
419 | // creates a copy of theSurf before to segment: |
420 | Handle(Geom_Surface) theNew = Handle(Geom_Surface)::DownCast ( mySurface->Copy() ); |
421 | if ( isBSpline || isBezier ) { |
422 | try { |
423 | OCC_CATCH_SIGNALS |
424 | if ( isBSpline ) |
425 | Handle(Geom_BSplineSurface)::DownCast(theNew)->Segment(U1,U2,V1,V2); |
426 | else if ( isBezier ) { |
427 | //pdn K4L+ (work around) |
428 | // Standard_Real u1 = 2*U1 - 1; |
429 | // Standard_Real u2 = 2*U2 - 1; |
430 | // Standard_Real v1 = 2*V1 - 1; |
431 | // Standard_Real v2 = 2*V2 - 1; |
432 | //rln C30 (direct use) |
433 | Standard_Real u1 = U1; |
434 | Standard_Real u2 = U2; |
435 | Standard_Real v1 = V1; |
436 | Standard_Real v2 = V2; |
437 | Handle(Geom_BezierSurface)::DownCast(theNew)->Segment(u1,u2,v1,v2); |
438 | } |
439 | myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE3 ); |
440 | } |
441 | catch (Standard_Failure) { |
442 | #ifdef DEB |
443 | cout << "Warning: ShapeUpgrade_SplitSurface::Build(): Exception in Segment :"; |
444 | Standard_Failure::Caught()->Print(cout); cout << endl; |
445 | #endif |
446 | Handle(Geom_Surface) theNewSurf = theNew; |
447 | theNew = new Geom_RectangularTrimmedSurface(theNewSurf,U1,U2,V1,V2); |
448 | } |
449 | Surfaces->SetValue((irow-1),(icol-1),theNew); |
450 | } |
451 | else { |
452 | // not a BSpline: trimming instead of segmentation |
453 | Handle(Geom_Surface) |
454 | theNewSurf = Handle(Geom_Surface)::DownCast(theNew); |
455 | Handle(Geom_RectangularTrimmedSurface) SplittedSurf= |
456 | new Geom_RectangularTrimmedSurface(theNewSurf,U1,U2,V1,V2); |
457 | Surfaces->SetValue((irow-1),(icol-1),SplittedSurf); |
458 | } |
459 | |
460 | V1=V2; |
461 | } |
462 | U1=U2; |
463 | V1 = myVSplitValues->Value(1); |
464 | } |
465 | Standard_Integer nbU = myUSplitValues->Length(); |
466 | TColStd_Array1OfReal UJoints(1,nbU); |
467 | Standard_Integer i;//svv Jan 10 2000 : porting on DEC |
468 | for(i = 1; i <= nbU; i++) |
469 | UJoints(i) = myUSplitValues->Value(i); |
470 | |
471 | Standard_Integer nbV= myVSplitValues->Length(); |
472 | TColStd_Array1OfReal VJoints(1,nbV); |
473 | for(i = 1; i <= nbV; i++) |
474 | VJoints(i) = myVSplitValues->Value(i); |
475 | myResSurfaces->Init(Surfaces,UJoints,VJoints); |
476 | // if (ShapeUpgrade::Debug()) cout<<"SplitSurface::Build - end"<<endl; |
477 | } |
478 | |
479 | |
480 | //======================================================================= |
481 | //function : GlobalUKnots |
482 | //purpose : |
483 | //======================================================================= |
484 | |
485 | const Handle(TColStd_HSequenceOfReal)& ShapeUpgrade_SplitSurface::USplitValues() const |
486 | { |
487 | return myUSplitValues; |
488 | } |
489 | //======================================================================= |
490 | //function : GlobalVKnots |
491 | //purpose : |
492 | //======================================================================= |
493 | |
494 | const Handle(TColStd_HSequenceOfReal)& ShapeUpgrade_SplitSurface::VSplitValues() const |
495 | { |
496 | return myVSplitValues; |
497 | } |
498 | //======================================================================= |
499 | //function : Perform |
500 | //purpose : |
501 | //======================================================================= |
502 | |
503 | void ShapeUpgrade_SplitSurface::Perform(const Standard_Boolean Segment) |
504 | { |
505 | Compute(Segment); |
506 | // SetUSplitValues(myUSplitValues); |
507 | // SetVSplitValues(myVSplitValues); |
508 | Build (Segment); |
509 | |
510 | } |
511 | //======================================================================= |
512 | //function : Compute |
513 | //purpose : |
514 | //======================================================================= |
515 | |
516 | void ShapeUpgrade_SplitSurface::Compute(const Standard_Boolean /*Segment*/) |
517 | { |
518 | myStatus = ShapeExtend::EncodeStatus (ShapeExtend_OK); |
519 | } |
520 | //======================================================================= |
521 | //function : Status |
522 | //purpose : |
523 | //======================================================================= |
524 | |
525 | Standard_Boolean ShapeUpgrade_SplitSurface::Status(const ShapeExtend_Status status) const |
526 | { |
527 | return ShapeExtend::DecodeStatus (myStatus, status); |
528 | } |
529 | |
530 | const Handle(ShapeExtend_CompositeSurface)& ShapeUpgrade_SplitSurface::ResSurfaces() const |
531 | { |
532 | return myResSurfaces; |
533 | } |