0031035: Coding - uninitialized class fields reported by Visual Studio Code Analysis
[occt.git] / src / ShapePersistent / ShapePersistent_Poly.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_Poly_HeaderFile
16 #define _ShapePersistent_Poly_HeaderFile
17
18 #include <StdObjMgt_SharedObject.hxx>
19 #include <StdObjMgt_TransientPersistentMap.hxx>
20 #include <StdObjMgt_ReadData.hxx>
21 #include <StdObjMgt_WriteData.hxx>
22 #include <StdLPersistent_HArray1.hxx>
23 #include <ShapePersistent_HArray1.hxx>
24
25 class Poly_Polygon2D;
26 class Poly_Polygon3D;
27 class Poly_PolygonOnTriangulation;
28 class Poly_Triangulation;
29
30
31 class ShapePersistent_Poly : private StdObjMgt_SharedObject
32 {
33   class pPolygon2D : public Standard_Transient
34   {
35     friend class ShapePersistent_Poly;
36
37   public:
38     pPolygon2D()
39     : myDeflection(0.0)
40     {
41     }
42     inline void Read (StdObjMgt_ReadData& theReadData)
43       { theReadData >> myDeflection >> myNodes; }
44     inline void Write (StdObjMgt_WriteData& theWriteData) const
45       { theWriteData << myDeflection << myNodes; }
46     Standard_EXPORT void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
47     inline Standard_CString PName() const { return "PPoly_Polygon2D"; }
48
49     Handle(Poly_Polygon2D) Import() const;
50
51   private:
52     Standard_Real                          myDeflection;
53     Handle(ShapePersistent_HArray1::Pnt2d) myNodes;
54   };
55
56   class pPolygon3D : public Standard_Transient
57   {
58     friend class ShapePersistent_Poly;
59
60   public:
61     inline void Read (StdObjMgt_ReadData& theReadData)
62       { theReadData >> myDeflection >> myNodes >> myParameters; }
63     inline void Write (StdObjMgt_WriteData& theWriteData) const
64       { theWriteData << myDeflection << myNodes << myParameters; }
65     Standard_EXPORT void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
66     inline Standard_CString PName() const { return "PPoly_Polygon3D"; }
67
68     Handle(Poly_Polygon3D) Import() const;
69
70   private:
71     Standard_Real                        myDeflection;
72     Handle(ShapePersistent_HArray1::Pnt) myNodes;
73     Handle(StdLPersistent_HArray1::Real) myParameters;
74   };
75
76   class pPolygonOnTriangulation : public Standard_Transient
77   {
78     friend class ShapePersistent_Poly;
79
80   public:
81     pPolygonOnTriangulation()
82     : myDeflection(0.0)
83     {
84     }
85     inline void Read (StdObjMgt_ReadData& theReadData)
86       { theReadData >> myDeflection >> myNodes >> myParameters; }
87     inline void Write (StdObjMgt_WriteData& theWriteData) const
88       { theWriteData << myDeflection << myNodes << myParameters; }
89     Standard_EXPORT void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
90     inline Standard_CString PName() const { return "PPoly_PolygonOnTriangulation"; }
91
92     Handle(Poly_PolygonOnTriangulation) Import() const;
93
94   private:
95     Standard_Real                           myDeflection;
96     Handle(StdLPersistent_HArray1::Integer) myNodes;
97     Handle(StdLPersistent_HArray1::Real)    myParameters;
98   };
99
100   class pTriangulation : public Standard_Transient
101   {
102     friend class ShapePersistent_Poly;
103
104   public:
105     pTriangulation()
106     : myDeflection(0.0)
107     {
108     }
109     inline void Read (StdObjMgt_ReadData& theReadData)
110       { theReadData >> myDeflection >> myNodes >> myUVNodes >> myTriangles; }
111     inline void Write (StdObjMgt_WriteData& theWriteData) const
112       { theWriteData << myDeflection << myNodes << myUVNodes << myTriangles; }
113     Standard_EXPORT void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const;
114     inline Standard_CString PName() const { return "PPoly_Triangulation"; }
115
116     Handle(Poly_Triangulation) Import() const;
117
118   private:
119     Standard_Real                             myDeflection;
120     Handle(ShapePersistent_HArray1::Pnt)      myNodes;
121     Handle(ShapePersistent_HArray1::Pnt2d)    myUVNodes;
122     Handle(ShapePersistent_HArray1::Triangle) myTriangles;
123   };
124
125   template <class Persistent, class Transient>
126   struct instance
127     : public Delayed <DelayedBase<StdObjMgt_Persistent, Transient, Persistent> > {};
128
129 public:
130   typedef instance <pPolygon2D, Poly_Polygon2D>         Polygon2D;
131   typedef instance <pPolygon3D, Poly_Polygon3D>         Polygon3D;
132   typedef instance <pPolygonOnTriangulation,
133                     Poly_PolygonOnTriangulation>        PolygonOnTriangulation;
134   typedef instance <pTriangulation, Poly_Triangulation> Triangulation;
135
136 public:
137   //! Create a persistent object for a 2D polygon
138   Standard_EXPORT static Handle(Polygon2D) Translate (const Handle(Poly_Polygon2D)& thePoly,
139                                                       StdObjMgt_TransientPersistentMap& theMap);
140   //! Create a persistent object for a 3D polygon
141   Standard_EXPORT static Handle(Polygon3D) Translate (const Handle(Poly_Polygon3D)& thePoly,
142                                                       StdObjMgt_TransientPersistentMap& theMap);
143   //! Create a persistent object for a triangulation
144   Standard_EXPORT static Handle(PolygonOnTriangulation) Translate (const Handle(Poly_PolygonOnTriangulation)& thePolyOnTriang,
145                                                                    StdObjMgt_TransientPersistentMap& theMap);
146   //! Create a persistent object for a polygon on triangulation
147   Standard_EXPORT static Handle(Triangulation) Translate(const Handle(Poly_Triangulation)& thePolyTriang,
148                                                          StdObjMgt_TransientPersistentMap& theMap);
149 };
150
151 #endif