b311480e |
1 | // Created on: 1991-07-02 |
2 | // Created by: Remi LEQUETTE |
3 | // Copyright (c) 1991-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. |
7fd59977 |
16 | |
17 | #include <BRep_Builder.ixx> |
18 | |
19 | #include <BRep_TEdge.hxx> |
20 | #include <BRep_Curve3D.hxx> |
21 | #include <BRep_GCurve.hxx> |
22 | #include <BRep_CurveOnClosedSurface.hxx> |
23 | #include <BRep_CurveOn2Surfaces.hxx> |
24 | #include <BRep_ListIteratorOfListOfCurveRepresentation.hxx> |
25 | |
26 | #include <BRep_PointOnCurve.hxx> |
27 | #include <BRep_PointOnCurveOnSurface.hxx> |
28 | #include <BRep_PointOnSurface.hxx> |
29 | #include <BRep_ListIteratorOfListOfPointRepresentation.hxx> |
30 | |
31 | #include <TopoDS.hxx> |
32 | #include <TopoDS_Iterator.hxx> |
33 | |
34 | #include <Precision.hxx> |
35 | |
36 | #include <BRep_Polygon3D.hxx> |
37 | #include <BRep_PolygonOnSurface.hxx> |
38 | #include <BRep_PolygonOnClosedSurface.hxx> |
39 | #include <BRep_PolygonOnTriangulation.hxx> |
40 | #include <BRep_PolygonOnClosedTriangulation.hxx> |
41 | |
42 | #include <Standard_NullObject.hxx> |
43 | |
44 | //======================================================================= |
45 | //function : Auxiliary methods |
46 | //purpose : |
47 | //======================================================================= |
48 | |
49 | //======================================================================= |
50 | //function : UpdateCurves |
51 | //purpose : Insert a 3d curve <C> with location <L> |
52 | // in a list of curve representations <lcr> |
53 | //======================================================================= |
54 | |
55 | static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr, |
56 | const Handle(Geom_Curve)& C, |
57 | const TopLoc_Location& L) |
58 | { |
59 | BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr); |
60 | Handle(BRep_GCurve) GC; |
1d47d8d0 |
61 | Standard_Real f = 0.,l = 0.; |
7fd59977 |
62 | |
63 | while (itcr.More()) { |
64 | GC = Handle(BRep_GCurve)::DownCast(itcr.Value()); |
65 | if (!GC.IsNull()) { |
66 | GC->Range(f, l); |
67 | if (GC->IsCurve3D()) break; |
68 | |
69 | } |
70 | itcr.Next(); |
71 | } |
72 | |
73 | if (itcr.More()) { |
74 | itcr.Value()->Curve3D(C); |
75 | itcr.Value()->Location(L); |
76 | } |
77 | else { |
78 | Handle(BRep_Curve3D) C3d = new BRep_Curve3D(C,L); |
79 | // test if there is already a range |
80 | if (!GC.IsNull()) { |
81 | C3d->SetRange(f,l); |
82 | } |
83 | lcr.Append(C3d); |
84 | } |
85 | |
86 | } |
87 | |
88 | //======================================================================= |
89 | //function : UpdateCurves |
90 | //purpose : Insert a pcurve <C> on surface <S> with location <L> |
91 | // in a list of curve representations <lcr> |
92 | // Remove the pcurve on <S> from <lcr> if <C> is null |
93 | //======================================================================= |
94 | |
95 | static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr, |
96 | const Handle(Geom2d_Curve)& C, |
97 | const Handle(Geom_Surface)& S, |
98 | const TopLoc_Location& L) |
99 | { |
100 | BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr); |
101 | Handle(BRep_CurveRepresentation) cr; |
102 | Handle(BRep_GCurve) GC; |
1d47d8d0 |
103 | Standard_Real f = 0.,l = 0.; |
7fd59977 |
104 | Standard_Boolean rangeFound = Standard_False; |
105 | |
106 | // search the range of the 3d curve |
107 | // and remove any existing representation |
108 | |
109 | while (itcr.More()) { |
110 | GC = Handle(BRep_GCurve)::DownCast(itcr.Value()); |
111 | if (!GC.IsNull()) { |
112 | if (GC->IsCurve3D()) { |
7fd59977 |
113 | // if (!C.IsNull()) { //xpu031198, edge degeneree |
114 | |
115 | // xpu151298 : parameters can be setted for null curves |
116 | // see lbo & flo, to determine whether range is defined |
117 | // compare first and last parameters with default values. |
118 | GC->Range(f, l); |
119 | //lvt 15/6/99: On enleve la comparaison de reels infinis. |
120 | Standard_Boolean undefined = (Precision::IsPositiveInfinite(l) || |
121 | Precision::IsNegativeInfinite(f)); |
122 | |
123 | if (!undefined) { |
124 | rangeFound = Standard_True; |
125 | } |
126 | } |
127 | if (GC->IsCurveOnSurface(S,L)) { |
128 | // remove existing curve on surface |
129 | // cr is used to keep a reference on the curve representation |
130 | // this avoid deleting it as its content may be referenced by C or S |
131 | cr = itcr.Value(); |
132 | lcr.Remove(itcr); |
133 | } |
134 | else { |
135 | itcr.Next(); |
136 | } |
137 | } |
138 | else { |
139 | itcr.Next(); |
140 | } |
141 | } |
142 | |
143 | if (! C.IsNull()) { |
144 | Handle(BRep_CurveOnSurface) COS = new BRep_CurveOnSurface(C,S,L); |
145 | // test if there is already a range |
146 | if (rangeFound) { |
147 | COS->SetRange(f,l); |
148 | } |
149 | lcr.Append(COS); |
150 | } |
151 | } |
152 | |
153 | //======================================================================= |
154 | //function : UpdateCurves |
155 | //purpose : Insert a pcurve <C> on surface <S> with location <L> |
156 | // in a list of curve representations <lcr> |
157 | // Remove the pcurve on <S> from <lcr> if <C> is null |
158 | //======================================================================= |
159 | static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr, |
160 | const Handle(Geom2d_Curve)& C, |
161 | const Handle(Geom_Surface)& S, |
162 | const TopLoc_Location& L, |
163 | const gp_Pnt2d& Pf, |
164 | const gp_Pnt2d& Pl) |
165 | { |
166 | BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr); |
167 | Handle(BRep_CurveRepresentation) cr; |
168 | Handle(BRep_GCurve) GC; |
1d47d8d0 |
169 | Standard_Real f = 0.,l = 0.; |
7fd59977 |
170 | Standard_Boolean rangeFound = Standard_False; |
171 | |
172 | // search the range of the 3d curve |
173 | // and remove any existing representation |
174 | |
175 | while (itcr.More()) { |
176 | GC = Handle(BRep_GCurve)::DownCast(itcr.Value()); |
177 | if (!GC.IsNull()) { |
178 | if (GC->IsCurve3D()) { |
7fd59977 |
179 | // if (!C.IsNull()) { //xpu031198, edge degeneree |
180 | |
181 | // xpu151298 : parameters can be setted for null curves |
182 | // see lbo & flo, to determine whether range is defined |
183 | // compare first and last parameters with default values. |
184 | GC->Range(f, l); |
185 | //lvt 15/6/99: On enleve la comparaison de reels infinis. |
186 | Standard_Boolean undefined = (Precision::IsPositiveInfinite(l) || |
187 | Precision::IsNegativeInfinite(f)); |
188 | |
189 | if (!undefined) { |
190 | rangeFound = Standard_True; |
191 | } |
192 | } |
193 | if (GC->IsCurveOnSurface(S,L)) { |
194 | // remove existing curve on surface |
195 | // cr is used to keep a reference on the curve representation |
196 | // this avoid deleting it as its content may be referenced by C or S |
197 | cr = itcr.Value(); |
198 | lcr.Remove(itcr); |
199 | } |
200 | else { |
201 | itcr.Next(); |
202 | } |
203 | } |
204 | else { |
205 | itcr.Next(); |
206 | } |
207 | } |
208 | |
209 | if (! C.IsNull()) { |
210 | Handle(BRep_CurveOnSurface) COS = new BRep_CurveOnSurface(C,S,L); |
211 | // test if there is already a range |
212 | if (rangeFound) { |
213 | COS->SetRange(f,l); |
214 | } |
215 | COS->SetUVPoints(Pf,Pl); |
216 | lcr.Append(COS); |
217 | } |
218 | } |
219 | |
220 | //======================================================================= |
221 | //function : UpdateCurves |
222 | //purpose : Insert two pcurves <C1,C2> on surface <S> with location <L> |
223 | // in a list of curve representations <lcr> |
224 | // Remove the pcurves on <S> from <lcr> if <C1> or <C2> is null |
225 | //======================================================================= |
226 | |
227 | static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr, |
228 | const Handle(Geom2d_Curve)& C1, |
229 | const Handle(Geom2d_Curve)& C2, |
230 | const Handle(Geom_Surface)& S, |
231 | const TopLoc_Location& L) |
232 | { |
233 | BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr); |
234 | Handle(BRep_CurveRepresentation) cr; |
235 | Handle(BRep_GCurve) GC; |
1d47d8d0 |
236 | Standard_Real f = 0.,l = 0.; |
7fd59977 |
237 | |
238 | while (itcr.More()) { |
239 | GC = Handle(BRep_GCurve)::DownCast(itcr.Value()); |
240 | if ( !GC.IsNull() ) { |
241 | GC->Range(f,l); |
242 | Standard_Boolean iscos = GC->IsCurveOnSurface(S,L); |
243 | if (iscos) break; |
244 | } |
245 | itcr.Next(); |
246 | } |
247 | |
248 | if (itcr.More()) { |
249 | // cr is used to keep a reference on the curve representation |
250 | // this avoid deleting it as its content may be referenced by C or S |
251 | cr = itcr.Value(); |
252 | lcr.Remove(itcr); |
253 | } |
254 | |
255 | if ( !C1.IsNull() && !C2.IsNull() ) { |
256 | Handle(BRep_CurveOnClosedSurface) COS = |
257 | new BRep_CurveOnClosedSurface(C1,C2,S,L,GeomAbs_C0); |
258 | // test if there is already a range |
259 | if (!GC.IsNull()) { |
260 | COS->SetRange(f,l); |
261 | } |
262 | lcr.Append(COS); |
263 | } |
264 | } |
265 | |
266 | //======================================================================= |
267 | //function : UpdateCurves |
268 | //purpose : Insert two pcurves <C1,C2> on surface <S> with location <L> |
269 | // in a list of curve representations <lcr> |
270 | // Remove the pcurves on <S> from <lcr> if <C1> or <C2> is null |
271 | //======================================================================= |
272 | static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr, |
273 | const Handle(Geom2d_Curve)& C1, |
274 | const Handle(Geom2d_Curve)& C2, |
275 | const Handle(Geom_Surface)& S, |
276 | const TopLoc_Location& L, |
277 | const gp_Pnt2d& Pf, |
278 | const gp_Pnt2d& Pl) |
279 | { |
280 | BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr); |
281 | Handle(BRep_CurveRepresentation) cr; |
282 | Handle(BRep_GCurve) GC; |
1d47d8d0 |
283 | Standard_Real f = 0.,l = 0.; |
7fd59977 |
284 | |
285 | while (itcr.More()) { |
286 | GC = Handle(BRep_GCurve)::DownCast(itcr.Value()); |
287 | if ( !GC.IsNull() ) { |
288 | GC->Range(f,l); |
289 | Standard_Boolean iscos = GC->IsCurveOnSurface(S,L); |
290 | if (iscos) break; |
291 | } |
292 | itcr.Next(); |
293 | } |
294 | |
295 | if (itcr.More()) { |
296 | // cr is used to keep a reference on the curve representation |
297 | // this avoid deleting it as its content may be referenced by C or S |
298 | cr = itcr.Value(); |
299 | lcr.Remove(itcr); |
300 | } |
301 | |
302 | if ( !C1.IsNull() && !C2.IsNull() ) { |
303 | Handle(BRep_CurveOnClosedSurface) COS = |
304 | new BRep_CurveOnClosedSurface(C1,C2,S,L,GeomAbs_C0); |
305 | // test if there is already a range |
306 | if (!GC.IsNull()) { |
307 | COS->SetRange(f,l); |
308 | } |
309 | COS->SetUVPoints2(Pf,Pl); |
310 | lcr.Append(COS); |
311 | } |
312 | } |
313 | |
314 | |
315 | static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr, |
316 | const Handle(Geom_Surface)& S1, |
317 | const Handle(Geom_Surface)& S2, |
318 | const TopLoc_Location& L1, |
319 | const TopLoc_Location& L2, |
320 | const GeomAbs_Shape C) |
321 | { |
322 | BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr); |
323 | while (itcr.More()) { |
324 | const Handle(BRep_CurveRepresentation)& cr = itcr.Value(); |
325 | Standard_Boolean isregu = cr->IsRegularity(S1,S2,L1,L2); |
326 | if (isregu) break; |
327 | itcr.Next(); |
328 | } |
329 | |
330 | if (itcr.More()) { |
331 | Handle(BRep_CurveRepresentation)& cr = itcr.Value(); |
332 | cr->Continuity(C); |
333 | } |
334 | else { |
335 | Handle(BRep_CurveOn2Surfaces) COS = new BRep_CurveOn2Surfaces |
336 | (S1,S2,L1,L2,C); |
337 | lcr.Append(COS); |
338 | } |
339 | } |
340 | |
341 | static void UpdatePoints(BRep_ListOfPointRepresentation& lpr, |
342 | Standard_Real p, |
343 | const Handle(Geom_Curve)& C, |
344 | const TopLoc_Location& L) |
345 | { |
346 | BRep_ListIteratorOfListOfPointRepresentation itpr(lpr); |
347 | while (itpr.More()) { |
348 | const Handle(BRep_PointRepresentation)& pr = itpr.Value(); |
349 | Standard_Boolean isponc = pr->IsPointOnCurve(C,L); |
350 | if (isponc) break; |
351 | itpr.Next(); |
352 | } |
353 | |
354 | if (itpr.More()) { |
355 | Handle(BRep_PointRepresentation)& pr = itpr.Value(); |
356 | pr->Parameter(p); |
357 | } |
358 | else { |
359 | Handle(BRep_PointOnCurve) POC = new BRep_PointOnCurve(p,C,L); |
360 | lpr.Append(POC); |
361 | } |
362 | } |
363 | |
364 | static void UpdatePoints(BRep_ListOfPointRepresentation& lpr, |
365 | Standard_Real p, |
366 | const Handle(Geom2d_Curve)& PC, |
367 | const Handle(Geom_Surface)& S, |
368 | const TopLoc_Location& L) |
369 | { |
370 | BRep_ListIteratorOfListOfPointRepresentation itpr(lpr); |
371 | while (itpr.More()) { |
372 | const Handle(BRep_PointRepresentation)& pr = itpr.Value(); |
373 | Standard_Boolean isponcons = pr->IsPointOnCurveOnSurface(PC,S,L); |
374 | if (isponcons) break; |
375 | itpr.Next(); |
376 | } |
377 | |
378 | if (itpr.More()) { |
379 | Handle(BRep_PointRepresentation)& pr = itpr.Value(); |
380 | pr->Parameter(p); |
381 | } |
382 | else { |
383 | Handle(BRep_PointOnCurveOnSurface) POCS = |
384 | new BRep_PointOnCurveOnSurface(p,PC,S,L); |
385 | lpr.Append(POCS); |
386 | } |
387 | } |
388 | |
389 | |
390 | static void UpdatePoints(BRep_ListOfPointRepresentation& lpr, |
391 | Standard_Real p1, |
392 | Standard_Real p2, |
393 | const Handle(Geom_Surface)& S, |
394 | const TopLoc_Location& L) |
395 | { |
396 | BRep_ListIteratorOfListOfPointRepresentation itpr(lpr); |
397 | while (itpr.More()) { |
398 | const Handle(BRep_PointRepresentation)& pr = itpr.Value(); |
399 | Standard_Boolean ispons = pr->IsPointOnSurface(S,L); |
400 | if (ispons) break; |
401 | itpr.Next(); |
402 | } |
403 | |
404 | if (itpr.More()) { |
405 | Handle(BRep_PointRepresentation)& pr = itpr.Value(); |
406 | pr->Parameter(p1); |
407 | // pr->Parameter(p2); // skv |
408 | pr->Parameter2(p2); // skv |
409 | } |
410 | else { |
411 | Handle(BRep_PointOnSurface) POS = new BRep_PointOnSurface(p1,p2,S,L); |
412 | lpr.Append(POS); |
413 | } |
414 | } |
415 | |
416 | |
417 | //======================================================================= |
418 | //function : MakeFace |
419 | //purpose : |
420 | //======================================================================= |
421 | |
422 | void BRep_Builder::MakeFace(TopoDS_Face& F, |
423 | const Handle(Geom_Surface)& S, |
424 | const Standard_Real Tol) const |
425 | { |
426 | Handle(BRep_TFace) TF = new BRep_TFace(); |
427 | TF->Surface(S); |
428 | TF->Tolerance(Tol); |
429 | MakeShape(F,TF); |
430 | } |
431 | |
432 | |
433 | //======================================================================= |
434 | //function : MakeFace |
435 | //purpose : |
436 | //======================================================================= |
437 | |
438 | void BRep_Builder::MakeFace(TopoDS_Face& F, |
439 | const Handle(Poly_Triangulation)& T) const |
440 | { |
441 | Handle(BRep_TFace) TF = new BRep_TFace(); |
442 | TF->Triangulation(T); |
443 | MakeShape(F, TF); |
444 | } |
445 | |
446 | |
447 | //======================================================================= |
448 | //function : MakeFace |
449 | //purpose : |
450 | //======================================================================= |
451 | |
452 | void BRep_Builder::MakeFace(TopoDS_Face& F, |
453 | const Handle(Geom_Surface)& S, |
454 | const TopLoc_Location& L, |
455 | const Standard_Real Tol) const |
456 | { |
457 | Handle(BRep_TFace) TF = new BRep_TFace(); |
458 | TF->Surface(S); |
459 | TF->Tolerance(Tol); |
460 | TF->Location(L); |
461 | MakeShape(F,TF); |
462 | } |
463 | |
464 | |
465 | //======================================================================= |
466 | //function : UpdateFace |
467 | //purpose : |
468 | //======================================================================= |
469 | |
470 | void BRep_Builder::UpdateFace(const TopoDS_Face& F, |
471 | const Handle(Geom_Surface)& S, |
472 | const TopLoc_Location& L, |
473 | const Standard_Real Tol) const |
474 | { |
475 | const Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &F.TShape()); |
476 | TF->Surface(S); |
477 | TF->Tolerance(Tol); |
478 | TF->Location(L.Predivided(F.Location())); |
479 | F.TShape()->Modified(Standard_True); |
480 | } |
481 | |
482 | |
483 | //======================================================================= |
484 | //function : UpdateFace |
485 | //purpose : |
486 | //======================================================================= |
487 | |
488 | void BRep_Builder::UpdateFace(const TopoDS_Face& F, |
489 | const Handle(Poly_Triangulation)& T) const |
490 | { |
491 | (*((Handle(BRep_TFace)*) &F.TShape()))->Triangulation(T); |
492 | F.TShape()->Modified(Standard_True); |
493 | } |
494 | |
495 | |
496 | //======================================================================= |
497 | //function : UpdateFace |
498 | //purpose : |
499 | //======================================================================= |
500 | |
501 | void BRep_Builder::UpdateFace(const TopoDS_Face& F, |
502 | const Standard_Real Tol) const |
503 | { |
504 | (*((Handle(BRep_TFace)*) &F.TShape()))->Tolerance(Tol); |
505 | F.TShape()->Modified(Standard_True); |
506 | } |
507 | |
508 | |
509 | //======================================================================= |
510 | //function : NaturalRestriction |
511 | //purpose : |
512 | //======================================================================= |
513 | |
514 | void BRep_Builder::NaturalRestriction(const TopoDS_Face& F, |
515 | const Standard_Boolean N) const |
516 | { |
517 | (*((Handle(BRep_TFace)*) &F.TShape()))->NaturalRestriction(N); |
518 | F.TShape()->Modified(Standard_True); |
519 | } |
520 | |
521 | |
522 | //======================================================================= |
523 | //function : MakeEdge |
524 | //purpose : make undefined edge |
525 | //======================================================================= |
526 | |
527 | void BRep_Builder::MakeEdge(TopoDS_Edge& E) const |
528 | { |
529 | Handle(BRep_TEdge) TE = new BRep_TEdge(); |
530 | TE->Closed(Standard_False); |
531 | MakeShape(E,TE); |
532 | } |
533 | |
534 | |
535 | //======================================================================= |
536 | //function : UpdateEdge |
537 | //purpose : |
538 | //======================================================================= |
539 | |
540 | void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, |
541 | const Handle(Geom_Curve)& C, |
542 | const TopLoc_Location& L, |
543 | const Standard_Real Tol) const |
544 | { |
545 | const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); |
546 | const TopLoc_Location l = L.Predivided(E.Location()); |
547 | |
548 | UpdateCurves(TE->ChangeCurves(),C,l); |
549 | if (!C.IsNull()) TE->Closed(C->IsClosed()); |
550 | |
551 | TE->UpdateTolerance(Tol); |
552 | TE->Modified(Standard_True); |
553 | } |
554 | |
555 | |
556 | //======================================================================= |
557 | //function : UpdateEdge |
558 | //purpose : |
559 | //======================================================================= |
560 | |
561 | void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, |
562 | const Handle(Geom2d_Curve)& C, |
563 | const Handle(Geom_Surface)& S, |
564 | const TopLoc_Location& L, |
565 | const Standard_Real Tol) const |
566 | { |
567 | const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); |
568 | const TopLoc_Location l = L.Predivided(E.Location()); |
569 | |
570 | UpdateCurves(TE->ChangeCurves(),C,S,l); |
571 | |
572 | TE->UpdateTolerance(Tol); |
573 | TE->Modified(Standard_True); |
574 | } |
575 | |
576 | |
577 | //======================================================================= |
578 | //function : UpdateEdge |
579 | //purpose : for the second format (for XML Persistence) |
580 | //======================================================================= |
581 | |
582 | void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, |
583 | const Handle(Geom2d_Curve)& C, |
584 | const Handle(Geom_Surface)& S, |
585 | const TopLoc_Location& L, |
586 | const Standard_Real Tol, |
587 | const gp_Pnt2d& Pf, |
588 | const gp_Pnt2d& Pl) const |
589 | { |
590 | const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); |
591 | const TopLoc_Location l = L.Predivided(E.Location()); |
592 | |
593 | UpdateCurves(TE->ChangeCurves(),C,S,l,Pf,Pl); |
594 | |
595 | TE->UpdateTolerance(Tol); |
596 | TE->Modified(Standard_True); |
597 | } |
598 | |
599 | |
600 | //======================================================================= |
601 | //function : UpdateEdge |
602 | //purpose : |
603 | //======================================================================= |
604 | |
605 | void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, |
606 | const Handle(Geom2d_Curve)& C1, |
607 | const Handle(Geom2d_Curve)& C2, |
608 | const Handle(Geom_Surface)& S, |
609 | const TopLoc_Location& L, |
610 | const Standard_Real Tol) const |
611 | { |
612 | const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); |
613 | const TopLoc_Location l = L.Predivided(E.Location()); |
614 | |
615 | UpdateCurves(TE->ChangeCurves(),C1,C2,S,l); |
616 | if (!C1.IsNull() && !C2.IsNull()) |
617 | TE->Closed(C1->IsClosed() && C2->IsClosed()); |
618 | |
619 | TE->UpdateTolerance(Tol); |
620 | TE->Modified(Standard_True); |
621 | } |
622 | |
623 | |
624 | //======================================================================= |
625 | //function : UpdateEdge |
626 | //purpose : for the second format (for XML Persistence) |
627 | //======================================================================= |
628 | |
629 | void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, |
630 | const Handle(Geom2d_Curve)& C1, |
631 | const Handle(Geom2d_Curve)& C2, |
632 | const Handle(Geom_Surface)& S, |
633 | const TopLoc_Location& L, |
634 | const Standard_Real Tol, |
635 | const gp_Pnt2d& Pf, |
636 | const gp_Pnt2d& Pl) const |
637 | { |
638 | const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); |
639 | const TopLoc_Location l = L.Predivided(E.Location()); |
640 | |
641 | UpdateCurves(TE->ChangeCurves(),C1,C2,S,l,Pf,Pl); |
642 | if (!C1.IsNull() && !C2.IsNull()) |
643 | TE->Closed(C1->IsClosed() && C2->IsClosed()); |
644 | |
645 | TE->UpdateTolerance(Tol); |
646 | TE->Modified(Standard_True); |
647 | } |
648 | |
649 | |
650 | //======================================================================= |
651 | //function : UpdateEdge |
652 | //purpose : |
653 | //======================================================================= |
654 | |
655 | void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, |
656 | const Handle(Poly_Polygon3D)& P, |
657 | const TopLoc_Location& L) const |
658 | { |
659 | const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); |
660 | |
661 | BRep_ListOfCurveRepresentation& lcr = TE->ChangeCurves(); |
662 | BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr); |
663 | |
664 | while (itcr.More()) |
665 | { |
666 | if (itcr.Value()->IsPolygon3D()) |
667 | { |
668 | if (P.IsNull()) |
669 | lcr.Remove(itcr); |
670 | else |
671 | itcr.Value()->Polygon3D(P); |
672 | TE->Modified(Standard_True); |
673 | return; |
674 | } |
675 | itcr.Next(); |
676 | } |
677 | |
678 | const TopLoc_Location l = L.Predivided(E.Location()); |
679 | Handle(BRep_Polygon3D) P3d = new BRep_Polygon3D(P,l); |
680 | lcr.Append(P3d); |
681 | |
682 | TE->Modified(Standard_True); |
683 | } |
684 | |
685 | |
686 | //======================================================================= |
687 | //function : UpdateEdge |
688 | //purpose : |
689 | //======================================================================= |
690 | |
691 | void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, |
692 | const Handle(Poly_PolygonOnTriangulation)& P, |
693 | const Handle(Poly_Triangulation)& T, |
694 | const TopLoc_Location& L) const |
695 | { |
696 | const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); |
697 | const TopLoc_Location l = L.Predivided(E.Location()); |
698 | |
699 | Standard_Boolean isModified = Standard_False; |
700 | |
701 | BRep_ListOfCurveRepresentation& lcr = TE->ChangeCurves(); |
702 | BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr); |
703 | Handle(BRep_CurveRepresentation) cr; |
704 | |
705 | while (itcr.More()) |
706 | { |
707 | if (itcr.Value()->IsPolygonOnTriangulation(T,l)) |
708 | { |
709 | // cr is used to keep a reference on the curve representation |
710 | // this avoid deleting it as its content may be referenced by T |
711 | cr = itcr.Value(); |
712 | lcr.Remove(itcr); |
713 | isModified = Standard_True; |
714 | break; |
715 | } |
716 | itcr.Next(); |
717 | } |
718 | |
719 | if (!P.IsNull()) |
720 | { |
721 | Handle(BRep_PolygonOnTriangulation) PT = |
722 | new BRep_PolygonOnTriangulation(P,T,l); |
723 | lcr.Append(PT); |
724 | isModified = Standard_True; |
725 | } |
726 | |
727 | if (isModified) |
728 | TE->Modified(Standard_True); |
729 | } |
730 | |
731 | |
732 | //======================================================================= |
733 | //function : UpdateEdge |
734 | //purpose : |
735 | //======================================================================= |
736 | |
737 | void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, |
738 | const Handle(Poly_PolygonOnTriangulation)& P1, |
739 | const Handle(Poly_PolygonOnTriangulation)& P2, |
740 | const Handle(Poly_Triangulation)& T, |
741 | const TopLoc_Location& L) const |
742 | { |
743 | const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); |
744 | const TopLoc_Location l = L.Predivided(E.Location()); |
745 | |
746 | Standard_Boolean isModified = Standard_False; |
747 | |
748 | BRep_ListOfCurveRepresentation& lcr = TE->ChangeCurves(); |
749 | BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr); |
750 | Handle(BRep_CurveRepresentation) cr; |
751 | |
752 | while (itcr.More()) |
753 | { |
754 | if (itcr.Value()->IsPolygonOnTriangulation(T,l)) //szv:was L |
755 | { |
756 | // cr is used to keep a reference on the curve representation |
757 | // this avoid deleting it as its content may be referenced by T |
758 | cr = itcr.Value(); |
759 | lcr.Remove(itcr); |
760 | isModified = Standard_True; |
761 | break; |
762 | } |
763 | itcr.Next(); |
764 | } |
765 | |
766 | if (!P1.IsNull() && !P2.IsNull()) |
767 | { |
768 | Handle(BRep_PolygonOnClosedTriangulation) PT = |
769 | new BRep_PolygonOnClosedTriangulation(P1,P2,T,l); |
770 | lcr.Append(PT); |
771 | isModified = Standard_True; |
772 | } |
773 | |
774 | if (isModified) |
775 | TE->Modified(Standard_True); |
776 | } |
777 | |
778 | //======================================================================= |
779 | //function : UpdateEdge |
780 | //purpose : |
781 | //======================================================================= |
782 | |
783 | void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, |
784 | const Handle(Poly_Polygon2D)& P, |
785 | const TopoDS_Face& F) const |
786 | { |
787 | TopLoc_Location l; |
788 | const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,l); |
789 | UpdateEdge(E, P, S, l); |
790 | } |
791 | |
792 | //======================================================================= |
793 | //function : UpdateEdge |
794 | //purpose : |
795 | //======================================================================= |
796 | |
797 | void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, |
798 | const Handle(Poly_Polygon2D)& P, |
799 | const Handle(Geom_Surface)& S, |
800 | const TopLoc_Location& L) const |
801 | { |
802 | const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); |
803 | TopLoc_Location l = L.Predivided(E.Location()); |
804 | |
805 | BRep_ListOfCurveRepresentation& lcr = TE->ChangeCurves(); |
806 | Handle(BRep_CurveRepresentation) cr; |
807 | |
808 | BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr); |
809 | while (itcr.More()) { |
810 | if (itcr.Value()->IsPolygonOnSurface(S, l)) break; |
811 | itcr.Next(); |
812 | } |
813 | |
814 | if (itcr.More()) { |
815 | // cr is used to keep a reference on the curve representation |
816 | // this avoid deleting it as its content may be referenced by T |
817 | cr = itcr.Value(); |
818 | lcr.Remove(itcr); |
819 | } |
820 | |
821 | if (!P.IsNull()) { |
822 | Handle(BRep_PolygonOnSurface) PS = |
823 | new BRep_PolygonOnSurface(P, S, l); |
824 | lcr.Append(PS); |
825 | } |
826 | |
827 | TE->Modified(Standard_True); |
828 | } |
829 | |
830 | //======================================================================= |
831 | //function : UpdateEdge |
832 | //purpose : |
833 | //======================================================================= |
834 | |
835 | void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, |
836 | const Handle(Poly_Polygon2D)& P1, |
837 | const Handle(Poly_Polygon2D)& P2, |
838 | const TopoDS_Face& F) const |
839 | { |
840 | TopLoc_Location l; |
841 | const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,l); |
842 | UpdateEdge(E, P1, P2, S, l); |
843 | } |
844 | |
845 | //======================================================================= |
846 | //function : UpdateEdge |
847 | //purpose : |
848 | //======================================================================= |
849 | |
850 | void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, |
851 | const Handle(Poly_Polygon2D)& P1, |
852 | const Handle(Poly_Polygon2D)& P2, |
853 | const Handle(Geom_Surface)& S, |
854 | const TopLoc_Location& L) const |
855 | { |
856 | const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); |
857 | TopLoc_Location l = L.Predivided(E.Location()); |
858 | |
859 | BRep_ListOfCurveRepresentation& lcr = TE->ChangeCurves(); |
860 | Handle(BRep_CurveRepresentation) cr; |
861 | |
862 | BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr); |
863 | while (itcr.More()) { |
864 | if (itcr.Value()->IsPolygonOnSurface(S, l)) break; |
865 | itcr.Next(); |
866 | } |
867 | |
868 | if (itcr.More()) { |
869 | // cr is used to keep a reference on the curve representation |
870 | // this avoid deleting it as its content may be referenced by T |
871 | cr = itcr.Value(); |
872 | lcr.Remove(itcr); |
873 | } |
874 | |
875 | if (!P1.IsNull() && !P2.IsNull()) { |
876 | Handle(BRep_PolygonOnClosedSurface) PS = |
877 | new BRep_PolygonOnClosedSurface(P1, P2, S, TopLoc_Location()); |
878 | lcr.Append(PS); |
879 | } |
880 | |
881 | TE->Modified(Standard_True); |
882 | } |
883 | |
884 | //======================================================================= |
885 | //function : UpdateEdge |
886 | //purpose : |
887 | //======================================================================= |
888 | |
889 | void BRep_Builder::UpdateEdge(const TopoDS_Edge& E, |
890 | const Standard_Real Tol) const |
891 | { |
892 | const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); |
893 | TE->UpdateTolerance(Tol); |
894 | TE->Modified(Standard_True); |
895 | } |
896 | |
897 | |
898 | //======================================================================= |
899 | //function : Continuity |
900 | //purpose : |
901 | //======================================================================= |
902 | |
903 | void BRep_Builder::Continuity(const TopoDS_Edge& E, |
904 | const TopoDS_Face& F1, |
905 | const TopoDS_Face& F2, |
906 | const GeomAbs_Shape C) const |
907 | { |
908 | TopLoc_Location l1,l2; |
909 | const Handle(Geom_Surface)& S1 = BRep_Tool::Surface(F1,l1); |
910 | const Handle(Geom_Surface)& S2 = BRep_Tool::Surface(F2,l2); |
911 | Continuity(E,S1,S2,l1,l2,C); |
912 | } |
913 | |
914 | //======================================================================= |
915 | //function : Continuity |
916 | //purpose : |
917 | //======================================================================= |
918 | |
919 | void BRep_Builder::Continuity(const TopoDS_Edge& E, |
920 | const Handle(Geom_Surface)& S1, |
921 | const Handle(Geom_Surface)& S2, |
922 | const TopLoc_Location& L1, |
923 | const TopLoc_Location& L2, |
924 | const GeomAbs_Shape C)const |
925 | { |
926 | const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); |
927 | |
928 | const TopLoc_Location l1 = L1.Predivided(E.Location()); |
929 | const TopLoc_Location l2 = L2.Predivided(E.Location()); |
930 | |
931 | UpdateCurves(TE->ChangeCurves(),S1,S2,l1,l2,C); |
932 | |
933 | TE->Modified(Standard_True); |
934 | } |
935 | |
936 | //======================================================================= |
937 | //function : SameParameter |
938 | //purpose : |
939 | //======================================================================= |
940 | |
941 | void BRep_Builder::SameParameter(const TopoDS_Edge& E, |
942 | const Standard_Boolean S) const |
943 | { |
944 | const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); |
945 | TE->SameParameter(S); |
946 | TE->Modified(Standard_True); |
947 | } |
948 | |
949 | //======================================================================= |
950 | //function : SameRange |
951 | //purpose : |
952 | //======================================================================= |
953 | |
954 | void BRep_Builder::SameRange(const TopoDS_Edge& E, |
955 | const Standard_Boolean S) const |
956 | { |
957 | const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); |
958 | TE->SameRange(S); |
959 | TE->Modified(Standard_True); |
960 | } |
961 | |
962 | //======================================================================= |
963 | //function : Degenerated |
964 | //purpose : |
965 | //======================================================================= |
966 | |
967 | void BRep_Builder::Degenerated(const TopoDS_Edge& E, |
968 | const Standard_Boolean D) const |
969 | { |
970 | const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); |
971 | TE->Degenerated(D); |
972 | if (D) { |
973 | // set a null 3d curve |
974 | UpdateCurves(TE->ChangeCurves(),Handle(Geom_Curve)(),E.Location()); |
975 | } |
976 | TE->Modified(Standard_True); |
977 | } |
978 | |
979 | |
980 | //======================================================================= |
981 | //function : Range |
982 | //purpose : |
983 | //======================================================================= |
984 | |
985 | void BRep_Builder::Range(const TopoDS_Edge& E, |
986 | const Standard_Real First, |
987 | const Standard_Real Last, |
988 | const Standard_Boolean Only3d) const |
989 | { |
990 | // set the range to all the representations if Only3d=FALSE |
991 | const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); |
992 | |
993 | BRep_ListOfCurveRepresentation& lcr = TE->ChangeCurves(); |
994 | BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr); |
995 | Handle(BRep_GCurve) GC; |
996 | |
997 | while (itcr.More()) { |
998 | GC = Handle(BRep_GCurve)::DownCast(itcr.Value()); |
999 | if (!GC.IsNull()) { |
1000 | if (!Only3d || GC->IsCurve3D()) |
1001 | GC->SetRange(First,Last); |
1002 | if (GC->IsCurve3D()) { |
1003 | // Set the closedness flag to the correct value. |
1004 | Handle(Geom_Curve) C = GC->Curve3D(); |
1005 | |
1006 | //fixing a bug PRO18577 to avoid infinite values of First and Last |
1007 | if ( !C.IsNull() && |
1008 | !Precision::IsNegativeInfinite(First) && |
1009 | !Precision::IsPositiveInfinite(Last) ) { |
1010 | Standard_Boolean closed = |
1011 | C->Value(First).IsEqual(C->Value(Last),BRep_Tool::Tolerance(E)); |
1012 | TE->Closed(closed); |
1013 | } |
1014 | } |
1015 | } |
1016 | itcr.Next(); |
1017 | } |
1018 | |
1019 | TE->Modified(Standard_True); |
1020 | } |
1021 | |
1022 | |
1023 | //======================================================================= |
1024 | //function : Range |
1025 | //purpose : |
1026 | //======================================================================= |
1027 | |
1028 | void BRep_Builder::Range(const TopoDS_Edge& E, |
1029 | const Handle(Geom_Surface)& S, |
1030 | const TopLoc_Location& L, |
1031 | const Standard_Real First, |
1032 | const Standard_Real Last) const |
1033 | { |
1034 | const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); |
1035 | const TopLoc_Location l = L.Predivided(E.Location()); |
1036 | |
1037 | BRep_ListOfCurveRepresentation& lcr = TE->ChangeCurves(); |
1038 | BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr); |
1039 | Handle(BRep_GCurve) GC; |
1040 | |
1041 | while (itcr.More()) { |
1042 | GC = Handle(BRep_GCurve)::DownCast(itcr.Value()); |
1043 | if (!GC.IsNull()) { |
1044 | if (GC->IsCurveOnSurface(S,l)) { |
1045 | GC->SetRange(First,Last); |
1046 | |
1047 | // Set the closedness flag to the correct value. |
1048 | Handle(Geom2d_Curve) PC = GC->PCurve(); |
1049 | gp_Pnt2d P1 = PC->Value(First); |
1050 | gp_Pnt2d P2 = PC->Value(Last); |
1051 | gp_Pnt PP1 = S->Value(P1.X(),P1.Y()); |
1052 | gp_Pnt PP2 = S->Value(P2.X(),P2.Y()); |
1053 | Standard_Boolean closed = PP1.IsEqual(PP2,BRep_Tool::Tolerance(E)); |
1054 | TE->Closed(closed); |
1055 | break; |
1056 | } |
1057 | } |
1058 | itcr.Next(); |
1059 | } |
1060 | |
1061 | if (!itcr.More()) |
1062 | Standard_DomainError::Raise("BRep_Builder::Range, no pcurve"); |
1063 | |
1064 | TE->Modified(Standard_True); |
1065 | } |
1066 | |
1067 | |
1068 | //======================================================================= |
1069 | //function : Transfert |
1070 | //purpose : |
1071 | //======================================================================= |
1072 | |
1073 | void BRep_Builder::Transfert(const TopoDS_Edge& Ein, |
1074 | const TopoDS_Edge& Eout) const |
1075 | { |
1076 | const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &Ein.TShape()); |
1077 | |
1078 | const Standard_Real tol = TE->Tolerance(); |
1079 | |
1080 | BRep_ListOfCurveRepresentation& lcr = TE->ChangeCurves(); |
1081 | BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr); |
1082 | |
1083 | while (itcr.More()) { |
1084 | |
1085 | const Handle(BRep_CurveRepresentation)& CR = itcr.Value(); |
1086 | |
1087 | if (CR->IsCurveOnSurface()) { |
1088 | UpdateEdge(Eout, |
1089 | CR->PCurve(), |
1090 | CR->Surface(), |
1091 | Ein.Location() * CR->Location(),tol); |
1092 | } |
1093 | |
1094 | else if (CR->IsCurveOnClosedSurface()) { |
1095 | UpdateEdge(Eout, |
1096 | CR->PCurve(), |
1097 | CR->PCurve2(), |
1098 | CR->Surface(), |
1099 | Ein.Location() * CR->Location(),tol); |
1100 | } |
1101 | |
1102 | if (CR->IsRegularity()) { |
1103 | Continuity(Eout, |
1104 | CR->Surface(), |
1105 | CR->Surface2(), |
1106 | Ein.Location() * CR->Location(), |
1107 | Ein.Location() * CR->Location2(), |
1108 | CR->Continuity()); |
1109 | } |
1110 | |
1111 | itcr.Next(); |
1112 | } |
1113 | } |
1114 | |
1115 | |
1116 | //======================================================================= |
1117 | //function : UpdateVertex |
1118 | //purpose : update vertex with 3d point |
1119 | //======================================================================= |
1120 | |
1121 | void BRep_Builder::UpdateVertex(const TopoDS_Vertex& V, |
1122 | const gp_Pnt& P, |
1123 | const Standard_Real Tol) const |
1124 | { |
1125 | const Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &V.TShape()); |
1126 | |
1127 | TV->Pnt(P.Transformed(V.Location().Inverted().Transformation())); |
1128 | TV->UpdateTolerance(Tol); |
1129 | TV->Modified(Standard_True); |
1130 | } |
1131 | |
1132 | |
1133 | //======================================================================= |
1134 | //function : UpdateVertex |
1135 | //purpose : update vertex with parameter on edge |
1136 | //======================================================================= |
1137 | |
1138 | void BRep_Builder::UpdateVertex(const TopoDS_Vertex& V, |
1139 | const Standard_Real Par, |
1140 | const TopoDS_Edge& E, |
1141 | const Standard_Real Tol) const |
1142 | { |
1143 | if (Precision::IsPositiveInfinite(Par) || |
1144 | Precision::IsNegativeInfinite(Par)) |
1145 | Standard_DomainError::Raise("BRep_Builder::Infinite parameter"); |
1146 | |
1147 | const Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &V.TShape()); |
1148 | const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); |
1149 | |
1150 | TopLoc_Location L = E.Location().Predivided(V.Location()); |
1151 | |
1152 | // Search the vertex in the edge |
1153 | TopAbs_Orientation ori = TopAbs_INTERNAL; |
1154 | |
1155 | TopoDS_Iterator itv(E.Oriented(TopAbs_FORWARD)); |
1156 | |
1157 | // if the edge has no vertices |
1158 | // and is degenerated use the vertex orientation |
1159 | // RLE, june 94 |
1160 | |
1161 | if (!itv.More() && TE->Degenerated()) |
1162 | ori = V.Orientation(); |
1163 | |
1164 | while (itv.More()) { |
1165 | const TopoDS_Shape& Vcur = itv.Value(); |
1166 | if (V.IsSame(Vcur)) { |
1167 | ori = Vcur.Orientation(); |
1168 | if (ori == V.Orientation()) break; |
1169 | } |
1170 | itv.Next(); |
1171 | } |
1172 | |
1173 | BRep_ListOfCurveRepresentation& lcr = TE->ChangeCurves(); |
1174 | BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr); |
1175 | Handle(BRep_GCurve) GC; |
1176 | |
1177 | while (itcr.More()) { |
1178 | GC = Handle(BRep_GCurve)::DownCast(itcr.Value()); |
1179 | if (!GC.IsNull()) { |
1180 | if (ori == TopAbs_FORWARD) |
1181 | GC->First(Par); |
1182 | else if (ori == TopAbs_REVERSED) |
1183 | GC->Last(Par); |
1184 | else { |
1185 | BRep_ListOfPointRepresentation& lpr = TV->ChangePoints(); |
1186 | const TopLoc_Location& GCloc = GC->Location(); |
1187 | TopLoc_Location LGCloc = L*GCloc; |
1188 | if (GC->IsCurve3D()) { |
1189 | const Handle(Geom_Curve)& GC3d = GC->Curve3D(); |
1190 | UpdatePoints(lpr,Par,GC3d,LGCloc); |
1191 | } |
1192 | else if (GC->IsCurveOnSurface()) { |
1193 | const Handle(Geom2d_Curve)& GCpc = GC->PCurve(); |
1194 | const Handle(Geom_Surface)& GCsu = GC->Surface(); |
1195 | UpdatePoints(lpr,Par,GCpc,GCsu,LGCloc); |
1196 | } |
1197 | } |
1198 | } |
1199 | itcr.Next(); |
1200 | } |
1201 | |
1202 | if ((ori != TopAbs_FORWARD) && (ori != TopAbs_REVERSED)) |
1203 | TV->Modified(Standard_True); |
1204 | TV->UpdateTolerance(Tol); |
1205 | TE->Modified(Standard_True); |
1206 | } |
1207 | |
1208 | |
1209 | //======================================================================= |
1210 | //function : UpdateVertex |
1211 | //purpose : update vertex with parameter on edge on face |
1212 | //======================================================================= |
1213 | |
1214 | void BRep_Builder::UpdateVertex(const TopoDS_Vertex& V, |
1215 | const Standard_Real Par, |
1216 | const TopoDS_Edge& E, |
1217 | const Handle(Geom_Surface)& S, |
1218 | const TopLoc_Location& L, |
1219 | const Standard_Real Tol) const |
1220 | { |
1221 | if (Precision::IsPositiveInfinite(Par) || |
1222 | Precision::IsNegativeInfinite(Par)) |
1223 | Standard_DomainError::Raise("BRep_Builder::Infinite parameter"); |
1224 | |
1225 | // Find the curve representation |
1226 | TopLoc_Location l = L.Predivided(V.Location()); |
1227 | |
1228 | const Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &V.TShape()); |
1229 | const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape()); |
1230 | |
1231 | |
1232 | // Search the vertex in the edge |
1233 | TopAbs_Orientation ori = TopAbs_INTERNAL; |
1234 | |
1235 | TopoDS_Iterator itv(E.Oriented(TopAbs_FORWARD)); |
1236 | |
1237 | // if the edge has no vertices |
1238 | // and is degenerated use the vertex orientation |
1239 | // RLE, june 94 |
1240 | |
1241 | if (!itv.More() && TE->Degenerated()) |
1242 | ori = V.Orientation(); |
1243 | |
1244 | while (itv.More()) { |
1245 | const TopoDS_Shape& Vcur = itv.Value(); |
1246 | if (V.IsSame(Vcur)) { |
1247 | ori = Vcur.Orientation(); |
1248 | if (ori == V.Orientation()) break; |
1249 | } |
1250 | itv.Next(); |
1251 | } |
1252 | |
1253 | BRep_ListOfCurveRepresentation& lcr = TE->ChangeCurves(); |
1254 | BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr); |
1255 | Handle(BRep_GCurve) GC; |
1256 | |
1257 | while (itcr.More()) { |
1258 | GC = Handle(BRep_GCurve)::DownCast(itcr.Value()); |
1259 | if (!GC.IsNull()) { |
1260 | // if (GC->IsCurveOnSurface(S,l)) { |
1261 | if (GC->IsCurveOnSurface(S,L)) { //xpu020198 : BUC60407 |
1262 | if (ori == TopAbs_FORWARD) |
1263 | GC->First(Par); |
1264 | else if (ori == TopAbs_REVERSED) |
1265 | GC->Last(Par); |
1266 | else { |
1267 | BRep_ListOfPointRepresentation& lpr = TV->ChangePoints(); |
1268 | const Handle(Geom2d_Curve)& GCpc = GC->PCurve(); |
1269 | UpdatePoints(lpr,Par,GCpc,S,l); |
1270 | TV->Modified(Standard_True); |
1271 | } |
1272 | break; |
1273 | } |
1274 | } |
1275 | itcr.Next(); |
1276 | } |
1277 | |
1278 | if (!itcr.More()) |
1279 | Standard_DomainError::Raise("BRep_Builder:: no pcurve"); |
1280 | |
1281 | TV->UpdateTolerance(Tol); |
1282 | TE->Modified(Standard_True); |
1283 | } |
1284 | |
1285 | //======================================================================= |
1286 | //function : UpdateVertex |
1287 | //purpose : update vertex with parameters on face |
1288 | //======================================================================= |
1289 | |
1290 | void BRep_Builder::UpdateVertex(const TopoDS_Vertex& Ve, |
1291 | const Standard_Real U, |
1292 | const Standard_Real V, |
1293 | const TopoDS_Face& F, |
1294 | const Standard_Real Tol) const |
1295 | { |
1296 | const Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &Ve.TShape()); |
1297 | |
1298 | TopLoc_Location L; |
1299 | const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,L); |
1300 | L = L.Predivided(Ve.Location()); |
1301 | BRep_ListOfPointRepresentation& lpr = TV->ChangePoints(); |
1302 | UpdatePoints(lpr,U,V,S,L); |
1303 | |
1304 | TV->UpdateTolerance(Tol); |
1305 | TV->Modified(Standard_True); |
1306 | } |
1307 | |
1308 | //======================================================================= |
1309 | //function : UpdateVertex |
1310 | //purpose : update vertex with 3d point |
1311 | //======================================================================= |
1312 | |
1313 | void BRep_Builder::UpdateVertex(const TopoDS_Vertex& V, |
1314 | const Standard_Real Tol) const |
1315 | { |
1316 | const Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &V.TShape()); |
1317 | TV->UpdateTolerance(Tol); |
1318 | TV->Modified(Standard_True); |
1319 | } |
1320 | |
1321 | |
1322 | //======================================================================= |
1323 | //function : Transfert |
1324 | //purpose : |
1325 | //======================================================================= |
1326 | |
1327 | void BRep_Builder::Transfert(const TopoDS_Edge& Ein, |
1328 | const TopoDS_Edge& Eout, |
1329 | const TopoDS_Vertex& Vin, |
1330 | const TopoDS_Vertex& Vout) const |
1331 | { |
1332 | const Standard_Real tol = BRep_Tool::Tolerance(Vin); |
1333 | const Standard_Real parin = BRep_Tool::Parameter(Vin,Ein); |
1334 | UpdateVertex(Vout,parin,Eout,tol); |
1335 | } |