1 // Created on: 1993-06-14
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <MgtBRep_TranslateTool.ixx>
18 #include <MgtTopLoc.hxx>
19 #include <MgtGeom.hxx>
20 #include <MgtGeom2d.hxx>
21 #include <MgtPoly.hxx>
25 #include <BRep_Builder.hxx>
26 #include <BRep_TVertex.hxx>
27 #include <BRep_TEdge.hxx>
28 #include <BRep_TFace.hxx>
30 #include <BRep_Curve3D.hxx>
31 #include <BRep_CurveOnSurface.hxx>
32 #include <BRep_CurveOnClosedSurface.hxx>
33 #include <BRep_CurveOn2Surfaces.hxx>
34 #include <BRep_Polygon3D.hxx>
35 #include <BRep_PolygonOnSurface.hxx>
36 #include <BRep_PolygonOnClosedSurface.hxx>
37 #include <BRep_PolygonOnTriangulation.hxx>
38 #include <BRep_PolygonOnClosedTriangulation.hxx>
39 #include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
41 #include <BRep_PointOnCurve.hxx>
42 #include <BRep_PointOnCurveOnSurface.hxx>
43 #include <BRep_PointOnSurface.hxx>
44 #include <BRep_ListIteratorOfListOfPointRepresentation.hxx>
46 #include <PTopoDS_TWire.hxx>
47 #include <PTopoDS_TShell.hxx>
48 #include <PTopoDS_TSolid.hxx>
49 #include <PTopoDS_TCompSolid.hxx>
50 #include <PTopoDS_TCompound.hxx>
52 #include <PBRep_TVertex.hxx>
53 #include <PBRep_TEdge.hxx>
54 #include <PBRep_TFace.hxx>
56 #include <PBRep_Curve3D.hxx>
57 #include <PBRep_CurveOnSurface.hxx>
58 #include <PBRep_CurveOnClosedSurface.hxx>
59 #include <PBRep_CurveOn2Surfaces.hxx>
61 #include <PBRep_PointOnCurve.hxx>
62 #include <PBRep_PointOnCurveOnSurface.hxx>
63 #include <PBRep_PointOnSurface.hxx>
64 #include <PBRep_Polygon3D.hxx>
65 #include <PBRep_PolygonOnSurface.hxx>
66 #include <PBRep_PolygonOnClosedSurface.hxx>
67 #include <PBRep_PolygonOnTriangulation.hxx>
68 #include <PBRep_PolygonOnClosedTriangulation.hxx>
70 #include <Standard_NullObject.hxx>
72 // szy 23.01.2014 (bug 24565) correction for edge which has null 3d curve representation
74 // Used for testing DownCast time
77 #include <OSD_Timer.hxx>
78 extern OSD_Timer CurveTimer;
79 extern OSD_Timer Curve2dTimer;
80 extern OSD_Timer SurfaceTimer;
83 // *****************************
84 // Auxiliary translation methods
85 // *****************************
87 //=======================================================================
88 //function : Translate
89 //purpose : Curve T->P
90 //=======================================================================
92 Handle(PGeom_Curve) MgtBRep_TranslateTool::Translate
93 (const Handle(Geom_Curve)& TP,
94 PTColStd_TransientPersistentMap& aMap) const
96 Handle(PGeom_Curve) PP;
98 if (aMap.IsBound(TP)) {
99 Handle(Standard_Persistent) aPers = aMap.Find(TP);
100 PP = (Handle(PGeom_Curve)&) aPers;
103 PP = MgtGeom::Translate(TP);
110 //=======================================================================
111 //function : Translate
112 //purpose : Curve P->T
113 //=======================================================================
115 Handle(Geom_Curve) MgtBRep_TranslateTool::Translate
116 (const Handle(PGeom_Curve)& PP,
117 PTColStd_PersistentTransientMap& aMap) const
122 Handle(Geom_Curve) TP;
124 if (aMap.IsBound(PP)) {
125 Handle(Standard_Transient) aTrans = aMap.Find(PP);
126 TP = (Handle(Geom_Curve)&) aTrans;
129 TP = MgtGeom::Translate(PP);
139 //=======================================================================
140 //function : Translate
141 //purpose : Curve2d T->P
142 //=======================================================================
144 Handle(PGeom2d_Curve) MgtBRep_TranslateTool::Translate
145 (const Handle(Geom2d_Curve)& TP,
146 PTColStd_TransientPersistentMap& aMap) const
148 Handle(PGeom2d_Curve) PP;
150 if (aMap.IsBound(TP)) {
151 Handle(Standard_Persistent) aPers = aMap.Find(TP);
152 PP = (Handle(PGeom2d_Curve)&) aPers;
155 PP = MgtGeom2d::Translate(TP);
162 //=======================================================================
163 //function : Translate
164 //purpose : Curve2d P->T
165 //=======================================================================
167 Handle(Geom2d_Curve) MgtBRep_TranslateTool::Translate
168 (const Handle(PGeom2d_Curve)& PP,
169 PTColStd_PersistentTransientMap& aMap) const
172 Curve2dTimer.Start();
174 Handle(Geom2d_Curve) TP;
176 if (aMap.IsBound(PP)) {
177 Handle(Standard_Transient) aTrans = aMap.Find(PP);
178 TP = (Handle(Geom2d_Curve)&) aTrans;
181 TP = MgtGeom2d::Translate(PP);
191 //=======================================================================
192 //function : Translate
193 //purpose : Surface T->P
194 //=======================================================================
196 Handle(PGeom_Surface) MgtBRep_TranslateTool::Translate
197 (const Handle(Geom_Surface)& TP,
198 PTColStd_TransientPersistentMap& aMap) const
200 Handle(PGeom_Surface) PP;
202 if (aMap.IsBound(TP)) {
203 Handle(Standard_Persistent) aPers = aMap.Find(TP);
204 PP = (Handle(PGeom_Surface)&) aPers;
207 PP = MgtGeom::Translate(TP);
214 //=======================================================================
215 //function : Translate
216 //purpose : Surface P->T
217 //=======================================================================
219 Handle(Geom_Surface) MgtBRep_TranslateTool::Translate
220 (const Handle(PGeom_Surface)& PP,
221 PTColStd_PersistentTransientMap& aMap) const
224 SurfaceTimer.Start();
226 Handle(Geom_Surface) TP;
228 if (aMap.IsBound(PP)) {
229 Handle(Standard_Transient) aTrans = aMap.Find(PP);
230 TP = (Handle(Geom_Surface)&) aTrans;
233 TP = MgtGeom::Translate(PP);
243 //=======================================================================
244 //function : MgtBRep_TranslateTool
245 //purpose : Constructor
246 //=======================================================================
248 MgtBRep_TranslateTool::MgtBRep_TranslateTool
249 (const MgtBRep_TriangleMode aTriMode) :
250 myTriangleMode(aTriMode)
254 //=======================================================================
257 //=======================================================================
259 void MgtBRep_TranslateTool::Add(TopoDS_Shape& S1,
260 const TopoDS_Shape& S2) const
266 //=======================================================================
267 //function : MakeVertex
269 //=======================================================================
271 void MgtBRep_TranslateTool::MakeVertex(TopoDS_Shape& S) const
274 B.MakeVertex(TopoDS::Vertex(S));
278 //=======================================================================
279 //function : MakeVertex
281 //=======================================================================
283 void MgtBRep_TranslateTool::MakeVertex(const Handle(PTopoDS_HShape)& S) const
285 Handle(PBRep_TVertex) T = new PBRep_TVertex();
290 //=======================================================================
291 //function : MakeEdge
293 //=======================================================================
295 void MgtBRep_TranslateTool::MakeEdge(TopoDS_Shape& S) const
298 B.MakeEdge(TopoDS::Edge(S));
302 //=======================================================================
303 //function : MakeEdge
305 //=======================================================================
307 void MgtBRep_TranslateTool::MakeEdge(const Handle(PTopoDS_HShape)& S) const
309 Handle(PBRep_TEdge) T = new PBRep_TEdge();
314 //=======================================================================
315 //function : MakeWire
317 //=======================================================================
319 void MgtBRep_TranslateTool::MakeWire(TopoDS_Shape& S) const
322 B.MakeWire(TopoDS::Wire(S));
326 //=======================================================================
327 //function : MakeWire
329 //=======================================================================
331 void MgtBRep_TranslateTool::MakeWire(const Handle(PTopoDS_HShape)& S) const
333 Handle(PTopoDS_TWire) T = new PTopoDS_TWire();
338 //=======================================================================
339 //function : MakeFace
341 //=======================================================================
343 void MgtBRep_TranslateTool::MakeFace(TopoDS_Shape& S) const
346 B.MakeFace(TopoDS::Face(S));
350 //=======================================================================
351 //function : MakeFace
353 //=======================================================================
355 void MgtBRep_TranslateTool::MakeFace(const Handle(PTopoDS_HShape)& S) const
357 Handle(PBRep_TFace) T = new PBRep_TFace();
362 //=======================================================================
363 //function : MakeShell
365 //=======================================================================
367 void MgtBRep_TranslateTool::MakeShell(TopoDS_Shape& S) const
370 B.MakeShell(TopoDS::Shell(S));
374 //=======================================================================
375 //function : MakeShell
377 //=======================================================================
379 void MgtBRep_TranslateTool::MakeShell(const Handle(PTopoDS_HShape)& S) const
381 Handle(PTopoDS_TShell) T = new PTopoDS_TShell();
386 //=======================================================================
387 //function : MakeSolid
389 //=======================================================================
391 void MgtBRep_TranslateTool::MakeSolid(TopoDS_Shape& S) const
394 B.MakeSolid(TopoDS::Solid(S));
398 //=======================================================================
399 //function : MakeSolid
401 //=======================================================================
403 void MgtBRep_TranslateTool::MakeSolid(const Handle(PTopoDS_HShape)& S) const
405 Handle(PTopoDS_TSolid) T = new PTopoDS_TSolid();
410 //=======================================================================
411 //function : MakeCompSolid
413 //=======================================================================
415 void MgtBRep_TranslateTool::MakeCompSolid(TopoDS_Shape& S) const
418 B.MakeCompSolid(TopoDS::CompSolid(S));
422 //=======================================================================
423 //function : MakeCompSolid
425 //=======================================================================
428 MgtBRep_TranslateTool::MakeCompSolid(const Handle(PTopoDS_HShape)& S) const
430 Handle(PTopoDS_TCompSolid) T = new PTopoDS_TCompSolid();
435 //=======================================================================
436 //function : MakeCompound
438 //=======================================================================
440 void MgtBRep_TranslateTool::MakeCompound(TopoDS_Shape& S) const
443 B.MakeCompound(TopoDS::Compound(S));
447 //=======================================================================
448 //function : MakeCompound
450 //=======================================================================
453 MgtBRep_TranslateTool::MakeCompound(const Handle(PTopoDS_HShape)& S) const
455 Handle(PTopoDS_TCompound) T = new PTopoDS_TCompound();
460 //=======================================================================
461 //function : UpdateVertex
462 //purpose : Transient->Persistent
463 //=======================================================================
465 void MgtBRep_TranslateTool::UpdateVertex
466 (const TopoDS_Shape& S1,
467 const Handle(PTopoDS_HShape)& S2,
468 PTColStd_TransientPersistentMap& aMap) const
470 Handle(TopoDS_TShape) aTransTShape = S1.TShape();
471 Handle(BRep_TVertex)& TTV = (Handle(BRep_TVertex)&) aTransTShape;
472 Handle(PTopoDS_TShape) aPersTShape = S2->TShape();
473 Handle(PBRep_TVertex)& PTV = (Handle(PBRep_TVertex)&) aPersTShape;
476 PTV->Pnt(TTV->Pnt());
479 PTV->Tolerance(TTV->Tolerance());
482 BRep_ListIteratorOfListOfPointRepresentation itpr(TTV->Points());
484 Handle(PBRep_PointRepresentation) PPR, CPPR;
485 while (itpr.More()) {
487 const Handle(BRep_PointRepresentation)& PR = itpr.Value();
489 if (PR->IsPointOnCurve()) {
490 Handle(PBRep_PointOnCurve) POC = new
491 PBRep_PointOnCurve(PR->Parameter(),
492 MgtBRep_TranslateTool::Translate(PR->Curve(), aMap),
493 MgtTopLoc::Translate(PR->Location(), aMap));
497 else if (PR->IsPointOnCurveOnSurface()) {
498 Handle(PBRep_PointOnCurveOnSurface) POCS =
499 new PBRep_PointOnCurveOnSurface(PR->Parameter(),
500 MgtBRep_TranslateTool::Translate(PR->PCurve(), aMap),
501 MgtBRep_TranslateTool::Translate(PR->Surface(), aMap),
502 MgtTopLoc::Translate(PR->Location(), aMap));
506 else if (PR->IsPointOnSurface()) {
507 Handle(PBRep_PointOnSurface) POS =
508 new PBRep_PointOnSurface(PR->Parameter(),
510 MgtBRep_TranslateTool::Translate(PR->Surface(), aMap),
511 MgtTopLoc::Translate(PR->Location(), aMap));
522 MgtTopoDS_TranslateTool::UpdateVertex(S1,S2, aMap);
526 //=======================================================================
527 //function : UpdateVertex
528 //purpose : Persistent->Transient
529 //=======================================================================
531 void MgtBRep_TranslateTool::UpdateVertex
532 (const Handle(PTopoDS_HShape)& S1,
534 PTColStd_PersistentTransientMap& aMap) const
536 Handle(PTopoDS_TShape) aPersTShape = S1->TShape();
537 Handle(PBRep_TVertex)& PTV = (Handle(PBRep_TVertex)&) aPersTShape;
539 Handle(TopoDS_TShape) aTransTShape = S2.TShape();
540 Handle(BRep_TVertex)& TTV = (Handle(BRep_TVertex)&) aTransTShape;
543 TTV->Pnt(PTV->Pnt());
546 TTV->Tolerance(PTV->Tolerance());
549 Handle(PBRep_PointRepresentation) PPR = PTV->Points();
550 BRep_ListOfPointRepresentation& lpr = TTV->ChangePoints();
554 Handle(BRep_PointRepresentation) PR;
556 while (!PPR.IsNull()) {
558 if (PPR->IsPointOnCurve()) {
559 Handle(PBRep_PointOnCurve)& POC = (Handle(PBRep_PointOnCurve)&) PPR;
560 Handle(BRep_PointOnCurve) OC =
561 new BRep_PointOnCurve(POC->Parameter(),
562 MgtBRep_TranslateTool::Translate(POC->Curve(), aMap),
563 MgtTopLoc::Translate(POC->Location(), aMap));
567 else if (PPR->IsPointOnCurveOnSurface()) {
568 Handle(PBRep_PointOnCurveOnSurface)& POCS =
569 (Handle(PBRep_PointOnCurveOnSurface)&) PPR;
570 Handle(BRep_PointOnCurveOnSurface) OCS =
571 new BRep_PointOnCurveOnSurface(POCS->Parameter(),
572 MgtBRep_TranslateTool::Translate(POCS->PCurve(), aMap),
573 MgtBRep_TranslateTool::Translate(POCS->Surface(), aMap),
574 MgtTopLoc::Translate(POCS->Location(), aMap));
578 else if (PPR->IsPointOnSurface()) {
579 Handle(PBRep_PointOnSurface)& POS = (Handle(PBRep_PointOnSurface)&) PPR;
580 Handle(BRep_PointOnSurface) OS =
581 new BRep_PointOnSurface(POS->Parameter(),
583 MgtBRep_TranslateTool::Translate(POS->Surface(), aMap),
584 MgtTopLoc::Translate(POS->Location(), aMap));
592 MgtTopoDS_TranslateTool::UpdateVertex(S1,S2, aMap);
596 //=======================================================================
597 //function : UpdateEdge
598 //purpose : Transient->Persistent
599 //=======================================================================
602 MgtBRep_TranslateTool::UpdateEdge(const TopoDS_Shape& S1,
603 const Handle(PTopoDS_HShape)& S2,
604 PTColStd_TransientPersistentMap& aMap) const
606 Handle(TopoDS_TShape) aTransTShape = S1.TShape();
607 Handle(BRep_TEdge)& TTE = (Handle(BRep_TEdge)&) aTransTShape;
609 Handle(PTopoDS_TShape) aPersTShape = S2->TShape();
610 Handle(PBRep_TEdge)& PTE = (Handle(PBRep_TEdge)&) aPersTShape;
613 PTE->Tolerance(TTE->Tolerance());
616 PTE->SameParameter(TTE->SameParameter());
619 PTE->SameRange(TTE->SameRange());
622 PTE->Degenerated(TTE->Degenerated());
625 BRep_ListIteratorOfListOfCurveRepresentation itcr(TTE->Curves());
627 Handle(PBRep_CurveRepresentation) PCR, CPCR;
628 Handle(BRep_GCurve) GC;
631 while (itcr.More()) {
633 const Handle(BRep_CurveRepresentation)& CR = itcr.Value();
635 GC = Handle(BRep_GCurve)::DownCast(CR);
639 // CurveRepresentation is Curve3D
640 if (CR->IsCurve3D()) {
641 Handle(PBRep_Curve3D) C3D = new
642 PBRep_Curve3D(MgtBRep_TranslateTool::Translate(CR->Curve3D(),aMap),
643 f, l, MgtTopLoc::Translate(CR->Location(), aMap));
647 // CurveRepresentation is CurveOnSurface
648 else if (CR->IsCurveOnSurface()) {
650 Handle(BRep_CurveOnSurface)& theCOS=(Handle(BRep_CurveOnSurface)&) CR;
651 Handle(PBRep_CurveOnSurface) COS;
653 // CurveRepresentation is CurveOnSurface
654 if (!CR->IsCurveOnClosedSurface()) {
656 new PBRep_CurveOnSurface
657 (MgtBRep_TranslateTool::Translate(CR->PCurve(), aMap),
659 MgtBRep_TranslateTool::Translate(CR->Surface(), aMap),
660 MgtTopLoc::Translate(CR->Location(), aMap));
663 // CurveRepresentation is CurveOnClosedSurface
665 // get UVPoints for the CurveOnClosedSurface definition.
666 Handle(BRep_CurveOnClosedSurface)& theCOCS =
667 (Handle(BRep_CurveOnClosedSurface)&) CR;
668 gp_Pnt2d Pnt21, Pnt22;
669 theCOCS->UVPoints2(Pnt21, Pnt22);
670 Handle(PBRep_CurveOnClosedSurface) COCS =
671 new PBRep_CurveOnClosedSurface
672 (MgtBRep_TranslateTool::Translate(CR->PCurve(), aMap),
673 MgtBRep_TranslateTool::Translate(CR->PCurve2(), aMap),
675 MgtBRep_TranslateTool::Translate(CR->Surface(), aMap),
676 MgtTopLoc::Translate(CR->Location(), aMap),
678 COCS->SetUVPoints2(Pnt21, Pnt22);
682 // get UVPoints for the CurveOnSurface definition.
684 theCOS->UVPoints(Pnt1, Pnt2);
686 // If we don't do that, there is anything (NAN: Not A Number) instead.
687 COS->SetUVPoints(Pnt1, Pnt2);
693 // CurveRepresentation is CurveOn2Surfaces
694 else if (CR->IsRegularity()) {
696 Handle(PBRep_CurveOn2Surfaces) R =
697 new PBRep_CurveOn2Surfaces
698 (MgtBRep_TranslateTool::Translate(CR->Surface(), aMap),
699 MgtBRep_TranslateTool::Translate(CR->Surface2(), aMap),
700 MgtTopLoc::Translate(CR->Location(), aMap),
701 MgtTopLoc::Translate(CR->Location2(), aMap),
706 // CurveRepresentation is Polygon or Triangulation
707 else if (myTriangleMode == MgtBRep_WithTriangle) {
709 // CurveRepresentation is Polygon3D
710 if (CR->IsPolygon3D()) {
711 Handle(PBRep_Polygon3D) P3D =
712 new PBRep_Polygon3D(MgtPoly::Translate(CR->Polygon3D(), aMap),
713 MgtTopLoc::Translate(CR->Location(), aMap));
717 // CurveRepresentation is PolygonOnSurface
718 else if (CR->IsPolygonOnSurface()) {
720 // CurveRepresentation is PolygonOnClosedSurface
721 if (CR->IsPolygonOnClosedSurface()) {
722 Handle(PBRep_PolygonOnClosedSurface) PolOCS = new
723 PBRep_PolygonOnClosedSurface(MgtPoly::Translate(CR->Polygon(), aMap),
724 MgtPoly::Translate(CR->Polygon2(), aMap),
725 MgtBRep_TranslateTool::Translate(CR->Surface(), aMap),
726 MgtTopLoc::Translate(CR->Location(), aMap));
730 // CurveRepresentation is PolygonOnSurface
732 Handle(PBRep_PolygonOnSurface) PolOS = new
733 PBRep_PolygonOnSurface(MgtPoly::Translate(CR->Polygon(), aMap),
734 MgtBRep_TranslateTool::Translate(CR->Surface(),aMap),
735 MgtTopLoc::Translate(CR->Location(), aMap));
740 // CurveRepresentation is PolygonOnTriangulation
741 else if (CR->IsPolygonOnTriangulation()) {
743 // CurveRepresentation is PolygonOnClosedTriangulation
744 if (CR->IsPolygonOnClosedTriangulation()) {
746 Handle(PBRep_PolygonOnClosedTriangulation) PolOCT= new
747 PBRep_PolygonOnClosedTriangulation
748 (MgtPoly::Translate(CR->PolygonOnTriangulation(), aMap),
749 MgtPoly::Translate(CR->PolygonOnTriangulation2(), aMap),
750 MgtPoly::Translate(CR->Triangulation(), aMap),
751 MgtTopLoc::Translate(CR->Location(), aMap));
755 // CurveRepresentation is PolygonOnTriangulation
757 Handle(PBRep_PolygonOnTriangulation) PolOT = new
758 PBRep_PolygonOnTriangulation
759 (MgtPoly::Translate(CR->PolygonOnTriangulation(), aMap),
760 MgtPoly::Translate(CR->Triangulation(), aMap),
761 MgtTopLoc::Translate(CR->Location(), aMap));
767 // jumps the curve representation
772 Standard_NullObject_Raise_if (CPCR.IsNull(), "Null CurveRepresentation");
782 MgtTopoDS_TranslateTool::UpdateEdge(S1,S2, aMap);
786 //=======================================================================
787 //function : UpdateEdge
788 //purpose : Persistent->Transient
789 //=======================================================================
792 MgtBRep_TranslateTool::UpdateEdge(const Handle(PTopoDS_HShape)& S1,
794 PTColStd_PersistentTransientMap& aMap) const
796 Handle(PTopoDS_TShape) aPersTShape = S1->TShape();
797 Handle(PBRep_TEdge)& PTE = (Handle(PBRep_TEdge)&) aPersTShape;
799 Handle(TopoDS_TShape) aTransTShape = S2.TShape();
800 Handle(BRep_TEdge)& TTE = (Handle(BRep_TEdge)&) aTransTShape;
803 TTE->Tolerance(PTE->Tolerance());
806 TTE->SameParameter(PTE->SameParameter());
809 TTE->SameRange(PTE->SameRange());
812 TTE->Degenerated(PTE->Degenerated());
815 Handle(PBRep_CurveRepresentation) PCR = PTE->Curves();
816 BRep_ListOfCurveRepresentation& lcr = TTE->ChangeCurves();
819 Handle(BRep_CurveRepresentation) CR;
821 while (!PCR.IsNull()) {
823 if (PCR->IsGCurve()) {
824 Handle(PBRep_GCurve)& PGC = (Handle(PBRep_GCurve)&) PCR;
825 if (PCR->IsCurveOnSurface()) {
827 if (!PCR->IsCurveOnClosedSurface()) {
828 // CurveRepresentation is a PBRep_CurveOnSurface
829 Handle(PBRep_CurveOnSurface)& PCOS = (Handle(PBRep_CurveOnSurface)&) PCR;
830 Handle(BRep_CurveOnSurface) COS =
831 new BRep_CurveOnSurface
832 (MgtBRep_TranslateTool::Translate(PCOS->PCurve(), aMap),
833 MgtBRep_TranslateTool::Translate(PCOS->Surface(), aMap),
834 MgtTopLoc::Translate(PCOS->Location(), aMap));
835 Pnt1 = PCOS->FirstUV();
836 Pnt2 = PCOS->LastUV();
837 COS->SetUVPoints(Pnt1, Pnt2);
838 COS->SetRange(PGC->First(), PGC->Last());
842 // CurveRepresentation is a PBRep_CurveOnClosedSurface
843 gp_Pnt2d Pnt21, Pnt22;
844 Handle(PBRep_CurveOnClosedSurface)& PCOCS =
845 (Handle(PBRep_CurveOnClosedSurface)&) PCR;
846 Handle(BRep_CurveOnClosedSurface) COCS =
847 new BRep_CurveOnClosedSurface
848 (MgtBRep_TranslateTool::Translate(PCOCS->PCurve(), aMap),
849 MgtBRep_TranslateTool::Translate(PCOCS->PCurve2(), aMap),
850 MgtBRep_TranslateTool::Translate(PCOCS->Surface(), aMap),
851 MgtTopLoc::Translate(PCOCS->Location(), aMap),
852 PCOCS->Continuity());
853 Pnt21 = PCOCS->FirstUV2();
854 Pnt22 = PCOCS->LastUV2();
855 COCS->SetUVPoints(Pnt1, Pnt2); // Is it necessary?
856 COCS->SetUVPoints2(Pnt21, Pnt22);
857 COCS->SetRange(PGC->First(), PGC->Last());
861 else if (PCR->IsCurve3D()) {
862 Handle(PBRep_Curve3D)& PC3D = (Handle(PBRep_Curve3D)&) PCR;
864 // szy 23.01.2014: correction for edge which has null 3d curve representation
865 Handle(BRep_Curve3D) C3D =
866 new BRep_Curve3D(MgtBRep_TranslateTool::Translate(PC3D->Curve3D(), aMap),
867 MgtTopLoc::Translate(PC3D->Location(), aMap));
868 C3D->SetRange(PGC->First(), PGC->Last());
872 else if (PCR->IsRegularity()) {
873 Handle(PBRep_CurveOn2Surfaces)& PR =
874 (Handle(PBRep_CurveOn2Surfaces)&) PCR;
875 Handle(BRep_CurveOn2Surfaces) R =
876 new BRep_CurveOn2Surfaces
877 (MgtBRep_TranslateTool::Translate(PR->Surface(), aMap),
878 MgtBRep_TranslateTool::Translate(PR->Surface2(), aMap),
879 MgtTopLoc::Translate(PR->Location(), aMap),
880 MgtTopLoc::Translate(PR->Location2(), aMap),
885 else if (myTriangleMode == MgtBRep_WithTriangle) {
886 if (PCR->IsPolygon3D()) {
887 Handle(PBRep_Polygon3D)& PP3D = (Handle(PBRep_Polygon3D)&) PCR;
888 Handle(BRep_Polygon3D) P3D = new
889 BRep_Polygon3D(MgtPoly::Translate(PP3D->Polygon3D(), aMap),
890 MgtTopLoc::Translate(PP3D->Location(), aMap));
893 else if (PCR->IsPolygonOnSurface()) {
894 if (PCR->IsPolygonOnClosedSurface()) {
895 Handle(PBRep_PolygonOnClosedSurface)& PPol =
896 (Handle(PBRep_PolygonOnClosedSurface)&) PCR;
897 Handle(BRep_PolygonOnClosedSurface) PolOCS = new
898 BRep_PolygonOnClosedSurface
899 (MgtPoly::Translate(PPol->Polygon(), aMap),
900 MgtPoly::Translate(PPol->Polygon2(), aMap),
901 MgtBRep_TranslateTool::Translate(PPol->Surface(), aMap),
902 MgtTopLoc::Translate(PPol->Location(), aMap));
906 Handle(PBRep_PolygonOnSurface)& PPol =
907 (Handle(PBRep_PolygonOnSurface)&) PCR;
908 Handle(BRep_PolygonOnSurface) PolOS = new
909 BRep_PolygonOnSurface
910 (MgtPoly::Translate(PPol->Polygon(), aMap),
911 MgtBRep_TranslateTool::Translate(PPol->Surface(), aMap),
912 MgtTopLoc::Translate(PPol->Location(), aMap));
916 // PCR is a PolygonOnTriangulation
917 else if (PCR->IsPolygonOnTriangulation()) {
919 Handle(PBRep_PolygonOnTriangulation)& POT =
920 (Handle(PBRep_PolygonOnTriangulation)&) PCR;
922 // PCR is a PolygonOnClosedTriangulation
923 if (PCR->IsPolygonOnClosedTriangulation()) {
924 Handle(PBRep_PolygonOnClosedTriangulation)& POCT =
925 (Handle(PBRep_PolygonOnClosedTriangulation)&) PCR;
927 Handle(BRep_PolygonOnClosedTriangulation) PolOCT= new
928 BRep_PolygonOnClosedTriangulation
929 (MgtPoly::Translate(POCT->PolygonOnTriangulation(), aMap),
930 MgtPoly::Translate(POCT->PolygonOnTriangulation2(), aMap),
931 MgtPoly::Translate(POCT->Triangulation(), aMap),
932 MgtTopLoc::Translate(POCT->Location(), aMap));
935 // PCR is a PolygonOnTriangulation
937 Handle(BRep_PolygonOnTriangulation) PolOT = new
938 BRep_PolygonOnTriangulation
939 (MgtPoly::Translate(POT->PolygonOnTriangulation(), aMap),
940 MgtPoly::Translate(POT->Triangulation(), aMap),
941 MgtTopLoc::Translate(POT->Location(), aMap));
947 // jumps the Curve Representation
952 Standard_NullObject_Raise_if (CR.IsNull(), "Persistant CurveRep is Null");
958 MgtTopoDS_TranslateTool::UpdateEdge(S1,S2, aMap);
962 //=======================================================================
963 //function : UpdateFace
964 //purpose : Transient->Persistent
965 //=======================================================================
968 MgtBRep_TranslateTool::UpdateFace(const TopoDS_Shape& S1,
969 const Handle(PTopoDS_HShape)& S2,
970 PTColStd_TransientPersistentMap& aMap) const
972 Handle(TopoDS_TShape) aTransTShape = S1.TShape();
973 Handle(BRep_TFace)& TTF = (Handle(BRep_TFace)&) aTransTShape;
975 Handle(PTopoDS_TShape) aPersTShape = S2->TShape();
976 Handle(PBRep_TFace)& PTF = (Handle(PBRep_TFace)&) aPersTShape;
978 // natural restriction
979 PTF->NaturalRestriction(TTF->NaturalRestriction());
982 PTF->Tolerance(TTF->Tolerance());
985 PTF->Location(MgtTopLoc::Translate(TTF->Location(), aMap));
988 PTF->Surface(MgtBRep_TranslateTool::Translate(TTF->Surface(), aMap));
991 if (myTriangleMode == MgtBRep_WithTriangle) {
992 PTF->Triangulation(MgtPoly::Translate(TTF->Triangulation(), aMap));
995 MgtTopoDS_TranslateTool::UpdateFace(S1,S2, aMap);
999 //=======================================================================
1000 //function : UpdateFace
1001 //purpose : Persistent->Transient
1002 //=======================================================================
1005 MgtBRep_TranslateTool::UpdateFace(const Handle(PTopoDS_HShape)& S1,
1007 PTColStd_PersistentTransientMap& aMap) const
1009 Handle(PTopoDS_TShape) aPersTShape = S1->TShape();
1010 Handle(PBRep_TFace)& PTF = (Handle(PBRep_TFace)&) aPersTShape;
1012 Handle(TopoDS_TShape) aTransTShape = S2.TShape();
1013 Handle(BRep_TFace)& TTF = (Handle(BRep_TFace)&) aTransTShape;
1015 // natural restriction
1016 TTF->NaturalRestriction(PTF->NaturalRestriction());
1019 TTF->Tolerance(PTF->Tolerance());
1022 TTF->Location(MgtTopLoc::Translate(PTF->Location(), aMap));
1025 TTF->Surface(MgtBRep_TranslateTool::Translate(PTF->Surface(), aMap));
1028 if ( myTriangleMode == MgtBRep_WithTriangle) {
1029 TTF->Triangulation(MgtPoly::Translate(PTF->Triangulation(), aMap));
1032 MgtTopoDS_TranslateTool::UpdateFace(S1,S2, aMap);