0026377: Passing Handle objects as arguments to functions as non-const reference...
[occt.git] / src / IFSelect / IFSelect_SelectSuite.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
42cf5bc1 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>
7fd59977 24
42cf5bc1 25#include <stdio.h>
92efcf78 26IMPLEMENT_STANDARD_RTTIEXT(IFSelect_SelectSuite,IFSelect_SelectDeduct)
27
7fd59977 28IFSelect_SelectSuite::IFSelect_SelectSuite () { }
29
30 Standard_Boolean IFSelect_SelectSuite::AddInput
31 (const Handle(IFSelect_Selection)& item)
32{
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);
39 return Standard_True;
40}
41
42 void IFSelect_SelectSuite::AddPrevious
43 (const Handle(IFSelect_SelectDeduct)& item)
44 { if (!item.IsNull()) thesel.Prepend (item); }
45
46 void IFSelect_SelectSuite::AddNext
47 (const Handle(IFSelect_SelectDeduct)& item)
48 { if (!item.IsNull()) thesel.Append (item); }
49
50 Standard_Integer IFSelect_SelectSuite::NbItems () const
51 { return thesel.Length(); }
52
53 Handle(IFSelect_SelectDeduct) IFSelect_SelectSuite::Item
54 (const Standard_Integer num) const
55 { return Handle(IFSelect_SelectDeduct)::DownCast(thesel.Value(num)); }
56
57 void IFSelect_SelectSuite::SetLabel (const Standard_CString lab)
58 { thelab.Clear(); thelab.AssignCat (lab); }
59
60
61 Interface_EntityIterator IFSelect_SelectSuite::RootResult
62 (const Interface_Graph& G) const
63{
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
69
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);
76 }
77 return iter;
78}
79
80 TCollection_AsciiString IFSelect_SelectSuite::Label () const
81{
82 if (thelab.Length() > 0) return thelab;
83 char txt[100];
84 sprintf (txt,"Suite of %d Selections",NbItems());
85 TCollection_AsciiString lab(txt);
86 return lab;
87}