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.
15 #ifndef _ShapePersistent_Geom2d_Curve_HeaderFile
16 #define _ShapePersistent_Geom2d_Curve_HeaderFile
18 #include <StdObjMgt_TransientPersistentMap.hxx>
20 #include <ShapePersistent_Geom2d.hxx>
21 #include <ShapePersistent_HArray1.hxx>
22 #include <StdLPersistent_HArray1.hxx>
24 #include <Geom2d_Line.hxx>
25 #include <Geom2d_Circle.hxx>
26 #include <Geom2d_Ellipse.hxx>
27 #include <Geom2d_Hyperbola.hxx>
28 #include <Geom2d_Parabola.hxx>
29 #include <Geom2d_BezierCurve.hxx>
30 #include <Geom2d_BSplineCurve.hxx>
31 #include <Geom2d_TrimmedCurve.hxx>
32 #include <Geom2d_OffsetCurve.hxx>
34 #include <gp_Circ2d.hxx>
35 #include <gp_Elips2d.hxx>
36 #include <gp_Hypr2d.hxx>
37 #include <gp_Parab2d.hxx>
40 class ShapePersistent_Geom2d_Curve : public ShapePersistent_Geom2d
42 typedef Curve::PersistentBase pBase;
44 typedef pBase pBounded;
46 class pBezier : public pBounded
48 friend class ShapePersistent_Geom2d_Curve;
51 inline void Read (StdObjMgt_ReadData& theReadData)
52 { theReadData >> myRational >> myPoles >> myWeights; }
53 inline void Write (StdObjMgt_WriteData& theWriteData) const
54 { theWriteData << myRational << myPoles << myWeights; }
55 inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
57 theChildren.Append(myPoles);
58 theChildren.Append(myWeights);
60 inline Standard_CString PName() const
61 { return "PGeom2d_BezierCurve"; }
63 virtual Handle(Geom2d_Curve) Import() const;
66 Standard_Boolean myRational;
67 Handle(ShapePersistent_HArray1::Pnt2d) myPoles;
68 Handle(StdLPersistent_HArray1::Real) myWeights;
71 class pBSpline : public pBounded
73 friend class ShapePersistent_Geom2d_Curve;
76 inline void Read (StdObjMgt_ReadData& theReadData)
78 theReadData >> myRational >> myPeriodic >> mySpineDegree;
79 theReadData >> myPoles >> myWeights >> myKnots >> myMultiplicities;
81 inline void Write (StdObjMgt_WriteData& theWriteData) const
83 theWriteData << myRational << myPeriodic << mySpineDegree;
84 theWriteData << myPoles << myWeights << myKnots << myMultiplicities;
86 inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
88 theChildren.Append(myPoles);
89 theChildren.Append(myWeights);
90 theChildren.Append(myKnots);
91 theChildren.Append(myMultiplicities);
93 inline Standard_CString PName() const
94 { return "PGeom2d_BSplineCurve"; }
96 virtual Handle(Geom2d_Curve) Import() const;
99 Standard_Boolean myRational;
100 Standard_Boolean myPeriodic;
101 Standard_Integer mySpineDegree;
102 Handle(ShapePersistent_HArray1::Pnt2d) myPoles;
103 Handle(StdLPersistent_HArray1::Real) myWeights;
104 Handle(StdLPersistent_HArray1::Real) myKnots;
105 Handle(StdLPersistent_HArray1::Integer) myMultiplicities;
108 class pTrimmed : public pBounded
110 friend class ShapePersistent_Geom2d_Curve;
113 inline void Read (StdObjMgt_ReadData& theReadData)
114 { theReadData >> myBasisCurve >> myFirstU >> myLastU; }
115 inline void Write (StdObjMgt_WriteData& theWriteData) const
116 { theWriteData << myBasisCurve << myFirstU << myLastU; }
117 inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
118 { theChildren.Append(myBasisCurve); }
119 inline Standard_CString PName() const
120 { return "PGeom2d_TrimmedCurve"; }
122 virtual Handle(Geom2d_Curve) Import() const;
125 Handle(Curve) myBasisCurve;
126 Standard_Real myFirstU;
127 Standard_Real myLastU;
130 class pOffset : public pBase
132 friend class ShapePersistent_Geom2d_Curve;
135 inline void Read (StdObjMgt_ReadData& theReadData)
136 { theReadData >> myBasisCurve >> myOffsetValue; }
137 inline void Write (StdObjMgt_WriteData& theWriteData) const
138 { theWriteData << myBasisCurve << myOffsetValue; }
139 inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
140 { theChildren.Append(myBasisCurve); }
141 inline Standard_CString PName() const
142 { return "PGeom2d_OffsetCurve"; }
144 virtual Handle(Geom2d_Curve) Import() const;
147 Handle(Curve) myBasisCurve;
148 Standard_Real myOffsetValue;
152 typedef instance<Curve, Geom2d_Line, gp_Ax2d> Line;
154 typedef subBase_gp<Curve, gp_Ax22d> Conic;
155 typedef instance<Conic, Geom2d_Circle , gp_Circ2d > Circle;
156 typedef instance<Conic, Geom2d_Ellipse , gp_Elips2d> Ellipse;
157 typedef instance<Conic, Geom2d_Hyperbola, gp_Hypr2d > Hyperbola;
158 typedef instance<Conic, Geom2d_Parabola , gp_Parab2d> Parabola;
160 typedef subBase_empty<Curve> Bounded;
161 typedef Delayed<Bounded, pBezier> Bezier;
162 typedef Delayed<Bounded, pBSpline> BSpline;
163 typedef Delayed<Bounded, pTrimmed> Trimmed;
165 typedef Delayed<Curve, pOffset> Offset;
168 //! Create a persistent object for a line
169 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_Line)& theCurve,
170 StdObjMgt_TransientPersistentMap& theMap);
171 //! Create a persistent object for a circle
172 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_Circle)& theCurve,
173 StdObjMgt_TransientPersistentMap& theMap);
174 //! Create a persistent object for a ellipse
175 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_Ellipse)& theCurve,
176 StdObjMgt_TransientPersistentMap& theMap);
177 //! Create a persistent object for a hyperbola
178 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_Hyperbola)& theCurve,
179 StdObjMgt_TransientPersistentMap& theMap);
180 //! Create a persistent object for a parabola
181 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_Parabola)& theCurve,
182 StdObjMgt_TransientPersistentMap& theMap);
183 //! Create a persistent object for a Bezier curve
184 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_BezierCurve)& theCurve,
185 StdObjMgt_TransientPersistentMap& theMap);
186 //! Create a persistent object for a BSpline curve
187 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_BSplineCurve)& theCurve,
188 StdObjMgt_TransientPersistentMap& theMap);
189 //! Create a persistent object for a trimmed curve
190 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_TrimmedCurve)& theCurve,
191 StdObjMgt_TransientPersistentMap& theMap);
192 //! Create a persistent object for an offset curve
193 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_OffsetCurve)& theCurve,
194 StdObjMgt_TransientPersistentMap& theMap);
197 //=======================================================================
199 //=======================================================================
201 Standard_CString ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d::Curve,
207 void ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d::Curve,
210 ::Write(StdObjMgt_WriteData& theWriteData) const;
212 //=======================================================================
214 //=======================================================================
216 Standard_CString ShapePersistent_Geom2d_Curve::subBase_gp<ShapePersistent_Geom2d::Curve,
220 //=======================================================================
222 //=======================================================================
224 Standard_CString ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
230 void ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
233 ::Write(StdObjMgt_WriteData& theWriteData) const;
235 //=======================================================================
237 //=======================================================================
239 Standard_CString ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
245 void ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
248 ::Write(StdObjMgt_WriteData& theWriteData) const;
250 //=======================================================================
252 //=======================================================================
254 Standard_CString ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
260 void ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
263 ::Write(StdObjMgt_WriteData& theWriteData) const;
265 //=======================================================================
267 //=======================================================================
269 Standard_CString ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
275 void ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
278 ::Write(StdObjMgt_WriteData& theWriteData) const;