0031035: Coding - uninitialized class fields reported by Visual Studio Code Analysis
[occt.git] / src / ShapePersistent / ShapePersistent_Geom_Surface.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_Geom_Surface_HeaderFile
16 #define _ShapePersistent_Geom_Surface_HeaderFile
17
18 #include <StdObjMgt_TransientPersistentMap.hxx>
19
20 #include <ShapePersistent_Geom.hxx>
21 #include <ShapePersistent_HArray2.hxx>
22 #include <StdLPersistent_HArray1.hxx>
23 #include <StdLPersistent_HArray2.hxx>
24
25 #include <Geom_Plane.hxx>
26 #include <Geom_ConicalSurface.hxx>
27 #include <Geom_CylindricalSurface.hxx>
28 #include <Geom_SphericalSurface.hxx>
29 #include <Geom_ToroidalSurface.hxx>
30 #include <Geom_SurfaceOfLinearExtrusion.hxx>
31 #include <Geom_SurfaceOfRevolution.hxx>
32 #include <Geom_BezierSurface.hxx>
33 #include <Geom_BSplineSurface.hxx>
34 #include <Geom_RectangularTrimmedSurface.hxx>
35 #include <Geom_OffsetSurface.hxx>
36
37 #include <gp_Ax3.hxx>
38 #include <gp_Cone.hxx>
39 #include <gp_Cylinder.hxx>
40 #include <gp_Sphere.hxx>
41 #include <gp_Torus.hxx>
42
43 class gp_Dir;
44 class gp_Pnt;
45
46
47 class ShapePersistent_Geom_Surface : private ShapePersistent_Geom
48 {
49   typedef Surface::PersistentBase pBase;
50
51   class pSweptData
52   {
53     friend class ShapePersistent_Geom_Surface;
54
55   public:
56     inline void Read (StdObjMgt_ReadData& theReadData)
57       { theReadData >> myBasisCurve >> myDirection; }
58     inline void Write (StdObjMgt_WriteData& theWriteData) const
59       { theWriteData << myBasisCurve << myDirection; }
60     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
61       { theChildren.Append(myBasisCurve); }
62
63   protected:
64     Handle(Curve) myBasisCurve;
65     gp_Dir        myDirection;
66   };
67
68   struct pSwept : pBase, pSweptData 
69   {
70     inline Standard_CString PName() const 
71       { return "PGeom_SweptSurface"; }
72   };
73
74   class pLinearExtrusion : public pSwept
75   {
76     friend class ShapePersistent_Geom_Surface;
77
78   public:
79     virtual Handle(Geom_Surface) Import() const;
80     inline Standard_CString PName() const 
81       { return "PGeom_SurfaceOfLinearExtrusion"; }
82   };
83
84   class pRevolution : public pSwept
85   {
86     friend class ShapePersistent_Geom_Surface;
87
88   public:
89     inline void Read (StdObjMgt_ReadData& theReadData)
90     {
91       pSwept::Read (theReadData);
92       theReadData >> myLocation;
93     }
94     inline void Write (StdObjMgt_WriteData& theWriteData) const
95     {
96       pSwept::Write(theWriteData);
97       theWriteData << myLocation;
98     }
99     inline Standard_CString PName() const 
100       { return "PGeom_SurfaceOfRevolution"; }
101
102     virtual Handle(Geom_Surface) Import() const;
103
104   private:
105     gp_Pnt myLocation;
106   };
107
108   typedef pBase pBounded;
109
110   class pBezier : public pBounded
111   {
112     friend class ShapePersistent_Geom_Surface;
113
114   public:
115     pBezier()
116     : myURational(Standard_False),
117       myVRational(Standard_False)
118     {
119     }
120     inline void Read (StdObjMgt_ReadData& theReadData)
121       { theReadData >> myURational >> myVRational >> myPoles >> myWeights; }
122     inline void Write (StdObjMgt_WriteData& theWriteData) const
123       { theWriteData << myURational << myVRational << myPoles << myWeights; }
124     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
125     {
126       theChildren.Append(myPoles);
127       theChildren.Append(myWeights);
128     }
129     inline Standard_CString PName() const 
130       { return "PGeom_BezierSurface"; }
131
132     virtual Handle(Geom_Surface) Import() const;
133
134   private:
135     Standard_Boolean                     myURational;
136     Standard_Boolean                     myVRational;
137     Handle(ShapePersistent_HArray2::Pnt) myPoles;
138     Handle(StdLPersistent_HArray2::Real) myWeights;
139   };
140
141   class pBSpline : public pBounded
142   {
143     friend class ShapePersistent_Geom_Surface;
144
145   public:
146     pBSpline()
147     : myURational(Standard_False),
148       myVRational(Standard_False),
149       myUPeriodic(Standard_False),
150       myVPeriodic(Standard_False),
151       myUSpineDegree(0),
152       myVSpineDegree(0)
153     {
154     }
155     inline void Read (StdObjMgt_ReadData& theReadData)
156     {
157       theReadData >> myURational >> myVRational;
158       theReadData >> myUPeriodic >> myVPeriodic;
159       theReadData >> myUSpineDegree >> myVSpineDegree;
160       theReadData >> myPoles;
161       theReadData >> myWeights;
162       theReadData >> myUKnots >> myVKnots;
163       theReadData >> myUMultiplicities >> myVMultiplicities;
164     }
165     inline void Write (StdObjMgt_WriteData& theWriteData) const
166     {
167       theWriteData << myURational << myVRational;
168       theWriteData << myUPeriodic << myVPeriodic;
169       theWriteData << myUSpineDegree << myVSpineDegree;
170       theWriteData << myPoles;
171       theWriteData << myWeights;
172       theWriteData << myUKnots << myVKnots;
173       theWriteData << myUMultiplicities << myVMultiplicities;
174     }
175     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
176     {
177       theChildren.Append(myPoles);
178       theChildren.Append(myWeights);
179       theChildren.Append(myUKnots);
180       theChildren.Append(myVKnots);
181       theChildren.Append(myUMultiplicities);
182       theChildren.Append(myVMultiplicities);
183     }
184     inline Standard_CString PName() const 
185       { return "PGeom_BSplineSurface"; }
186
187     virtual Handle(Geom_Surface) Import() const;
188
189   private:
190     Standard_Boolean                        myURational;
191     Standard_Boolean                        myVRational;
192     Standard_Boolean                        myUPeriodic;
193     Standard_Boolean                        myVPeriodic;
194     Standard_Integer                        myUSpineDegree;
195     Standard_Integer                        myVSpineDegree;
196     Handle(ShapePersistent_HArray2::Pnt)    myPoles;
197     Handle(StdLPersistent_HArray2::Real)    myWeights;
198     Handle(StdLPersistent_HArray1::Real)    myUKnots;
199     Handle(StdLPersistent_HArray1::Real)    myVKnots;
200     Handle(StdLPersistent_HArray1::Integer) myUMultiplicities;
201     Handle(StdLPersistent_HArray1::Integer) myVMultiplicities;
202   };
203
204   class pRectangularTrimmed : public pBounded
205   {
206     friend class ShapePersistent_Geom_Surface;
207
208   public:
209     pRectangularTrimmed()
210     : myFirstU(0.0),
211       myLastU(0.0),
212       myFirstV(0.0),
213       myLastV(0.0)
214     {
215     }
216     inline void Read (StdObjMgt_ReadData& theReadData)
217     {
218       theReadData >> myBasisSurface;
219       theReadData >> myFirstU >> myLastU >> myFirstV >> myLastV;
220     }
221     inline void Write (StdObjMgt_WriteData& theWriteData) const
222     {
223       theWriteData << myBasisSurface;
224       theWriteData << myFirstU << myLastU << myFirstV << myLastV;
225     }
226     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
227       { theChildren.Append(myBasisSurface); }
228     inline Standard_CString PName() const 
229       { return "PGeom_RectangularTrimmedSurface"; }
230
231     virtual Handle(Geom_Surface) Import() const;
232
233   private:
234     Handle(Surface) myBasisSurface;
235     Standard_Real   myFirstU;
236     Standard_Real   myLastU;
237     Standard_Real   myFirstV;
238     Standard_Real   myLastV;
239   };
240
241   class pOffset : public pBase
242   {
243     friend class ShapePersistent_Geom_Surface;
244
245   public:
246     pOffset()
247     : myOffsetValue(0.0)
248     {
249     }
250     inline void Read (StdObjMgt_ReadData& theReadData)
251       { theReadData >> myBasisSurface >> myOffsetValue; }
252     inline void Write (StdObjMgt_WriteData& theWriteData) const
253       { theWriteData << myBasisSurface << myOffsetValue; }
254     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
255       { theChildren.Append(myBasisSurface); }
256     inline Standard_CString PName() const 
257       { return "PGeom_OffsetSurface"; }
258
259     virtual Handle(Geom_Surface) Import() const;
260
261   private:
262     Handle(Surface) myBasisSurface;
263     Standard_Real   myOffsetValue;
264   };
265
266 public:
267   typedef subBase_gp<Surface, gp_Ax3>                                Elementary;
268   typedef instance<Elementary, Geom_Plane             , gp_Ax3>      Plane;
269   typedef instance<Elementary, Geom_ConicalSurface    , gp_Cone>     Conical;
270   typedef instance<Elementary, Geom_CylindricalSurface, gp_Cylinder> Cylindrical;
271   typedef instance<Elementary, Geom_SphericalSurface  , gp_Sphere>   Spherical;
272   typedef instance<Elementary, Geom_ToroidalSurface   , gp_Torus>    Toroidal;
273
274   typedef subBase<Surface, pSweptData>                               Swept;
275   typedef Delayed<Swept, pLinearExtrusion>                           LinearExtrusion;
276   typedef Delayed<Swept, pRevolution>                                Revolution;
277
278   typedef subBase_empty<Surface>                                     Bounded;
279   typedef Delayed<Bounded, pBezier>                                  Bezier;
280   typedef Delayed<Bounded, pBSpline>                                 BSpline;
281   typedef Delayed<Bounded, pRectangularTrimmed>                      RectangularTrimmed;
282
283   typedef Delayed<Surface, pOffset>                                  Offset;
284
285 public:
286   //! Create a persistent object for a plane
287   Standard_EXPORT static Handle(Surface) Translate (const Handle(Geom_Plane)& theSurf,
288                                                     StdObjMgt_TransientPersistentMap& theMap);
289   //! Create a persistent object for a cylinder
290   Standard_EXPORT static Handle(Surface) Translate (const Handle(Geom_CylindricalSurface)& theSurf,
291                                                     StdObjMgt_TransientPersistentMap& theMap);
292   //! Create a persistent object for a cone
293   Standard_EXPORT static Handle(Surface) Translate (const Handle(Geom_ConicalSurface)& theSurf,
294                                                     StdObjMgt_TransientPersistentMap& theMap);
295   //! Create a persistent object for a sphere
296   Standard_EXPORT static Handle(Surface) Translate (const Handle(Geom_SphericalSurface)& theSurf,
297                                                     StdObjMgt_TransientPersistentMap& theMap);
298   //! Create a persistent object for a torus
299   Standard_EXPORT static Handle(Surface) Translate (const Handle(Geom_ToroidalSurface)& theSurf,
300                                                     StdObjMgt_TransientPersistentMap& theMap);
301   //! Create a persistent object for a surface of linear extrusion
302   Standard_EXPORT static Handle(Surface) Translate (const Handle(Geom_SurfaceOfLinearExtrusion)& theSurf,
303                                                     StdObjMgt_TransientPersistentMap& theMap);
304   //! Create a persistent object for a surface of evolution
305   Standard_EXPORT static Handle(Surface) Translate (const Handle(Geom_SurfaceOfRevolution)& theSurf,
306                                                     StdObjMgt_TransientPersistentMap& theMap);
307   //! Create a persistent object for a Bezier surface
308   Standard_EXPORT static Handle(Surface) Translate (const Handle(Geom_BezierSurface)& theSurf,
309                                                     StdObjMgt_TransientPersistentMap& theMap);
310   //! Create a persistent object for a BSpline surface
311   Standard_EXPORT static Handle(Surface) Translate (const Handle(Geom_BSplineSurface)& theSurf,
312                                                     StdObjMgt_TransientPersistentMap& theMap);
313   //! Create a persistent object for a rectangylar trimmed surface
314   Standard_EXPORT static Handle(Surface) Translate (const Handle(Geom_RectangularTrimmedSurface)& theSurf,
315                                                     StdObjMgt_TransientPersistentMap& theMap);
316   //! Create a persistent object for an offset surface 
317   Standard_EXPORT static Handle(Surface) Translate (const Handle(Geom_OffsetSurface)& theSurf,
318                                                     StdObjMgt_TransientPersistentMap& theMap);
319 };
320
321 //=======================================================================
322 // Elementary
323 //=======================================================================
324 template<>
325 Standard_CString ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, 
326                                                   gp_Ax3>
327   ::PName() const;
328
329 //=======================================================================
330 // Plane
331 //=======================================================================
332 template<>
333 Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>, 
334                                                 Geom_Plane, 
335                                                 gp_Ax3>
336   ::PName() const;
337
338 template<>
339 void ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
340                                     Geom_Plane,
341                                     gp_Ax3>
342   ::Write(StdObjMgt_WriteData& theWriteData) const;
343
344 //=======================================================================
345 // Conical
346 //=======================================================================
347 template<>
348 Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
349                                                 Geom_ConicalSurface,
350                                                 gp_Cone>
351   ::PName() const;
352
353 template<>
354 void ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
355                                     Geom_ConicalSurface,
356                                     gp_Cone>
357   ::Write(StdObjMgt_WriteData& theWriteData) const;
358
359 //=======================================================================
360 // Cylindrical
361 //=======================================================================
362 template<>
363 Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
364                                                 Geom_CylindricalSurface,
365                                                 gp_Cylinder>
366   ::PName() const;
367
368 template<>
369 void ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
370                                     Geom_CylindricalSurface,
371                                     gp_Cylinder>
372   ::Write(StdObjMgt_WriteData& theWriteData) const;
373
374 //=======================================================================
375 // Spherical
376 //=======================================================================
377 template<>
378 Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
379                                                 Geom_SphericalSurface,
380                                                 gp_Sphere>
381   ::PName() const;
382
383 template<>
384 void ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
385                                     Geom_SphericalSurface,
386                                     gp_Sphere>
387   ::Write(StdObjMgt_WriteData& theWriteData) const;
388
389 //=======================================================================
390 // Toroidal
391 //=======================================================================
392 template<>
393 Standard_CString ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
394                                                 Geom_ToroidalSurface,
395                                                 gp_Torus>
396   ::PName() const;
397
398 template<>
399 void ShapePersistent_Geom::instance<ShapePersistent_Geom::subBase_gp<ShapePersistent_Geom::Surface, gp_Ax3>,
400                                     Geom_ToroidalSurface,
401                                     gp_Torus>
402   ::Write(StdObjMgt_WriteData& theWriteData) const;
403
404 #endif