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