Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:57

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