0024023: Revamp the OCCT Handle -- general
[occt.git] / src / IGESSelect / IGESSelect_SelectPCurves.cxx
CommitLineData
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_SelectPCurves.ixx>
15#include <IGESData_IGESEntity.hxx>
16#include <IGESGeom_CurveOnSurface.hxx>
17#include <IGESGeom_TrimmedSurface.hxx>
18#include <IGESGeom_BoundedSurface.hxx>
19#include <IGESGeom_Boundary.hxx>
20#include <IGESBasic_Group.hxx>
21#include <IGESSolid_ManifoldSolid.hxx>
22#include <IGESSolid_Shell.hxx>
23#include <IGESSolid_Face.hxx>
24#include <IGESSolid_Loop.hxx>
25#include <IGESSelect_SelectBasicGeom.hxx>
26
27#include <Interface_Macros.hxx>
28
b311480e 29IGESSelect_SelectPCurves::IGESSelect_SelectPCurves
7fd59977 30 (const Standard_Boolean basic)
31 : IFSelect_SelectExplore (-1) , thebasic (basic) { }
32
33
34 Standard_Boolean IGESSelect_SelectPCurves::Explore
35 (const Standard_Integer level, const Handle(Standard_Transient)& ent,
35e08fe8 36 const Interface_Graph& /*G*/, Interface_EntityIterator& explored) const
7fd59977 37{
38 DeclareAndCast(IGESData_IGESEntity,igesent,ent);
39 if (igesent.IsNull()) return Standard_False;
40 Standard_Integer igt = igesent->TypeNumber();
41
42// TrimmedSurface 144
43 if (igt == 144) {
44 DeclareAndCast(IGESGeom_TrimmedSurface,trs,ent);
45 explored.AddItem(trs->OuterContour());
46 Standard_Integer i, nb = trs->NbInnerContours();
47 for (i = 1; i <= nb; i ++) explored.AddItem (trs->InnerContour(i));
48 return Standard_True;
49 }
50
51// CurveOnSurface 142
52 if (igt == 142) {
53 DeclareAndCast(IGESGeom_CurveOnSurface,crf,ent);
54 explored.AddItem(crf->CurveUV());
55 if (thebasic) IGESSelect_SelectBasicGeom::SubCurves (crf->CurveUV(),explored);
56 return Standard_True;
57 }
58
59// Boundary 141
60 if (igt == 141) {
61 DeclareAndCast(IGESGeom_Boundary,bnd,ent);
62 Standard_Integer i, nb = bnd->NbModelSpaceCurves();
63 for (i = 1; i <= nb; i ++) {
64 Standard_Integer j,np = bnd->NbParameterCurves(i);
65 for (j = 1; j <= np; j ++) {
66 explored.AddItem (bnd->ParameterCurve(i,j));
67 }
68 }
69 return (nb > 0);
70 }
71
72// BoundedSurface 143
73 if (igt == 143) {
74 DeclareAndCast(IGESGeom_BoundedSurface,bns,ent);
75 Standard_Integer i, nb = bns->NbBoundaries(); //szv#4:S4163:12Mar99 optimized
76 for (i = 1; i <= nb; i ++) explored.AddItem (bns->Boundary(i));
77 return (nb != 0);
78 //return Standard_True; //szv#4:S4163:12Mar99 unreached
79 }
80
81
82// Groups ... en dernier de la serie 402
83 if (igt == 402) {
84 DeclareAndCast(IGESBasic_Group,gr,ent);
85 if (gr.IsNull()) return Standard_False;
86 Standard_Integer i, nb = gr->NbEntities();
87 for (i = 1; i <= nb; i ++) explored.AddItem (gr->Entity(i));
88 return Standard_True;
89 }
90
91
92// ManifoldSolid 186 -> Shells
93 if (igt == 186) {
94 DeclareAndCast(IGESSolid_ManifoldSolid,msb,ent);
95 explored.AddItem (msb->Shell());
96 Standard_Integer i, nb = msb->NbVoidShells();
97 for (i = 1; i <= nb; i ++) explored.AddItem (msb->VoidShell(i));
98 return Standard_True;
99 }
100
101// Shell 514 -> Faces
102 if (igt == 514) {
103 DeclareAndCast(IGESSolid_Shell,sh,ent);
104 Standard_Integer i, nb = sh->NbFaces();
105 for (i = 1; i <= nb; i ++) explored.AddItem (sh->Face(i));
106 return Standard_True;
107 }
108
109// Face 510 -> Loops
110 if (igt == 510) {
111 DeclareAndCast(IGESSolid_Face,fc,ent);
112 Standard_Integer i, nb = fc->NbLoops();
113 for (i = 1; i <= nb; i ++) explored.AddItem (fc->Loop(i));
114 return Standard_True;
115 }
116
117// Loop 508 -> PCurves (enfin !)
118 if (igt == 508) {
119 DeclareAndCast(IGESSolid_Loop,lp,ent);
120 Standard_Integer i, nb = lp->NbEdges();
121 for (i = 1; i <= nb; i ++) {
122 Standard_Integer j, np = lp->NbParameterCurves(i);
123 for (j = 1; j <= np; j ++) //szv#4:S4163:12Mar99 was bug
124 explored.AddItem(lp->ParametricCurve(i,j));
125 }
126 return Standard_True;
127 }
128
129// LES LIGNES : seult si en tant que pcurve : donc level >= 3
130// Lignes en general. Attention CopiousData, aux variantes "habillage"
131 if (level < 3) return Standard_False;
132
133 if (igt == 106) return (igesent->FormNumber() < 20);
134 if ( (igt >= 100 && igt <= 106) || igt == 110 || igt == 112 || igt == 116 ||
135 igt == 126 || igt == 130) return Standard_True;
136
137// Pas trouve
138 return Standard_False;
139}
140
141
142 TCollection_AsciiString IGESSelect_SelectPCurves::ExploreLabel () const
143{
144 if (thebasic) return TCollection_AsciiString ("Basic PCurves");
145 else return TCollection_AsciiString ("Global PCurves");
146}