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