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