7fd59977 |
1 | #include <IGESSolid_TopoBuilder.ixx> |
2 | #include <Standard_DomainError.hxx> |
3 | #include <TColgp_HArray1OfXYZ.hxx> |
4 | #include <IGESData_HArray1OfIGESEntity.hxx> |
5 | #include <IGESSolid_HArray1OfVertexList.hxx> |
6 | #include <TColStd_HArray1OfInteger.hxx> |
7 | #include <IGESBasic_HArray1OfHArray1OfInteger.hxx> |
8 | #include <IGESBasic_HArray1OfHArray1OfIGESEntity.hxx> |
9 | #include <IGESSolid_HArray1OfLoop.hxx> |
10 | #include <IGESSolid_HArray1OfFace.hxx> |
11 | #include <IGESSolid_HArray1OfShell.hxx> |
12 | #include <Interface_Macros.hxx> |
13 | |
14 | |
15 | |
16 | |
17 | IGESSolid_TopoBuilder::IGESSolid_TopoBuilder () { Clear(); } |
18 | |
19 | void IGESSolid_TopoBuilder::Clear () |
20 | { |
21 | thesolid = new IGESSolid_ManifoldSolid; |
22 | thevoids = new TColStd_HSequenceOfTransient(); |
23 | thevflag = new TColStd_HSequenceOfInteger(); |
24 | theshell = new IGESSolid_Shell; |
25 | thefaces = new TColStd_HSequenceOfTransient(); |
26 | thefflag = new TColStd_HSequenceOfInteger(); |
27 | theface.Nullify(); |
28 | theinner = new TColStd_HSequenceOfTransient(); |
29 | theloop.Nullify(); |
30 | theetype = new TColStd_HSequenceOfInteger(); |
31 | thee3d = new TColStd_HSequenceOfInteger(); |
32 | theeflag = new TColStd_HSequenceOfInteger(); |
33 | theeuv = new TColStd_HSequenceOfTransient(); |
34 | theisol = new TColStd_HSequenceOfInteger(); |
35 | thecuruv = new TColStd_HSequenceOfTransient(); |
36 | theiso = new TColStd_HSequenceOfTransient(); |
37 | theedgel = new IGESSolid_EdgeList; |
38 | thecur3d = new TColStd_HSequenceOfTransient(); |
39 | thevstar = new TColStd_HSequenceOfInteger(); |
40 | thevend = new TColStd_HSequenceOfInteger(); |
41 | thevertl = new IGESSolid_VertexList; |
42 | thepoint = new TColgp_HSequenceOfXYZ(); |
43 | } |
44 | |
45 | void IGESSolid_TopoBuilder::AddVertex (const gp_XYZ& val) |
46 | { thepoint->Append(val); } |
47 | |
48 | Standard_Integer IGESSolid_TopoBuilder::NbVertices () const |
49 | { return thepoint->Length(); } |
50 | |
51 | const gp_XYZ& IGESSolid_TopoBuilder::Vertex |
52 | (const Standard_Integer num) const |
53 | { return thepoint->Value(num); } |
54 | |
55 | Handle(IGESSolid_VertexList) IGESSolid_TopoBuilder::VertexList () const |
56 | { return thevertl; } |
57 | |
58 | |
59 | void IGESSolid_TopoBuilder::AddEdge |
60 | (const Handle(IGESData_IGESEntity)& curve, |
61 | const Standard_Integer vstart, const Standard_Integer vend) |
62 | { |
63 | if (curve.IsNull() || vstart <= 0 || vend <= 0 || |
64 | vstart > thepoint->Length() || vend > thepoint->Length()) |
65 | Standard_DomainError::Raise ("IGESSolid_TopoBuilder : AddEdge"); |
66 | thecur3d->Append (curve); |
67 | thevstar->Append (vstart); |
68 | thevend->Append (vend); |
69 | } |
70 | |
71 | Standard_Integer IGESSolid_TopoBuilder::NbEdges () const |
72 | { return thecur3d->Length(); } |
73 | |
74 | void IGESSolid_TopoBuilder::Edge |
75 | (const Standard_Integer num, |
76 | Handle(IGESData_IGESEntity)& curve, |
77 | Standard_Integer& vstart, Standard_Integer& vend) const |
78 | { |
79 | if (num <= 0 || num > thecur3d->Length()) return; |
80 | curve = GetCasted(IGESData_IGESEntity,thecur3d->Value(num)); |
81 | vstart = thevstar->Value(num); |
82 | vend = thevend->Value(num); |
83 | } |
84 | |
85 | Handle(IGESSolid_EdgeList) IGESSolid_TopoBuilder::EdgeList () const |
86 | { return theedgel; } |
87 | |
88 | void IGESSolid_TopoBuilder::EndLists () |
89 | { |
90 | Standard_Integer i,nb; |
91 | Handle(TColgp_HArray1OfXYZ) vert; |
92 | Handle(IGESData_HArray1OfIGESEntity) curves; |
93 | Handle(IGESSolid_HArray1OfVertexList) estart, eend; |
94 | Handle(TColStd_HArray1OfInteger) nstart, nend; |
95 | |
96 | nb = thepoint->Length(); |
97 | if (nb > 0) { |
98 | vert = new TColgp_HArray1OfXYZ (1,nb); |
99 | for (i = 1; i <= nb; i ++) vert->SetValue (i, thepoint->Value(i)); |
100 | } |
101 | thevertl->Init (vert); |
102 | |
103 | nb = thecur3d->Length(); |
104 | if (nb > 0) { |
105 | curves = new IGESData_HArray1OfIGESEntity (1,nb); |
106 | nstart = new TColStd_HArray1OfInteger (1,nb); nstart->Init(0); |
107 | nend = new TColStd_HArray1OfInteger (1,nb); nend->Init(0); |
108 | estart = new IGESSolid_HArray1OfVertexList (1,nb); |
109 | eend = new IGESSolid_HArray1OfVertexList (1,nb); |
110 | for (i = 1; i <= nb; i ++) { |
111 | curves->SetValue |
112 | (i,GetCasted(IGESData_IGESEntity,thecur3d->Value(i))); |
113 | nstart->SetValue (i,thevstar->Value(i)); |
114 | nend->SetValue (i,thevend->Value(i)); |
115 | estart->SetValue (i,thevertl); |
116 | estart->SetValue (i,thevertl); |
117 | } |
118 | } |
119 | theedgel->Init (curves,estart,nstart,eend,nend); |
120 | } |
121 | |
122 | void IGESSolid_TopoBuilder::MakeLoop () |
123 | { |
124 | theloop = new IGESSolid_Loop; |
125 | theetype->Clear(); thee3d->Clear(); theeflag->Clear(); |
126 | theeuv->Clear(); theisol->Clear(); |
127 | } |
128 | |
129 | void IGESSolid_TopoBuilder::MakeEdge |
130 | (const Standard_Integer edgetype, const Standard_Integer edge3d, |
131 | const Standard_Integer orientation) |
132 | { |
133 | if (edge3d <= 0 || edge3d > thecur3d->Length()) |
134 | Standard_DomainError::Raise ("IGESSolid_TopoBuilder : MakeEdge"); |
135 | theetype->Append (edgetype); |
136 | thee3d->Append (edge3d); |
137 | theeflag->Append (orientation); |
138 | thecuruv->Clear(); theisol->Clear(); |
139 | } |
140 | |
141 | void IGESSolid_TopoBuilder::AddCurveUV |
142 | (const Handle(IGESData_IGESEntity)& curve, const Standard_Integer iso) |
143 | { |
144 | if (curve.IsNull() || thee3d->IsEmpty()) |
145 | Standard_DomainError::Raise ("IGESSolid_TopoBuilder : AddCurveUV"); |
146 | thecuruv->Append(curve); |
147 | theisol->Append(iso); |
148 | } |
149 | |
150 | void IGESSolid_TopoBuilder::EndEdge () |
151 | { |
152 | // transformer thecuruv,theiso en array et le mettre dans theeuv |
153 | Handle(IGESData_HArray1OfIGESEntity) curuv; |
154 | Handle(TColStd_HArray1OfInteger) iso; |
155 | if (!thecuruv->IsEmpty()) { |
156 | Standard_Integer i, nb = thecuruv->Length(); |
157 | curuv = new IGESData_HArray1OfIGESEntity (1,nb); |
158 | iso = new TColStd_HArray1OfInteger (1,nb); iso->Init(0); |
159 | for (i = 1; i <= nb; i ++) { |
160 | curuv->SetValue (i, GetCasted(IGESData_IGESEntity,thecuruv->Value(i))); |
161 | iso->SetValue (i, theisol->Value(i)); |
162 | } |
163 | } |
164 | theeuv->Append(curuv); |
165 | } |
166 | |
167 | void IGESSolid_TopoBuilder::EndLoop () |
168 | { |
169 | Handle(TColStd_HArray1OfInteger) etypes, e3d, eflags, enbuv, eiso; |
170 | Handle(IGESData_HArray1OfIGESEntity) edges, curves; |
171 | Handle(IGESBasic_HArray1OfHArray1OfInteger) isol; |
172 | Handle(IGESBasic_HArray1OfHArray1OfIGESEntity) curvl; |
173 | Standard_Integer i, nb; //szv#4:S4163:12Mar99 nbuv not needed |
174 | nb = thee3d->Length(); |
175 | if (nb > 0) { |
176 | etypes = new TColStd_HArray1OfInteger (1,nb); |
177 | e3d = new TColStd_HArray1OfInteger (1,nb); |
178 | eflags = new TColStd_HArray1OfInteger (1,nb); |
179 | enbuv = new TColStd_HArray1OfInteger (1,nb); |
180 | edges = new IGESData_HArray1OfIGESEntity (1,nb); |
181 | curvl = new IGESBasic_HArray1OfHArray1OfIGESEntity (1,nb); |
182 | isol = new IGESBasic_HArray1OfHArray1OfInteger (1,nb); |
183 | |
184 | for (i = 1; i <= nb; i ++) { |
185 | etypes->SetValue (i, theetype->Value(i)); |
186 | e3d->SetValue (i, thee3d->Value(i)); |
187 | eflags->SetValue (i, theeflag->Value(i)); |
188 | enbuv->SetValue (i,0); |
189 | edges->SetValue (i,theedgel); |
190 | curves = GetCasted(IGESData_HArray1OfIGESEntity,thecuruv->Value(i)); |
191 | if (!curves.IsNull()) { |
192 | //nbuv = curves->Length(); //szv#4:S4163:12Mar99 not needed |
193 | enbuv->SetValue (i,nb); |
194 | curvl->SetValue (i,curves); |
195 | isol->SetValue (i,GetCasted(TColStd_HArray1OfInteger,theiso->Value(i))); |
196 | } |
197 | } |
198 | } |
199 | theloop->Init (etypes,edges,e3d,eflags,enbuv, isol,curvl); |
200 | } |
201 | |
202 | |
203 | void IGESSolid_TopoBuilder::MakeFace |
204 | (const Handle(IGESData_IGESEntity)& surface) |
205 | { |
206 | if (surface.IsNull()) |
207 | Standard_DomainError::Raise ("IGESSolid_TopoBuilder : MakeFace"); |
208 | thesurf = surface; |
209 | theouter = 0; |
210 | theinner->Clear(); |
211 | theface = new IGESSolid_Face; |
212 | } |
213 | |
214 | void IGESSolid_TopoBuilder::SetOuter () |
215 | { |
216 | EndLoop(); |
217 | theouter = 1; |
218 | theinner->Append (theloop); |
219 | theloop.Nullify(); |
220 | } |
221 | |
222 | void IGESSolid_TopoBuilder::AddInner () |
223 | { |
224 | EndLoop(); |
225 | theinner->Append (theloop); |
226 | theloop.Nullify(); |
227 | } |
228 | |
229 | void IGESSolid_TopoBuilder::EndFace (const Standard_Integer orientation) |
230 | { |
231 | Handle(IGESSolid_HArray1OfLoop) loops; |
232 | Standard_Integer i, nb = theinner->Length(); |
233 | if (nb > 0) { |
234 | loops = new IGESSolid_HArray1OfLoop (1,nb); |
235 | for (i = 1; i <= nb; i ++) loops->SetValue |
236 | (i, GetCasted(IGESSolid_Loop,theinner->Value(i))); |
237 | } |
238 | theface->Init (thesurf,theouter,loops); |
239 | thefaces->Append(theface); |
240 | thefflag->Append(orientation); |
241 | } |
242 | |
243 | |
244 | void IGESSolid_TopoBuilder::MakeShell () |
245 | { |
246 | theshell = new IGESSolid_Shell; |
247 | thefaces->Clear(); |
248 | thefflag->Clear(); |
249 | } |
250 | |
251 | void IGESSolid_TopoBuilder::EndShell () |
252 | { |
253 | Handle(IGESSolid_HArray1OfFace) faces; |
254 | Handle(TColStd_HArray1OfInteger) flags; |
255 | Standard_Integer i, nb = thefaces->Length(); |
256 | if (nb > 0) { |
257 | faces = new IGESSolid_HArray1OfFace ( 1,nb); |
258 | flags = new TColStd_HArray1OfInteger (1,nb); flags->Init(0); |
259 | for (i = 1; i <= nb; i ++) { |
260 | faces->SetValue (i,GetCasted(IGESSolid_Face,thefaces->Value(i))); |
261 | flags->SetValue (i, thefflag->Value(i)); |
262 | } |
263 | } |
264 | theshell->Init (faces,flags); |
265 | } |
266 | |
267 | void IGESSolid_TopoBuilder::EndSimpleShell () |
268 | { EndShell(); EndLists(); } |
269 | |
270 | void IGESSolid_TopoBuilder::SetMainShell |
271 | (const Standard_Integer orientation) |
272 | { |
273 | EndShell(); |
274 | themains = theshell; |
275 | themflag = orientation; |
276 | theshell.Nullify(); |
277 | } |
278 | |
279 | void IGESSolid_TopoBuilder::AddVoidShell |
280 | (const Standard_Integer orientation) |
281 | { |
282 | EndShell(); |
283 | thevoids->Append (theshell); |
284 | thevflag->Append (orientation); |
285 | theshell.Nullify(); |
286 | } |
287 | |
288 | |
289 | void IGESSolid_TopoBuilder::EndSolid () |
290 | { |
291 | EndLists(); |
292 | Handle(IGESSolid_HArray1OfShell) shells; |
293 | Handle(TColStd_HArray1OfInteger) flags; |
294 | Standard_Integer i, nb = thevoids->Length(); |
295 | if (nb > 0) { |
296 | shells = new IGESSolid_HArray1OfShell (1,nb); |
297 | flags = new TColStd_HArray1OfInteger (1,nb); flags->Init(0); |
298 | for (i = 1; i <= nb; i ++) { |
299 | shells->SetValue (i,GetCasted(IGESSolid_Shell,thevoids->Value(i))); |
300 | flags->SetValue (i,thevflag->Value(i)); |
301 | } |
302 | } |
303 | thesolid->Init (themains,themflag, shells,flags); |
304 | } |
305 | |
306 | Handle(IGESSolid_Shell) IGESSolid_TopoBuilder::Shell () const |
307 | { return theshell; } |
308 | |
309 | Handle(IGESSolid_ManifoldSolid) IGESSolid_TopoBuilder::Solid () const |
310 | { return thesolid; } |