6a660acde8520a0d3dfbd92d4dc39ae8af18ac1a
[occt.git] / src / ShapePersistent / ShapePersistent_BRep.hxx
1 // Copyright (c) 2015 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
15 #ifndef _ShapePersistent_BRep_HeaderFile
16 #define _ShapePersistent_BRep_HeaderFile
17
18 #include <ShapePersistent_TopoDS.hxx>
19 #include <ShapePersistent_Geom.hxx>
20 #include <ShapePersistent_Geom2d.hxx>
21 #include <ShapePersistent_Poly.hxx>
22 #include <StdObject_Location.hxx>
23 #include <StdObject_gp.hxx>
24
25 #include <BRep_ListOfPointRepresentation.hxx>
26 #include <BRep_ListOfCurveRepresentation.hxx>
27
28 #include <gp_Pnt.hxx>
29 #include <gp_Pnt2d.hxx>
30 #include <GeomAbs_Shape.hxx>
31
32 class BRep_PointRepresentation;
33 class BRep_CurveRepresentation;
34
35
36 class ShapePersistent_BRep : public ShapePersistent_TopoDS
37 {
38 public:
39   class PointRepresentation : public StdObjMgt_Persistent
40   {
41   public:
42     //! Read persistent data from a file.
43     Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
44
45     //! Import transient object from the persistent data.
46     Standard_EXPORT void Import (BRep_ListOfPointRepresentation& thePoints)
47       const;
48
49   protected:
50     virtual Handle(BRep_PointRepresentation) import() const;
51
52   protected:
53     Object <StdObject_Location> myLocation;
54     Value  <Standard_Real>      myParameter;
55
56   private:
57     Reference<PointRepresentation> myNext;
58   };
59
60   class PointOnCurve : public PointRepresentation
61   {
62   public:
63     virtual void Read (StdObjMgt_ReadData& theReadData);
64     virtual Handle(BRep_PointRepresentation) import() const;
65
66   private:
67     Reference<ShapePersistent_Geom::Curve> myCurve;
68   };
69
70   class PointsOnSurface : public PointRepresentation
71   {
72   public:
73     virtual void Read (StdObjMgt_ReadData& theReadData);
74
75   protected:
76     Reference<ShapePersistent_Geom::Surface> mySurface;
77   };
78
79   class PointOnCurveOnSurface : public PointsOnSurface
80   {
81   public:
82     virtual void Read (StdObjMgt_ReadData& theReadData);
83     virtual Handle(BRep_PointRepresentation) import() const;
84
85   private:
86     Reference<ShapePersistent_Geom2d::Curve> myPCurve;
87   };
88
89   class PointOnSurface : public PointsOnSurface
90   {
91   public:
92     virtual void Read (StdObjMgt_ReadData& theReadData);
93     virtual Handle(BRep_PointRepresentation) import() const;
94
95   private:
96     Value<Standard_Real> myParameter2;
97   };
98
99   class CurveRepresentation : public StdObjMgt_Persistent
100   {
101   public:
102     //! Read persistent data from a file.
103     Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
104
105     //! Import transient object from the persistent data.
106     Standard_EXPORT void Import (BRep_ListOfCurveRepresentation& theCurves)
107       const;
108
109   protected:
110     virtual Handle(BRep_CurveRepresentation) import() const;
111
112   protected:
113     Object<StdObject_Location> myLocation;
114
115   private:
116     Reference<CurveRepresentation> myNext;
117   };
118
119   class GCurve : public CurveRepresentation
120   {
121   public:
122     virtual void Read (StdObjMgt_ReadData& theReadData);
123
124   protected:
125     Value<Standard_Real> myFirst;
126     Value<Standard_Real> myLast;
127   };
128
129   class Curve3D : public GCurve
130   {
131   public:
132     virtual void Read (StdObjMgt_ReadData& theReadData);
133     virtual Handle(BRep_CurveRepresentation) import() const;
134
135   private:
136     Reference<ShapePersistent_Geom::Curve> myCurve3D;
137   };
138
139   class CurveOnSurface : public GCurve
140   {
141   public:
142     virtual void Read (StdObjMgt_ReadData& theReadData);
143     virtual Handle(BRep_CurveRepresentation) import() const;
144
145   protected:
146     Reference<ShapePersistent_Geom2d::Curve> myPCurve;
147     Reference<ShapePersistent_Geom::Surface> mySurface;
148     StdObject_gp::Object<gp_Pnt2d>           myUV1;
149     StdObject_gp::Object<gp_Pnt2d>           myUV2;
150   };
151
152   class CurveOnClosedSurface : public CurveOnSurface
153   {
154   public:
155     virtual void Read (StdObjMgt_ReadData& theReadData);
156     virtual Handle(BRep_CurveRepresentation) import() const;
157
158   private:
159     Reference<ShapePersistent_Geom2d::Curve> myPCurve2;
160     Enum<GeomAbs_Shape>                      myContinuity;
161     StdObject_gp::Object<gp_Pnt2d>           myUV21;
162     StdObject_gp::Object<gp_Pnt2d>           myUV22;
163   };
164
165   class Polygon3D : public CurveRepresentation
166   {
167   public:
168     virtual void Read (StdObjMgt_ReadData& theReadData);
169     virtual Handle(BRep_CurveRepresentation) import() const;
170
171   private:
172     Reference<ShapePersistent_Poly::Polygon3D> myPolygon3D;
173   };
174
175   class PolygonOnTriangulation : public CurveRepresentation
176   {
177   public:
178     virtual void Read (StdObjMgt_ReadData& theReadData);
179     virtual Handle(BRep_CurveRepresentation) import() const;
180
181   protected:
182     Reference<ShapePersistent_Poly::PolygonOnTriangulation> myPolygon;
183     Reference<ShapePersistent_Poly::Triangulation>          myTriangulation;
184   };
185
186   class PolygonOnClosedTriangulation : public PolygonOnTriangulation
187   {
188   public:
189     virtual void Read (StdObjMgt_ReadData& theReadData);
190     virtual Handle(BRep_CurveRepresentation) import() const;
191
192   private:
193     Reference<ShapePersistent_Poly::PolygonOnTriangulation> myPolygon2;
194   };
195
196   class PolygonOnSurface : public CurveRepresentation
197   {
198   public:
199     virtual void Read (StdObjMgt_ReadData& theReadData);
200     virtual Handle(BRep_CurveRepresentation) import() const;
201
202   protected:
203     Reference<ShapePersistent_Poly::Polygon2D> myPolygon2D;
204     Reference<ShapePersistent_Geom::Surface>   mySurface;
205   };
206
207   class PolygonOnClosedSurface : public PolygonOnSurface
208   {
209   public:
210     virtual void Read (StdObjMgt_ReadData& theReadData);
211     virtual Handle(BRep_CurveRepresentation) import() const;
212
213   private:
214     Reference<ShapePersistent_Poly::Polygon2D> myPolygon2;
215   };
216
217   class CurveOn2Surfaces : public CurveRepresentation
218   {
219   public:
220     virtual void Read (StdObjMgt_ReadData& theReadData);
221     virtual Handle(BRep_CurveRepresentation) import() const;
222
223   private:
224     Reference <ShapePersistent_Geom::Surface> mySurface;
225     Reference <ShapePersistent_Geom::Surface> mySurface2;
226     Object    <StdObject_Location>            myLocation2;
227     Enum      <GeomAbs_Shape>                 myContinuity;
228   };
229
230 private:
231   class pTVertex : public pTBase
232   {
233   public:
234     inline void Read (StdObjMgt_ReadData& theReadData)
235     {
236       pTBase::Read (theReadData);
237       theReadData >> myTolerance >> myPnt >> myPoints;
238     }
239
240   private:
241     virtual Handle(TopoDS_TShape) createTShape() const;
242
243   private:
244     Value<Standard_Real>           myTolerance;
245     StdObject_gp::Object<gp_Pnt>   myPnt;
246     Reference<PointRepresentation> myPoints;
247   };
248
249   class pTEdge : public pTBase
250   {
251   public:
252     inline void Read (StdObjMgt_ReadData& theReadData)
253     {
254       pTBase::Read (theReadData);
255       theReadData >> myTolerance >> myFlags >> myCurves;
256     }
257
258   private:
259     virtual Handle(TopoDS_TShape) createTShape() const;
260
261   private:
262     Value     <Standard_Real>       myTolerance;
263     Value     <Standard_Integer>    myFlags;
264     Reference <CurveRepresentation> myCurves;
265   };
266
267   class pTFace : public pTBase
268   {
269   public:
270     inline void Read (StdObjMgt_ReadData& theReadData)
271     {
272       pTBase::Read (theReadData);
273       theReadData >> mySurface >> myTriangulation >> myLocation;
274       theReadData >> myTolerance >> myNaturalRestriction;
275     }
276
277   private:
278     virtual Handle(TopoDS_TShape) createTShape() const;
279
280   private:
281     Reference <ShapePersistent_Geom::Surface>       mySurface;
282     Reference <ShapePersistent_Poly::Triangulation> myTriangulation;
283     Object    <StdObject_Location>                  myLocation;
284     Value     <Standard_Real>                       myTolerance;
285     Value     <Standard_Boolean>                    myNaturalRestriction;
286   };
287
288 public:
289   typedef tObject  <pTVertex> TVertex;
290   typedef tObject  <pTEdge>   TEdge;
291   typedef tObject  <pTFace>   TFace;
292
293   typedef tObject1 <pTVertex> TVertex1;
294   typedef tObject1 <pTEdge>   TEdge1;
295   typedef tObject1 <pTFace>   TFace1;
296 };
297
298 #endif