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