0026377: Passing Handle objects as arguments to functions as non-const reference...
[occt.git] / src / IFSelect / IFSelect_SelectDeduct.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
15 #include <IFSelect_SelectDeduct.hxx>
16 #include <IFSelect_Selection.hxx>
17 #include <IFSelect_SelectionIterator.hxx>
18 #include <IFSelect_SelectPointed.hxx>
19 #include <Interface_EntityIterator.hxx>
20 #include <Interface_Graph.hxx>
21 #include <Interface_InterfaceError.hxx>
22 #include <Standard_Type.hxx>
23
24 IMPLEMENT_STANDARD_RTTIEXT(IFSelect_SelectDeduct,IFSelect_Selection)
25
26 void  IFSelect_SelectDeduct::SetInput (const Handle(IFSelect_Selection)& sel)
27       {  thesel = sel;  }
28
29     Handle(IFSelect_Selection)  IFSelect_SelectDeduct::Input () const 
30       {  return thesel;  }
31
32     Standard_Boolean  IFSelect_SelectDeduct::HasInput () const 
33       {  return (!thesel.IsNull());  }
34
35     Standard_Boolean  IFSelect_SelectDeduct::HasAlternate () const 
36 {  if (!thealt.IsNull()) return thealt->IsSet();  return Standard_False;  }
37
38     Handle(IFSelect_SelectPointed)&  IFSelect_SelectDeduct::Alternate ()
39 {
40   if (thealt.IsNull()) thealt = new IFSelect_SelectPointed;
41   return thealt;
42 }
43
44
45     Interface_EntityIterator  IFSelect_SelectDeduct::InputResult
46   (const Interface_Graph& G) const
47 {
48   Interface_EntityIterator res;
49   if (!thealt.IsNull()) {
50     if (thealt->IsSet()) {
51       res = thealt->UniqueResult (G);
52       thealt->Clear();
53       return res;
54     }
55   }
56   if (thesel.IsNull()) return res;
57   return  thesel->UniqueResult(G);
58 }
59
60     void  IFSelect_SelectDeduct::FillIterator
61   (IFSelect_SelectionIterator& iter) const 
62       {  iter.AddItem(thesel);  }