0031035: Coding - uninitialized class fields reported by Visual Studio Code Analysis
[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 <StdObjMgt_TransientPersistentMap.hxx>
23 #include <StdObject_Location.hxx>
24 #include <StdObject_gp_Vectors.hxx>
25
26 #include <BRep_ListOfPointRepresentation.hxx>
27 #include <BRep_ListOfCurveRepresentation.hxx>
28
29 #include <gp_Pnt.hxx>
30 #include <gp_Pnt2d.hxx>
31
32 class BRep_PointRepresentation;
33 class BRep_CurveRepresentation;
34 class TopoDS_Vertex;
35 class TopoDS_Edge;
36 class TopoDS_Face;
37
38 class ShapePersistent_BRep : public ShapePersistent_TopoDS
39 {
40 public:
41   class PointRepresentation : public StdObjMgt_Persistent
42   {
43     friend class ShapePersistent_BRep;
44
45   public:
46     //! Empty constructor.
47     PointRepresentation()
48     : myParameter(0.0)
49     {
50     }
51     //! Read persistent data from a file.
52     Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
53     //! Write persistent data to a file.
54     Standard_EXPORT virtual void Write(StdObjMgt_WriteData& theWriteData) const;
55     //! Gets persistent child objects
56     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
57     //! Returns persistent type name
58     virtual Standard_CString PName() const { return "PBRep_PointRepresentation"; }
59     //! Import transient object from the persistent data.
60     Standard_EXPORT void Import (BRep_ListOfPointRepresentation& thePoints) const;
61
62   protected:
63     virtual Handle(BRep_PointRepresentation) import() const;
64
65   protected:
66     StdObject_Location myLocation;
67     Standard_Real      myParameter;
68
69   private:
70     Handle(PointRepresentation) myNext;
71   };
72
73   class PointOnCurve : public PointRepresentation
74   {
75     friend class ShapePersistent_BRep;
76
77   public:
78     virtual void Read (StdObjMgt_ReadData& theReadData);
79     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
80     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
81     virtual Standard_CString PName() const { return "PBRep_PointOnCurve"; }
82     virtual Handle(BRep_PointRepresentation) import() const;
83
84   private:
85     Handle(ShapePersistent_Geom::Curve) myCurve;
86   };
87
88   class PointsOnSurface : public PointRepresentation
89   {
90     friend class ShapePersistent_BRep;
91
92   public:
93     virtual void Read (StdObjMgt_ReadData& theReadData);
94     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
95     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
96     virtual Standard_CString PName() const { return "PBRep_PointsOnSurface"; }
97
98   protected:
99     Handle(ShapePersistent_Geom::Surface) mySurface;
100   };
101
102   class PointOnCurveOnSurface : public PointsOnSurface
103   {
104     friend class ShapePersistent_BRep;
105
106   public:
107     virtual void Read (StdObjMgt_ReadData& theReadData);
108     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
109     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
110     virtual Standard_CString PName() const { return "PBRep_PointOnCurveOnSurface"; }
111     virtual Handle(BRep_PointRepresentation) import() const;
112
113   private:
114     Handle(ShapePersistent_Geom2d::Curve) myPCurve;
115   };
116
117   class PointOnSurface : public PointsOnSurface
118   {
119     friend class ShapePersistent_BRep;
120
121   public:
122     PointOnSurface()
123     : myParameter2(0.0)
124     {
125     }
126     virtual void Read (StdObjMgt_ReadData& theReadData);
127     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
128     virtual Standard_CString PName() const { return "PBRep_PointOnSurface"; }
129     virtual Handle(BRep_PointRepresentation) import() const;
130
131   private:
132     Standard_Real myParameter2;
133   };
134
135   class CurveRepresentation : public StdObjMgt_Persistent
136   {
137     friend class ShapePersistent_BRep;
138
139   public:
140     //! Read persistent data from a file.
141     Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
142     //! Write persistent data from a file.
143     Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const;
144     //! Gets persistent child objects
145     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
146     //! Returns persistent type name
147     virtual Standard_CString PName() const { return "PBRep_CurveRepresentation"; }
148     //! Import transient object from the persistent data.
149     Standard_EXPORT void Import (BRep_ListOfCurveRepresentation& theCurves) const;
150
151   protected:
152     virtual Handle(BRep_CurveRepresentation) import() const;
153
154   protected:
155     StdObject_Location myLocation;
156
157   private:
158     Handle(CurveRepresentation) myNext;
159   };
160
161   class GCurve : public CurveRepresentation
162   {
163     friend class ShapePersistent_BRep;
164
165   public:
166     GCurve()
167     : myFirst(0.0),
168       myLast(0.0)
169     {
170     }
171     virtual void Read (StdObjMgt_ReadData& theReadData);
172     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
173     virtual Standard_CString PName() const { return "PBRep_GCurve"; }
174
175   protected:
176     Standard_Real myFirst;
177     Standard_Real myLast;
178   };
179
180   class Curve3D : public GCurve
181   {
182     friend class ShapePersistent_BRep;
183
184   public:
185     virtual void Read (StdObjMgt_ReadData& theReadData);
186     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
187     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
188     virtual Standard_CString PName() const { return "PBRep_Curve3D"; }
189     virtual Handle(BRep_CurveRepresentation) import() const;
190
191   private:
192     Handle(ShapePersistent_Geom::Curve) myCurve3D;
193   };
194
195   class CurveOnSurface : public GCurve
196   {
197     friend class ShapePersistent_BRep;
198
199   public:
200     virtual void Read (StdObjMgt_ReadData& theReadData);
201     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
202     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
203     virtual Standard_CString PName() const { return "PBRep_CurveOnSurface"; }
204     virtual Handle(BRep_CurveRepresentation) import() const;
205
206   protected:
207     Handle(ShapePersistent_Geom2d::Curve) myPCurve;
208     Handle(ShapePersistent_Geom::Surface) mySurface;
209     gp_Pnt2d                              myUV1;
210     gp_Pnt2d                              myUV2;
211   };
212
213   class CurveOnClosedSurface : public CurveOnSurface
214   {
215     friend class ShapePersistent_BRep;
216
217   public:
218     CurveOnClosedSurface()
219     : myContinuity(0)
220     {
221     }
222     virtual void Read (StdObjMgt_ReadData& theReadData);
223     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
224     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
225     virtual Standard_CString PName() const { return "PBRep_CurveOnClosedSurface"; }
226     virtual Handle(BRep_CurveRepresentation) import() const;
227
228   private:
229     Handle(ShapePersistent_Geom2d::Curve) myPCurve2;
230     Standard_Integer                      myContinuity;
231     gp_Pnt2d                              myUV21;
232     gp_Pnt2d                              myUV22;
233   };
234
235   class Polygon3D : public CurveRepresentation
236   {
237     friend class ShapePersistent_BRep;
238
239   public:
240     virtual void Read (StdObjMgt_ReadData& theReadData);
241     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
242     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
243     virtual Standard_CString PName() const { return "PBRep_Polygon3D"; }
244     virtual Handle(BRep_CurveRepresentation) import() const;
245
246   private:
247     Handle(ShapePersistent_Poly::Polygon3D) myPolygon3D;
248   };
249
250   class PolygonOnTriangulation : public CurveRepresentation
251   {
252     friend class ShapePersistent_BRep;
253
254   public:
255     virtual void Read (StdObjMgt_ReadData& theReadData);
256     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
257     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
258     virtual Standard_CString PName() const { return "PBRep_PolygonOnTriangulation"; }
259     virtual Handle(BRep_CurveRepresentation) import() const;
260
261   protected:
262     Handle(ShapePersistent_Poly::PolygonOnTriangulation) myPolygon;
263     Handle(ShapePersistent_Poly::Triangulation)          myTriangulation;
264   };
265
266   class PolygonOnClosedTriangulation : public PolygonOnTriangulation
267   {
268     friend class ShapePersistent_BRep;
269
270   public:
271     virtual void Read (StdObjMgt_ReadData& theReadData);
272     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
273     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
274     virtual Standard_CString PName() const { return "PBRep_PolygonOnClosedTriangulation"; }
275     virtual Handle(BRep_CurveRepresentation) import() const;
276
277   private:
278     Handle(ShapePersistent_Poly::PolygonOnTriangulation) myPolygon2;
279   };
280
281   class PolygonOnSurface : public CurveRepresentation
282   {
283     friend class ShapePersistent_BRep;
284
285   public:
286     virtual void Read (StdObjMgt_ReadData& theReadData);
287     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
288     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
289     virtual Standard_CString PName() const { return "PBRep_PolygonOnSurface"; }
290     virtual Handle(BRep_CurveRepresentation) import() const;
291
292   protected:
293     Handle(ShapePersistent_Poly::Polygon2D) myPolygon2D;
294     Handle(ShapePersistent_Geom::Surface)   mySurface;
295   };
296
297   class PolygonOnClosedSurface : public PolygonOnSurface
298   {
299     friend class ShapePersistent_BRep;
300
301   public:
302     virtual void Read (StdObjMgt_ReadData& theReadData);
303     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
304     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
305     virtual Standard_CString PName() const { return "PBRep_PolygonOnClosedSurface"; }
306     virtual Handle(BRep_CurveRepresentation) import() const;
307
308   private:
309     Handle(ShapePersistent_Poly::Polygon2D) myPolygon2;
310   };
311
312   class CurveOn2Surfaces : public CurveRepresentation
313   {
314     friend class ShapePersistent_BRep;
315
316   public:
317     CurveOn2Surfaces()
318     : myContinuity(0)
319     {
320     }
321     virtual void Read (StdObjMgt_ReadData& theReadData);
322     virtual void Write (StdObjMgt_WriteData& theWriteData) const;
323     virtual void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
324     virtual Standard_CString PName() const { return "PBRep_CurveOn2Surfaces"; }
325     virtual Handle(BRep_CurveRepresentation) import() const;
326
327   private:
328     Handle(ShapePersistent_Geom::Surface) mySurface;
329     Handle(ShapePersistent_Geom::Surface) mySurface2;
330     StdObject_Location                    myLocation2;
331     Standard_Integer                      myContinuity;
332   };
333
334 private:
335   class pTVertex : public pTBase
336   {
337     friend class ShapePersistent_BRep;
338
339   public:
340     pTVertex()
341     : myTolerance(0.0)
342     {
343     }
344     inline void Read (StdObjMgt_ReadData& theReadData)
345     {
346       pTBase::Read (theReadData);
347       theReadData >> myTolerance >> myPnt >> myPoints;
348     }
349     inline void Write (StdObjMgt_WriteData& theWriteData) const
350     {
351       pTBase::Write (theWriteData);
352       theWriteData << myTolerance << myPnt << myPoints;
353     }
354     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const 
355     { 
356       pTBase::PChildren(theChildren);
357       theChildren.Append(myPoints);
358     }
359     inline Standard_CString PName() const 
360       { return "PBRep_TVertex"; }
361
362   private:
363     virtual Handle(TopoDS_TShape) createTShape() const;
364
365   private:
366     Standard_Real               myTolerance;
367     gp_Pnt                      myPnt;
368     Handle(PointRepresentation) myPoints;
369   };
370
371   class pTEdge : public pTBase
372   {
373     friend class ShapePersistent_BRep;
374
375   public:
376     pTEdge()
377     : myTolerance(0.0),
378       myFlags(0)
379     {
380     }
381     inline void Read (StdObjMgt_ReadData& theReadData)
382     {
383       pTBase::Read (theReadData);
384       theReadData >> myTolerance >> myFlags >> myCurves;
385     }
386     inline void Write (StdObjMgt_WriteData& theWriteData) const
387     {
388       pTBase::Write (theWriteData);
389       theWriteData << myTolerance << myFlags << myCurves;
390     }
391     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const 
392     { 
393       pTBase::PChildren(theChildren);
394       theChildren.Append(myCurves);
395     }
396     inline Standard_CString PName() const 
397       { return "PBRep_TEdge"; }
398
399   private:
400     virtual Handle(TopoDS_TShape) createTShape() const;
401
402   private:
403     Standard_Real               myTolerance;
404     Standard_Integer            myFlags;
405     Handle(CurveRepresentation) myCurves;
406   };
407
408   class pTFace : public pTBase
409   {
410     friend class ShapePersistent_BRep;
411
412   public:
413     pTFace()
414     : myTolerance(0.0),
415       myNaturalRestriction(Standard_False)
416     {
417     }
418     inline void Read (StdObjMgt_ReadData& theReadData)
419     {
420       pTBase::Read (theReadData);
421       theReadData >> mySurface >> myTriangulation >> myLocation;
422       theReadData >> myTolerance >> myNaturalRestriction;
423     }
424     inline void Write (StdObjMgt_WriteData& theWriteData) const
425     {
426       pTBase::Write (theWriteData);
427       theWriteData << mySurface << myTriangulation << myLocation;
428       theWriteData << myTolerance << myNaturalRestriction;
429     }
430     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const 
431     {
432       pTBase::PChildren(theChildren);
433       theChildren.Append(mySurface);
434       theChildren.Append(myTriangulation);
435       myLocation.PChildren(theChildren);
436     }
437     inline Standard_CString PName() const
438       { return "PBRep_TFace"; }
439
440   private:
441     virtual Handle(TopoDS_TShape) createTShape() const;
442
443   private:
444     Handle(ShapePersistent_Geom::Surface)       mySurface;
445     Handle(ShapePersistent_Poly::Triangulation) myTriangulation;
446     StdObject_Location                          myLocation;
447     Standard_Real                               myTolerance;
448     Standard_Boolean                            myNaturalRestriction;
449   };
450
451 public:
452   typedef tObject  <pTVertex> TVertex;
453   typedef tObject  <pTEdge>   TEdge;
454   typedef tObject  <pTFace>   TFace;
455
456   typedef tObject1 <pTVertex> TVertex1;
457   typedef tObject1 <pTEdge>   TEdge1;
458   typedef tObject1 <pTFace>   TFace1;
459
460 public:
461   //! Create a persistent object for a vertex
462   Standard_EXPORT static Handle(TVertex::pTObjectT) Translate (const TopoDS_Vertex& theVertex,
463                                                                StdObjMgt_TransientPersistentMap& theMap);
464   //! Create a persistent object for an edge
465   Standard_EXPORT static Handle(TEdge::pTObjectT) Translate (const TopoDS_Edge& theEdge,
466                                                              StdObjMgt_TransientPersistentMap& theMap,
467                                                              ShapePersistent_TriangleMode theTriangleMode);
468   //! Create a persistent object for a face
469   Standard_EXPORT static Handle(TFace::pTObjectT) Translate (const TopoDS_Face& theFace,
470                                                              StdObjMgt_TransientPersistentMap& theMap,
471                                                              ShapePersistent_TriangleMode theTriangleMode);
472   //! Create a persistent object for a point on a 3D curve
473   Standard_EXPORT static Handle(PointOnCurve) Translate(Standard_Real theParam, 
474                                                         const Handle(Geom_Curve)& theCurve, 
475                                                         const TopLoc_Location& theLoc, 
476                                                         StdObjMgt_TransientPersistentMap& theMap);
477   //! Create a persistent object for a point on a 3D curve on a surface
478   Standard_EXPORT static Handle(PointOnCurveOnSurface) Translate (Standard_Real theParam, 
479                                                                   const Handle(Geom2d_Curve)& theCurve, 
480                                                                   const Handle(Geom_Surface)& theSurf, 
481                                                                   const TopLoc_Location& theLoc,
482                                                                   StdObjMgt_TransientPersistentMap& theMap);
483   //! Create a persistent object for a point on a surface
484   Standard_EXPORT static Handle(PointOnSurface) Translate (Standard_Real theParam, 
485                                                            Standard_Real theParam2, 
486                                                            const Handle(Geom_Surface)& theSurf, 
487                                                            const TopLoc_Location& theLoc,
488                                                            StdObjMgt_TransientPersistentMap& theMap);
489   //! Create a persistent object for a curve on a surface
490   Standard_EXPORT static Handle(CurveOnSurface) Translate (const Handle(Geom2d_Curve)& theCurve, 
491                                                            const Standard_Real theFirstParam,
492                                                            const Standard_Real theLastParam, 
493                                                            const Handle(Geom_Surface)& theSurf, 
494                                                            const TopLoc_Location& theLoc,
495                                                            StdObjMgt_TransientPersistentMap& theMap);
496   //! Create a persistent object for a curve on a closed surface
497   Standard_EXPORT static Handle(CurveOnClosedSurface) Translate (const Handle(Geom2d_Curve)& theCurve, 
498                                                                  const Handle(Geom2d_Curve)& theCurve2,
499                                                                  const Standard_Real theFirstParam,
500                                                                  const Standard_Real theLastParam, 
501                                                                  const Handle(Geom_Surface)& theSurf,
502                                                                  const TopLoc_Location& theLoc, 
503                                                                  const GeomAbs_Shape theContinuity,
504                                                                  StdObjMgt_TransientPersistentMap& theMap);
505   //! Create a persistent object for a curve on two surfaces
506   Standard_EXPORT static Handle(CurveOn2Surfaces) Translate (const Handle(Geom_Surface)& theSurf, 
507                                                              const Handle(Geom_Surface)& theSurf2,
508                                                              const TopLoc_Location& theLoc, 
509                                                              const TopLoc_Location& theLoc2,
510                                                              const GeomAbs_Shape theContinuity,
511                                                              StdObjMgt_TransientPersistentMap& theMap);
512   //! Create a persistent object for a 3D curve
513   Standard_EXPORT static Handle(Curve3D) Translate (const Handle(Geom_Curve)& theCurve,
514                                                     const Standard_Real theFirstParam, 
515                                                     const Standard_Real theLastParam,
516                                                     const TopLoc_Location& theLoc,
517                                                     StdObjMgt_TransientPersistentMap& theMap);
518   //! Create a persistent object for a 3D polygon
519   Standard_EXPORT static Handle(Polygon3D) Translate (const Handle(Poly_Polygon3D)& thePoly,
520                                                       const TopLoc_Location& theLoc,
521                                                       StdObjMgt_TransientPersistentMap& theMap);
522   //! Create a persistent object for a polygon on a closed surface
523   Standard_EXPORT static Handle(PolygonOnClosedSurface) Translate (const Handle(Poly_Polygon2D)& thePoly, 
524                                                                    const Handle(Poly_Polygon2D)& thePoly2,
525                                                                    const Handle(Geom_Surface)& theSurf, 
526                                                                    const TopLoc_Location& theLoc,
527                                                                    StdObjMgt_TransientPersistentMap& theMap);
528   //! Create a persistent object for a polygon on a surface
529   Standard_EXPORT static Handle(PolygonOnSurface) Translate (const Handle(Poly_Polygon2D)& thePoly, 
530                                                              const Handle(Geom_Surface)& theSurf,
531                                                              const TopLoc_Location& theLoc, 
532                                                              StdObjMgt_TransientPersistentMap& theMap);
533   //! Create a persistent object for a polygon on a surface
534   Standard_EXPORT static Handle(PolygonOnClosedTriangulation) Translate (const Handle(Poly_PolygonOnTriangulation)& thePolyOnTriang,
535                                                                          const Handle(Poly_PolygonOnTriangulation)& thePolyOnTriang2,
536                                                                          const Handle(Poly_Triangulation)& thePolyTriang,
537                                                                          const TopLoc_Location& theLoc,
538                                                                          StdObjMgt_TransientPersistentMap& theMap);
539   //! Create a persistent object for a polygon on a surface
540   Standard_EXPORT static Handle(PolygonOnTriangulation) Translate (const Handle(Poly_PolygonOnTriangulation)& thePolyOnTriang,
541                                                                    const Handle(Poly_Triangulation)& thePolyTriang,
542                                                                    const TopLoc_Location& theLoc,
543                                                                    StdObjMgt_TransientPersistentMap& theMap);
544 };
545
546 #endif