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;
52 : myRational(Standard_False)
55 inline void Read (StdObjMgt_ReadData& theReadData)
56 { theReadData >> myRational >> myPoles >> myWeights; }
57 inline void Write (StdObjMgt_WriteData& theWriteData) const
58 { theWriteData << myRational << myPoles << myWeights; }
59 inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
61 theChildren.Append(myPoles);
62 theChildren.Append(myWeights);
64 inline Standard_CString PName() const
65 { return "PGeom2d_BezierCurve"; }
67 virtual Handle(Geom2d_Curve) Import() const;
70 Standard_Boolean myRational;
71 Handle(ShapePersistent_HArray1::Pnt2d) myPoles;
72 Handle(StdLPersistent_HArray1::Real) myWeights;
75 class pBSpline : public pBounded
77 friend class ShapePersistent_Geom2d_Curve;
81 : myRational(Standard_False),
82 myPeriodic(Standard_False),
86 inline void Read (StdObjMgt_ReadData& theReadData)
88 theReadData >> myRational >> myPeriodic >> mySpineDegree;
89 theReadData >> myPoles >> myWeights >> myKnots >> myMultiplicities;
91 inline void Write (StdObjMgt_WriteData& theWriteData) const
93 theWriteData << myRational << myPeriodic << mySpineDegree;
94 theWriteData << myPoles << myWeights << myKnots << myMultiplicities;
96 inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
98 theChildren.Append(myPoles);
99 theChildren.Append(myWeights);
100 theChildren.Append(myKnots);
101 theChildren.Append(myMultiplicities);
103 inline Standard_CString PName() const
104 { return "PGeom2d_BSplineCurve"; }
106 virtual Handle(Geom2d_Curve) Import() const;
109 Standard_Boolean myRational;
110 Standard_Boolean myPeriodic;
111 Standard_Integer mySpineDegree;
112 Handle(ShapePersistent_HArray1::Pnt2d) myPoles;
113 Handle(StdLPersistent_HArray1::Real) myWeights;
114 Handle(StdLPersistent_HArray1::Real) myKnots;
115 Handle(StdLPersistent_HArray1::Integer) myMultiplicities;
118 class pTrimmed : public pBounded
120 friend class ShapePersistent_Geom2d_Curve;
128 inline void Read (StdObjMgt_ReadData& theReadData)
129 { theReadData >> myBasisCurve >> myFirstU >> myLastU; }
130 inline void Write (StdObjMgt_WriteData& theWriteData) const
131 { theWriteData << myBasisCurve << myFirstU << myLastU; }
132 inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
133 { theChildren.Append(myBasisCurve); }
134 inline Standard_CString PName() const
135 { return "PGeom2d_TrimmedCurve"; }
137 virtual Handle(Geom2d_Curve) Import() const;
140 Handle(Curve) myBasisCurve;
141 Standard_Real myFirstU;
142 Standard_Real myLastU;
145 class pOffset : public pBase
147 friend class ShapePersistent_Geom2d_Curve;
154 inline void Read (StdObjMgt_ReadData& theReadData)
155 { theReadData >> myBasisCurve >> myOffsetValue; }
156 inline void Write (StdObjMgt_WriteData& theWriteData) const
157 { theWriteData << myBasisCurve << myOffsetValue; }
158 inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
159 { theChildren.Append(myBasisCurve); }
160 inline Standard_CString PName() const
161 { return "PGeom2d_OffsetCurve"; }
163 virtual Handle(Geom2d_Curve) Import() const;
166 Handle(Curve) myBasisCurve;
167 Standard_Real myOffsetValue;
171 typedef instance<Curve, Geom2d_Line, gp_Ax2d> Line;
173 typedef subBase_gp<Curve, gp_Ax22d> Conic;
174 typedef instance<Conic, Geom2d_Circle , gp_Circ2d > Circle;
175 typedef instance<Conic, Geom2d_Ellipse , gp_Elips2d> Ellipse;
176 typedef instance<Conic, Geom2d_Hyperbola, gp_Hypr2d > Hyperbola;
177 typedef instance<Conic, Geom2d_Parabola , gp_Parab2d> Parabola;
179 typedef subBase_empty<Curve> Bounded;
180 typedef Delayed<Bounded, pBezier> Bezier;
181 typedef Delayed<Bounded, pBSpline> BSpline;
182 typedef Delayed<Bounded, pTrimmed> Trimmed;
184 typedef Delayed<Curve, pOffset> Offset;
187 //! Create a persistent object for a line
188 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_Line)& theCurve,
189 StdObjMgt_TransientPersistentMap& theMap);
190 //! Create a persistent object for a circle
191 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_Circle)& theCurve,
192 StdObjMgt_TransientPersistentMap& theMap);
193 //! Create a persistent object for a ellipse
194 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_Ellipse)& theCurve,
195 StdObjMgt_TransientPersistentMap& theMap);
196 //! Create a persistent object for a hyperbola
197 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_Hyperbola)& theCurve,
198 StdObjMgt_TransientPersistentMap& theMap);
199 //! Create a persistent object for a parabola
200 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_Parabola)& theCurve,
201 StdObjMgt_TransientPersistentMap& theMap);
202 //! Create a persistent object for a Bezier curve
203 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_BezierCurve)& theCurve,
204 StdObjMgt_TransientPersistentMap& theMap);
205 //! Create a persistent object for a BSpline curve
206 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_BSplineCurve)& theCurve,
207 StdObjMgt_TransientPersistentMap& theMap);
208 //! Create a persistent object for a trimmed curve
209 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_TrimmedCurve)& theCurve,
210 StdObjMgt_TransientPersistentMap& theMap);
211 //! Create a persistent object for an offset curve
212 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom2d_OffsetCurve)& theCurve,
213 StdObjMgt_TransientPersistentMap& theMap);
216 //=======================================================================
218 //=======================================================================
220 Standard_CString ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d::Curve,
226 void ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d::Curve,
229 ::Write(StdObjMgt_WriteData& theWriteData) const;
231 //=======================================================================
233 //=======================================================================
235 Standard_CString ShapePersistent_Geom2d_Curve::subBase_gp<ShapePersistent_Geom2d::Curve,
239 //=======================================================================
241 //=======================================================================
243 Standard_CString ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
249 void ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
252 ::Write(StdObjMgt_WriteData& theWriteData) const;
254 //=======================================================================
256 //=======================================================================
258 Standard_CString ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
264 void ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
267 ::Write(StdObjMgt_WriteData& theWriteData) const;
269 //=======================================================================
271 //=======================================================================
273 Standard_CString ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
279 void ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
282 ::Write(StdObjMgt_WriteData& theWriteData) const;
284 //=======================================================================
286 //=======================================================================
288 Standard_CString ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
294 void ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d_Curve::Conic,
297 ::Write(StdObjMgt_WriteData& theWriteData) const;