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