1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
15 #include <IFSelect_SelectDeduct.hxx>
16 #include <IFSelect_Selection.hxx>
17 #include <IFSelect_SelectPointed.hxx>
18 #include <IFSelect_SelectSuite.hxx>
19 #include <Interface_EntityIterator.hxx>
20 #include <Interface_Graph.hxx>
21 #include <Interface_InterfaceError.hxx>
22 #include <Standard_Type.hxx>
23 #include <TCollection_AsciiString.hxx>
26 IMPLEMENT_STANDARD_RTTIEXT(IFSelect_SelectSuite,IFSelect_SelectDeduct)
28 IFSelect_SelectSuite::IFSelect_SelectSuite () { }
30 Standard_Boolean IFSelect_SelectSuite::AddInput
31 (const Handle(IFSelect_Selection)& item)
33 if (item.IsNull()) return Standard_False;
34 Handle(IFSelect_Selection) input = Input();
35 if (!input.IsNull()) return Standard_False;
36 Handle(IFSelect_SelectDeduct) first = Handle(IFSelect_SelectDeduct)::DownCast(item);
37 if (first.IsNull()) SetInput(item);
38 else thesel.Prepend (item);
42 void IFSelect_SelectSuite::AddPrevious
43 (const Handle(IFSelect_SelectDeduct)& item)
44 { if (!item.IsNull()) thesel.Prepend (item); }
46 void IFSelect_SelectSuite::AddNext
47 (const Handle(IFSelect_SelectDeduct)& item)
48 { if (!item.IsNull()) thesel.Append (item); }
50 Standard_Integer IFSelect_SelectSuite::NbItems () const
51 { return thesel.Length(); }
53 Handle(IFSelect_SelectDeduct) IFSelect_SelectSuite::Item
54 (const Standard_Integer num) const
55 { return Handle(IFSelect_SelectDeduct)::DownCast(thesel.Value(num)); }
57 void IFSelect_SelectSuite::SetLabel (const Standard_CString lab)
58 { thelab.Clear(); thelab.AssignCat (lab); }
61 Interface_EntityIterator IFSelect_SelectSuite::RootResult
62 (const Interface_Graph& G) const
64 Interface_EntityIterator iter;
65 Standard_Boolean firstin = (HasInput() || HasAlternate());
66 if (firstin) iter = InputResult(G);
67 // Demarrage : on prend l Input/Alternate SI un des 2 est mis
68 // Sinon, on demarre sur la definition de base de la premiere selection
70 Standard_Integer i, nb = NbItems();
71 for (i = 1; i <= nb; i ++) {
72 Handle(IFSelect_SelectDeduct) anitem = Item(i);
73 if (firstin) anitem->Alternate()->SetList (iter.Content());
74 firstin = Standard_True; // ensuite c est systematique
75 iter = anitem->UniqueResult(G);
80 TCollection_AsciiString IFSelect_SelectSuite::Label () const
82 if (thelab.Length() > 0) return thelab;
84 sprintf (txt,"Suite of %d Selections",NbItems());
85 TCollection_AsciiString lab(txt);