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