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