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