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