1 // Copyright (c) 2015 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13 
14 
15 #ifndef _ShapePersistent_Geom2d_HeaderFile
16 #define _ShapePersistent_Geom2d_HeaderFile
17 
18 #include <StdObjMgt_TransientPersistentMap.hxx>
19 #include <ShapePersistent_Geom.hxx>
20 
21 #include <Geom2d_CartesianPoint.hxx>
22 #include <Geom2d_Direction.hxx>
23 #include <Geom2d_VectorWithMagnitude.hxx>
24 #include <Geom2d_AxisPlacement.hxx>
25 #include <Geom2d_Transformation.hxx>
26 #include <Geom2d_Curve.hxx>
27 
28 class ShapePersistent_Geom2d : public ShapePersistent_Geom
29 {
30   typedef geometryBase<Geom2d_Geometry> basic;
31 
32 public:
33   typedef ShapePersistent_Geom::Geometry                         Geometry;
34 
35   typedef subBase_empty<basic>                                   Point;
36   typedef instance<Point, Geom2d_CartesianPoint, gp_Pnt2d>       CartesianPoint;
37 
38   typedef subBase_gp<basic, gp_Vec2d>                            Vector;
39   typedef instance<Vector, Geom2d_Direction          , gp_Dir2d> Direction;
40   typedef instance<Vector, Geom2d_VectorWithMagnitude, gp_Vec2d> VectorWithMagnitude;
41 
42   typedef instance<basic, Geom2d_AxisPlacement, gp_Ax2d>         AxisPlacement;
43 
44   typedef instance <SharedBase<Geom2d_Transformation>,
45                     Geom2d_Transformation,
46                     gp_Trsf2d>                                   Transformation;
47 
48   typedef geometryBase<Geom2d_Curve>                             Curve;
49 
50 public:
51   //! Create a persistent object for a curve
52   Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_Curve)& theCurve,
53                                                   StdObjMgt_TransientPersistentMap& theMap);
54 };
55 
56 //=======================================================================
57 // Geometry
58 //=======================================================================
59 template<>
60 inline Standard_CString ShapePersistent_Geom::geometryBase<Geom2d_Geometry>
PName() const61   ::PName() const { return "PGeom2d_Geometry"; }
62 
63 //=======================================================================
64 // Point
65 //=======================================================================
66 template<>
67 inline Standard_CString ShapePersistent_Geom::subBase_empty<ShapePersistent_Geom2d::geometryBase<Geom2d_Geometry> >
PName() const68   ::PName() const { return "PGeom2d_Point"; }
69 
70 //=======================================================================
71 // CartesianPoint
72 //=======================================================================
73 template<>
74 inline Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom2d::Point,
75                                                   Geom2d_CartesianPoint,
76                                                   gp_Pnt2d>
PName() const77   ::PName() const { return "PGeom2d_CartesianPoint"; }
78 
79 template<>
80 inline void ShapePersistent_Geom::instance<ShapePersistent_Geom2d::Point,
81                                       Geom2d_CartesianPoint,
82                                       gp_Pnt2d>
Write(StdObjMgt_WriteData & theWriteData) const83   ::Write(StdObjMgt_WriteData& theWriteData) const
84 {
85   Handle(Geom2d_CartesianPoint) aMyGeom =
86     Handle(Geom2d_CartesianPoint)::DownCast(myTransient);
87   theWriteData << aMyGeom->Pnt2d();
88 }
89 
90 //=======================================================================
91 // Direction
92 //=======================================================================
93 template<>
94 Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom2d::Direction,
95                                                   Geom2d_Direction,
96                                                   gp_Dir2d>
97   ::PName() const;
98 
99 template<>
100 void ShapePersistent_Geom::instance<ShapePersistent_Geom2d::Direction,
101                                       Geom2d_Direction,
102                                       gp_Dir2d>
103   ::Write(StdObjMgt_WriteData& theWriteData) const;
104 
105 //=======================================================================
106 // VectorWithMagnitude
107 //=======================================================================
108 template<>
109 Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom2d::VectorWithMagnitude,
110                                                   Geom2d_VectorWithMagnitude,
111                                                   gp_Vec2d>
112   ::PName() const;
113 
114 template<>
115 void ShapePersistent_Geom::instance<ShapePersistent_Geom2d::VectorWithMagnitude,
116                                       Geom2d_VectorWithMagnitude,
117                                       gp_Vec2d>
118   ::Write(StdObjMgt_WriteData& theWriteData) const;
119 
120 //=======================================================================
121 // AxisPlacement
122 //=======================================================================
123 template<>
124 Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom2d::AxisPlacement,
125                                                   Geom2d_AxisPlacement,
126                                                   gp_Ax2d>
127   ::PName() const;
128 
129 template<>
130 void ShapePersistent_Geom::instance<ShapePersistent_Geom2d::AxisPlacement,
131                                       Geom2d_AxisPlacement,
132                                       gp_Ax2d>
133   ::Write(StdObjMgt_WriteData& theWriteData) const;
134 
135 //=======================================================================
136 // Transformation
137 //=======================================================================
138 template<>
139 Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom2d::Transformation,
140                                                   Geom2d_Transformation,
141                                                   gp_Trsf2d>
142   ::PName() const;
143 
144 template<>
145 void ShapePersistent_Geom::instance<ShapePersistent_Geom2d::Transformation,
146                                     Geom2d_Transformation,
147                                     gp_Trsf2d>
148   ::PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
149 
150 template<>
151 void ShapePersistent_Geom::instance<ShapePersistent_Geom2d::Transformation,
152                                       Geom2d_Transformation,
153                                       gp_Trsf2d>
154   ::Write(StdObjMgt_WriteData& theWriteData) const;
155 
156 //=======================================================================
157 // Curve
158 //=======================================================================
159 template<>
160 inline Standard_CString ShapePersistent_Geom::geometryBase<Geom2d_Curve>
PName() const161   ::PName() const { return "PGeom2d_Curve"; }
162 
163 #endif
164