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.
15 #include <IGESBasic_Group.hxx>
16 #include <IGESBasic_SingleParent.hxx>
17 #include <IGESData_IGESEntity.hxx>
18 #include <IGESGeom_Boundary.hxx>
19 #include <IGESGeom_BoundedSurface.hxx>
20 #include <IGESGeom_CompositeCurve.hxx>
21 #include <IGESGeom_CurveOnSurface.hxx>
22 #include <IGESGeom_Plane.hxx>
23 #include <IGESGeom_TrimmedSurface.hxx>
24 #include <IGESSelect_SelectBasicGeom.hxx>
25 #include <IGESSolid_EdgeList.hxx>
26 #include <IGESSolid_Face.hxx>
27 #include <IGESSolid_Loop.hxx>
28 #include <IGESSolid_ManifoldSolid.hxx>
29 #include <IGESSolid_Shell.hxx>
30 #include <Interface_EntityIterator.hxx>
31 #include <Interface_Graph.hxx>
32 #include <Interface_Macros.hxx>
33 #include <Standard_Transient.hxx>
34 #include <Standard_Type.hxx>
35 #include <TCollection_AsciiString.hxx>
37 IMPLEMENT_STANDARD_RTTIEXT(IGESSelect_SelectBasicGeom,IFSelect_SelectExplore)
39 IGESSelect_SelectBasicGeom::IGESSelect_SelectBasicGeom
40 (const Standard_Integer mode)
41 : IFSelect_SelectExplore (-1) { thegeom = mode; }
43 Standard_Boolean IGESSelect_SelectBasicGeom::Explore
44 (const Standard_Integer /*level*/, const Handle(Standard_Transient)& ent,
45 const Interface_Graph& /*G*/, Interface_EntityIterator& explored) const
47 // thegeom > 0 : curves3d < 0 : surfaces == 0 : curves3d + surfaces libres
49 DeclareAndCast(IGESData_IGESEntity,igesent,ent);
50 if (igesent.IsNull()) return Standard_False;
51 Standard_Integer igt = igesent->TypeNumber();
53 // CompositeCurve : a decomposer ?
54 if (igt == 102 && thegeom == 2) {
55 DeclareAndCast(IGESGeom_CompositeCurve,cmc,ent);
56 Standard_Integer i, nb = cmc->NbCurves();
57 for (i = 1; i <= nb; i ++) explored.AddItem (cmc->Curve(i));
61 // Lignes en general. Attention CopiousData, aux variantes "habillage"
62 if (igt == 106) return (igesent->FormNumber() < 20);
63 if ( (igt >= 100 && igt <= 106) || igt == 110 || igt == 112 || igt == 116 ||
64 igt == 126 || igt == 130) return (thegeom >= 0);
66 // Surfaces LIBRES, car il n y a pas d autre moyen de les reperer
67 // (l ideal serait de prendre les bords naturels)
68 // Ou surfaces debarassees de leurs contours
69 if (igt == 114 || igt == 118 || igt == 120 || igt == 122 || igt == 128 || igt == 140 || igt == 190)
70 return (thegeom <= 0);
73 // mode surface : on retourne tout le Plane sinon c est inexploitable
75 DeclareAndCast(IGESGeom_Plane,pln,ent);
76 if (thegeom >= 0) explored.AddItem(pln->BoundingCurve());
77 return pln->HasBoundingCurve();
80 if (igt == 116) return (thegeom >= 0); // on point, ca va bien ...
84 DeclareAndCast(IGESGeom_TrimmedSurface,trs,ent);
86 explored.AddItem(trs->OuterContour());
87 Standard_Integer i, nb = trs->NbInnerContours();
88 for (i = 1; i <= nb; i ++) explored.AddItem (trs->InnerContour(i));
90 else explored.AddItem (trs->Surface());
95 if (igt == 142 && thegeom >= 0) {
96 DeclareAndCast(IGESGeom_CurveOnSurface,crf,ent);
97 explored.AddItem(crf->Curve3D());
102 if (igt == 141 && thegeom >= 0) {
103 DeclareAndCast(IGESGeom_Boundary,bnd,ent);
104 Standard_Integer i, nb = bnd->NbModelSpaceCurves();
105 for (i = 1; i <= nb; i ++) explored.AddItem (bnd->ModelSpaceCurve(i));
109 // BoundedSurface 143
111 DeclareAndCast(IGESGeom_BoundedSurface,bns,ent);
112 Standard_Integer i, nb = 0;
114 nb = bns->NbBoundaries();
115 for (i = 1; i <= nb; i ++) explored.AddItem (bns->Boundary(i));
118 else explored.AddItem (bns->Surface());
119 return Standard_True;
123 if (igt == 402 && igesent->FormNumber() == 9) {
124 DeclareAndCast(IGESBasic_SingleParent,sp,ent);
125 if (sp.IsNull()) return Standard_False;
126 explored.AddItem (sp->SingleParent());
127 Standard_Integer i,nb = sp->NbChildren();
128 for (i = 1; i <= nb; i ++) explored.AddItem (sp->Child(i));
129 return Standard_True;
132 // Groups ... en dernier de la serie 402
134 DeclareAndCast(IGESBasic_Group,gr,ent);
135 if (gr.IsNull()) return Standard_False;
136 Standard_Integer i, nb = gr->NbEntities();
137 for (i = 1; i <= nb; i ++) explored.AddItem (gr->Entity(i));
138 return Standard_True;
141 // ManifoldSolid 186 -> Shells
143 DeclareAndCast(IGESSolid_ManifoldSolid,msb,ent);
144 explored.AddItem (msb->Shell());
145 Standard_Integer i, nb = msb->NbVoidShells();
146 for (i = 1; i <= nb; i ++) explored.AddItem (msb->VoidShell(i));
147 return Standard_True;
150 // Shell 514 -> Faces
152 DeclareAndCast(IGESSolid_Shell,sh,ent);
153 Standard_Integer i, nb = sh->NbFaces();
154 for (i = 1; i <= nb; i ++) explored.AddItem (sh->Face(i));
155 return Standard_True;
160 DeclareAndCast(IGESSolid_Face,fc,ent);
162 Standard_Integer i, nb = fc->NbLoops();
163 for (i = 1; i <= nb; i ++) explored.AddItem (fc->Loop(i));
165 else explored.AddItem (fc->Surface());
166 return Standard_True;
169 // Loop 508 -> Curves 3D (enfin !) mais via EdgeList ...
170 if (igt == 508 && thegeom >= 0) {
171 DeclareAndCast(IGESSolid_Loop,lp,ent);
172 Standard_Integer i, nb = lp->NbEdges();
173 for (i = 1; i <= nb; i ++) {
174 DeclareAndCast(IGESSolid_EdgeList,edl,lp->Edge(i));
175 Standard_Integer ind = lp->ListIndex(i);
176 if (edl.IsNull()) continue;
177 explored.AddItem(edl->Curve(ind));
179 return Standard_True;
183 return Standard_False;
187 TCollection_AsciiString IGESSelect_SelectBasicGeom::ExploreLabel () const
189 if (thegeom == 2) return TCollection_AsciiString ("Basic Curves 3d");
190 else if (thegeom > 0) return TCollection_AsciiString ("Curves 3d");
191 else if (thegeom < 0) return TCollection_AsciiString ("Surfaces");
192 else return TCollection_AsciiString ("Basic Geometry");
196 Standard_Boolean IGESSelect_SelectBasicGeom::SubCurves
197 (const Handle(IGESData_IGESEntity)& ent,
198 Interface_EntityIterator& explored)
200 if (ent.IsNull()) return Standard_False;
201 Standard_Integer igt = ent->TypeNumber();
203 // CompositeCurve : a decomposer ?
205 DeclareAndCast(IGESGeom_CompositeCurve,cmc,ent);
206 Standard_Integer i, nb = cmc->NbCurves();
207 for (i = 1; i <= nb; i ++) explored.AddItem (cmc->Curve(i));
208 return Standard_True;
211 // Lignes en general. Attention CopiousData, aux variantes "habillage"
212 if (igt == 106) return (ent->FormNumber() < 20);
213 if ( (igt >= 100 && igt <= 106) || igt == 110 || igt == 112 || igt == 116 ||
214 igt == 126 || igt == 130) return Standard_True;
217 return Standard_False;