Back to home page

EIC code displayed by LXR

 
 

    


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

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_BRep_HeaderFile
0016 #define _ShapePersistent_BRep_HeaderFile
0017 
0018 #include <ShapePersistent_TopoDS.hxx>
0019 #include <ShapePersistent_Geom2d.hxx>
0020 #include <ShapePersistent_Poly.hxx>
0021 #include <StdObjMgt_TransientPersistentMap.hxx>
0022 #include <StdObject_Location.hxx>
0023 #include <StdObject_gp_Vectors.hxx>
0024 
0025 #include <BRep_ListOfPointRepresentation.hxx>
0026 #include <BRep_ListOfCurveRepresentation.hxx>
0027 
0028 #include <gp_Pnt.hxx>
0029 #include <gp_Pnt2d.hxx>
0030 
0031 class BRep_PointRepresentation;
0032 class BRep_CurveRepresentation;
0033 class TopoDS_Vertex;
0034 class TopoDS_Edge;
0035 class TopoDS_Face;
0036 
0037 class ShapePersistent_BRep : public ShapePersistent_TopoDS
0038 {
0039 public:
0040   class PointRepresentation : public StdObjMgt_Persistent
0041   {
0042     friend class ShapePersistent_BRep;
0043 
0044   public:
0045     //! Empty constructor.
0046     PointRepresentation()
0047     : myParameter(0.0)
0048     {
0049     }
0050     //! Read persistent data from a file.
0051     Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
0052     //! Write persistent data to a file.
0053     Standard_EXPORT virtual void Write(StdObjMgt_WriteData& theWriteData) const;
0054     //! Gets persistent child objects
0055     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
0056     //! Returns persistent type name
0057     virtual Standard_CString PName() const { return "PBRep_PointRepresentation"; }
0058     //! Import transient object from the persistent data.
0059     Standard_EXPORT void Import (BRep_ListOfPointRepresentation& thePoints) const;
0060 
0061   protected:
0062     virtual Handle(BRep_PointRepresentation) import() const;
0063 
0064   protected:
0065     StdObject_Location myLocation;
0066     Standard_Real      myParameter;
0067 
0068   private:
0069     Handle(PointRepresentation) myNext;
0070   };
0071 
0072   class PointOnCurve : public PointRepresentation
0073   {
0074     friend class ShapePersistent_BRep;
0075 
0076   public:
0077     virtual void Read (StdObjMgt_ReadData& theReadData);
0078     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
0079     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
0080     virtual Standard_CString PName() const { return "PBRep_PointOnCurve"; }
0081     virtual Handle(BRep_PointRepresentation) import() const;
0082 
0083   private:
0084     Handle(ShapePersistent_Geom::Curve) myCurve;
0085   };
0086 
0087   class PointsOnSurface : public PointRepresentation
0088   {
0089     friend class ShapePersistent_BRep;
0090 
0091   public:
0092     virtual void Read (StdObjMgt_ReadData& theReadData);
0093     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
0094     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
0095     virtual Standard_CString PName() const { return "PBRep_PointsOnSurface"; }
0096 
0097   protected:
0098     Handle(ShapePersistent_Geom::Surface) mySurface;
0099   };
0100 
0101   class PointOnCurveOnSurface : public PointsOnSurface
0102   {
0103     friend class ShapePersistent_BRep;
0104 
0105   public:
0106     virtual void Read (StdObjMgt_ReadData& theReadData);
0107     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
0108     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
0109     virtual Standard_CString PName() const { return "PBRep_PointOnCurveOnSurface"; }
0110     virtual Handle(BRep_PointRepresentation) import() const;
0111 
0112   private:
0113     Handle(ShapePersistent_Geom2d::Curve) myPCurve;
0114   };
0115 
0116   class PointOnSurface : public PointsOnSurface
0117   {
0118     friend class ShapePersistent_BRep;
0119 
0120   public:
0121     PointOnSurface()
0122     : myParameter2(0.0)
0123     {
0124     }
0125     virtual void Read (StdObjMgt_ReadData& theReadData);
0126     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
0127     virtual Standard_CString PName() const { return "PBRep_PointOnSurface"; }
0128     virtual Handle(BRep_PointRepresentation) import() const;
0129 
0130   private:
0131     Standard_Real myParameter2;
0132   };
0133 
0134   class CurveRepresentation : public StdObjMgt_Persistent
0135   {
0136     friend class ShapePersistent_BRep;
0137 
0138   public:
0139     //! Read persistent data from a file.
0140     Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
0141     //! Write persistent data from a file.
0142     Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const;
0143     //! Gets persistent child objects
0144     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
0145     //! Returns persistent type name
0146     virtual Standard_CString PName() const { return "PBRep_CurveRepresentation"; }
0147     //! Import transient object from the persistent data.
0148     Standard_EXPORT void Import (BRep_ListOfCurveRepresentation& theCurves) const;
0149 
0150   protected:
0151     virtual Handle(BRep_CurveRepresentation) import() const;
0152 
0153   protected:
0154     StdObject_Location myLocation;
0155 
0156   private:
0157     Handle(CurveRepresentation) myNext;
0158   };
0159 
0160   class GCurve : public CurveRepresentation
0161   {
0162     friend class ShapePersistent_BRep;
0163 
0164   public:
0165     GCurve()
0166     : myFirst(0.0),
0167       myLast(0.0)
0168     {
0169     }
0170     virtual void Read (StdObjMgt_ReadData& theReadData);
0171     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
0172     virtual Standard_CString PName() const { return "PBRep_GCurve"; }
0173 
0174   protected:
0175     Standard_Real myFirst;
0176     Standard_Real myLast;
0177   };
0178 
0179   class Curve3D : public GCurve
0180   {
0181     friend class ShapePersistent_BRep;
0182 
0183   public:
0184     virtual void Read (StdObjMgt_ReadData& theReadData);
0185     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
0186     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
0187     virtual Standard_CString PName() const { return "PBRep_Curve3D"; }
0188     virtual Handle(BRep_CurveRepresentation) import() const;
0189 
0190   private:
0191     Handle(ShapePersistent_Geom::Curve) myCurve3D;
0192   };
0193 
0194   class CurveOnSurface : public GCurve
0195   {
0196     friend class ShapePersistent_BRep;
0197 
0198   public:
0199     virtual void Read (StdObjMgt_ReadData& theReadData);
0200     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
0201     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
0202     virtual Standard_CString PName() const { return "PBRep_CurveOnSurface"; }
0203     virtual Handle(BRep_CurveRepresentation) import() const;
0204 
0205   protected:
0206     Handle(ShapePersistent_Geom2d::Curve) myPCurve;
0207     Handle(ShapePersistent_Geom::Surface) mySurface;
0208     gp_Pnt2d                              myUV1;
0209     gp_Pnt2d                              myUV2;
0210   };
0211 
0212   class CurveOnClosedSurface : public CurveOnSurface
0213   {
0214     friend class ShapePersistent_BRep;
0215 
0216   public:
0217     CurveOnClosedSurface()
0218     : myContinuity(0)
0219     {
0220     }
0221     virtual void Read (StdObjMgt_ReadData& theReadData);
0222     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
0223     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
0224     virtual Standard_CString PName() const { return "PBRep_CurveOnClosedSurface"; }
0225     virtual Handle(BRep_CurveRepresentation) import() const;
0226 
0227   private:
0228     Handle(ShapePersistent_Geom2d::Curve) myPCurve2;
0229     Standard_Integer                      myContinuity;
0230     gp_Pnt2d                              myUV21;
0231     gp_Pnt2d                              myUV22;
0232   };
0233 
0234   class Polygon3D : public CurveRepresentation
0235   {
0236     friend class ShapePersistent_BRep;
0237 
0238   public:
0239     virtual void Read (StdObjMgt_ReadData& theReadData);
0240     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
0241     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
0242     virtual Standard_CString PName() const { return "PBRep_Polygon3D"; }
0243     virtual Handle(BRep_CurveRepresentation) import() const;
0244 
0245   private:
0246     Handle(ShapePersistent_Poly::Polygon3D) myPolygon3D;
0247   };
0248 
0249   class PolygonOnTriangulation : public CurveRepresentation
0250   {
0251     friend class ShapePersistent_BRep;
0252 
0253   public:
0254     virtual void Read (StdObjMgt_ReadData& theReadData);
0255     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
0256     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
0257     virtual Standard_CString PName() const { return "PBRep_PolygonOnTriangulation"; }
0258     virtual Handle(BRep_CurveRepresentation) import() const;
0259 
0260   protected:
0261     Handle(ShapePersistent_Poly::PolygonOnTriangulation) myPolygon;
0262     Handle(ShapePersistent_Poly::Triangulation)          myTriangulation;
0263   };
0264 
0265   class PolygonOnClosedTriangulation : public PolygonOnTriangulation
0266   {
0267     friend class ShapePersistent_BRep;
0268 
0269   public:
0270     virtual void Read (StdObjMgt_ReadData& theReadData);
0271     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
0272     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
0273     virtual Standard_CString PName() const { return "PBRep_PolygonOnClosedTriangulation"; }
0274     virtual Handle(BRep_CurveRepresentation) import() const;
0275 
0276   private:
0277     Handle(ShapePersistent_Poly::PolygonOnTriangulation) myPolygon2;
0278   };
0279 
0280   class PolygonOnSurface : public CurveRepresentation
0281   {
0282     friend class ShapePersistent_BRep;
0283 
0284   public:
0285     virtual void Read (StdObjMgt_ReadData& theReadData);
0286     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
0287     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
0288     virtual Standard_CString PName() const { return "PBRep_PolygonOnSurface"; }
0289     virtual Handle(BRep_CurveRepresentation) import() const;
0290 
0291   protected:
0292     Handle(ShapePersistent_Poly::Polygon2D) myPolygon2D;
0293     Handle(ShapePersistent_Geom::Surface)   mySurface;
0294   };
0295 
0296   class PolygonOnClosedSurface : public PolygonOnSurface
0297   {
0298     friend class ShapePersistent_BRep;
0299 
0300   public:
0301     virtual void Read (StdObjMgt_ReadData& theReadData);
0302     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
0303     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
0304     virtual Standard_CString PName() const { return "PBRep_PolygonOnClosedSurface"; }
0305     virtual Handle(BRep_CurveRepresentation) import() const;
0306 
0307   private:
0308     Handle(ShapePersistent_Poly::Polygon2D) myPolygon2;
0309   };
0310 
0311   class CurveOn2Surfaces : public CurveRepresentation
0312   {
0313     friend class ShapePersistent_BRep;
0314 
0315   public:
0316     CurveOn2Surfaces()
0317     : myContinuity(0)
0318     {
0319     }
0320     virtual void Read (StdObjMgt_ReadData& theReadData);
0321     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
0322     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
0323     virtual Standard_CString PName() const { return "PBRep_CurveOn2Surfaces"; }
0324     virtual Handle(BRep_CurveRepresentation) import() const;
0325 
0326   private:
0327     Handle(ShapePersistent_Geom::Surface) mySurface;
0328     Handle(ShapePersistent_Geom::Surface) mySurface2;
0329     StdObject_Location                    myLocation2;
0330     Standard_Integer                      myContinuity;
0331   };
0332 
0333 private:
0334   class pTVertex : public pTBase
0335   {
0336     friend class ShapePersistent_BRep;
0337 
0338   public:
0339     pTVertex()
0340     : myTolerance(0.0)
0341     {
0342     }
0343     inline void Read (StdObjMgt_ReadData& theReadData)
0344     {
0345       pTBase::Read (theReadData);
0346       theReadData >> myTolerance >> myPnt >> myPoints;
0347     }
0348     inline void Write (StdObjMgt_WriteData& theWriteData) const
0349     {
0350       pTBase::Write (theWriteData);
0351       theWriteData << myTolerance << myPnt << myPoints;
0352     }
0353     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const 
0354     { 
0355       pTBase::PChildren(theChildren);
0356       theChildren.Append(myPoints);
0357     }
0358     inline Standard_CString PName() const 
0359       { return "PBRep_TVertex"; }
0360 
0361   private:
0362     virtual Handle(TopoDS_TShape) createTShape() const;
0363 
0364   private:
0365     Standard_Real               myTolerance;
0366     gp_Pnt                      myPnt;
0367     Handle(PointRepresentation) myPoints;
0368   };
0369 
0370   class pTEdge : public pTBase
0371   {
0372     friend class ShapePersistent_BRep;
0373 
0374   public:
0375     pTEdge()
0376     : myTolerance(0.0),
0377       myFlags(0)
0378     {
0379     }
0380     inline void Read (StdObjMgt_ReadData& theReadData)
0381     {
0382       pTBase::Read (theReadData);
0383       theReadData >> myTolerance >> myFlags >> myCurves;
0384     }
0385     inline void Write (StdObjMgt_WriteData& theWriteData) const
0386     {
0387       pTBase::Write (theWriteData);
0388       theWriteData << myTolerance << myFlags << myCurves;
0389     }
0390     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const 
0391     { 
0392       pTBase::PChildren(theChildren);
0393       theChildren.Append(myCurves);
0394     }
0395     inline Standard_CString PName() const 
0396       { return "PBRep_TEdge"; }
0397 
0398   private:
0399     virtual Handle(TopoDS_TShape) createTShape() const;
0400 
0401   private:
0402     Standard_Real               myTolerance;
0403     Standard_Integer            myFlags;
0404     Handle(CurveRepresentation) myCurves;
0405   };
0406 
0407   class pTFace : public pTBase
0408   {
0409     friend class ShapePersistent_BRep;
0410 
0411   public:
0412     pTFace()
0413     : myTolerance(0.0),
0414       myNaturalRestriction(Standard_False)
0415     {
0416     }
0417     inline void Read (StdObjMgt_ReadData& theReadData)
0418     {
0419       pTBase::Read (theReadData);
0420       theReadData >> mySurface >> myTriangulation >> myLocation;
0421       theReadData >> myTolerance >> myNaturalRestriction;
0422     }
0423     inline void Write (StdObjMgt_WriteData& theWriteData) const
0424     {
0425       pTBase::Write (theWriteData);
0426       theWriteData << mySurface << myTriangulation << myLocation;
0427       theWriteData << myTolerance << myNaturalRestriction;
0428     }
0429     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const 
0430     {
0431       pTBase::PChildren(theChildren);
0432       theChildren.Append(mySurface);
0433       theChildren.Append(myTriangulation);
0434       myLocation.PChildren(theChildren);
0435     }
0436     inline Standard_CString PName() const
0437       { return "PBRep_TFace"; }
0438 
0439   private:
0440     virtual Handle(TopoDS_TShape) createTShape() const;
0441 
0442   private:
0443     Handle(ShapePersistent_Geom::Surface)       mySurface;
0444     Handle(ShapePersistent_Poly::Triangulation) myTriangulation;
0445     StdObject_Location                          myLocation;
0446     Standard_Real                               myTolerance;
0447     Standard_Boolean                            myNaturalRestriction;
0448   };
0449 
0450 public:
0451   typedef tObject  <pTVertex> TVertex;
0452   typedef tObject  <pTEdge>   TEdge;
0453   typedef tObject  <pTFace>   TFace;
0454 
0455   typedef tObject1 <pTVertex> TVertex1;
0456   typedef tObject1 <pTEdge>   TEdge1;
0457   typedef tObject1 <pTFace>   TFace1;
0458 
0459 public:
0460   //! Create a persistent object for a vertex
0461   Standard_EXPORT static Handle(TVertex::pTObjectT) Translate (const TopoDS_Vertex& theVertex,
0462                                                                StdObjMgt_TransientPersistentMap& theMap);
0463   //! Create a persistent object for an edge
0464   Standard_EXPORT static Handle(TEdge::pTObjectT) Translate (const TopoDS_Edge& theEdge,
0465                                                              StdObjMgt_TransientPersistentMap& theMap,
0466                                                              ShapePersistent_TriangleMode theTriangleMode);
0467   //! Create a persistent object for a face
0468   Standard_EXPORT static Handle(TFace::pTObjectT) Translate (const TopoDS_Face& theFace,
0469                                                              StdObjMgt_TransientPersistentMap& theMap,
0470                                                              ShapePersistent_TriangleMode theTriangleMode);
0471   //! Create a persistent object for a point on a 3D curve
0472   Standard_EXPORT static Handle(PointOnCurve) Translate(Standard_Real theParam, 
0473                                                         const Handle(Geom_Curve)& theCurve, 
0474                                                         const TopLoc_Location& theLoc, 
0475                                                         StdObjMgt_TransientPersistentMap& theMap);
0476   //! Create a persistent object for a point on a 3D curve on a surface
0477   Standard_EXPORT static Handle(PointOnCurveOnSurface) Translate (Standard_Real theParam, 
0478                                                                   const Handle(Geom2d_Curve)& theCurve, 
0479                                                                   const Handle(Geom_Surface)& theSurf, 
0480                                                                   const TopLoc_Location& theLoc,
0481                                                                   StdObjMgt_TransientPersistentMap& theMap);
0482   //! Create a persistent object for a point on a surface
0483   Standard_EXPORT static Handle(PointOnSurface) Translate (Standard_Real theParam, 
0484                                                            Standard_Real theParam2, 
0485                                                            const Handle(Geom_Surface)& theSurf, 
0486                                                            const TopLoc_Location& theLoc,
0487                                                            StdObjMgt_TransientPersistentMap& theMap);
0488   //! Create a persistent object for a curve on a surface
0489   Standard_EXPORT static Handle(CurveOnSurface) Translate (const Handle(Geom2d_Curve)& theCurve, 
0490                                                            const Standard_Real theFirstParam,
0491                                                            const Standard_Real theLastParam, 
0492                                                            const Handle(Geom_Surface)& theSurf, 
0493                                                            const TopLoc_Location& theLoc,
0494                                                            StdObjMgt_TransientPersistentMap& theMap);
0495   //! Create a persistent object for a curve on a closed surface
0496   Standard_EXPORT static Handle(CurveOnClosedSurface) Translate (const Handle(Geom2d_Curve)& theCurve, 
0497                                                                  const Handle(Geom2d_Curve)& theCurve2,
0498                                                                  const Standard_Real theFirstParam,
0499                                                                  const Standard_Real theLastParam, 
0500                                                                  const Handle(Geom_Surface)& theSurf,
0501                                                                  const TopLoc_Location& theLoc, 
0502                                                                  const GeomAbs_Shape theContinuity,
0503                                                                  StdObjMgt_TransientPersistentMap& theMap);
0504   //! Create a persistent object for a curve on two surfaces
0505   Standard_EXPORT static Handle(CurveOn2Surfaces) Translate (const Handle(Geom_Surface)& theSurf, 
0506                                                              const Handle(Geom_Surface)& theSurf2,
0507                                                              const TopLoc_Location& theLoc, 
0508                                                              const TopLoc_Location& theLoc2,
0509                                                              const GeomAbs_Shape theContinuity,
0510                                                              StdObjMgt_TransientPersistentMap& theMap);
0511   //! Create a persistent object for a 3D curve
0512   Standard_EXPORT static Handle(Curve3D) Translate (const Handle(Geom_Curve)& theCurve,
0513                                                     const Standard_Real theFirstParam, 
0514                                                     const Standard_Real theLastParam,
0515                                                     const TopLoc_Location& theLoc,
0516                                                     StdObjMgt_TransientPersistentMap& theMap);
0517   //! Create a persistent object for a 3D polygon
0518   Standard_EXPORT static Handle(Polygon3D) Translate (const Handle(Poly_Polygon3D)& thePoly,
0519                                                       const TopLoc_Location& theLoc,
0520                                                       StdObjMgt_TransientPersistentMap& theMap);
0521   //! Create a persistent object for a polygon on a closed surface
0522   Standard_EXPORT static Handle(PolygonOnClosedSurface) Translate (const Handle(Poly_Polygon2D)& thePoly, 
0523                                                                    const Handle(Poly_Polygon2D)& thePoly2,
0524                                                                    const Handle(Geom_Surface)& theSurf, 
0525                                                                    const TopLoc_Location& theLoc,
0526                                                                    StdObjMgt_TransientPersistentMap& theMap);
0527   //! Create a persistent object for a polygon on a surface
0528   Standard_EXPORT static Handle(PolygonOnSurface) Translate (const Handle(Poly_Polygon2D)& thePoly, 
0529                                                              const Handle(Geom_Surface)& theSurf,
0530                                                              const TopLoc_Location& theLoc, 
0531                                                              StdObjMgt_TransientPersistentMap& theMap);
0532   //! Create a persistent object for a polygon on a surface
0533   Standard_EXPORT static Handle(PolygonOnClosedTriangulation) Translate (const Handle(Poly_PolygonOnTriangulation)& thePolyOnTriang,
0534                                                                          const Handle(Poly_PolygonOnTriangulation)& thePolyOnTriang2,
0535                                                                          const Handle(Poly_Triangulation)& thePolyTriang,
0536                                                                          const TopLoc_Location& theLoc,
0537                                                                          StdObjMgt_TransientPersistentMap& theMap);
0538   //! Create a persistent object for a polygon on a surface
0539   Standard_EXPORT static Handle(PolygonOnTriangulation) Translate (const Handle(Poly_PolygonOnTriangulation)& thePolyOnTriang,
0540                                                                    const Handle(Poly_Triangulation)& thePolyTriang,
0541                                                                    const TopLoc_Location& theLoc,
0542                                                                    StdObjMgt_TransientPersistentMap& theMap);
0543 };
0544 
0545 #endif