0023687: Two opposite conditions. The second condition is always false in ifselect_sh...
[occt.git] / src / IFSelect / IFSelect_SelectSuite.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_SelectSuite.ixx>
19#include <IFSelect_SelectPointed.hxx>
20#include <stdio.h>
21
22
23IFSelect_SelectSuite::IFSelect_SelectSuite () { }
24
25 Standard_Boolean IFSelect_SelectSuite::AddInput
26 (const Handle(IFSelect_Selection)& item)
27{
28 if (item.IsNull()) return Standard_False;
29 Handle(IFSelect_Selection) input = Input();
30 if (!input.IsNull()) return Standard_False;
31 Handle(IFSelect_SelectDeduct) first = Handle(IFSelect_SelectDeduct)::DownCast(item);
32 if (first.IsNull()) SetInput(item);
33 else thesel.Prepend (item);
34 return Standard_True;
35}
36
37 void IFSelect_SelectSuite::AddPrevious
38 (const Handle(IFSelect_SelectDeduct)& item)
39 { if (!item.IsNull()) thesel.Prepend (item); }
40
41 void IFSelect_SelectSuite::AddNext
42 (const Handle(IFSelect_SelectDeduct)& item)
43 { if (!item.IsNull()) thesel.Append (item); }
44
45 Standard_Integer IFSelect_SelectSuite::NbItems () const
46 { return thesel.Length(); }
47
48 Handle(IFSelect_SelectDeduct) IFSelect_SelectSuite::Item
49 (const Standard_Integer num) const
50 { return Handle(IFSelect_SelectDeduct)::DownCast(thesel.Value(num)); }
51
52 void IFSelect_SelectSuite::SetLabel (const Standard_CString lab)
53 { thelab.Clear(); thelab.AssignCat (lab); }
54
55
56 Interface_EntityIterator IFSelect_SelectSuite::RootResult
57 (const Interface_Graph& G) const
58{
59 Interface_EntityIterator iter;
60 Standard_Boolean firstin = (HasInput() || HasAlternate());
61 if (firstin) iter = InputResult(G);
62// Demarrage : on prend l Input/Alternate SI un des 2 est mis
63// Sinon, on demarre sur la definition de base de la premiere selection
64
65 Standard_Integer i, nb = NbItems();
66 for (i = 1; i <= nb; i ++) {
67 Handle(IFSelect_SelectDeduct) anitem = Item(i);
68 if (firstin) anitem->Alternate()->SetList (iter.Content());
69 firstin = Standard_True; // ensuite c est systematique
70 iter = anitem->UniqueResult(G);
71 }
72 return iter;
73}
74
75 TCollection_AsciiString IFSelect_SelectSuite::Label () const
76{
77 if (thelab.Length() > 0) return thelab;
78 char txt[100];
79 sprintf (txt,"Suite of %d Selections",NbItems());
80 TCollection_AsciiString lab(txt);
81 return lab;
82}