0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / STEPSelections / STEPSelections_SelectGSCurves.cxx
1 // Created on: 1999-03-22
2 // Created by: data exchange team
3 // Copyright (c) 1999-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <Interface_EntityIterator.hxx>
19 #include <Interface_Graph.hxx>
20 #include <Standard_Transient.hxx>
21 #include <Standard_Type.hxx>
22 #include <StepGeom_CompositeCurve.hxx>
23 #include <StepGeom_CompositeCurveSegment.hxx>
24 #include <StepGeom_Curve.hxx>
25 #include <STEPSelections_SelectGSCurves.hxx>
26 #include <StepShape_GeometricSet.hxx>
27 #include <TCollection_AsciiString.hxx>
28
29 IMPLEMENT_STANDARD_RTTIEXT(STEPSelections_SelectGSCurves,IFSelect_SelectExplore)
30
31 static Standard_Integer flag;
32
33 STEPSelections_SelectGSCurves::STEPSelections_SelectGSCurves():IFSelect_SelectExplore (-1){ flag = 1;}
34      
35 Standard_Boolean STEPSelections_SelectGSCurves::Explore(const Standard_Integer /*level*/,
36                                                        const Handle(Standard_Transient)& start,
37                                                        const Interface_Graph& G,
38                                                        Interface_EntityIterator& explored) const
39 {
40   if(start.IsNull()) return Standard_False;
41   
42   if (start->IsKind(STANDARD_TYPE(StepGeom_Curve))) {
43     if(start->IsKind(STANDARD_TYPE(StepGeom_CompositeCurve))) {
44       Interface_EntityIterator subs = G.Sharings(start);
45       Standard_Boolean isInGeomSet = Standard_False;
46       for (subs.Start(); subs.More()&&!isInGeomSet; subs.Next()) 
47         if(subs.Value()->IsKind(STANDARD_TYPE(StepShape_GeometricSet))){
48           if(flag) {
49             explored.AddItem (subs.Value());
50             flag =0;
51           }
52           isInGeomSet = Standard_True; 
53         }
54       if(isInGeomSet) {
55         Interface_EntityIterator aSubsShareds = G.Shareds(start);
56         aSubsShareds.Start();
57         Standard_Boolean isSome = aSubsShareds.More();
58         for (; aSubsShareds.More(); aSubsShareds.Next())
59           explored.AddItem (aSubsShareds.Value());
60         return isSome;
61       } else
62         return Standard_False;
63     } else {
64       Interface_EntityIterator subs = G.Sharings(start);
65       for (subs.Start(); subs.More(); subs.Next()) {
66         if(subs.Value()->IsKind(STANDARD_TYPE(StepShape_GeometricSet))||
67            subs.Value()->IsKind(STANDARD_TYPE(StepGeom_CompositeCurveSegment)))
68           return Standard_True;
69       }
70     }
71   }
72   
73   Interface_EntityIterator subs = G.Shareds(start);
74   subs.Start();
75   Standard_Boolean isSome = subs.More();
76   for (; subs.More(); subs.Next()) 
77     explored.AddItem (subs.Value());
78   
79   return isSome;
80 }
81
82 TCollection_AsciiString STEPSelections_SelectGSCurves::ExploreLabel() const
83 {
84   return TCollection_AsciiString ("Curves in GS");
85 }