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_Geom_Curve_HeaderFile
16 #define _ShapePersistent_Geom_Curve_HeaderFile
18 #include <StdObjMgt_TransientPersistentMap.hxx>
20 #include <ShapePersistent_Geom.hxx>
21 #include <ShapePersistent_HArray1.hxx>
22 #include <StdLPersistent_HArray1.hxx>
24 #include <Geom_Line.hxx>
25 #include <Geom_Circle.hxx>
26 #include <Geom_Ellipse.hxx>
27 #include <Geom_Hyperbola.hxx>
28 #include <Geom_Parabola.hxx>
29 #include <Geom_BezierCurve.hxx>
30 #include <Geom_BSplineCurve.hxx>
31 #include <Geom_TrimmedCurve.hxx>
32 #include <Geom_OffsetCurve.hxx>
34 #include <gp_Circ.hxx>
35 #include <gp_Elips.hxx>
36 #include <gp_Hypr.hxx>
37 #include <gp_Parab.hxx>
41 class ShapePersistent_Geom_Curve : private ShapePersistent_Geom
43 typedef Curve::PersistentBase pBase;
45 typedef pBase pBounded;
47 class pBezier : public pBounded
49 friend class ShapePersistent_Geom_Curve;
52 inline void Read (StdObjMgt_ReadData& theReadData)
53 { theReadData >> myRational >> myPoles >> myWeights; }
54 inline void Write(StdObjMgt_WriteData& theWriteData)
55 { theWriteData << myRational << myPoles << myWeights; }
56 inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
58 theChildren.Append(myPoles);
59 theChildren.Append(myWeights);
61 inline Standard_CString PName() const { return "PGeom_BezierCurve"; }
63 virtual Handle(Geom_Curve) Import() const;
66 Standard_Boolean myRational;
67 Handle(ShapePersistent_HArray1::Pnt) myPoles;
68 Handle(StdLPersistent_HArray1::Real) myWeights;
71 class pBSpline : public pBounded
73 friend class ShapePersistent_Geom_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 { return "PGeom_BSplineCurve"; }
95 virtual Handle(Geom_Curve) Import() const;
98 Standard_Boolean myRational;
99 Standard_Boolean myPeriodic;
100 Standard_Integer mySpineDegree;
101 Handle(ShapePersistent_HArray1::Pnt) myPoles;
102 Handle(StdLPersistent_HArray1::Real) myWeights;
103 Handle(StdLPersistent_HArray1::Real) myKnots;
104 Handle(StdLPersistent_HArray1::Integer) myMultiplicities;
107 class pTrimmed : public pBounded
109 friend class ShapePersistent_Geom_Curve;
112 inline void Read (StdObjMgt_ReadData& theReadData)
113 { theReadData >> myBasisCurve >> myFirstU >> myLastU; }
114 inline void Write (StdObjMgt_WriteData& theWriteData) const
115 { theWriteData << myBasisCurve << myFirstU << myLastU; }
116 inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
117 { theChildren.Append(myBasisCurve); }
118 inline Standard_CString PName() const { return "PGeom_TrimmedCurve"; }
120 virtual Handle(Geom_Curve) Import() const;
123 Handle(Curve) myBasisCurve;
124 Standard_Real myFirstU;
125 Standard_Real myLastU;
128 class pOffset : public pBase
130 friend class ShapePersistent_Geom_Curve;
133 inline void Read (StdObjMgt_ReadData& theReadData)
134 { theReadData >> myBasisCurve >> myOffsetDirection >> myOffsetValue; }
135 inline void Write (StdObjMgt_WriteData& theWriteData) const
136 { theWriteData << myBasisCurve << myOffsetDirection << myOffsetValue; }
137 inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
138 { theChildren.Append(myBasisCurve); }
139 inline Standard_CString PName() const { return "PGeom_OffsetCurve"; }
141 virtual Handle(Geom_Curve) Import() const;
144 Handle(Curve) myBasisCurve;
145 gp_Dir myOffsetDirection;
146 Standard_Real myOffsetValue;
150 typedef instance<Curve, Geom_Line, gp_Ax1> Line;
152 typedef subBase_gp<Curve, gp_Ax2> Conic;
153 typedef instance<Conic, Geom_Circle , gp_Circ > Circle;
154 typedef instance<Conic, Geom_Ellipse , gp_Elips> Ellipse;
155 typedef instance<Conic, Geom_Hyperbola, gp_Hypr > Hyperbola;
156 typedef instance<Conic, Geom_Parabola , gp_Parab> Parabola;
158 typedef subBase_empty<Curve> Bounded;
159 typedef Delayed<Bounded, pBezier> Bezier;
160 typedef Delayed<Bounded, pBSpline> BSpline;
161 typedef Delayed<Bounded, pTrimmed> Trimmed;
163 typedef Delayed<Curve, pOffset> Offset;
166 //! Create a persistent object for a line
167 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom_Line)& theCurve,
168 StdObjMgt_TransientPersistentMap& theMap);
169 //! Create a persistent object for a circle
170 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom_Circle)& theCurve,
171 StdObjMgt_TransientPersistentMap& theMap);
172 //! Create a persistent object for a ellipse
173 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom_Ellipse)& theCurve,
174 StdObjMgt_TransientPersistentMap& theMap);
175 //! Create a persistent object for a hyperbola
176 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom_Hyperbola)& theCurve,
177 StdObjMgt_TransientPersistentMap& theMap);
178 //! Create a persistent object for a parabola
179 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom_Parabola)& theCurve,
180 StdObjMgt_TransientPersistentMap& theMap);
181 //! Create a persistent object for a Bezier curve
182 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom_BezierCurve)& theCurve,
183 StdObjMgt_TransientPersistentMap& theMap);
184 //! Create a persistent object for a BSpline curve
185 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom_BSplineCurve)& theCurve,
186 StdObjMgt_TransientPersistentMap& theMap);
187 //! Create a persistent object for a trimmed curve
188 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom_TrimmedCurve)& theCurve,
189 StdObjMgt_TransientPersistentMap& theMap);
190 //! Create a persistent object for an offset curve
191 Standard_EXPORT static Handle(Curve) Translate (const Handle(Geom_OffsetCurve)& theCurve,
192 StdObjMgt_TransientPersistentMap& theMap);
195 //=======================================================================
197 //=======================================================================
199 Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom::Curve,
205 void ShapePersistent_Geom::instance<ShapePersistent_Geom::Curve,
208 ::Write(StdObjMgt_WriteData& theWriteData) const;
210 //=======================================================================
212 //=======================================================================
214 Standard_CString ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Curve,
218 //=======================================================================
220 //=======================================================================
222 Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic,
228 void ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic,
231 ::Write(StdObjMgt_WriteData& theWriteData) const;
233 //=======================================================================
235 //=======================================================================
237 Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic,
243 void ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic,
246 ::Write(StdObjMgt_WriteData& theWriteData) const;
248 //=======================================================================
250 //=======================================================================
252 Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic,
258 void ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic,
261 ::Write(StdObjMgt_WriteData& theWriteData) const;
263 //=======================================================================
265 //=======================================================================
267 Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic,
273 void ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic,
276 ::Write(StdObjMgt_WriteData& theWriteData) const;