0022934: Wrong delete operator in IGESSelect_SelectFromDrawing.cxx / IGESSelect_Selec...
[occt.git] / src / IGESSelect / IGESSelect_SelectBasicGeom.cxx
CommitLineData
7fd59977 1#include <IGESSelect_SelectBasicGeom.ixx>
2#include <IGESData_IGESEntity.hxx>
3#include <IGESGeom_Plane.hxx>
4#include <IGESGeom_CompositeCurve.hxx>
5#include <IGESGeom_CurveOnSurface.hxx>
6#include <IGESGeom_TrimmedSurface.hxx>
7#include <IGESGeom_BoundedSurface.hxx>
8#include <IGESGeom_Boundary.hxx>
9#include <IGESBasic_SingleParent.hxx>
10#include <IGESBasic_Group.hxx>
11#include <IGESSolid_ManifoldSolid.hxx>
12#include <IGESSolid_Shell.hxx>
13#include <IGESSolid_Face.hxx>
14#include <IGESSolid_Loop.hxx>
15#include <IGESSolid_EdgeList.hxx>
16
17#include <Interface_Macros.hxx>
18
19
20
21 IGESSelect_SelectBasicGeom::IGESSelect_SelectBasicGeom
22 (const Standard_Integer mode)
23 : IFSelect_SelectExplore (-1) { thegeom = mode; }
24
25 Standard_Boolean IGESSelect_SelectBasicGeom::Explore
26 (const Standard_Integer level, const Handle(Standard_Transient)& ent,
27 const Interface_Graph& G, Interface_EntityIterator& explored) const
28{
29// thegeom > 0 : curves3d < 0 : surfaces == 0 : curves3d + surfaces libres
30
31 DeclareAndCast(IGESData_IGESEntity,igesent,ent);
32 if (igesent.IsNull()) return Standard_False;
33 Standard_Integer igt = igesent->TypeNumber();
34
35// CompositeCurve : a decomposer ?
36 if (igt == 102 && thegeom == 2) {
37 DeclareAndCast(IGESGeom_CompositeCurve,cmc,ent);
38 Standard_Integer i, nb = cmc->NbCurves();
39 for (i = 1; i <= nb; i ++) explored.AddItem (cmc->Curve(i));
40 return Standard_True;
41 }
42
43// Lignes en general. Attention CopiousData, aux variantes "habillage"
44 if (igt == 106) return (igesent->FormNumber() < 20);
45 if ( (igt >= 100 && igt <= 106) || igt == 110 || igt == 112 || igt == 116 ||
46 igt == 126 || igt == 130) return (thegeom >= 0);
47
48// Surfaces LIBRES, car il n y a pas d autre moyen de les reperer
49// (l ideal serait de prendre les bords naturels)
50// Ou surfaces debarassees de leurs contours
51 if (igt == 114 || igt == 118 || igt == 120 || igt == 122 || igt == 128 || igt == 140 || igt == 190)
52 return (thegeom <= 0);
53
54// Plan 108
55// mode surface : on retourne tout le Plane sinon c est inexploitable
56 if (igt == 108) {
57 DeclareAndCast(IGESGeom_Plane,pln,ent);
58 if (thegeom >= 0) explored.AddItem(pln->BoundingCurve());
59 return pln->HasBoundingCurve();
60 }
61
62 if (igt == 116) return (thegeom >= 0); // on point, ca va bien ...
63
64// TrimmedSurface 144
65 if (igt == 144) {
66 DeclareAndCast(IGESGeom_TrimmedSurface,trs,ent);
67 if (thegeom >= 0) {
68 explored.AddItem(trs->OuterContour());
69 Standard_Integer i, nb = trs->NbInnerContours();
70 for (i = 1; i <= nb; i ++) explored.AddItem (trs->InnerContour(i));
71 }
72 else explored.AddItem (trs->Surface());
73 return Standard_True;
74 }
75
76// CurveOnSurface 142
77 if (igt == 142 && thegeom >= 0) {
78 DeclareAndCast(IGESGeom_CurveOnSurface,crf,ent);
79 explored.AddItem(crf->Curve3D());
80 return Standard_True;
81 }
82
83// Boundary 141
84 if (igt == 141 && thegeom >= 0) {
85 DeclareAndCast(IGESGeom_Boundary,bnd,ent);
86 Standard_Integer i, nb = bnd->NbModelSpaceCurves();
87 for (i = 1; i <= nb; i ++) explored.AddItem (bnd->ModelSpaceCurve(i));
88 return (nb > 0);
89 }
90
91// BoundedSurface 143
92 if (igt == 143) {
93 DeclareAndCast(IGESGeom_BoundedSurface,bns,ent);
94 Standard_Integer i, nb = 0;
95 if (thegeom >= 0) {
96 nb = bns->NbBoundaries();
97 for (i = 1; i <= nb; i ++) explored.AddItem (bns->Boundary(i));
98 return (nb != 0);
99 }
100 else explored.AddItem (bns->Surface());
101 return Standard_True;
102 }
103
104// SingleParent
105 if (igt == 402 && igesent->FormNumber() == 9) {
106 DeclareAndCast(IGESBasic_SingleParent,sp,ent);
107 if (sp.IsNull()) return Standard_False;
108 explored.AddItem (sp->SingleParent());
109 Standard_Integer i,nb = sp->NbChildren();
110 for (i = 1; i <= nb; i ++) explored.AddItem (sp->Child(i));
111 return Standard_True;
112 }
113
114// Groups ... en dernier de la serie 402
115 if (igt == 402) {
116 DeclareAndCast(IGESBasic_Group,gr,ent);
117 if (gr.IsNull()) return Standard_False;
118 Standard_Integer i, nb = gr->NbEntities();
119 for (i = 1; i <= nb; i ++) explored.AddItem (gr->Entity(i));
120 return Standard_True;
121 }
122
123// ManifoldSolid 186 -> Shells
124 if (igt == 186) {
125 DeclareAndCast(IGESSolid_ManifoldSolid,msb,ent);
126 explored.AddItem (msb->Shell());
127 Standard_Integer i, nb = msb->NbVoidShells();
128 for (i = 1; i <= nb; i ++) explored.AddItem (msb->VoidShell(i));
129 return Standard_True;
130 }
131
132// Shell 514 -> Faces
133 if (igt == 514) {
134 DeclareAndCast(IGESSolid_Shell,sh,ent);
135 Standard_Integer i, nb = sh->NbFaces();
136 for (i = 1; i <= nb; i ++) explored.AddItem (sh->Face(i));
137 return Standard_True;
138 }
139
140// Face 510 -> Loops
141 if (igt == 510) {
142 DeclareAndCast(IGESSolid_Face,fc,ent);
143 if (thegeom >= 0) {
144 Standard_Integer i, nb = fc->NbLoops();
145 for (i = 1; i <= nb; i ++) explored.AddItem (fc->Loop(i));
146 }
147 else explored.AddItem (fc->Surface());
148 return Standard_True;
149 }
150
151// Loop 508 -> Curves 3D (enfin !) mais via EdgeList ...
152 if (igt == 508 && thegeom >= 0) {
153 DeclareAndCast(IGESSolid_Loop,lp,ent);
154 Standard_Integer i, nb = lp->NbEdges();
155 for (i = 1; i <= nb; i ++) {
156 DeclareAndCast(IGESSolid_EdgeList,edl,lp->Edge(i));
157 Standard_Integer ind = lp->ListIndex(i);
158 if (edl.IsNull()) continue;
159 explored.AddItem(edl->Curve(ind));
160 }
161 return Standard_True;
162 }
163
164// Pas trouve
165 return Standard_False;
166}
167
168
169 TCollection_AsciiString IGESSelect_SelectBasicGeom::ExploreLabel () const
170{
171 if (thegeom == 2) return TCollection_AsciiString ("Basic Curves 3d");
172 else if (thegeom > 0) return TCollection_AsciiString ("Curves 3d");
173 else if (thegeom < 0) return TCollection_AsciiString ("Surfaces");
174 else return TCollection_AsciiString ("Basic Geometry");
175}
176
177
178 Standard_Boolean IGESSelect_SelectBasicGeom::SubCurves
179 (const Handle(IGESData_IGESEntity)& ent,
180 Interface_EntityIterator& explored)
181{
182 if (ent.IsNull()) return Standard_False;
183 Standard_Integer igt = ent->TypeNumber();
184
185// CompositeCurve : a decomposer ?
186 if (igt == 102) {
187 DeclareAndCast(IGESGeom_CompositeCurve,cmc,ent);
188 Standard_Integer i, nb = cmc->NbCurves();
189 for (i = 1; i <= nb; i ++) explored.AddItem (cmc->Curve(i));
190 return Standard_True;
191 }
192
193// Lignes en general. Attention CopiousData, aux variantes "habillage"
194 if (igt == 106) return (ent->FormNumber() < 20);
195 if ( (igt >= 100 && igt <= 106) || igt == 110 || igt == 112 || igt == 116 ||
196 igt == 126 || igt == 130) return Standard_True;
197
198// Sinon
199 return Standard_False;
200}