ff205346 |
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> |
ec964372 |
19 | #include <StdObjMgt_TransientPersistentMap.hxx> |
ff205346 |
20 | #include <StdObjMgt_ReadData.hxx> |
ec964372 |
21 | #include <StdObjMgt_WriteData.hxx> |
ff205346 |
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 | { |
45d8465e |
33 | class pPolygon2D : public Standard_Transient |
ff205346 |
34 | { |
ec964372 |
35 | friend class ShapePersistent_Poly; |
36 | |
ff205346 |
37 | public: |
d533dafb |
38 | pPolygon2D() |
39 | : myDeflection(0.0) |
40 | { |
41 | } |
ff205346 |
42 | inline void Read (StdObjMgt_ReadData& theReadData) |
43 | { theReadData >> myDeflection >> myNodes; } |
ec964372 |
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"; } |
ff205346 |
48 | |
49 | Handle(Poly_Polygon2D) Import() const; |
50 | |
51 | private: |
45d8465e |
52 | Standard_Real myDeflection; |
53 | Handle(ShapePersistent_HArray1::Pnt2d) myNodes; |
ff205346 |
54 | }; |
55 | |
45d8465e |
56 | class pPolygon3D : public Standard_Transient |
ff205346 |
57 | { |
ec964372 |
58 | friend class ShapePersistent_Poly; |
59 | |
ff205346 |
60 | public: |
61 | inline void Read (StdObjMgt_ReadData& theReadData) |
62 | { theReadData >> myDeflection >> myNodes >> myParameters; } |
ec964372 |
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"; } |
ff205346 |
67 | |
68 | Handle(Poly_Polygon3D) Import() const; |
69 | |
70 | private: |
45d8465e |
71 | Standard_Real myDeflection; |
72 | Handle(ShapePersistent_HArray1::Pnt) myNodes; |
73 | Handle(StdLPersistent_HArray1::Real) myParameters; |
ff205346 |
74 | }; |
75 | |
45d8465e |
76 | class pPolygonOnTriangulation : public Standard_Transient |
ff205346 |
77 | { |
ec964372 |
78 | friend class ShapePersistent_Poly; |
79 | |
ff205346 |
80 | public: |
d533dafb |
81 | pPolygonOnTriangulation() |
82 | : myDeflection(0.0) |
83 | { |
84 | } |
ff205346 |
85 | inline void Read (StdObjMgt_ReadData& theReadData) |
86 | { theReadData >> myDeflection >> myNodes >> myParameters; } |
ec964372 |
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"; } |
ff205346 |
91 | |
92 | Handle(Poly_PolygonOnTriangulation) Import() const; |
93 | |
94 | private: |
45d8465e |
95 | Standard_Real myDeflection; |
96 | Handle(StdLPersistent_HArray1::Integer) myNodes; |
97 | Handle(StdLPersistent_HArray1::Real) myParameters; |
ff205346 |
98 | }; |
99 | |
45d8465e |
100 | class pTriangulation : public Standard_Transient |
ff205346 |
101 | { |
ec964372 |
102 | friend class ShapePersistent_Poly; |
103 | |
ff205346 |
104 | public: |
d533dafb |
105 | pTriangulation() |
106 | : myDeflection(0.0) |
107 | { |
108 | } |
ff205346 |
109 | inline void Read (StdObjMgt_ReadData& theReadData) |
110 | { theReadData >> myDeflection >> myNodes >> myUVNodes >> myTriangles; } |
ec964372 |
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"; } |
ff205346 |
115 | |
116 | Handle(Poly_Triangulation) Import() const; |
117 | |
118 | private: |
45d8465e |
119 | Standard_Real myDeflection; |
120 | Handle(ShapePersistent_HArray1::Pnt) myNodes; |
121 | Handle(ShapePersistent_HArray1::Pnt2d) myUVNodes; |
122 | Handle(ShapePersistent_HArray1::Triangle) myTriangles; |
ff205346 |
123 | }; |
124 | |
125 | template <class Persistent, class Transient> |
126 | struct instance |
ec964372 |
127 | : public Delayed <DelayedBase<StdObjMgt_Persistent, Transient, Persistent> > {}; |
ff205346 |
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; |
ec964372 |
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); |
ff205346 |
149 | }; |
150 | |
151 | #endif |