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 | #include <ShapePersistent_Poly.hxx> |
ec964372 |
15 | #include <ShapePersistent_HArray1.hxx> |
ff205346 |
16 | |
17 | #include <Poly_Polygon2D.hxx> |
18 | #include <Poly_Polygon3D.hxx> |
19 | #include <Poly_PolygonOnTriangulation.hxx> |
20 | #include <Poly_Triangulation.hxx> |
21 | |
22 | |
ec964372 |
23 | void ShapePersistent_Poly::pPolygon2D::PChildren |
24 | (StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const |
25 | { |
26 | theChildren.Append(myNodes); |
27 | } |
28 | |
ff205346 |
29 | Handle(Poly_Polygon2D) ShapePersistent_Poly::pPolygon2D::Import() const |
30 | { |
31 | if (myNodes.IsNull()) |
32 | return NULL; |
33 | |
34 | Handle(Poly_Polygon2D) aPolygon = new Poly_Polygon2D (*myNodes->Array()); |
35 | aPolygon->Deflection (myDeflection); |
36 | return aPolygon; |
37 | } |
38 | |
ec964372 |
39 | void ShapePersistent_Poly::pPolygon3D::PChildren |
40 | (StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const |
41 | { |
42 | theChildren.Append(myNodes); |
43 | theChildren.Append(myParameters); |
44 | } |
45 | |
ff205346 |
46 | Handle(Poly_Polygon3D) ShapePersistent_Poly::pPolygon3D::Import() const |
47 | { |
48 | if (myNodes.IsNull() || myParameters.IsNull()) |
49 | return NULL; |
50 | |
51 | Handle(Poly_Polygon3D) aPolygon = new Poly_Polygon3D (*myNodes->Array(), |
52 | *myParameters->Array()); |
53 | aPolygon->Deflection (myDeflection); |
54 | return aPolygon; |
55 | } |
56 | |
ec964372 |
57 | void ShapePersistent_Poly::pPolygonOnTriangulation::PChildren |
58 | (StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const |
59 | { |
60 | theChildren.Append(myNodes); |
61 | theChildren.Append(myParameters); |
62 | } |
63 | |
ff205346 |
64 | Handle(Poly_PolygonOnTriangulation) |
65 | ShapePersistent_Poly::pPolygonOnTriangulation::Import() const |
66 | { |
67 | Handle(Poly_PolygonOnTriangulation) aPolygon; |
68 | |
69 | if (myNodes) |
70 | { |
71 | if (myParameters) |
72 | aPolygon = new Poly_PolygonOnTriangulation (*myNodes->Array(), |
73 | *myParameters->Array()); |
74 | else |
75 | aPolygon = new Poly_PolygonOnTriangulation (*myNodes->Array()); |
76 | |
77 | aPolygon->Deflection (myDeflection); |
78 | } |
79 | |
80 | return aPolygon; |
81 | } |
82 | |
ec964372 |
83 | void ShapePersistent_Poly::pTriangulation::PChildren |
84 | (StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const |
85 | { |
86 | theChildren.Append(myNodes); |
87 | theChildren.Append(myUVNodes); |
88 | theChildren.Append(myTriangles); |
89 | } |
90 | |
ff205346 |
91 | Handle(Poly_Triangulation) ShapePersistent_Poly::pTriangulation::Import() const |
92 | { |
93 | Handle(Poly_Triangulation) aTriangulation; |
94 | |
95 | // Triangulation is not used |
ec964372 |
96 | #if 1 |
ff205346 |
97 | if (myNodes && myTriangles) |
98 | { |
99 | if (myUVNodes) |
100 | aTriangulation = new Poly_Triangulation (*myNodes->Array(), |
101 | *myUVNodes->Array(), |
102 | *myTriangles->Array()); |
103 | else |
104 | aTriangulation = new Poly_Triangulation (*myNodes->Array(), |
105 | *myTriangles->Array()); |
106 | |
107 | aTriangulation->Deflection (myDeflection); |
108 | } |
109 | #endif |
110 | |
111 | return aTriangulation; |
112 | } |
ec964372 |
113 | |
114 | Handle(ShapePersistent_Poly::Polygon2D) |
115 | ShapePersistent_Poly::Translate(const Handle(Poly_Polygon2D)& thePoly, |
116 | StdObjMgt_TransientPersistentMap& theMap) |
117 | { |
118 | Handle(Polygon2D) aPP; |
119 | if (!thePoly.IsNull()) |
120 | { |
121 | if (theMap.IsBound(thePoly)) |
122 | aPP = Handle(Polygon2D)::DownCast(theMap.Find(thePoly)); |
123 | else |
124 | { |
125 | aPP = new Polygon2D; |
126 | aPP->myPersistent = new pPolygon2D; |
127 | aPP->myPersistent->myDeflection = thePoly->Deflection(); |
128 | aPP->myPersistent->myNodes = |
129 | StdLPersistent_HArray1::Translate<TColgp_HArray1OfPnt2d>("PColgp_HArray1OfPnt2d", thePoly->Nodes()); |
130 | theMap.Bind(thePoly, aPP); |
131 | } |
132 | } |
133 | return aPP; |
134 | } |
135 | |
136 | Handle(ShapePersistent_Poly::Polygon3D) |
137 | ShapePersistent_Poly::Translate(const Handle(Poly_Polygon3D)& thePoly, |
138 | StdObjMgt_TransientPersistentMap& theMap) |
139 | { |
140 | Handle(Polygon3D) aPP = new Polygon3D; |
141 | if (!thePoly.IsNull()) |
142 | { |
143 | if (theMap.IsBound(thePoly)) |
144 | aPP = Handle(Polygon3D)::DownCast(theMap.Find(thePoly)); |
145 | else |
146 | { |
147 | aPP = new Polygon3D; |
148 | aPP->myPersistent = new pPolygon3D; |
149 | aPP->myPersistent->myDeflection = thePoly->Deflection(); |
150 | aPP->myPersistent->myNodes = |
151 | StdLPersistent_HArray1::Translate<TColgp_HArray1OfPnt>("PColgp_HArray1OfPnt", thePoly->Nodes()); |
152 | if (thePoly->HasParameters()) { |
153 | aPP->myPersistent->myParameters = |
154 | StdLPersistent_HArray1::Translate<TColStd_HArray1OfReal>(thePoly->Parameters()); |
155 | } |
156 | theMap.Bind(thePoly, aPP); |
157 | } |
158 | } |
159 | return aPP; |
160 | } |
161 | |
162 | Handle(ShapePersistent_Poly::PolygonOnTriangulation) |
163 | ShapePersistent_Poly::Translate(const Handle(Poly_PolygonOnTriangulation)& thePolyOnTriang, |
164 | StdObjMgt_TransientPersistentMap& theMap) |
165 | { |
166 | Handle(PolygonOnTriangulation) aPPonT; |
167 | if (!thePolyOnTriang.IsNull()) |
168 | { |
169 | if (theMap.IsBound(thePolyOnTriang)) |
170 | aPPonT = Handle(PolygonOnTriangulation)::DownCast(theMap.Find(thePolyOnTriang)); |
171 | else |
172 | { |
173 | aPPonT = new PolygonOnTriangulation; |
174 | aPPonT->myPersistent = new pPolygonOnTriangulation; |
175 | aPPonT->myPersistent->myDeflection = thePolyOnTriang->Deflection(); |
176 | aPPonT->myPersistent->myNodes = |
177 | StdLPersistent_HArray1::Translate<TColStd_HArray1OfInteger>(thePolyOnTriang->Nodes()); |
178 | if (thePolyOnTriang->HasParameters()) { |
179 | aPPonT->myPersistent->myParameters = |
180 | StdLPersistent_HArray1::Translate<TColStd_HArray1OfReal>(thePolyOnTriang->Parameters()->Array1()); |
181 | } |
182 | theMap.Bind(thePolyOnTriang, aPPonT); |
183 | } |
184 | } |
185 | return aPPonT; |
186 | } |
187 | |
188 | Handle(ShapePersistent_Poly::Triangulation) |
189 | ShapePersistent_Poly::Translate(const Handle(Poly_Triangulation)& thePolyTriang, |
190 | StdObjMgt_TransientPersistentMap& theMap) |
191 | { |
192 | Handle(Triangulation) aPT; |
193 | if (!thePolyTriang.IsNull()) |
194 | { |
195 | if (theMap.IsBound(thePolyTriang)) |
196 | aPT = Handle(Triangulation)::DownCast(theMap.Find(thePolyTriang)); |
197 | else |
198 | { |
199 | aPT = new Triangulation; |
200 | aPT->myPersistent = new pTriangulation; |
201 | aPT->myPersistent->myNodes = |
202 | StdLPersistent_HArray1::Translate<TColgp_HArray1OfPnt>("PColgp_HArray1OfPnt", thePolyTriang->Nodes()); |
203 | aPT->myPersistent->myTriangles = |
204 | StdLPersistent_HArray1::Translate<Poly_HArray1OfTriangle>("PPoly_HArray1OfTriangle", thePolyTriang->Triangles()); |
205 | if (thePolyTriang->HasUVNodes()) { |
206 | aPT->myPersistent->myUVNodes = |
207 | StdLPersistent_HArray1::Translate<TColgp_HArray1OfPnt2d>("PColgp_HArray1OfPnt2d", thePolyTriang->UVNodes()); |
208 | } |
209 | theMap.Bind(thePolyTriang, aPT); |
210 | } |
211 | } |
212 | return aPT; |
213 | } |