Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-28 10:21:38

0001 // Copyright (c) 2015 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _ShapePersistent_Geom2d_Curve_HeaderFile
0015 #define _ShapePersistent_Geom2d_Curve_HeaderFile
0016 
0017 #include <ShapePersistent_Geom2d.hxx>
0018 #include <ShapePersistent_HArray1.hxx>
0019 #include <StdLPersistent_HArray1.hxx>
0020 
0021 #include <Geom2d_Line.hxx>
0022 #include <Geom2d_Circle.hxx>
0023 #include <Geom2d_Ellipse.hxx>
0024 #include <Geom2d_Hyperbola.hxx>
0025 #include <Geom2d_Parabola.hxx>
0026 #include <Geom2d_BezierCurve.hxx>
0027 #include <Geom2d_BSplineCurve.hxx>
0028 #include <Geom2d_TrimmedCurve.hxx>
0029 #include <Geom2d_OffsetCurve.hxx>
0030 
0031 #include <gp_Circ2d.hxx>
0032 #include <gp_Elips2d.hxx>
0033 #include <gp_Hypr2d.hxx>
0034 #include <gp_Parab2d.hxx>
0035 
0036 class ShapePersistent_Geom2d_Curve : public ShapePersistent_Geom2d
0037 {
0038   typedef Curve::PersistentBase pBase;
0039 
0040   typedef pBase pBounded;
0041 
0042   class pBezier : public pBounded
0043   {
0044     friend class ShapePersistent_Geom2d_Curve;
0045 
0046   public:
0047     pBezier()
0048         : myRational(false)
0049     {
0050     }
0051 
0052     inline void Read(StdObjMgt_ReadData& theReadData)
0053     {
0054       theReadData >> myRational >> myPoles >> myWeights;
0055     }
0056 
0057     inline void Write(StdObjMgt_WriteData& theWriteData) const
0058     {
0059       theWriteData << myRational << myPoles << myWeights;
0060     }
0061 
0062     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
0063     {
0064       theChildren.Append(myPoles);
0065       theChildren.Append(myWeights);
0066     }
0067 
0068     inline const char* PName() const { return "PGeom2d_BezierCurve"; }
0069 
0070     occ::handle<Geom2d_Curve> Import() const override;
0071 
0072   private:
0073     bool                                   myRational;
0074     Handle(ShapePersistent_HArray1::Pnt2d) myPoles;
0075     Handle(StdLPersistent_HArray1::Real)   myWeights;
0076   };
0077 
0078   class pBSpline : public pBounded
0079   {
0080     friend class ShapePersistent_Geom2d_Curve;
0081 
0082   public:
0083     pBSpline()
0084         : myRational(false),
0085           myPeriodic(false),
0086           mySpineDegree(0)
0087     {
0088     }
0089 
0090     inline void Read(StdObjMgt_ReadData& theReadData)
0091     {
0092       theReadData >> myRational >> myPeriodic >> mySpineDegree;
0093       theReadData >> myPoles >> myWeights >> myKnots >> myMultiplicities;
0094     }
0095 
0096     inline void Write(StdObjMgt_WriteData& theWriteData) const
0097     {
0098       theWriteData << myRational << myPeriodic << mySpineDegree;
0099       theWriteData << myPoles << myWeights << myKnots << myMultiplicities;
0100     }
0101 
0102     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
0103     {
0104       theChildren.Append(myPoles);
0105       theChildren.Append(myWeights);
0106       theChildren.Append(myKnots);
0107       theChildren.Append(myMultiplicities);
0108     }
0109 
0110     inline const char* PName() const { return "PGeom2d_BSplineCurve"; }
0111 
0112     occ::handle<Geom2d_Curve> Import() const override;
0113 
0114   private:
0115     bool                                    myRational;
0116     bool                                    myPeriodic;
0117     int                                     mySpineDegree;
0118     Handle(ShapePersistent_HArray1::Pnt2d)  myPoles;
0119     Handle(StdLPersistent_HArray1::Real)    myWeights;
0120     Handle(StdLPersistent_HArray1::Real)    myKnots;
0121     Handle(StdLPersistent_HArray1::Integer) myMultiplicities;
0122   };
0123 
0124   class pTrimmed : public pBounded
0125   {
0126     friend class ShapePersistent_Geom2d_Curve;
0127 
0128   public:
0129     pTrimmed()
0130         : myFirstU(0.0),
0131           myLastU(0.0)
0132     {
0133     }
0134 
0135     inline void Read(StdObjMgt_ReadData& theReadData)
0136     {
0137       theReadData >> myBasisCurve >> myFirstU >> myLastU;
0138     }
0139 
0140     inline void Write(StdObjMgt_WriteData& theWriteData) const
0141     {
0142       theWriteData << myBasisCurve << myFirstU << myLastU;
0143     }
0144 
0145     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
0146     {
0147       theChildren.Append(myBasisCurve);
0148     }
0149 
0150     inline const char* PName() const { return "PGeom2d_TrimmedCurve"; }
0151 
0152     occ::handle<Geom2d_Curve> Import() const override;
0153 
0154   private:
0155     occ::handle<Curve> myBasisCurve;
0156     double             myFirstU;
0157     double             myLastU;
0158   };
0159 
0160   class pOffset : public pBase
0161   {
0162     friend class ShapePersistent_Geom2d_Curve;
0163 
0164   public:
0165     pOffset()
0166         : myOffsetValue(0.0)
0167     {
0168     }
0169 
0170     inline void Read(StdObjMgt_ReadData& theReadData)
0171     {
0172       theReadData >> myBasisCurve >> myOffsetValue;
0173     }
0174 
0175     inline void Write(StdObjMgt_WriteData& theWriteData) const
0176     {
0177       theWriteData << myBasisCurve << myOffsetValue;
0178     }
0179 
0180     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
0181     {
0182       theChildren.Append(myBasisCurve);
0183     }
0184 
0185     inline const char* PName() const { return "PGeom2d_OffsetCurve"; }
0186 
0187     occ::handle<Geom2d_Curve> Import() const override;
0188 
0189   private:
0190     occ::handle<Curve> myBasisCurve;
0191     double             myOffsetValue;
0192   };
0193 
0194 public:
0195   typedef instance<Curve, Geom2d_Line, gp_Ax2d> Line;
0196 
0197   typedef subBase_gp<Curve, gp_Ax22d>                  Conic;
0198   typedef instance<Conic, Geom2d_Circle, gp_Circ2d>    Circle;
0199   typedef instance<Conic, Geom2d_Ellipse, gp_Elips2d>  Ellipse;
0200   typedef instance<Conic, Geom2d_Hyperbola, gp_Hypr2d> Hyperbola;
0201   typedef instance<Conic, Geom2d_Parabola, gp_Parab2d> Parabola;
0202 
0203   typedef subBase_empty<Curve>       Bounded;
0204   typedef Delayed<Bounded, pBezier>  Bezier;
0205   typedef Delayed<Bounded, pBSpline> BSpline;
0206   typedef Delayed<Bounded, pTrimmed> Trimmed;
0207 
0208   typedef Delayed<Curve, pOffset> Offset;
0209 
0210 public:
0211   //! Create a persistent object for a line
0212   Standard_EXPORT static occ::handle<Curve> Translate(
0213     const occ::handle<Geom2d_Line>& theCurve,
0214     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0215       theMap);
0216   //! Create a persistent object for a circle
0217   Standard_EXPORT static occ::handle<Curve> Translate(
0218     const occ::handle<Geom2d_Circle>& theCurve,
0219     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0220       theMap);
0221   //! Create a persistent object for a ellipse
0222   Standard_EXPORT static occ::handle<Curve> Translate(
0223     const occ::handle<Geom2d_Ellipse>& theCurve,
0224     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0225       theMap);
0226   //! Create a persistent object for a hyperbola
0227   Standard_EXPORT static occ::handle<Curve> Translate(
0228     const occ::handle<Geom2d_Hyperbola>& theCurve,
0229     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0230       theMap);
0231   //! Create a persistent object for a parabola
0232   Standard_EXPORT static occ::handle<Curve> Translate(
0233     const occ::handle<Geom2d_Parabola>& theCurve,
0234     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0235       theMap);
0236   //! Create a persistent object for a Bezier curve
0237   Standard_EXPORT static occ::handle<Curve> Translate(
0238     const occ::handle<Geom2d_BezierCurve>& theCurve,
0239     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0240       theMap);
0241   //! Create a persistent object for a BSpline curve
0242   Standard_EXPORT static occ::handle<Curve> Translate(
0243     const occ::handle<Geom2d_BSplineCurve>& theCurve,
0244     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0245       theMap);
0246   //! Create a persistent object for a trimmed curve
0247   Standard_EXPORT static occ::handle<Curve> Translate(
0248     const occ::handle<Geom2d_TrimmedCurve>& theCurve,
0249     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0250       theMap);
0251   //! Create a persistent object for an offset curve
0252   Standard_EXPORT static occ::handle<Curve> Translate(
0253     const occ::handle<Geom2d_OffsetCurve>& theCurve,
0254     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0255       theMap);
0256 };
0257 
0258 //=======================================================================
0259 // Line
0260 //=======================================================================
0261 template <>
0262 const char* ShapePersistent_Geom2d_Curve::
0263   instance<ShapePersistent_Geom2d::Curve, Geom2d_Line, gp_Ax2d>::PName() const;
0264 
0265 template <>
0266 void ShapePersistent_Geom2d_Curve::instance<ShapePersistent_Geom2d::Curve, Geom2d_Line, gp_Ax2d>::
0267   Write(StdObjMgt_WriteData& theWriteData) const;
0268 
0269 //=======================================================================
0270 // Conic
0271 //=======================================================================
0272 template <>
0273 const char* ShapePersistent_Geom2d_Curve::subBase_gp<ShapePersistent_Geom2d::Curve,
0274                                                      gp_Ax22d>::PName() const;
0275 
0276 //=======================================================================
0277 // Circle
0278 //=======================================================================
0279 template <>
0280 const char* ShapePersistent_Geom2d_Curve::
0281   instance<ShapePersistent_Geom2d_Curve::Conic, Geom2d_Circle, gp_Circ2d>::PName() const;
0282 
0283 template <>
0284 void ShapePersistent_Geom2d_Curve::
0285   instance<ShapePersistent_Geom2d_Curve::Conic, Geom2d_Circle, gp_Circ2d>::Write(
0286     StdObjMgt_WriteData& theWriteData) const;
0287 
0288 //=======================================================================
0289 // Ellipse
0290 //=======================================================================
0291 template <>
0292 const char* ShapePersistent_Geom2d_Curve::
0293   instance<ShapePersistent_Geom2d_Curve::Conic, Geom2d_Ellipse, gp_Elips2d>::PName() const;
0294 
0295 template <>
0296 void ShapePersistent_Geom2d_Curve::
0297   instance<ShapePersistent_Geom2d_Curve::Conic, Geom2d_Ellipse, gp_Elips2d>::Write(
0298     StdObjMgt_WriteData& theWriteData) const;
0299 
0300 //=======================================================================
0301 // Hyperbola
0302 //=======================================================================
0303 template <>
0304 const char* ShapePersistent_Geom2d_Curve::
0305   instance<ShapePersistent_Geom2d_Curve::Conic, Geom2d_Hyperbola, gp_Hypr2d>::PName() const;
0306 
0307 template <>
0308 void ShapePersistent_Geom2d_Curve::
0309   instance<ShapePersistent_Geom2d_Curve::Conic, Geom2d_Hyperbola, gp_Hypr2d>::Write(
0310     StdObjMgt_WriteData& theWriteData) const;
0311 
0312 //=======================================================================
0313 // Parabola
0314 //=======================================================================
0315 template <>
0316 const char* ShapePersistent_Geom2d_Curve::
0317   instance<ShapePersistent_Geom2d_Curve::Conic, Geom2d_Parabola, gp_Parab2d>::PName() const;
0318 
0319 template <>
0320 void ShapePersistent_Geom2d_Curve::
0321   instance<ShapePersistent_Geom2d_Curve::Conic, Geom2d_Parabola, gp_Parab2d>::Write(
0322     StdObjMgt_WriteData& theWriteData) const;
0323 
0324 #endif