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