Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-04 09:15: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 #ifndef _ShapePersistent_Geom_Surface_HeaderFile
0015 #define _ShapePersistent_Geom_Surface_HeaderFile
0016 
0017 #include <ShapePersistent_Geom.hxx>
0018 #include <ShapePersistent_HArray2.hxx>
0019 #include <StdLPersistent_HArray1.hxx>
0020 #include <StdLPersistent_HArray2.hxx>
0021 
0022 #include <Geom_Plane.hxx>
0023 #include <Geom_ConicalSurface.hxx>
0024 #include <Geom_CylindricalSurface.hxx>
0025 #include <Geom_SphericalSurface.hxx>
0026 #include <Geom_ToroidalSurface.hxx>
0027 #include <Geom_SurfaceOfLinearExtrusion.hxx>
0028 #include <Geom_SurfaceOfRevolution.hxx>
0029 #include <Geom_BezierSurface.hxx>
0030 #include <Geom_RectangularTrimmedSurface.hxx>
0031 #include <Geom_OffsetSurface.hxx>
0032 
0033 #include <gp_Ax3.hxx>
0034 #include <gp_Cone.hxx>
0035 #include <gp_Cylinder.hxx>
0036 #include <gp_Sphere.hxx>
0037 #include <gp_Torus.hxx>
0038 
0039 class ShapePersistent_Geom_Surface : private ShapePersistent_Geom
0040 {
0041   typedef Surface::PersistentBase pBase;
0042 
0043   class pSweptData
0044   {
0045     friend class ShapePersistent_Geom_Surface;
0046 
0047   public:
0048     inline void Read(StdObjMgt_ReadData& theReadData)
0049     {
0050       theReadData >> myBasisCurve >> myDirection;
0051     }
0052 
0053     inline void Write(StdObjMgt_WriteData& theWriteData) const
0054     {
0055       theWriteData << myBasisCurve << myDirection;
0056     }
0057 
0058     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
0059     {
0060       theChildren.Append(myBasisCurve);
0061     }
0062 
0063   protected:
0064     occ::handle<Curve> myBasisCurve;
0065     gp_Dir             myDirection;
0066   };
0067 
0068   struct pSwept : pBase, pSweptData
0069   {
0070     inline const char* PName() const { return "PGeom_SweptSurface"; }
0071   };
0072 
0073   class pLinearExtrusion : public pSwept
0074   {
0075     friend class ShapePersistent_Geom_Surface;
0076 
0077   public:
0078     occ::handle<Geom_Surface> Import() const override;
0079 
0080     inline const char* PName() const { return "PGeom_SurfaceOfLinearExtrusion"; }
0081   };
0082 
0083   class pRevolution : public pSwept
0084   {
0085     friend class ShapePersistent_Geom_Surface;
0086 
0087   public:
0088     inline void Read(StdObjMgt_ReadData& theReadData)
0089     {
0090       pSwept::Read(theReadData);
0091       theReadData >> myLocation;
0092     }
0093 
0094     inline void Write(StdObjMgt_WriteData& theWriteData) const
0095     {
0096       pSwept::Write(theWriteData);
0097       theWriteData << myLocation;
0098     }
0099 
0100     inline const char* PName() const { return "PGeom_SurfaceOfRevolution"; }
0101 
0102     occ::handle<Geom_Surface> Import() const override;
0103 
0104   private:
0105     gp_Pnt myLocation;
0106   };
0107 
0108   typedef pBase pBounded;
0109 
0110   class pBezier : public pBounded
0111   {
0112     friend class ShapePersistent_Geom_Surface;
0113 
0114   public:
0115     pBezier()
0116         : myURational(false),
0117           myVRational(false)
0118     {
0119     }
0120 
0121     inline void Read(StdObjMgt_ReadData& theReadData)
0122     {
0123       theReadData >> myURational >> myVRational >> myPoles >> myWeights;
0124     }
0125 
0126     inline void Write(StdObjMgt_WriteData& theWriteData) const
0127     {
0128       theWriteData << myURational << myVRational << myPoles << myWeights;
0129     }
0130 
0131     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
0132     {
0133       theChildren.Append(myPoles);
0134       theChildren.Append(myWeights);
0135     }
0136 
0137     inline const char* PName() const { return "PGeom_BezierSurface"; }
0138 
0139     occ::handle<Geom_Surface> Import() const override;
0140 
0141   private:
0142     bool                                 myURational;
0143     bool                                 myVRational;
0144     Handle(ShapePersistent_HArray2::Pnt) myPoles;
0145     Handle(StdLPersistent_HArray2::Real) myWeights;
0146   };
0147 
0148   class pBSpline : public pBounded
0149   {
0150     friend class ShapePersistent_Geom_Surface;
0151 
0152   public:
0153     pBSpline()
0154         : myURational(false),
0155           myVRational(false),
0156           myUPeriodic(false),
0157           myVPeriodic(false),
0158           myUSpineDegree(0),
0159           myVSpineDegree(0)
0160     {
0161     }
0162 
0163     inline void Read(StdObjMgt_ReadData& theReadData)
0164     {
0165       theReadData >> myURational >> myVRational;
0166       theReadData >> myUPeriodic >> myVPeriodic;
0167       theReadData >> myUSpineDegree >> myVSpineDegree;
0168       theReadData >> myPoles;
0169       theReadData >> myWeights;
0170       theReadData >> myUKnots >> myVKnots;
0171       theReadData >> myUMultiplicities >> myVMultiplicities;
0172     }
0173 
0174     inline void Write(StdObjMgt_WriteData& theWriteData) const
0175     {
0176       theWriteData << myURational << myVRational;
0177       theWriteData << myUPeriodic << myVPeriodic;
0178       theWriteData << myUSpineDegree << myVSpineDegree;
0179       theWriteData << myPoles;
0180       theWriteData << myWeights;
0181       theWriteData << myUKnots << myVKnots;
0182       theWriteData << myUMultiplicities << myVMultiplicities;
0183     }
0184 
0185     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
0186     {
0187       theChildren.Append(myPoles);
0188       theChildren.Append(myWeights);
0189       theChildren.Append(myUKnots);
0190       theChildren.Append(myVKnots);
0191       theChildren.Append(myUMultiplicities);
0192       theChildren.Append(myVMultiplicities);
0193     }
0194 
0195     inline const char* PName() const { return "PGeom_BSplineSurface"; }
0196 
0197     occ::handle<Geom_Surface> Import() const override;
0198 
0199   private:
0200     bool                                    myURational;
0201     bool                                    myVRational;
0202     bool                                    myUPeriodic;
0203     bool                                    myVPeriodic;
0204     int                                     myUSpineDegree;
0205     int                                     myVSpineDegree;
0206     Handle(ShapePersistent_HArray2::Pnt)    myPoles;
0207     Handle(StdLPersistent_HArray2::Real)    myWeights;
0208     Handle(StdLPersistent_HArray1::Real)    myUKnots;
0209     Handle(StdLPersistent_HArray1::Real)    myVKnots;
0210     Handle(StdLPersistent_HArray1::Integer) myUMultiplicities;
0211     Handle(StdLPersistent_HArray1::Integer) myVMultiplicities;
0212   };
0213 
0214   class pRectangularTrimmed : public pBounded
0215   {
0216     friend class ShapePersistent_Geom_Surface;
0217 
0218   public:
0219     pRectangularTrimmed()
0220         : myFirstU(0.0),
0221           myLastU(0.0),
0222           myFirstV(0.0),
0223           myLastV(0.0)
0224     {
0225     }
0226 
0227     inline void Read(StdObjMgt_ReadData& theReadData)
0228     {
0229       theReadData >> myBasisSurface;
0230       theReadData >> myFirstU >> myLastU >> myFirstV >> myLastV;
0231     }
0232 
0233     inline void Write(StdObjMgt_WriteData& theWriteData) const
0234     {
0235       theWriteData << myBasisSurface;
0236       theWriteData << myFirstU << myLastU << myFirstV << myLastV;
0237     }
0238 
0239     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
0240     {
0241       theChildren.Append(myBasisSurface);
0242     }
0243 
0244     inline const char* PName() const { return "PGeom_RectangularTrimmedSurface"; }
0245 
0246     occ::handle<Geom_Surface> Import() const override;
0247 
0248   private:
0249     occ::handle<Surface> myBasisSurface;
0250     double               myFirstU;
0251     double               myLastU;
0252     double               myFirstV;
0253     double               myLastV;
0254   };
0255 
0256   class pOffset : public pBase
0257   {
0258     friend class ShapePersistent_Geom_Surface;
0259 
0260   public:
0261     pOffset()
0262         : myOffsetValue(0.0)
0263     {
0264     }
0265 
0266     inline void Read(StdObjMgt_ReadData& theReadData)
0267     {
0268       theReadData >> myBasisSurface >> myOffsetValue;
0269     }
0270 
0271     inline void Write(StdObjMgt_WriteData& theWriteData) const
0272     {
0273       theWriteData << myBasisSurface << myOffsetValue;
0274     }
0275 
0276     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
0277     {
0278       theChildren.Append(myBasisSurface);
0279     }
0280 
0281     inline const char* PName() const { return "PGeom_OffsetSurface"; }
0282 
0283     occ::handle<Geom_Surface> Import() const override;
0284 
0285   private:
0286     occ::handle<Surface> myBasisSurface;
0287     double               myOffsetValue;
0288   };
0289 
0290 public:
0291   typedef subBase_gp<Surface, gp_Ax3>                                Elementary;
0292   typedef instance<Elementary, Geom_Plane, gp_Ax3>                   Plane;
0293   typedef instance<Elementary, Geom_ConicalSurface, gp_Cone>         Conical;
0294   typedef instance<Elementary, Geom_CylindricalSurface, gp_Cylinder> Cylindrical;
0295   typedef instance<Elementary, Geom_SphericalSurface, gp_Sphere>     Spherical;
0296   typedef instance<Elementary, Geom_ToroidalSurface, gp_Torus>       Toroidal;
0297 
0298   typedef subBase<Surface, pSweptData>     Swept;
0299   typedef Delayed<Swept, pLinearExtrusion> LinearExtrusion;
0300   typedef Delayed<Swept, pRevolution>      Revolution;
0301 
0302   typedef subBase_empty<Surface>                Bounded;
0303   typedef Delayed<Bounded, pBezier>             Bezier;
0304   typedef Delayed<Bounded, pBSpline>            BSpline;
0305   typedef Delayed<Bounded, pRectangularTrimmed> RectangularTrimmed;
0306 
0307   typedef Delayed<Surface, pOffset> Offset;
0308 
0309 public:
0310   //! Create a persistent object for a plane
0311   Standard_EXPORT static occ::handle<Surface> Translate(
0312     const occ::handle<Geom_Plane>& theSurf,
0313     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0314       theMap);
0315   //! Create a persistent object for a cylinder
0316   Standard_EXPORT static occ::handle<Surface> Translate(
0317     const occ::handle<Geom_CylindricalSurface>& theSurf,
0318     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0319       theMap);
0320   //! Create a persistent object for a cone
0321   Standard_EXPORT static occ::handle<Surface> Translate(
0322     const occ::handle<Geom_ConicalSurface>& theSurf,
0323     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0324       theMap);
0325   //! Create a persistent object for a sphere
0326   Standard_EXPORT static occ::handle<Surface> Translate(
0327     const occ::handle<Geom_SphericalSurface>& theSurf,
0328     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0329       theMap);
0330   //! Create a persistent object for a torus
0331   Standard_EXPORT static occ::handle<Surface> Translate(
0332     const occ::handle<Geom_ToroidalSurface>& theSurf,
0333     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0334       theMap);
0335   //! Create a persistent object for a surface of linear extrusion
0336   Standard_EXPORT static occ::handle<Surface> Translate(
0337     const occ::handle<Geom_SurfaceOfLinearExtrusion>& theSurf,
0338     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0339       theMap);
0340   //! Create a persistent object for a surface of evolution
0341   Standard_EXPORT static occ::handle<Surface> Translate(
0342     const occ::handle<Geom_SurfaceOfRevolution>& theSurf,
0343     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0344       theMap);
0345   //! Create a persistent object for a Bezier surface
0346   Standard_EXPORT static occ::handle<Surface> Translate(
0347     const occ::handle<Geom_BezierSurface>& theSurf,
0348     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0349       theMap);
0350   //! Create a persistent object for a BSpline surface
0351   Standard_EXPORT static occ::handle<Surface> Translate(
0352     const occ::handle<Geom_BSplineSurface>& theSurf,
0353     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0354       theMap);
0355   //! Create a persistent object for a rectangylar trimmed surface
0356   Standard_EXPORT static occ::handle<Surface> Translate(
0357     const occ::handle<Geom_RectangularTrimmedSurface>& theSurf,
0358     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0359       theMap);
0360   //! Create a persistent object for an offset surface
0361   Standard_EXPORT static occ::handle<Surface> Translate(
0362     const occ::handle<Geom_OffsetSurface>& theSurf,
0363     NCollection_DataMap<occ::handle<Standard_Transient>, occ::handle<StdObjMgt_Persistent>>&
0364       theMap);
0365 };
0366 
0367 //=======================================================================
0368 // Elementary
0369 //=======================================================================
0370 template <>
0371 const char* ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>::PName() const;
0372 
0373 //=======================================================================
0374 // Plane
0375 //=======================================================================
0376 template <>
0377 const char* ShapePersistent_Geom::instance<
0378   ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
0379   Geom_Plane,
0380   gp_Ax3>::PName() const;
0381 
0382 template <>
0383 void ShapePersistent_Geom::instance<
0384   ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
0385   Geom_Plane,
0386   gp_Ax3>::Write(StdObjMgt_WriteData& theWriteData) const;
0387 
0388 //=======================================================================
0389 // Conical
0390 //=======================================================================
0391 template <>
0392 const char* ShapePersistent_Geom::instance<
0393   ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
0394   Geom_ConicalSurface,
0395   gp_Cone>::PName() const;
0396 
0397 template <>
0398 void ShapePersistent_Geom::instance<
0399   ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
0400   Geom_ConicalSurface,
0401   gp_Cone>::Write(StdObjMgt_WriteData& theWriteData) const;
0402 
0403 //=======================================================================
0404 // Cylindrical
0405 //=======================================================================
0406 template <>
0407 const char* ShapePersistent_Geom::instance<
0408   ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
0409   Geom_CylindricalSurface,
0410   gp_Cylinder>::PName() const;
0411 
0412 template <>
0413 void ShapePersistent_Geom::instance<
0414   ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
0415   Geom_CylindricalSurface,
0416   gp_Cylinder>::Write(StdObjMgt_WriteData& theWriteData) const;
0417 
0418 //=======================================================================
0419 // Spherical
0420 //=======================================================================
0421 template <>
0422 const char* ShapePersistent_Geom::instance<
0423   ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
0424   Geom_SphericalSurface,
0425   gp_Sphere>::PName() const;
0426 
0427 template <>
0428 void ShapePersistent_Geom::instance<
0429   ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
0430   Geom_SphericalSurface,
0431   gp_Sphere>::Write(StdObjMgt_WriteData& theWriteData) const;
0432 
0433 //=======================================================================
0434 // Toroidal
0435 //=======================================================================
0436 template <>
0437 const char* ShapePersistent_Geom::instance<
0438   ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
0439   Geom_ToroidalSurface,
0440   gp_Torus>::PName() const;
0441 
0442 template <>
0443 void ShapePersistent_Geom::instance<
0444   ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
0445   Geom_ToroidalSurface,
0446   gp_Torus>::Write(StdObjMgt_WriteData& theWriteData) const;
0447 
0448 #endif