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_Geom.hxx>
17 #include <ShapePersistent_Geom_Curve.hxx>
18 #include <ShapePersistent_Geom_Surface.hxx>
19 #include <StdObject_gp_Axes.hxx>
20 #include <StdObject_gp_Vectors.hxx>
23 //=======================================================================
25 //purpose : Read persistent data from a file
26 //=======================================================================
27 void ShapePersistent_Geom::Geometry::Read (StdObjMgt_ReadData&) {}
29 //=======================================================================
31 //purpose : Write persistent data to a file
32 //=======================================================================
33 void ShapePersistent_Geom::Geometry::Write (StdObjMgt_WriteData&) const {}
35 //=======================================================================
36 //function : PChildren
37 //purpose : Gets persistent objects
38 //=======================================================================
39 void ShapePersistent_Geom::Geometry::PChildren (SequenceOfPersistent&) const
43 //=======================================================================
44 //function : Translate
45 //purpose : Create a persistent object for a curve
46 //=======================================================================
47 Handle(ShapePersistent_Geom::Curve)
48 ShapePersistent_Geom::Translate (const Handle(Geom_Curve)& theCurve,
49 StdObjMgt_TransientPersistentMap& theMap)
52 if (!theCurve.IsNull())
54 if (theMap.IsBound(theCurve))
55 aPC = Handle(Curve)::DownCast(theMap.Find(theCurve));
58 Handle(Standard_Type) aCT = theCurve->DynamicType();
59 if (aCT == STANDARD_TYPE(Geom_Line)) {
60 aPC = ShapePersistent_Geom_Curve::Translate(Handle(Geom_Line)::DownCast(theCurve), theMap);
62 else if (aCT == STANDARD_TYPE(Geom_Circle)) {
63 aPC = ShapePersistent_Geom_Curve::Translate(Handle(Geom_Circle)::DownCast(theCurve), theMap);
65 else if (aCT == STANDARD_TYPE(Geom_Ellipse)) {
66 aPC = ShapePersistent_Geom_Curve::Translate(Handle(Geom_Ellipse)::DownCast(theCurve), theMap);
68 else if (aCT == STANDARD_TYPE(Geom_Hyperbola)) {
69 aPC = ShapePersistent_Geom_Curve::Translate(Handle(Geom_Hyperbola)::DownCast(theCurve), theMap);
71 else if (aCT == STANDARD_TYPE(Geom_Parabola)) {
72 aPC = ShapePersistent_Geom_Curve::Translate(Handle(Geom_Parabola)::DownCast(theCurve), theMap);
74 else if (aCT == STANDARD_TYPE(Geom_BezierCurve)) {
75 aPC = ShapePersistent_Geom_Curve::Translate(Handle(Geom_BezierCurve)::DownCast(theCurve), theMap);
77 else if (aCT == STANDARD_TYPE(Geom_BSplineCurve)) {
78 aPC = ShapePersistent_Geom_Curve::Translate(Handle(Geom_BSplineCurve)::DownCast(theCurve), theMap);
80 else if (aCT == STANDARD_TYPE(Geom_TrimmedCurve)) {
81 aPC = ShapePersistent_Geom_Curve::Translate(Handle(Geom_TrimmedCurve)::DownCast(theCurve), theMap);
83 else if (aCT == STANDARD_TYPE(Geom_OffsetCurve)) {
84 aPC = ShapePersistent_Geom_Curve::Translate(Handle(Geom_OffsetCurve)::DownCast(theCurve), theMap);
87 Standard_NullObject::Raise("No mapping for the current Transient Curve");
89 theMap.Bind(theCurve, aPC);
95 //=======================================================================
96 //function : Translate
97 //purpose : Create a persistent object for a surface
98 //=======================================================================
99 Handle(ShapePersistent_Geom::Surface)
100 ShapePersistent_Geom::Translate(const Handle(Geom_Surface)& theSurf,
101 StdObjMgt_TransientPersistentMap& theMap)
104 if (!theSurf.IsNull())
106 if (theMap.IsBound(theSurf))
107 aPS = Handle(Surface)::DownCast(theMap.Find(theSurf));
110 Handle(Standard_Type) aST = theSurf->DynamicType();
111 if (aST == STANDARD_TYPE(Geom_Plane)) {
112 aPS = ShapePersistent_Geom_Surface::Translate(Handle(Geom_Plane)::DownCast(theSurf), theMap);
114 else if (aST == STANDARD_TYPE(Geom_CylindricalSurface)) {
115 aPS = ShapePersistent_Geom_Surface::Translate(Handle(Geom_CylindricalSurface)::DownCast(theSurf), theMap);
117 else if (aST == STANDARD_TYPE(Geom_ConicalSurface)) {
118 aPS = ShapePersistent_Geom_Surface::Translate(Handle(Geom_ConicalSurface)::DownCast(theSurf), theMap);
120 else if (aST == STANDARD_TYPE(Geom_SphericalSurface)) {
121 aPS = ShapePersistent_Geom_Surface::Translate(Handle(Geom_SphericalSurface)::DownCast(theSurf), theMap);
123 else if (aST == STANDARD_TYPE(Geom_ToroidalSurface)) {
124 aPS = ShapePersistent_Geom_Surface::Translate(Handle(Geom_ToroidalSurface)::DownCast(theSurf), theMap);
126 else if (aST == STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion)) {
127 aPS = ShapePersistent_Geom_Surface::Translate(Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(theSurf), theMap);
129 else if (aST == STANDARD_TYPE(Geom_SurfaceOfRevolution)) {
130 aPS = ShapePersistent_Geom_Surface::Translate(Handle(Geom_SurfaceOfRevolution)::DownCast(theSurf), theMap);
132 else if (aST == STANDARD_TYPE(Geom_BezierSurface)) {
133 aPS = ShapePersistent_Geom_Surface::Translate(Handle(Geom_BezierSurface)::DownCast(theSurf), theMap);
135 else if (aST == STANDARD_TYPE(Geom_BSplineSurface)) {
136 aPS = ShapePersistent_Geom_Surface::Translate(Handle(Geom_BSplineSurface)::DownCast(theSurf), theMap);
138 else if (aST == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
139 aPS = ShapePersistent_Geom_Surface::Translate(Handle(Geom_RectangularTrimmedSurface)::DownCast(theSurf), theMap);
141 else if (aST == STANDARD_TYPE(Geom_OffsetSurface)) {
142 aPS = ShapePersistent_Geom_Surface::Translate(Handle(Geom_OffsetSurface)::DownCast(theSurf), theMap);
145 Standard_NullObject::Raise("No mapping for the current Transient Surface");
147 theMap.Bind(theSurf, aPS);