0024157: Parallelization of assembly part of BO
[occt.git] / src / IFSelect / IFSelect_SelectAnyList.cxx
CommitLineData
b311480e 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
7fd59977 18#include <IFSelect_SelectAnyList.ixx>
19#include <Interface_InterfaceError.hxx>
20#include <stdio.h>
21
22// .... Definition de liste : methodes "deferred" NbItems & FillResult
23
24
b311480e 25void IFSelect_SelectAnyList::SetRange
7fd59977 26 (const Handle(IFSelect_IntParam)& rankfrom,
27 const Handle(IFSelect_IntParam)& rankto)
28 { thelower = rankfrom; theupper = rankto; }
29
30 void IFSelect_SelectAnyList::SetOne (const Handle(IFSelect_IntParam)& rank)
31 { thelower = theupper = rank; }
32
33 void IFSelect_SelectAnyList::SetFrom
34 (const Handle(IFSelect_IntParam)& rankfrom)
35 { thelower = rankfrom; theupper.Nullify(); }
36
37 void IFSelect_SelectAnyList::SetUntil
38 (const Handle(IFSelect_IntParam)& rankto)
39 { thelower.Nullify(); theupper = rankto; }
40
41 Standard_Boolean IFSelect_SelectAnyList::HasLower () const
42 { return (!thelower.IsNull()); }
43
44 Handle(IFSelect_IntParam) IFSelect_SelectAnyList::Lower () const
45 { return thelower; }
46
47 Standard_Integer IFSelect_SelectAnyList::LowerValue () const
48{
49 if (thelower.IsNull()) return 0;
50 return thelower->Value();
51}
52
53 Standard_Boolean IFSelect_SelectAnyList::HasUpper () const
54 { return (!theupper.IsNull()); }
55
56 Handle(IFSelect_IntParam) IFSelect_SelectAnyList::Upper () const
57 { return theupper; }
58
59 Standard_Integer IFSelect_SelectAnyList::UpperValue () const
60{
61 if (theupper.IsNull()) return 0;
62 return theupper->Value();
63}
64
65// On prend les sous-entites de lower a upper (inclus)
66 Interface_EntityIterator IFSelect_SelectAnyList::RootResult
67 (const Interface_Graph& G) const
68{
69 Interface_EntityIterator input = InputResult(G);
70 KeepInputEntity (input); // selon type voulu
71 if (input.NbEntities() > 1) Interface_InterfaceError::Raise
72 ("SelectAnyList : more than ONE Entity in input");
73 if (input.NbEntities() == 0) return input;
74
75 Handle(Standard_Transient) ent;
76 for (input.Start(); input.More(); input.Next()) ent = input.Value();
77
78 Standard_Integer rankmax = NbItems(ent);
79 Standard_Integer rankfrom = 1;
80 if (!thelower.IsNull()) rankfrom = thelower->Value();
81 Standard_Integer rankto;
82 if (!theupper.IsNull()) rankto = theupper->Value();
83 else rankto = rankmax;
84 if (rankfrom < 1) rankfrom = 1;
85 if (rankto > rankmax) rankto = rankmax;
86
87 Interface_EntityIterator iter;
88 if (rankfrom <= rankto) FillResult(rankfrom,rankto,ent,iter);
89 return iter;
90}
91
92
93 TCollection_AsciiString IFSelect_SelectAnyList::Label () const
94{
95 char lab[30];
96 Standard_Integer rankfrom = 0;
97 if (HasLower()) rankfrom = LowerValue();
98 Standard_Integer rankto = 0;
99 if (HasUpper()) rankto = UpperValue();
100 if (rankfrom == rankto) sprintf(lab," (no %d)",rankfrom);
101 else if (rankfrom == 0) sprintf(lab," (-> %d)",rankfrom);
102 else if (rankto == 0) sprintf(lab," (%d ->)",rankto);
103 else sprintf(lab," (%d -> %d)",rankfrom,rankto);
104
105 TCollection_AsciiString labl("In List ");
106 labl.AssignCat(ListLabel());
107 labl.AssignCat(lab);
108 return labl;
109}