1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
16 #include <IGESBasic_HArray1OfHArray1OfIGESEntity.hxx>
17 #include <IGESBasic_HArray1OfHArray1OfInteger.hxx>
18 #include <IGESData_HArray1OfIGESEntity.hxx>
19 #include <IGESData_IGESEntity.hxx>
20 #include <IGESSolid_EdgeList.hxx>
21 #include <IGESSolid_Face.hxx>
22 #include <IGESSolid_HArray1OfFace.hxx>
23 #include <IGESSolid_HArray1OfLoop.hxx>
24 #include <IGESSolid_HArray1OfShell.hxx>
25 #include <IGESSolid_HArray1OfVertexList.hxx>
26 #include <IGESSolid_Loop.hxx>
27 #include <IGESSolid_ManifoldSolid.hxx>
28 #include <IGESSolid_Shell.hxx>
29 #include <IGESSolid_TopoBuilder.hxx>
30 #include <IGESSolid_VertexList.hxx>
31 #include <Interface_Macros.hxx>
32 #include <Standard_DomainError.hxx>
33 #include <TColgp_HArray1OfXYZ.hxx>
34 #include <TColStd_HArray1OfInteger.hxx>
36 IGESSolid_TopoBuilder::IGESSolid_TopoBuilder () { Clear(); }
38 void IGESSolid_TopoBuilder::Clear ()
40 thesolid = new IGESSolid_ManifoldSolid;
41 thevoids = new TColStd_HSequenceOfTransient();
42 thevflag = new TColStd_HSequenceOfInteger();
43 theshell = new IGESSolid_Shell;
44 thefaces = new TColStd_HSequenceOfTransient();
45 thefflag = new TColStd_HSequenceOfInteger();
47 theinner = new TColStd_HSequenceOfTransient();
49 theetype = new TColStd_HSequenceOfInteger();
50 thee3d = new TColStd_HSequenceOfInteger();
51 theeflag = new TColStd_HSequenceOfInteger();
52 theeuv = new TColStd_HSequenceOfTransient();
53 theisol = new TColStd_HSequenceOfInteger();
54 thecuruv = new TColStd_HSequenceOfTransient();
55 theiso = new TColStd_HSequenceOfTransient();
56 theedgel = new IGESSolid_EdgeList;
57 thecur3d = new TColStd_HSequenceOfTransient();
58 thevstar = new TColStd_HSequenceOfInteger();
59 thevend = new TColStd_HSequenceOfInteger();
60 thevertl = new IGESSolid_VertexList;
61 thepoint = new TColgp_HSequenceOfXYZ();
64 void IGESSolid_TopoBuilder::AddVertex (const gp_XYZ& val)
65 { thepoint->Append(val); }
67 Standard_Integer IGESSolid_TopoBuilder::NbVertices () const
68 { return thepoint->Length(); }
70 const gp_XYZ& IGESSolid_TopoBuilder::Vertex
71 (const Standard_Integer num) const
72 { return thepoint->Value(num); }
74 Handle(IGESSolid_VertexList) IGESSolid_TopoBuilder::VertexList () const
78 void IGESSolid_TopoBuilder::AddEdge
79 (const Handle(IGESData_IGESEntity)& curve,
80 const Standard_Integer vstart, const Standard_Integer vend)
82 if (curve.IsNull() || vstart <= 0 || vend <= 0 ||
83 vstart > thepoint->Length() || vend > thepoint->Length())
84 throw Standard_DomainError("IGESSolid_TopoBuilder : AddEdge");
85 thecur3d->Append (curve);
86 thevstar->Append (vstart);
87 thevend->Append (vend);
90 Standard_Integer IGESSolid_TopoBuilder::NbEdges () const
91 { return thecur3d->Length(); }
93 void IGESSolid_TopoBuilder::Edge
94 (const Standard_Integer num,
95 Handle(IGESData_IGESEntity)& curve,
96 Standard_Integer& vstart, Standard_Integer& vend) const
98 if (num <= 0 || num > thecur3d->Length()) return;
99 curve = GetCasted(IGESData_IGESEntity,thecur3d->Value(num));
100 vstart = thevstar->Value(num);
101 vend = thevend->Value(num);
104 Handle(IGESSolid_EdgeList) IGESSolid_TopoBuilder::EdgeList () const
107 void IGESSolid_TopoBuilder::EndLists ()
109 Standard_Integer i,nb;
110 Handle(TColgp_HArray1OfXYZ) vert;
111 Handle(IGESData_HArray1OfIGESEntity) curves;
112 Handle(IGESSolid_HArray1OfVertexList) estart, eend;
113 Handle(TColStd_HArray1OfInteger) nstart, nend;
115 nb = thepoint->Length();
117 vert = new TColgp_HArray1OfXYZ (1,nb);
118 for (i = 1; i <= nb; i ++) vert->SetValue (i, thepoint->Value(i));
120 thevertl->Init (vert);
122 nb = thecur3d->Length();
124 curves = new IGESData_HArray1OfIGESEntity (1,nb);
125 nstart = new TColStd_HArray1OfInteger (1,nb); nstart->Init(0);
126 nend = new TColStd_HArray1OfInteger (1,nb); nend->Init(0);
127 estart = new IGESSolid_HArray1OfVertexList (1,nb);
128 eend = new IGESSolid_HArray1OfVertexList (1,nb);
129 for (i = 1; i <= nb; i ++) {
131 (i,GetCasted(IGESData_IGESEntity,thecur3d->Value(i)));
132 nstart->SetValue (i,thevstar->Value(i));
133 nend->SetValue (i,thevend->Value(i));
134 estart->SetValue (i,thevertl);
135 estart->SetValue (i,thevertl);
138 theedgel->Init (curves,estart,nstart,eend,nend);
141 void IGESSolid_TopoBuilder::MakeLoop ()
143 theloop = new IGESSolid_Loop;
144 theetype->Clear(); thee3d->Clear(); theeflag->Clear();
145 theeuv->Clear(); theisol->Clear();
148 void IGESSolid_TopoBuilder::MakeEdge
149 (const Standard_Integer edgetype, const Standard_Integer edge3d,
150 const Standard_Integer orientation)
152 if (edge3d <= 0 || edge3d > thecur3d->Length())
153 throw Standard_DomainError("IGESSolid_TopoBuilder : MakeEdge");
154 theetype->Append (edgetype);
155 thee3d->Append (edge3d);
156 theeflag->Append (orientation);
157 thecuruv->Clear(); theisol->Clear();
160 void IGESSolid_TopoBuilder::AddCurveUV
161 (const Handle(IGESData_IGESEntity)& curve, const Standard_Integer iso)
163 if (curve.IsNull() || thee3d->IsEmpty())
164 throw Standard_DomainError("IGESSolid_TopoBuilder : AddCurveUV");
165 thecuruv->Append(curve);
166 theisol->Append(iso);
169 void IGESSolid_TopoBuilder::EndEdge ()
171 // transformer thecuruv,theiso en array et le mettre dans theeuv
172 Handle(IGESData_HArray1OfIGESEntity) curuv;
173 Handle(TColStd_HArray1OfInteger) iso;
174 if (!thecuruv->IsEmpty()) {
175 Standard_Integer i, nb = thecuruv->Length();
176 curuv = new IGESData_HArray1OfIGESEntity (1,nb);
177 iso = new TColStd_HArray1OfInteger (1,nb); iso->Init(0);
178 for (i = 1; i <= nb; i ++) {
179 curuv->SetValue (i, GetCasted(IGESData_IGESEntity,thecuruv->Value(i)));
180 iso->SetValue (i, theisol->Value(i));
183 theeuv->Append(curuv);
186 void IGESSolid_TopoBuilder::EndLoop ()
188 Handle(TColStd_HArray1OfInteger) etypes, e3d, eflags, enbuv, eiso;
189 Handle(IGESData_HArray1OfIGESEntity) edges, curves;
190 Handle(IGESBasic_HArray1OfHArray1OfInteger) isol;
191 Handle(IGESBasic_HArray1OfHArray1OfIGESEntity) curvl;
192 Standard_Integer i, nb; //szv#4:S4163:12Mar99 nbuv not needed
193 nb = thee3d->Length();
195 etypes = new TColStd_HArray1OfInteger (1,nb);
196 e3d = new TColStd_HArray1OfInteger (1,nb);
197 eflags = new TColStd_HArray1OfInteger (1,nb);
198 enbuv = new TColStd_HArray1OfInteger (1,nb);
199 edges = new IGESData_HArray1OfIGESEntity (1,nb);
200 curvl = new IGESBasic_HArray1OfHArray1OfIGESEntity (1,nb);
201 isol = new IGESBasic_HArray1OfHArray1OfInteger (1,nb);
203 for (i = 1; i <= nb; i ++) {
204 etypes->SetValue (i, theetype->Value(i));
205 e3d->SetValue (i, thee3d->Value(i));
206 eflags->SetValue (i, theeflag->Value(i));
207 enbuv->SetValue (i,0);
208 edges->SetValue (i,theedgel);
209 curves = GetCasted(IGESData_HArray1OfIGESEntity,thecuruv->Value(i));
210 if (!curves.IsNull()) {
211 //nbuv = curves->Length(); //szv#4:S4163:12Mar99 not needed
212 enbuv->SetValue (i,nb);
213 curvl->SetValue (i,curves);
214 isol->SetValue (i,GetCasted(TColStd_HArray1OfInteger,theiso->Value(i)));
218 theloop->Init (etypes,edges,e3d,eflags,enbuv, isol,curvl);
222 void IGESSolid_TopoBuilder::MakeFace
223 (const Handle(IGESData_IGESEntity)& surface)
225 if (surface.IsNull())
226 throw Standard_DomainError("IGESSolid_TopoBuilder : MakeFace");
228 theouter = Standard_False;
230 theface = new IGESSolid_Face;
233 void IGESSolid_TopoBuilder::SetOuter ()
236 theouter = Standard_True;
237 theinner->Append (theloop);
241 void IGESSolid_TopoBuilder::AddInner ()
244 theinner->Append (theloop);
248 void IGESSolid_TopoBuilder::EndFace (const Standard_Integer orientation)
250 Handle(IGESSolid_HArray1OfLoop) loops;
251 Standard_Integer i, nb = theinner->Length();
253 loops = new IGESSolid_HArray1OfLoop (1,nb);
254 for (i = 1; i <= nb; i ++) loops->SetValue
255 (i, GetCasted(IGESSolid_Loop,theinner->Value(i)));
257 theface->Init (thesurf,theouter,loops);
258 thefaces->Append(theface);
259 thefflag->Append(orientation);
263 void IGESSolid_TopoBuilder::MakeShell ()
265 theshell = new IGESSolid_Shell;
270 void IGESSolid_TopoBuilder::EndShell ()
272 Handle(IGESSolid_HArray1OfFace) faces;
273 Handle(TColStd_HArray1OfInteger) flags;
274 Standard_Integer i, nb = thefaces->Length();
276 faces = new IGESSolid_HArray1OfFace ( 1,nb);
277 flags = new TColStd_HArray1OfInteger (1,nb); flags->Init(0);
278 for (i = 1; i <= nb; i ++) {
279 faces->SetValue (i,GetCasted(IGESSolid_Face,thefaces->Value(i)));
280 flags->SetValue (i, thefflag->Value(i));
283 theshell->Init (faces,flags);
286 void IGESSolid_TopoBuilder::EndSimpleShell ()
287 { EndShell(); EndLists(); }
289 void IGESSolid_TopoBuilder::SetMainShell
290 (const Standard_Integer orientation)
294 themflag = orientation != 0;
298 void IGESSolid_TopoBuilder::AddVoidShell
299 (const Standard_Integer orientation)
302 thevoids->Append (theshell);
303 thevflag->Append (orientation);
308 void IGESSolid_TopoBuilder::EndSolid ()
311 Handle(IGESSolid_HArray1OfShell) shells;
312 Handle(TColStd_HArray1OfInteger) flags;
313 Standard_Integer i, nb = thevoids->Length();
315 shells = new IGESSolid_HArray1OfShell (1,nb);
316 flags = new TColStd_HArray1OfInteger (1,nb); flags->Init(0);
317 for (i = 1; i <= nb; i ++) {
318 shells->SetValue (i,GetCasted(IGESSolid_Shell,thevoids->Value(i)));
319 flags->SetValue (i,thevflag->Value(i));
322 thesolid->Init (themains,themflag, shells,flags);
325 Handle(IGESSolid_Shell) IGESSolid_TopoBuilder::Shell () const
328 Handle(IGESSolid_ManifoldSolid) IGESSolid_TopoBuilder::Solid () const