0027241: Create a complete test case to verify reading of all attribute types from...
[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_Vectors.hxx>
24
25 #include <BRep_ListOfPointRepresentation.hxx>
26 #include <BRep_ListOfCurveRepresentation.hxx>
27
28 #include <gp_Pnt.hxx>
29 #include <gp_Pnt2d.hxx>
30
31 class BRep_PointRepresentation;
32 class BRep_CurveRepresentation;
33
34
35 class ShapePersistent_BRep : public ShapePersistent_TopoDS
36 {
37 public:
38   class PointRepresentation : public StdObjMgt_Persistent
39   {
40   public:
41     //! Read persistent data from a file.
42     Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
43
44     //! Import transient object from the persistent data.
45     Standard_EXPORT void Import (BRep_ListOfPointRepresentation& thePoints)
46       const;
47
48   protected:
49     virtual Handle(BRep_PointRepresentation) import() const;
50
51   protected:
52     StdObject_Location myLocation;
53     Standard_Real      myParameter;
54
55   private:
56     Handle(PointRepresentation) myNext;
57   };
58
59   class PointOnCurve : public PointRepresentation
60   {
61   public:
62     virtual void Read (StdObjMgt_ReadData& theReadData);
63     virtual Handle(BRep_PointRepresentation) import() const;
64
65   private:
66     Handle(ShapePersistent_Geom::Curve) myCurve;
67   };
68
69   class PointsOnSurface : public PointRepresentation
70   {
71   public:
72     virtual void Read (StdObjMgt_ReadData& theReadData);
73
74   protected:
75     Handle(ShapePersistent_Geom::Surface) mySurface;
76   };
77
78   class PointOnCurveOnSurface : public PointsOnSurface
79   {
80   public:
81     virtual void Read (StdObjMgt_ReadData& theReadData);
82     virtual Handle(BRep_PointRepresentation) import() const;
83
84   private:
85     Handle(ShapePersistent_Geom2d::Curve) myPCurve;
86   };
87
88   class PointOnSurface : public PointsOnSurface
89   {
90   public:
91     virtual void Read (StdObjMgt_ReadData& theReadData);
92     virtual Handle(BRep_PointRepresentation) import() const;
93
94   private:
95     Standard_Real myParameter2;
96   };
97
98   class CurveRepresentation : public StdObjMgt_Persistent
99   {
100   public:
101     //! Read persistent data from a file.
102     Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
103
104     //! Import transient object from the persistent data.
105     Standard_EXPORT void Import (BRep_ListOfCurveRepresentation& theCurves)
106       const;
107
108   protected:
109     virtual Handle(BRep_CurveRepresentation) import() const;
110
111   protected:
112     StdObject_Location myLocation;
113
114   private:
115     Handle(CurveRepresentation) myNext;
116   };
117
118   class GCurve : public CurveRepresentation
119   {
120   public:
121     virtual void Read (StdObjMgt_ReadData& theReadData);
122
123   protected:
124     Standard_Real myFirst;
125     Standard_Real myLast;
126   };
127
128   class Curve3D : public GCurve
129   {
130   public:
131     virtual void Read (StdObjMgt_ReadData& theReadData);
132     virtual Handle(BRep_CurveRepresentation) import() const;
133
134   private:
135     Handle(ShapePersistent_Geom::Curve) myCurve3D;
136   };
137
138   class CurveOnSurface : public GCurve
139   {
140   public:
141     virtual void Read (StdObjMgt_ReadData& theReadData);
142     virtual Handle(BRep_CurveRepresentation) import() const;
143
144   protected:
145     Handle(ShapePersistent_Geom2d::Curve) myPCurve;
146     Handle(ShapePersistent_Geom::Surface) mySurface;
147     gp_Pnt2d                              myUV1;
148     gp_Pnt2d                              myUV2;
149   };
150
151   class CurveOnClosedSurface : public CurveOnSurface
152   {
153   public:
154     virtual void Read (StdObjMgt_ReadData& theReadData);
155     virtual Handle(BRep_CurveRepresentation) import() const;
156
157   private:
158     Handle(ShapePersistent_Geom2d::Curve) myPCurve2;
159     Standard_Integer                      myContinuity;
160     gp_Pnt2d                              myUV21;
161     gp_Pnt2d                              myUV22;
162   };
163
164   class Polygon3D : public CurveRepresentation
165   {
166   public:
167     virtual void Read (StdObjMgt_ReadData& theReadData);
168     virtual Handle(BRep_CurveRepresentation) import() const;
169
170   private:
171     Handle(ShapePersistent_Poly::Polygon3D) myPolygon3D;
172   };
173
174   class PolygonOnTriangulation : public CurveRepresentation
175   {
176   public:
177     virtual void Read (StdObjMgt_ReadData& theReadData);
178     virtual Handle(BRep_CurveRepresentation) import() const;
179
180   protected:
181     Handle(ShapePersistent_Poly::PolygonOnTriangulation) myPolygon;
182     Handle(ShapePersistent_Poly::Triangulation)          myTriangulation;
183   };
184
185   class PolygonOnClosedTriangulation : public PolygonOnTriangulation
186   {
187   public:
188     virtual void Read (StdObjMgt_ReadData& theReadData);
189     virtual Handle(BRep_CurveRepresentation) import() const;
190
191   private:
192     Handle(ShapePersistent_Poly::PolygonOnTriangulation) myPolygon2;
193   };
194
195   class PolygonOnSurface : public CurveRepresentation
196   {
197   public:
198     virtual void Read (StdObjMgt_ReadData& theReadData);
199     virtual Handle(BRep_CurveRepresentation) import() const;
200
201   protected:
202     Handle(ShapePersistent_Poly::Polygon2D) myPolygon2D;
203     Handle(ShapePersistent_Geom::Surface)   mySurface;
204   };
205
206   class PolygonOnClosedSurface : public PolygonOnSurface
207   {
208   public:
209     virtual void Read (StdObjMgt_ReadData& theReadData);
210     virtual Handle(BRep_CurveRepresentation) import() const;
211
212   private:
213     Handle(ShapePersistent_Poly::Polygon2D) myPolygon2;
214   };
215
216   class CurveOn2Surfaces : public CurveRepresentation
217   {
218   public:
219     virtual void Read (StdObjMgt_ReadData& theReadData);
220     virtual Handle(BRep_CurveRepresentation) import() const;
221
222   private:
223     Handle(ShapePersistent_Geom::Surface) mySurface;
224     Handle(ShapePersistent_Geom::Surface) mySurface2;
225     StdObject_Location                    myLocation2;
226     Standard_Integer                      myContinuity;
227   };
228
229 private:
230   class pTVertex : public pTBase
231   {
232   public:
233     inline void Read (StdObjMgt_ReadData& theReadData)
234     {
235       pTBase::Read (theReadData);
236       theReadData >> myTolerance >> myPnt >> myPoints;
237     }
238
239   private:
240     virtual Handle(TopoDS_TShape) createTShape() const;
241
242   private:
243     Standard_Real               myTolerance;
244     gp_Pnt                      myPnt;
245     Handle(PointRepresentation) myPoints;
246   };
247
248   class pTEdge : public pTBase
249   {
250   public:
251     inline void Read (StdObjMgt_ReadData& theReadData)
252     {
253       pTBase::Read (theReadData);
254       theReadData >> myTolerance >> myFlags >> myCurves;
255     }
256
257   private:
258     virtual Handle(TopoDS_TShape) createTShape() const;
259
260   private:
261     Standard_Real               myTolerance;
262     Standard_Integer            myFlags;
263     Handle(CurveRepresentation) myCurves;
264   };
265
266   class pTFace : public pTBase
267   {
268   public:
269     inline void Read (StdObjMgt_ReadData& theReadData)
270     {
271       pTBase::Read (theReadData);
272       theReadData >> mySurface >> myTriangulation >> myLocation;
273       theReadData >> myTolerance >> myNaturalRestriction;
274     }
275
276   private:
277     virtual Handle(TopoDS_TShape) createTShape() const;
278
279   private:
280     Handle(ShapePersistent_Geom::Surface)       mySurface;
281     Handle(ShapePersistent_Poly::Triangulation) myTriangulation;
282     StdObject_Location                          myLocation;
283     Standard_Real                               myTolerance;
284     Standard_Boolean                            myNaturalRestriction;
285   };
286
287 public:
288   typedef tObject  <pTVertex> TVertex;
289   typedef tObject  <pTEdge>   TEdge;
290   typedef tObject  <pTFace>   TFace;
291
292   typedef tObject1 <pTVertex> TVertex1;
293   typedef tObject1 <pTEdge>   TEdge1;
294   typedef tObject1 <pTFace>   TFace1;
295 };
296
297 #endif