Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-22 08:59:16

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_Geom_Curve_HeaderFile
0015 #define _ShapePersistent_Geom_Curve_HeaderFile
0016 
0017 #include <NCollection_DataMap.hxx>
0018 
0019 #include <ShapePersistent_Geom.hxx>
0020 #include <ShapePersistent_HArray1.hxx>
0021 #include <StdLPersistent_HArray1.hxx>
0022 
0023 #include <Geom_Line.hxx>
0024 #include <Geom_Circle.hxx>
0025 #include <Geom_Ellipse.hxx>
0026 #include <Geom_Hyperbola.hxx>
0027 #include <Geom_Parabola.hxx>
0028 #include <Geom_BezierCurve.hxx>
0029 #include <Geom_BSplineCurve.hxx>
0030 #include <Geom_TrimmedCurve.hxx>
0031 #include <Geom_OffsetCurve.hxx>
0032 
0033 #include <gp_Circ.hxx>
0034 #include <gp_Elips.hxx>
0035 #include <gp_Hypr.hxx>
0036 #include <gp_Parab.hxx>
0037 class Standard_Transient;
0038 class StdObjMgt_Persistent;
0039 
0040 class ShapePersistent_Geom_Curve : private ShapePersistent_Geom
0041 {
0042   typedef Curve::PersistentBase pBase;
0043 
0044   typedef pBase pBounded;
0045 
0046   class pBezier : public pBounded
0047   {
0048     friend class ShapePersistent_Geom_Curve;
0049 
0050   public:
0051     pBezier()
0052         : myRational(false)
0053     {
0054     }
0055 
0056     inline void Read(StdObjMgt_ReadData& theReadData)
0057     {
0058       theReadData >> myRational >> myPoles >> myWeights;
0059     }
0060 
0061     inline void Write(StdObjMgt_WriteData& theWriteData)
0062     {
0063       theWriteData << myRational << myPoles << myWeights;
0064     }
0065 
0066     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
0067     {
0068       theChildren.Append(myPoles);
0069       theChildren.Append(myWeights);
0070     }
0071 
0072     inline const char* PName() const { return "PGeom_BezierCurve"; }
0073 
0074     occ::handle<Geom_Curve> Import() const override;
0075 
0076   private:
0077     bool                                 myRational;
0078     Handle(ShapePersistent_HArray1::Pnt) myPoles;
0079     Handle(StdLPersistent_HArray1::Real) myWeights;
0080   };
0081 
0082   class pBSpline : public pBounded
0083   {
0084     friend class ShapePersistent_Geom_Curve;
0085 
0086   public:
0087     pBSpline()
0088         : myRational(false),
0089           myPeriodic(false),
0090           mySpineDegree(0)
0091     {
0092     }
0093 
0094     inline void Read(StdObjMgt_ReadData& theReadData)
0095     {
0096       theReadData >> myRational >> myPeriodic >> mySpineDegree;
0097       theReadData >> myPoles >> myWeights >> myKnots >> myMultiplicities;
0098     }
0099 
0100     inline void Write(StdObjMgt_WriteData& theWriteData) const
0101     {
0102       theWriteData << myRational << myPeriodic << mySpineDegree;
0103       theWriteData << myPoles << myWeights << myKnots << myMultiplicities;
0104     }
0105 
0106     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
0107     {
0108       theChildren.Append(myPoles);
0109       theChildren.Append(myWeights);
0110       theChildren.Append(myKnots);
0111       theChildren.Append(myMultiplicities);
0112     }
0113 
0114     inline const char* PName() const { return "PGeom_BSplineCurve"; }
0115 
0116     occ::handle<Geom_Curve> Import() const override;
0117 
0118   private:
0119     bool                                    myRational;
0120     bool                                    myPeriodic;
0121     int                                     mySpineDegree;
0122     Handle(ShapePersistent_HArray1::Pnt)    myPoles;
0123     Handle(StdLPersistent_HArray1::Real)    myWeights;
0124     Handle(StdLPersistent_HArray1::Real)    myKnots;
0125     Handle(StdLPersistent_HArray1::Integer) myMultiplicities;
0126   };
0127 
0128   class pTrimmed : public pBounded
0129   {
0130     friend class ShapePersistent_Geom_Curve;
0131 
0132   public:
0133     pTrimmed()
0134         : myFirstU(0.0),
0135           myLastU(0.0)
0136     {
0137     }
0138 
0139     inline void Read(StdObjMgt_ReadData& theReadData)
0140     {
0141       theReadData >> myBasisCurve >> myFirstU >> myLastU;
0142     }
0143 
0144     inline void Write(StdObjMgt_WriteData& theWriteData) const
0145     {
0146       theWriteData << myBasisCurve << myFirstU << myLastU;
0147     }
0148 
0149     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
0150     {
0151       theChildren.Append(myBasisCurve);
0152     }
0153 
0154     inline const char* PName() const { return "PGeom_TrimmedCurve"; }
0155 
0156     occ::handle<Geom_Curve> Import() const override;
0157 
0158   private:
0159     occ::handle<Curve> myBasisCurve;
0160     double             myFirstU;
0161     double             myLastU;
0162   };
0163 
0164   class pOffset : public pBase
0165   {
0166     friend class ShapePersistent_Geom_Curve;
0167 
0168   public:
0169     pOffset()
0170         : myOffsetValue(0.0)
0171     {
0172     }
0173 
0174     inline void Read(StdObjMgt_ReadData& theReadData)
0175     {
0176       theReadData >> myBasisCurve >> myOffsetDirection >> myOffsetValue;
0177     }
0178 
0179     inline void Write(StdObjMgt_WriteData& theWriteData) const
0180     {
0181       theWriteData << myBasisCurve << myOffsetDirection << myOffsetValue;
0182     }
0183 
0184     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
0185     {
0186       theChildren.Append(myBasisCurve);
0187     }
0188 
0189     inline const char* PName() const { return "PGeom_OffsetCurve"; }
0190 
0191     occ::handle<Geom_Curve> Import() const override;
0192 
0193   private:
0194     occ::handle<Curve> myBasisCurve;
0195     gp_Dir             myOffsetDirection;
0196     double             myOffsetValue;
0197   };
0198 
0199 public:
0200   typedef instance<Curve, Geom_Line, gp_Ax1> Line;
0201 
0202   typedef subBase_gp<Curve, gp_Ax2>                Conic;
0203   typedef instance<Conic, Geom_Circle, gp_Circ>    Circle;
0204   typedef instance<Conic, Geom_Ellipse, gp_Elips>  Ellipse;
0205   typedef instance<Conic, Geom_Hyperbola, gp_Hypr> Hyperbola;
0206   typedef instance<Conic, Geom_Parabola, gp_Parab> Parabola;
0207 
0208   typedef subBase_empty<Curve>       Bounded;
0209   typedef Delayed<Bounded, pBezier>  Bezier;
0210   typedef Delayed<Bounded, pBSpline> BSpline;
0211   typedef Delayed<Bounded, pTrimmed> Trimmed;
0212 
0213   typedef Delayed<Curve, pOffset> Offset;
0214 
0215 public:
0216   //! Create a persistent object for a line
0217   Standard_EXPORT static occ::handle<Curve> Translate(
0218     const occ::handle<Geom_Line>& theCurve,
0219     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0220       theMap);
0221   //! Create a persistent object for a circle
0222   Standard_EXPORT static occ::handle<Curve> Translate(
0223     const occ::handle<Geom_Circle>& theCurve,
0224     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0225       theMap);
0226   //! Create a persistent object for a ellipse
0227   Standard_EXPORT static occ::handle<Curve> Translate(
0228     const occ::handle<Geom_Ellipse>& theCurve,
0229     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0230       theMap);
0231   //! Create a persistent object for a hyperbola
0232   Standard_EXPORT static occ::handle<Curve> Translate(
0233     const occ::handle<Geom_Hyperbola>& theCurve,
0234     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0235       theMap);
0236   //! Create a persistent object for a parabola
0237   Standard_EXPORT static occ::handle<Curve> Translate(
0238     const occ::handle<Geom_Parabola>& theCurve,
0239     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0240       theMap);
0241   //! Create a persistent object for a Bezier curve
0242   Standard_EXPORT static occ::handle<Curve> Translate(
0243     const occ::handle<Geom_BezierCurve>& theCurve,
0244     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0245       theMap);
0246   //! Create a persistent object for a BSpline curve
0247   Standard_EXPORT static occ::handle<Curve> Translate(
0248     const occ::handle<Geom_BSplineCurve>& theCurve,
0249     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0250       theMap);
0251   //! Create a persistent object for a trimmed curve
0252   Standard_EXPORT static occ::handle<Curve> Translate(
0253     const occ::handle<Geom_TrimmedCurve>& theCurve,
0254     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0255       theMap);
0256   //! Create a persistent object for an offset curve
0257   Standard_EXPORT static occ::handle<Curve> Translate(
0258     const occ::handle<Geom_OffsetCurve>& theCurve,
0259     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0260       theMap);
0261 };
0262 
0263 //=======================================================================
0264 // Line
0265 //=======================================================================
0266 template <>
0267 const char* ShapePersistent_Geom::instance<ShapePersistent_Geom::Curve, Geom_Line, gp_Ax1>::PName()
0268   const;
0269 
0270 template <>
0271 void ShapePersistent_Geom::instance<ShapePersistent_Geom::Curve, Geom_Line, gp_Ax1>::Write(
0272   StdObjMgt_WriteData& theWriteData) const;
0273 
0274 //=======================================================================
0275 // Conic
0276 //=======================================================================
0277 template <>
0278 const char* ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Curve, gp_Ax2>::PName() const;
0279 
0280 //=======================================================================
0281 // Circle
0282 //=======================================================================
0283 template <>
0284 const char* ShapePersistent_Geom::
0285   instance<ShapePersistent_Geom_Curve::Conic, Geom_Circle, gp_Circ>::PName() const;
0286 
0287 template <>
0288 void ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic, Geom_Circle, gp_Circ>::Write(
0289   StdObjMgt_WriteData& theWriteData) const;
0290 
0291 //=======================================================================
0292 // Ellipse
0293 //=======================================================================
0294 template <>
0295 const char* ShapePersistent_Geom::
0296   instance<ShapePersistent_Geom_Curve::Conic, Geom_Ellipse, gp_Elips>::PName() const;
0297 
0298 template <>
0299 void ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic, Geom_Ellipse, gp_Elips>::
0300   Write(StdObjMgt_WriteData& theWriteData) const;
0301 
0302 //=======================================================================
0303 // Hyperbola
0304 //=======================================================================
0305 template <>
0306 const char* ShapePersistent_Geom::
0307   instance<ShapePersistent_Geom_Curve::Conic, Geom_Hyperbola, gp_Hypr>::PName() const;
0308 
0309 template <>
0310 void ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic, Geom_Hyperbola, gp_Hypr>::
0311   Write(StdObjMgt_WriteData& theWriteData) const;
0312 
0313 //=======================================================================
0314 // Parabola
0315 //=======================================================================
0316 template <>
0317 const char* ShapePersistent_Geom::
0318   instance<ShapePersistent_Geom_Curve::Conic, Geom_Parabola, gp_Parab>::PName() const;
0319 
0320 template <>
0321 void ShapePersistent_Geom::instance<ShapePersistent_Geom_Curve::Conic, Geom_Parabola, gp_Parab>::
0322   Write(StdObjMgt_WriteData& theWriteData) const;
0323 
0324 #endif