1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
18 #include <IGESSelect_SelectBasicGeom.ixx>
19 #include <IGESData_IGESEntity.hxx>
20 #include <IGESGeom_Plane.hxx>
21 #include <IGESGeom_CompositeCurve.hxx>
22 #include <IGESGeom_CurveOnSurface.hxx>
23 #include <IGESGeom_TrimmedSurface.hxx>
24 #include <IGESGeom_BoundedSurface.hxx>
25 #include <IGESGeom_Boundary.hxx>
26 #include <IGESBasic_SingleParent.hxx>
27 #include <IGESBasic_Group.hxx>
28 #include <IGESSolid_ManifoldSolid.hxx>
29 #include <IGESSolid_Shell.hxx>
30 #include <IGESSolid_Face.hxx>
31 #include <IGESSolid_Loop.hxx>
32 #include <IGESSolid_EdgeList.hxx>
34 #include <Interface_Macros.hxx>
38 IGESSelect_SelectBasicGeom::IGESSelect_SelectBasicGeom
39 (const Standard_Integer mode)
40 : IFSelect_SelectExplore (-1) { thegeom = mode; }
42 Standard_Boolean IGESSelect_SelectBasicGeom::Explore
43 (const Standard_Integer level, const Handle(Standard_Transient)& ent,
44 const Interface_Graph& G, Interface_EntityIterator& explored) const
46 // thegeom > 0 : curves3d < 0 : surfaces == 0 : curves3d + surfaces libres
48 DeclareAndCast(IGESData_IGESEntity,igesent,ent);
49 if (igesent.IsNull()) return Standard_False;
50 Standard_Integer igt = igesent->TypeNumber();
52 // CompositeCurve : a decomposer ?
53 if (igt == 102 && thegeom == 2) {
54 DeclareAndCast(IGESGeom_CompositeCurve,cmc,ent);
55 Standard_Integer i, nb = cmc->NbCurves();
56 for (i = 1; i <= nb; i ++) explored.AddItem (cmc->Curve(i));
60 // Lignes en general. Attention CopiousData, aux variantes "habillage"
61 if (igt == 106) return (igesent->FormNumber() < 20);
62 if ( (igt >= 100 && igt <= 106) || igt == 110 || igt == 112 || igt == 116 ||
63 igt == 126 || igt == 130) return (thegeom >= 0);
65 // Surfaces LIBRES, car il n y a pas d autre moyen de les reperer
66 // (l ideal serait de prendre les bords naturels)
67 // Ou surfaces debarassees de leurs contours
68 if (igt == 114 || igt == 118 || igt == 120 || igt == 122 || igt == 128 || igt == 140 || igt == 190)
69 return (thegeom <= 0);
72 // mode surface : on retourne tout le Plane sinon c est inexploitable
74 DeclareAndCast(IGESGeom_Plane,pln,ent);
75 if (thegeom >= 0) explored.AddItem(pln->BoundingCurve());
76 return pln->HasBoundingCurve();
79 if (igt == 116) return (thegeom >= 0); // on point, ca va bien ...
83 DeclareAndCast(IGESGeom_TrimmedSurface,trs,ent);
85 explored.AddItem(trs->OuterContour());
86 Standard_Integer i, nb = trs->NbInnerContours();
87 for (i = 1; i <= nb; i ++) explored.AddItem (trs->InnerContour(i));
89 else explored.AddItem (trs->Surface());
94 if (igt == 142 && thegeom >= 0) {
95 DeclareAndCast(IGESGeom_CurveOnSurface,crf,ent);
96 explored.AddItem(crf->Curve3D());
101 if (igt == 141 && thegeom >= 0) {
102 DeclareAndCast(IGESGeom_Boundary,bnd,ent);
103 Standard_Integer i, nb = bnd->NbModelSpaceCurves();
104 for (i = 1; i <= nb; i ++) explored.AddItem (bnd->ModelSpaceCurve(i));
108 // BoundedSurface 143
110 DeclareAndCast(IGESGeom_BoundedSurface,bns,ent);
111 Standard_Integer i, nb = 0;
113 nb = bns->NbBoundaries();
114 for (i = 1; i <= nb; i ++) explored.AddItem (bns->Boundary(i));
117 else explored.AddItem (bns->Surface());
118 return Standard_True;
122 if (igt == 402 && igesent->FormNumber() == 9) {
123 DeclareAndCast(IGESBasic_SingleParent,sp,ent);
124 if (sp.IsNull()) return Standard_False;
125 explored.AddItem (sp->SingleParent());
126 Standard_Integer i,nb = sp->NbChildren();
127 for (i = 1; i <= nb; i ++) explored.AddItem (sp->Child(i));
128 return Standard_True;
131 // Groups ... en dernier de la serie 402
133 DeclareAndCast(IGESBasic_Group,gr,ent);
134 if (gr.IsNull()) return Standard_False;
135 Standard_Integer i, nb = gr->NbEntities();
136 for (i = 1; i <= nb; i ++) explored.AddItem (gr->Entity(i));
137 return Standard_True;
140 // ManifoldSolid 186 -> Shells
142 DeclareAndCast(IGESSolid_ManifoldSolid,msb,ent);
143 explored.AddItem (msb->Shell());
144 Standard_Integer i, nb = msb->NbVoidShells();
145 for (i = 1; i <= nb; i ++) explored.AddItem (msb->VoidShell(i));
146 return Standard_True;
149 // Shell 514 -> Faces
151 DeclareAndCast(IGESSolid_Shell,sh,ent);
152 Standard_Integer i, nb = sh->NbFaces();
153 for (i = 1; i <= nb; i ++) explored.AddItem (sh->Face(i));
154 return Standard_True;
159 DeclareAndCast(IGESSolid_Face,fc,ent);
161 Standard_Integer i, nb = fc->NbLoops();
162 for (i = 1; i <= nb; i ++) explored.AddItem (fc->Loop(i));
164 else explored.AddItem (fc->Surface());
165 return Standard_True;
168 // Loop 508 -> Curves 3D (enfin !) mais via EdgeList ...
169 if (igt == 508 && thegeom >= 0) {
170 DeclareAndCast(IGESSolid_Loop,lp,ent);
171 Standard_Integer i, nb = lp->NbEdges();
172 for (i = 1; i <= nb; i ++) {
173 DeclareAndCast(IGESSolid_EdgeList,edl,lp->Edge(i));
174 Standard_Integer ind = lp->ListIndex(i);
175 if (edl.IsNull()) continue;
176 explored.AddItem(edl->Curve(ind));
178 return Standard_True;
182 return Standard_False;
186 TCollection_AsciiString IGESSelect_SelectBasicGeom::ExploreLabel () const
188 if (thegeom == 2) return TCollection_AsciiString ("Basic Curves 3d");
189 else if (thegeom > 0) return TCollection_AsciiString ("Curves 3d");
190 else if (thegeom < 0) return TCollection_AsciiString ("Surfaces");
191 else return TCollection_AsciiString ("Basic Geometry");
195 Standard_Boolean IGESSelect_SelectBasicGeom::SubCurves
196 (const Handle(IGESData_IGESEntity)& ent,
197 Interface_EntityIterator& explored)
199 if (ent.IsNull()) return Standard_False;
200 Standard_Integer igt = ent->TypeNumber();
202 // CompositeCurve : a decomposer ?
204 DeclareAndCast(IGESGeom_CompositeCurve,cmc,ent);
205 Standard_Integer i, nb = cmc->NbCurves();
206 for (i = 1; i <= nb; i ++) explored.AddItem (cmc->Curve(i));
207 return Standard_True;
210 // Lignes en general. Attention CopiousData, aux variantes "habillage"
211 if (igt == 106) return (ent->FormNumber() < 20);
212 if ( (igt >= 100 && igt <= 106) || igt == 110 || igt == 112 || igt == 116 ||
213 igt == 126 || igt == 130) return Standard_True;
216 return Standard_False;