1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
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.
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.
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.
18 #include <IFSelect_SelectSuite.ixx>
19 #include <IFSelect_SelectPointed.hxx>
23 IFSelect_SelectSuite::IFSelect_SelectSuite () { }
25 Standard_Boolean IFSelect_SelectSuite::AddInput
26 (const Handle(IFSelect_Selection)& item)
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);
37 void IFSelect_SelectSuite::AddPrevious
38 (const Handle(IFSelect_SelectDeduct)& item)
39 { if (!item.IsNull()) thesel.Prepend (item); }
41 void IFSelect_SelectSuite::AddNext
42 (const Handle(IFSelect_SelectDeduct)& item)
43 { if (!item.IsNull()) thesel.Append (item); }
45 Standard_Integer IFSelect_SelectSuite::NbItems () const
46 { return thesel.Length(); }
48 Handle(IFSelect_SelectDeduct) IFSelect_SelectSuite::Item
49 (const Standard_Integer num) const
50 { return Handle(IFSelect_SelectDeduct)::DownCast(thesel.Value(num)); }
52 void IFSelect_SelectSuite::SetLabel (const Standard_CString lab)
53 { thelab.Clear(); thelab.AssignCat (lab); }
56 Interface_EntityIterator IFSelect_SelectSuite::RootResult
57 (const Interface_Graph& G) const
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
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);
75 TCollection_AsciiString IFSelect_SelectSuite::Label () const
77 if (thelab.Length() > 0) return thelab;
79 sprintf (txt,"Suite of %d Selections",NbItems());
80 TCollection_AsciiString lab(txt);