1 // Copyright (c) 2015 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <Standard_NullObject.hxx>
16 #include <ShapePersistent_BRep.hxx>
18 #include <BRep_PointOnCurve.hxx>
19 #include <BRep_PointOnCurveOnSurface.hxx>
20 #include <BRep_PointOnSurface.hxx>
21 #include <BRep_Curve3D.hxx>
22 #include <BRep_CurveOnSurface.hxx>
23 #include <BRep_CurveOnClosedSurface.hxx>
24 #include <BRep_Polygon3D.hxx>
25 #include <BRep_PolygonOnTriangulation.hxx>
26 #include <BRep_PolygonOnClosedTriangulation.hxx>
27 #include <BRep_PolygonOnSurface.hxx>
28 #include <BRep_PolygonOnClosedSurface.hxx>
29 #include <BRep_CurveOn2Surfaces.hxx>
31 #include <BRep_TVertex.hxx>
32 #include <BRep_TEdge.hxx>
33 #include <BRep_TFace.hxx>
35 #include <Geom_Surface.hxx>
37 #include <TopoDS_Vertex.hxx>
38 #include <TopoDS_Edge.hxx>
39 #include <TopoDS_Face.hxx>
41 #include <Poly_Polygon2D.hxx>
42 #include <Poly_Polygon3D.hxx>
43 #include <Poly_PolygonOnTriangulation.hxx>
44 #include <Poly_Triangulation.hxx>
54 //=======================================================================
55 // PointRepresentation
56 //=======================================================================
57 void ShapePersistent_BRep::PointRepresentation::Read
58 (StdObjMgt_ReadData& theReadData)
59 { theReadData >> myLocation >> myParameter >> myNext; }
61 void ShapePersistent_BRep::PointRepresentation::Write
62 (StdObjMgt_WriteData& theWriteData) const
63 { theWriteData << myLocation << myParameter << myNext; }
65 void ShapePersistent_BRep::PointRepresentation::PChildren
66 (StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
68 myLocation.PChildren(theChildren);
69 theChildren.Append(myNext);
72 void ShapePersistent_BRep::PointRepresentation::Import
73 (BRep_ListOfPointRepresentation& thePoints) const
76 Handle(PointRepresentation) aPoint = this;
77 for (; aPoint; aPoint = aPoint->myNext)
78 thePoints.Prepend (aPoint->import());
81 Handle(BRep_PointRepresentation)
82 ShapePersistent_BRep::PointRepresentation::import() const
85 //=======================================================================
87 //=======================================================================
88 void ShapePersistent_BRep::PointOnCurve::Read
89 (StdObjMgt_ReadData& theReadData)
91 PointRepresentation::Read (theReadData);
92 theReadData >> myCurve;
95 void ShapePersistent_BRep::PointOnCurve::Write
96 (StdObjMgt_WriteData& theWriteData) const
98 PointRepresentation::Write (theWriteData);
99 theWriteData << myCurve;
102 void ShapePersistent_BRep::PointOnCurve::PChildren
103 (StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
105 PointRepresentation::PChildren(theChildren);
106 theChildren.Append(myCurve);
109 Handle(BRep_PointRepresentation)
110 ShapePersistent_BRep::PointOnCurve::import() const
112 Handle(Geom_Curve) aCurve;
114 aCurve = myCurve->Import();
116 return new BRep_PointOnCurve
117 (myParameter, aCurve, myLocation.Import());
120 //=======================================================================
122 //=======================================================================
123 void ShapePersistent_BRep::PointsOnSurface::Read
124 (StdObjMgt_ReadData& theReadData)
126 PointRepresentation::Read (theReadData);
127 theReadData >> mySurface;
130 void ShapePersistent_BRep::PointsOnSurface::Write
131 (StdObjMgt_WriteData& theWriteData) const
133 PointRepresentation::Write (theWriteData);
134 theWriteData << mySurface;
137 void ShapePersistent_BRep::PointsOnSurface::PChildren
138 (StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
140 PointRepresentation::PChildren(theChildren);
141 theChildren.Append(mySurface);
144 //=======================================================================
145 // PointOnCurveOnSurface
146 //=======================================================================
147 void ShapePersistent_BRep::PointOnCurveOnSurface::Read
148 (StdObjMgt_ReadData& theReadData)
150 PointsOnSurface::Read (theReadData);
151 theReadData >> myPCurve;
154 void ShapePersistent_BRep::PointOnCurveOnSurface::Write
155 (StdObjMgt_WriteData& theWriteData) const
157 PointsOnSurface::Write (theWriteData);
158 theWriteData << myPCurve;
161 void ShapePersistent_BRep::PointOnCurveOnSurface::PChildren
162 (StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
164 PointRepresentation::PChildren(theChildren);
165 theChildren.Append(myPCurve);
168 Handle(BRep_PointRepresentation)
169 ShapePersistent_BRep::PointOnCurveOnSurface::import() const
171 Handle(Geom2d_Curve) aPCurve;
173 aPCurve = myPCurve->Import();
175 Handle(Geom_Surface) aSurface;
177 aSurface = mySurface->Import();
179 return new BRep_PointOnCurveOnSurface
180 (myParameter, aPCurve, aSurface, myLocation.Import());
183 //=======================================================================
185 //=======================================================================
186 void ShapePersistent_BRep::PointOnSurface::Read
187 (StdObjMgt_ReadData& theReadData)
189 PointsOnSurface::Read (theReadData);
190 theReadData >> myParameter2;
193 void ShapePersistent_BRep::PointOnSurface::Write
194 (StdObjMgt_WriteData& theWriteData) const
196 PointsOnSurface::Write(theWriteData);
197 theWriteData << myParameter2;
200 Handle(BRep_PointRepresentation)
201 ShapePersistent_BRep::PointOnSurface::import() const
203 Handle(Geom_Surface) aSurface;
205 aSurface = mySurface->Import();
207 return new BRep_PointOnSurface
208 (myParameter, myParameter2, aSurface, myLocation.Import());
211 //=======================================================================
212 // CurveRepresentation
213 //=======================================================================
214 void ShapePersistent_BRep::CurveRepresentation::Read
215 (StdObjMgt_ReadData& theReadData)
216 { theReadData >> myLocation >> myNext; }
218 void ShapePersistent_BRep::CurveRepresentation::Write
219 (StdObjMgt_WriteData& theWriteData) const
220 { theWriteData << myLocation << myNext; }
222 void ShapePersistent_BRep::CurveRepresentation::PChildren
223 (StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
225 myLocation.PChildren(theChildren);
226 theChildren.Append(myNext);
229 void ShapePersistent_BRep::CurveRepresentation::Import
230 (BRep_ListOfCurveRepresentation& theCurves) const
233 Handle(CurveRepresentation) aCurve = this;
234 for (; aCurve; aCurve = aCurve->myNext)
235 theCurves.Prepend (aCurve->import());
238 Handle(BRep_CurveRepresentation)
239 ShapePersistent_BRep::CurveRepresentation::import() const
242 //=======================================================================
244 //=======================================================================
245 void ShapePersistent_BRep::GCurve::Read
246 (StdObjMgt_ReadData& theReadData)
248 CurveRepresentation::Read (theReadData);
249 theReadData >> myFirst >> myLast;
252 void ShapePersistent_BRep::GCurve::Write
253 (StdObjMgt_WriteData& theWriteData) const
255 CurveRepresentation::Write(theWriteData);
256 theWriteData << myFirst << myLast;
259 //=======================================================================
261 //=======================================================================
262 void ShapePersistent_BRep::Curve3D::Read
263 (StdObjMgt_ReadData& theReadData)
265 GCurve::Read (theReadData);
266 theReadData >> myCurve3D;
269 void ShapePersistent_BRep::Curve3D::Write
270 (StdObjMgt_WriteData& theWriteData) const
272 GCurve::Write (theWriteData);
273 theWriteData << myCurve3D;
276 void ShapePersistent_BRep::Curve3D::PChildren
277 (StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
279 GCurve::PChildren(theChildren);
280 theChildren.Append(myCurve3D);
283 Handle(BRep_CurveRepresentation)
284 ShapePersistent_BRep::Curve3D::import() const
286 Handle(Geom_Curve) aCurve3D;
288 aCurve3D = myCurve3D->Import();
290 Handle(BRep_Curve3D) aRepresentation =
291 new BRep_Curve3D (aCurve3D, myLocation.Import());
293 aRepresentation->SetRange (myFirst, myLast);
294 return aRepresentation;
297 //=======================================================================
299 //=======================================================================
300 void ShapePersistent_BRep::CurveOnSurface::Read
301 (StdObjMgt_ReadData& theReadData)
303 GCurve::Read (theReadData);
304 theReadData >> myPCurve >> mySurface >> myUV1 >> myUV2;
307 void ShapePersistent_BRep::CurveOnSurface::Write
308 (StdObjMgt_WriteData& theWriteData) const
310 GCurve::Write (theWriteData);
311 theWriteData << myPCurve << mySurface << myUV1 << myUV2;
314 void ShapePersistent_BRep::CurveOnSurface::PChildren
315 (StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
317 GCurve::PChildren(theChildren);
318 theChildren.Append(myPCurve);
319 theChildren.Append(mySurface);
322 Handle(BRep_CurveRepresentation)
323 ShapePersistent_BRep::CurveOnSurface::import() const
325 Handle(Geom2d_Curve) aPCurve;
327 aPCurve = myPCurve->Import();
329 Handle(Geom_Surface) aSurface;
331 aSurface = mySurface->Import();
333 Handle(BRep_CurveOnSurface) aRepresentation =
334 new BRep_CurveOnSurface (aPCurve, aSurface, myLocation.Import());
336 aRepresentation->SetUVPoints (myUV1, myUV2);
337 aRepresentation->SetRange (myFirst, myLast);
339 return aRepresentation;
342 //=======================================================================
343 // CurveOnClosedSurface
344 //=======================================================================
345 void ShapePersistent_BRep::CurveOnClosedSurface::Read
346 (StdObjMgt_ReadData& theReadData)
348 CurveOnSurface::Read (theReadData);
349 theReadData >> myPCurve2 >> myContinuity >> myUV21 >> myUV22;
352 void ShapePersistent_BRep::CurveOnClosedSurface::Write
353 (StdObjMgt_WriteData& theWriteData) const
355 CurveOnSurface::Write (theWriteData);
356 theWriteData << myPCurve2 << myContinuity << myUV21 << myUV22;
359 void ShapePersistent_BRep::CurveOnClosedSurface::PChildren
360 (StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
362 CurveOnSurface::PChildren(theChildren);
363 theChildren.Append(myPCurve2);
366 Handle(BRep_CurveRepresentation)
367 ShapePersistent_BRep::CurveOnClosedSurface::import() const
369 Handle(Geom2d_Curve) aPCurve;
371 aPCurve = myPCurve->Import();
373 Handle(Geom2d_Curve) aPCurve2;
375 aPCurve2 = myPCurve2->Import();
377 Handle(Geom_Surface) aSurface;
379 aSurface = mySurface->Import();
381 GeomAbs_Shape aContinuity = static_cast<GeomAbs_Shape> (myContinuity);
383 Handle(BRep_CurveOnClosedSurface) aRepresentation =
384 new BRep_CurveOnClosedSurface
385 (aPCurve, aPCurve2, aSurface, myLocation.Import(), aContinuity);
387 aRepresentation->SetUVPoints (myUV1 , myUV2 );
388 aRepresentation->SetUVPoints2 (myUV21 , myUV22);
389 aRepresentation->SetRange (myFirst, myLast);
391 return aRepresentation;
394 //=======================================================================
396 //=======================================================================
397 void ShapePersistent_BRep::Polygon3D::Read
398 (StdObjMgt_ReadData& theReadData)
400 CurveRepresentation::Read (theReadData);
401 theReadData >> myPolygon3D;
404 void ShapePersistent_BRep::Polygon3D::Write
405 (StdObjMgt_WriteData& theWriteData) const
407 CurveRepresentation::Write (theWriteData);
408 theWriteData << myPolygon3D;
411 void ShapePersistent_BRep::Polygon3D::PChildren
412 (StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
414 CurveRepresentation::PChildren(theChildren);
415 theChildren.Append(myPolygon3D);
418 Handle(BRep_CurveRepresentation)
419 ShapePersistent_BRep::Polygon3D::import() const
421 Handle(Poly_Polygon3D) aPolygon3D;
423 aPolygon3D = myPolygon3D->Import();
425 return new BRep_Polygon3D (aPolygon3D, myLocation.Import());
428 //=======================================================================
429 // PolygonOnTriangulation
430 //=======================================================================
431 void ShapePersistent_BRep::PolygonOnTriangulation::Read
432 (StdObjMgt_ReadData& theReadData)
434 CurveRepresentation::Read (theReadData);
435 theReadData >> myPolygon >> myTriangulation;
438 void ShapePersistent_BRep::PolygonOnTriangulation::Write
439 (StdObjMgt_WriteData& theWriteData) const
441 CurveRepresentation::Write (theWriteData);
442 theWriteData << myPolygon << myTriangulation;
445 void ShapePersistent_BRep::PolygonOnTriangulation::PChildren
446 (StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
448 CurveRepresentation::PChildren(theChildren);
449 theChildren.Append(myPolygon);
450 theChildren.Append(myTriangulation);
453 Handle(BRep_CurveRepresentation)
454 ShapePersistent_BRep::PolygonOnTriangulation::import() const
456 Handle(Poly_PolygonOnTriangulation) aPolygon;
458 aPolygon = myPolygon->Import();
460 Handle(Poly_Triangulation) aTriangulation;
462 aTriangulation = myTriangulation->Import();
464 return new BRep_PolygonOnTriangulation
465 (aPolygon, aTriangulation, myLocation.Import());
468 //=======================================================================
469 // PolygonOnClosedTriangulation
470 //=======================================================================
471 void ShapePersistent_BRep::PolygonOnClosedTriangulation::Read
472 (StdObjMgt_ReadData& theReadData)
474 PolygonOnTriangulation::Read (theReadData);
475 theReadData >> myPolygon2;
478 void ShapePersistent_BRep::PolygonOnClosedTriangulation::Write
479 (StdObjMgt_WriteData& theWriteData) const
481 PolygonOnTriangulation::Write (theWriteData);
482 theWriteData << myPolygon2;
485 void ShapePersistent_BRep::PolygonOnClosedTriangulation::PChildren
486 (StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
488 PolygonOnTriangulation::PChildren(theChildren);
489 theChildren.Append(myPolygon2);
492 Handle(BRep_CurveRepresentation)
493 ShapePersistent_BRep::PolygonOnClosedTriangulation::import() const
495 Handle(Poly_PolygonOnTriangulation) aPolygon;
497 aPolygon = myPolygon->Import();
499 Handle(Poly_PolygonOnTriangulation) aPolygon2;
501 aPolygon2 = myPolygon2->Import();
503 Handle(Poly_Triangulation) aTriangulation;
505 aTriangulation = myTriangulation->Import();
507 return new BRep_PolygonOnClosedTriangulation
508 (aPolygon, aPolygon2, aTriangulation, myLocation.Import());
511 //=======================================================================
513 //=======================================================================
514 void ShapePersistent_BRep::PolygonOnSurface::Read
515 (StdObjMgt_ReadData& theReadData)
517 CurveRepresentation::Read (theReadData);
518 theReadData >> myPolygon2D >> mySurface;
521 void ShapePersistent_BRep::PolygonOnSurface::Write
522 (StdObjMgt_WriteData& theWriteData) const
524 CurveRepresentation::Write (theWriteData);
525 theWriteData << myPolygon2D << mySurface;
528 void ShapePersistent_BRep::PolygonOnSurface::PChildren
529 (StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
531 CurveRepresentation::PChildren(theChildren);
532 theChildren.Append(myPolygon2D);
533 theChildren.Append(mySurface);
536 Handle(BRep_CurveRepresentation)
537 ShapePersistent_BRep::PolygonOnSurface::import() const
539 Handle(Poly_Polygon2D) aPolygon2D;
541 aPolygon2D = myPolygon2D->Import();
543 Handle(Geom_Surface) aSurface;
545 aSurface = mySurface->Import();
547 return new BRep_PolygonOnSurface (aPolygon2D, aSurface, myLocation.Import());
550 //=======================================================================
551 // PolygonOnClosedSurface
552 //=======================================================================
553 void ShapePersistent_BRep::PolygonOnClosedSurface::Read
554 (StdObjMgt_ReadData& theReadData)
556 PolygonOnSurface::Read (theReadData);
557 theReadData >> myPolygon2;
560 void ShapePersistent_BRep::PolygonOnClosedSurface::Write
561 (StdObjMgt_WriteData& theWriteData) const
563 PolygonOnSurface::Write (theWriteData);
564 theWriteData << myPolygon2;
567 void ShapePersistent_BRep::PolygonOnClosedSurface::PChildren
568 (StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
570 PolygonOnSurface::PChildren(theChildren);
571 theChildren.Append(myPolygon2);
574 Handle(BRep_CurveRepresentation)
575 ShapePersistent_BRep::PolygonOnClosedSurface::import() const
577 Handle(Poly_Polygon2D) aPolygon2D;
579 aPolygon2D = myPolygon2D->Import();
581 Handle(Poly_Polygon2D) aPolygon2;
583 aPolygon2 = myPolygon2->Import();
585 Handle(Geom_Surface) aSurface;
587 aSurface = mySurface->Import();
589 return new BRep_PolygonOnClosedSurface
590 (aPolygon2D, aPolygon2, aSurface, myLocation.Import());
593 //=======================================================================
595 //=======================================================================
596 void ShapePersistent_BRep::CurveOn2Surfaces::Read
597 (StdObjMgt_ReadData& theReadData)
599 CurveRepresentation::Read (theReadData);
600 theReadData >> mySurface >> mySurface2 >> myLocation2 >> myContinuity;
603 void ShapePersistent_BRep::CurveOn2Surfaces::Write
604 (StdObjMgt_WriteData& theWriteData) const
606 CurveRepresentation::Write (theWriteData);
607 theWriteData << mySurface << mySurface2 << myLocation2 << myContinuity;
610 void ShapePersistent_BRep::CurveOn2Surfaces::PChildren
611 (StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
613 CurveRepresentation::PChildren(theChildren);
614 theChildren.Append(mySurface);
615 theChildren.Append(mySurface2);
616 myLocation2.PChildren(theChildren);
619 Handle(BRep_CurveRepresentation)
620 ShapePersistent_BRep::CurveOn2Surfaces::import() const
622 Handle(Geom_Surface) aSurface;
624 aSurface = mySurface->Import();
626 Handle(Geom_Surface) aSurface2;
628 aSurface2 = mySurface2->Import();
630 GeomAbs_Shape aContinuity = static_cast<GeomAbs_Shape> (myContinuity);
632 return new BRep_CurveOn2Surfaces
633 (aSurface, aSurface2, myLocation.Import(), myLocation2.Import(), aContinuity);
636 //=======================================================================
637 //function : createTShape
638 //purpose : Create transient TShape object
639 //=======================================================================
640 Handle(TopoDS_TShape) ShapePersistent_BRep::pTVertex::createTShape() const
642 Handle(BRep_TVertex) aTVertex = new BRep_TVertex;
644 aTVertex->Tolerance (myTolerance);
645 aTVertex->Pnt (myPnt);
647 myPoints->Import (aTVertex->ChangePoints());
652 //=======================================================================
653 //function : createTShape
654 //purpose : Create transient TShape object
655 //=======================================================================
656 Handle(TopoDS_TShape) ShapePersistent_BRep::pTEdge::createTShape() const
658 Handle(BRep_TEdge) aTEdge = new BRep_TEdge;
660 aTEdge->Tolerance (myTolerance);
661 aTEdge->SameParameter ((myFlags & ParameterMask) != 0);
662 aTEdge->SameRange ((myFlags & RangeMask) != 0);
663 aTEdge->Degenerated ((myFlags & DegeneratedMask) != 0);
665 myCurves->Import (aTEdge->ChangeCurves());
670 //=======================================================================
671 //function : createTShape
672 //purpose : Create transient TShape object
673 //=======================================================================
674 Handle(TopoDS_TShape) ShapePersistent_BRep::pTFace::createTShape() const
676 Handle(BRep_TFace) aTFace = new BRep_TFace;
678 aTFace->NaturalRestriction (myNaturalRestriction);
679 aTFace->Tolerance (myTolerance);
680 aTFace->Location (myLocation.Import());
683 aTFace->Surface (mySurface->Import());
686 aTFace->Triangulation (myTriangulation->Import());
691 //=======================================================================
692 //function : Translate
693 //purpose : Translates a shape to its persistent avatar
694 //=======================================================================
695 Handle(ShapePersistent_BRep::TVertex::pTObjectT)
696 ShapePersistent_BRep::Translate (const TopoDS_Vertex& theVertex,
697 StdObjMgt_TransientPersistentMap& theMap)
699 Handle(BRep_TVertex) TTV = Handle(BRep_TVertex)::DownCast (theVertex.TShape());
701 Handle(TVertex::pTObjectT) PTV = new TVertex::pTObjectT;
703 PTV->myPnt = TTV->Pnt();
704 PTV->myTolerance = TTV->Tolerance();
706 BRep_ListIteratorOfListOfPointRepresentation anItPR(TTV->Points());
708 Handle(PointRepresentation) PPR, CPPR;
709 while (anItPR.More())
711 const Handle(BRep_PointRepresentation)& PR = anItPR.Value();
712 if (PR->IsPointOnCurve()) {
713 Handle(PointOnCurve) POC = Translate(PR->Parameter(),
719 else if (PR->IsPointOnCurveOnSurface()) {
720 Handle(PointOnCurveOnSurface) POCS = Translate(PR->Parameter(),
727 else if (PR->IsPointOnSurface()) {
728 Handle(PointOnSurface) POS = Translate(PR->Parameter(),
746 //=======================================================================
747 //function : Translate
748 //purpose : Translates a shape to its persistent avatar
749 //=======================================================================
750 Handle(ShapePersistent_BRep::TEdge::pTObjectT)
751 ShapePersistent_BRep::Translate (const TopoDS_Edge& theEdge,
752 StdObjMgt_TransientPersistentMap& theMap,
753 ShapePersistent_TriangleMode theTriangleMode)
755 Handle(BRep_TEdge) TTE = Handle(BRep_TEdge)::DownCast (theEdge.TShape());
757 Handle(TEdge::pTObjectT) PTE = new TEdge::pTObjectT;
759 PTE->myTolerance = TTE->Tolerance();
760 if (TTE->SameParameter()) PTE->myFlags |= ParameterMask;
761 if (TTE->SameRange()) PTE->myFlags |= RangeMask;
762 if (TTE->Degenerated()) PTE->myFlags |= DegeneratedMask;
765 BRep_ListIteratorOfListOfCurveRepresentation itcr(TTE->Curves());
767 Handle(CurveRepresentation) PCR, CPCR;
768 Handle(BRep_GCurve) GC;
773 const Handle(BRep_CurveRepresentation)& CR = itcr.Value();
774 GC = Handle(BRep_GCurve)::DownCast(CR);
778 // CurveRepresentation is Curve3D
779 if (CR->IsCurve3D()) {
780 Handle(Curve3D) C3D = Translate(CR->Curve3D(), f, l, CR->Location(), theMap);
783 // CurveRepresentation is CurveOnSurface
784 else if (CR->IsCurveOnSurface())
786 Handle(BRep_CurveOnSurface)& theCOS = (Handle(BRep_CurveOnSurface)&) CR;
787 Handle(CurveOnSurface) COS;
788 // CurveRepresentation is CurveOnSurface
789 if (!CR->IsCurveOnClosedSurface())
791 COS = Translate(CR->PCurve(), f, l, CR->Surface(), CR->Location(), theMap);
793 // CurveRepresentation is CurveOnClosedSurface
796 // get UVPoints for the CurveOnClosedSurface definition.
797 Handle(BRep_CurveOnClosedSurface)& theCOCS =
798 (Handle(BRep_CurveOnClosedSurface)&) CR;
799 gp_Pnt2d Pnt21, Pnt22;
800 theCOCS->UVPoints2(Pnt21, Pnt22);
801 Handle(CurveOnClosedSurface) COCS = Translate(CR->PCurve(), CR->PCurve2(),
803 CR->Location(), CR->Continuity(),
805 COCS->myUV21 = Pnt21;
806 COCS->myUV22 = Pnt22;
810 // get UVPoints for the CurveOnSurface definition.
812 theCOS->UVPoints(Pnt1, Pnt2);
818 // CurveRepresentation is CurveOn2Surfaces
819 else if (CR->IsRegularity())
821 Handle(CurveOn2Surfaces) R = Translate(CR->Surface(), CR->Surface2(),
822 CR->Location(), CR->Location2(),
827 // CurveRepresentation is Polygon or Triangulation
828 else if (theTriangleMode == ShapePersistent_WithTriangle) {
829 // CurveRepresentation is Polygon3D
830 if (CR->IsPolygon3D()) {
831 Handle(Polygon3D) P3D = Translate(CR->Polygon3D(), CR->Location(), theMap);
834 // CurveRepresentation is PolygonOnSurface
835 else if (CR->IsPolygonOnSurface())
837 // CurveRepresentation is PolygonOnClosedSurface
838 if (CR->IsPolygonOnClosedSurface()) {
839 Handle(PolygonOnClosedSurface) PolOCS = Translate(CR->Polygon(), CR->Polygon2(),
840 CR->Surface(), CR->Location(),
844 // CurveRepresentation is PolygonOnSurface
847 Handle(PolygonOnSurface) PolOS = Translate(CR->Polygon(), CR->Surface(),
848 CR->Location(), theMap);
852 // CurveRepresentation is PolygonOnTriangulation
853 else if (CR->IsPolygonOnTriangulation())
855 // CurveRepresentation is PolygonOnClosedTriangulation
856 if (CR->IsPolygonOnClosedTriangulation())
858 Handle(PolygonOnClosedTriangulation) PolOCT = Translate(CR->PolygonOnTriangulation(),
859 CR->PolygonOnTriangulation2(),
865 // CurveRepresentation is PolygonOnTriangulation
868 Handle(PolygonOnTriangulation) PolOT = Translate(CR->PolygonOnTriangulation(),
878 // jumps the curve representation
883 Standard_NullObject_Raise_if(CPCR.IsNull(), "Null CurveRepresentation");
896 //=======================================================================
897 //function : Translate
898 //purpose : Translates a shape to its persistent avatar
899 //=======================================================================
900 Handle(ShapePersistent_BRep::TFace::pTObjectT)
901 ShapePersistent_BRep::Translate (const TopoDS_Face& theFace,
902 StdObjMgt_TransientPersistentMap& theMap,
903 ShapePersistent_TriangleMode theTriangleMode)
905 Handle(BRep_TFace) TTF = Handle(BRep_TFace)::DownCast (theFace.TShape());
907 Handle(TFace::pTObjectT) PTF = new TFace::pTObjectT;
909 PTF->myTolerance = TTF->Tolerance();
910 PTF->myLocation = StdObject_Location::Translate(TTF->Location(), theMap);
911 PTF->myNaturalRestriction = TTF->NaturalRestriction();
914 PTF->mySurface = ShapePersistent_Geom::Translate(TTF->Surface(), theMap);
917 if (theTriangleMode == ShapePersistent_WithTriangle) {
918 PTF->myTriangulation = ShapePersistent_Poly::Translate(TTF->Triangulation(), theMap);
924 //=======================================================================
925 //function : Translate
926 //purpose : Translates a shape to its persistent avatar
927 //=======================================================================
928 Handle(ShapePersistent_BRep::PointOnCurve)
929 ShapePersistent_BRep::Translate (Standard_Real theParam,
930 const Handle(Geom_Curve)& theCurve,
931 const TopLoc_Location& theLoc,
932 StdObjMgt_TransientPersistentMap& theMap)
934 Handle(PointOnCurve) aPPonC = new PointOnCurve;
935 aPPonC->myParameter = theParam;
936 aPPonC->myCurve = ShapePersistent_Geom::Translate(theCurve, theMap);
937 aPPonC->myLocation = StdObject_Location::Translate(theLoc, theMap);
941 //=======================================================================
942 //function : Translate
943 //purpose : Translates a shape to its persistent avatar
944 //=======================================================================
945 Handle(ShapePersistent_BRep::PointOnCurveOnSurface)
946 ShapePersistent_BRep::Translate(Standard_Real theParam,
947 const Handle(Geom2d_Curve)& theCurve,
948 const Handle(Geom_Surface)& theSurf,
949 const TopLoc_Location& theLoc,
950 StdObjMgt_TransientPersistentMap& theMap)
952 Handle(PointOnCurveOnSurface) aPPonConS = new PointOnCurveOnSurface;
953 aPPonConS->myParameter = theParam;
954 aPPonConS->myPCurve = ShapePersistent_Geom2d::Translate(theCurve, theMap);
955 aPPonConS->mySurface = ShapePersistent_Geom::Translate(theSurf, theMap);
956 aPPonConS->myLocation = StdObject_Location::Translate(theLoc, theMap);
960 //=======================================================================
961 //function : Translate
962 //purpose : Translates a shape to its persistent avatar
963 //=======================================================================
964 Handle(ShapePersistent_BRep::PointOnSurface)
965 ShapePersistent_BRep::Translate(Standard_Real theParam,
966 Standard_Real theParam2,
967 const Handle(Geom_Surface)& theSurf,
968 const TopLoc_Location& theLoc,
969 StdObjMgt_TransientPersistentMap& theMap)
971 Handle(PointOnSurface) aPonS = new PointOnSurface;
972 aPonS->myParameter = theParam;
973 aPonS->myParameter2 = theParam2;
974 aPonS->mySurface = ShapePersistent_Geom::Translate(theSurf, theMap);
975 aPonS->myLocation = StdObject_Location::Translate(theLoc, theMap);
979 //=======================================================================
980 //function : Translate
981 //purpose : Translates a shape to its persistent avatar
982 //=======================================================================
983 Handle(ShapePersistent_BRep::CurveOnSurface)
984 ShapePersistent_BRep::Translate(const Handle(Geom2d_Curve)& theCurve,
985 const Standard_Real theFirstParam,
986 const Standard_Real theLastParam,
987 const Handle(Geom_Surface)& theSurf,
988 const TopLoc_Location& theLoc,
989 StdObjMgt_TransientPersistentMap& theMap)
991 Handle(CurveOnSurface) aPConS = new CurveOnSurface;
992 aPConS->myPCurve = ShapePersistent_Geom2d::Translate(theCurve, theMap);
993 aPConS->myFirst = theFirstParam;
994 aPConS->myLast = theLastParam;
995 aPConS->mySurface = ShapePersistent_Geom::Translate(theSurf, theMap);
996 aPConS->myLocation = StdObject_Location::Translate(theLoc, theMap);
1000 //=======================================================================
1001 //function : Translate
1002 //purpose : Translates a shape to its persistent avatar
1003 //=======================================================================
1004 Handle(ShapePersistent_BRep::CurveOnClosedSurface)
1005 ShapePersistent_BRep::Translate(const Handle(Geom2d_Curve)& theCurve,
1006 const Handle(Geom2d_Curve)& theCurve2,
1007 const Standard_Real theFirstParam,
1008 const Standard_Real theLastParam,
1009 const Handle(Geom_Surface)& theSurf,
1010 const TopLoc_Location& theLoc,
1011 const GeomAbs_Shape theContinuity,
1012 StdObjMgt_TransientPersistentMap& theMap)
1014 Handle(CurveOnClosedSurface) aPConCS = new CurveOnClosedSurface;
1015 aPConCS->myPCurve = ShapePersistent_Geom2d::Translate(theCurve, theMap);
1016 aPConCS->myPCurve2 = ShapePersistent_Geom2d::Translate(theCurve2, theMap);
1017 aPConCS->myFirst = theFirstParam;
1018 aPConCS->myLast = theLastParam;
1019 aPConCS->mySurface = ShapePersistent_Geom::Translate(theSurf, theMap);
1020 aPConCS->myLocation = StdObject_Location::Translate(theLoc, theMap);
1021 aPConCS->myContinuity = theContinuity;
1025 //=======================================================================
1026 //function : Translate
1027 //purpose : Translates a shape to its persistent avatar
1028 //=======================================================================
1029 Handle(ShapePersistent_BRep::CurveOn2Surfaces)
1030 ShapePersistent_BRep::Translate(const Handle(Geom_Surface)& theSurf,
1031 const Handle(Geom_Surface)& theSurf2,
1032 const TopLoc_Location& theLoc,
1033 const TopLoc_Location& theLoc2,
1034 const GeomAbs_Shape theContinuity,
1035 StdObjMgt_TransientPersistentMap& theMap)
1037 Handle(CurveOn2Surfaces) aPCon2S = new CurveOn2Surfaces;
1038 aPCon2S->mySurface = ShapePersistent_Geom::Translate(theSurf, theMap);
1039 aPCon2S->mySurface2 = ShapePersistent_Geom::Translate(theSurf2, theMap);
1040 aPCon2S->myLocation = StdObject_Location::Translate(theLoc, theMap);
1041 aPCon2S->myLocation2 = StdObject_Location::Translate(theLoc2, theMap);
1042 aPCon2S->myContinuity = theContinuity;
1046 //=======================================================================
1047 //function : Translate
1048 //purpose : Translates a shape to its persistent avatar
1049 //=======================================================================
1050 Handle(ShapePersistent_BRep::Curve3D)
1051 ShapePersistent_BRep::Translate (const Handle(Geom_Curve)& theCurve,
1052 const Standard_Real theFirstParam,
1053 const Standard_Real theLastParam,
1054 const TopLoc_Location& theLoc,
1055 StdObjMgt_TransientPersistentMap& theMap)
1057 Handle(Curve3D) aPCurve3D = new Curve3D;
1058 aPCurve3D->myCurve3D = ShapePersistent_Geom::Translate(theCurve, theMap);
1059 aPCurve3D->myLocation = StdObject_Location::Translate(theLoc, theMap);
1060 aPCurve3D->myFirst = theFirstParam;
1061 aPCurve3D->myLast = theLastParam;
1065 //=======================================================================
1066 //function : Translate
1067 //purpose : Translates a shape to its persistent avatar
1068 //=======================================================================
1069 Handle(ShapePersistent_BRep::Polygon3D)
1070 ShapePersistent_BRep::Translate(const Handle(Poly_Polygon3D)& thePoly,
1071 const TopLoc_Location& theLoc,
1072 StdObjMgt_TransientPersistentMap& theMap)
1074 Handle(Polygon3D) aPPoly = new Polygon3D;
1075 aPPoly->myPolygon3D = ShapePersistent_Poly::Translate(thePoly, theMap);
1076 aPPoly->myLocation = StdObject_Location::Translate(theLoc, theMap);
1080 //=======================================================================
1081 //function : Translate
1082 //purpose : Translates a shape to its persistent avatar
1083 //=======================================================================
1084 Handle(ShapePersistent_BRep::PolygonOnClosedSurface)
1085 ShapePersistent_BRep::Translate(const Handle(Poly_Polygon2D)& thePoly,
1086 const Handle(Poly_Polygon2D)& thePoly2,
1087 const Handle(Geom_Surface)& theSurf,
1088 const TopLoc_Location& theLoc,
1089 StdObjMgt_TransientPersistentMap& theMap)
1091 Handle(PolygonOnClosedSurface) aPPonCS = new PolygonOnClosedSurface;
1092 aPPonCS->myPolygon2D = ShapePersistent_Poly::Translate(thePoly, theMap);
1093 aPPonCS->myPolygon2 = ShapePersistent_Poly::Translate(thePoly2, theMap);
1094 aPPonCS->mySurface = ShapePersistent_Geom::Translate(theSurf, theMap);
1095 aPPonCS->myLocation = StdObject_Location::Translate(theLoc, theMap);
1099 //=======================================================================
1100 //function : Translate
1101 //purpose : Translates a shape to its persistent avatar
1102 //=======================================================================
1103 Handle(ShapePersistent_BRep::PolygonOnSurface)
1104 ShapePersistent_BRep::Translate(const Handle(Poly_Polygon2D)& thePoly,
1105 const Handle(Geom_Surface)& theSurf,
1106 const TopLoc_Location& theLoc,
1107 StdObjMgt_TransientPersistentMap& theMap)
1109 Handle(PolygonOnSurface) aPPonS = new PolygonOnSurface;
1110 aPPonS->myPolygon2D = ShapePersistent_Poly::Translate(thePoly, theMap);
1111 aPPonS->mySurface = ShapePersistent_Geom::Translate(theSurf, theMap);
1112 aPPonS->myLocation = StdObject_Location::Translate(theLoc, theMap);
1116 //=======================================================================
1117 //function : Translate
1118 //purpose : Translates a shape to its persistent avatar
1119 //=======================================================================
1120 Handle(ShapePersistent_BRep::PolygonOnClosedTriangulation)
1121 ShapePersistent_BRep::Translate(const Handle(Poly_PolygonOnTriangulation)& thePolyOnTriang,
1122 const Handle(Poly_PolygonOnTriangulation)& thePolyOnTriang2,
1123 const Handle(Poly_Triangulation)& thePolyTriang,
1124 const TopLoc_Location& theLoc,
1125 StdObjMgt_TransientPersistentMap& theMap)
1127 Handle(PolygonOnClosedTriangulation) aPPonCS = new PolygonOnClosedTriangulation;
1128 aPPonCS->myPolygon = ShapePersistent_Poly::Translate(thePolyOnTriang, theMap);
1129 aPPonCS->myPolygon2 = ShapePersistent_Poly::Translate(thePolyOnTriang2, theMap);
1130 aPPonCS->myTriangulation = ShapePersistent_Poly::Translate(thePolyTriang, theMap);
1131 aPPonCS->myLocation = StdObject_Location::Translate(theLoc, theMap);
1135 //=======================================================================
1136 //function : Translate
1137 //purpose : Translates a shape to its persistent avatar
1138 //=======================================================================
1139 Handle(ShapePersistent_BRep::PolygonOnTriangulation)
1140 ShapePersistent_BRep::Translate(const Handle(Poly_PolygonOnTriangulation)& thePolyOnTriang,
1141 const Handle(Poly_Triangulation)& thePolyTriang,
1142 const TopLoc_Location& theLoc,
1143 StdObjMgt_TransientPersistentMap& theMap)
1145 Handle(PolygonOnTriangulation) aPPonT = new PolygonOnTriangulation;
1146 aPPonT->myPolygon = ShapePersistent_Poly::Translate(thePolyOnTriang, theMap);
1147 aPPonT->myTriangulation = ShapePersistent_Poly::Translate(thePolyTriang, theMap);
1148 aPPonT->myLocation = StdObject_Location::Translate(theLoc, theMap);