0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / IFSelect / IFSelect_SelectRootComps.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
15 #include <IFGraph_Cumulate.hxx>
16 #include <IFGraph_StrongComponants.hxx>
17 #include <IFSelect_SelectRootComps.hxx>
18 #include <Interface_EntityIterator.hxx>
19 #include <Interface_Graph.hxx>
20 #include <Interface_InterfaceModel.hxx>
21 #include <Standard_Transient.hxx>
22 #include <Standard_Type.hxx>
23 #include <TCollection_AsciiString.hxx>
24
25 IMPLEMENT_STANDARD_RTTIEXT(IFSelect_SelectRootComps,IFSelect_SelectExtract)
26
27 IFSelect_SelectRootComps::IFSelect_SelectRootComps ()    {  }
28
29
30 // Refait pour travailler en une fois
31 // ATTENTION, il ne faut pas s interesser aux ENTITES mais aux COMPOSANTS
32 // c-a-d gerer les CYCLES s il y en a
33
34     Interface_EntityIterator  IFSelect_SelectRootComps::RootResult
35   (const Interface_Graph& G) const
36 {
37   Interface_EntityIterator IEIinput = InputResult(G);
38   Interface_EntityIterator iter;
39 //  ICI, extraire les Componants, puis considerer une Entite de chacun
40   IFGraph_StrongComponants comps(G,Standard_False);
41   comps.SetLoad();
42   comps.GetFromIter(IEIinput);
43   Interface_EntityIterator inp1;  // IEIinput reduit a une Entite par Composant
44
45   IFGraph_Cumulate GC(G);
46
47 //  On note dans le graphe : le cumul de chaque ensemble (Entite + Shared tous
48 //  niveaux). Les Roots initiales comptees une seule fois sont bonnes
49 //  Pour Entite : une par Componant (peu importe)
50   for (comps.Start(); comps.More(); comps.Next()) {
51     Handle(Standard_Transient) ent = comps.FirstEntity();
52     GC.GetFromEntity(ent);
53     inp1.GetOneItem(ent);
54   }
55 //  A present, on retient, parmi les inputs, celles comptees une seule fois
56 //  (N.B.: on prend inp1, qui donne UNE entite par composant, simple ou cycle)
57   for (inp1.Start(); inp1.More(); inp1.Next()) {
58     Handle(Standard_Transient) ent = inp1.Value();
59     if ((GC.NbTimes(ent) <= 1) == IsDirect()) iter.GetOneItem(ent);
60   }
61   return iter;
62 }
63
64     Standard_Boolean  IFSelect_SelectRootComps::HasUniqueResult () const
65       {  return Standard_True;  }
66
67
68     Standard_Boolean  IFSelect_SelectRootComps::Sort
69   (const Standard_Integer , const Handle(Standard_Transient)& ,
70    const Handle(Interface_InterfaceModel)& ) const 
71       {  return Standard_True;  }
72
73     TCollection_AsciiString  IFSelect_SelectRootComps::ExtractLabel () const 
74 {  return TCollection_AsciiString("Local Root Componants");  }