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_SelectSent.hxx>
16 #include <Interface_EntityIterator.hxx>
17 #include <Interface_Graph.hxx>
18 #include <Interface_InterfaceModel.hxx>
19 #include <Standard_Transient.hxx>
20 #include <Standard_Type.hxx>
21 #include <TCollection_AsciiString.hxx>
24 IMPLEMENT_STANDARD_RTTIEXT(IFSelect_SelectSent,IFSelect_SelectExtract)
26 IFSelect_SelectSent::IFSelect_SelectSent
27 (const Standard_Integer sentcount, const Standard_Boolean atleast)
28 { thecnt = sentcount; thelst = atleast; }
30 Standard_Integer IFSelect_SelectSent::SentCount () const
33 Standard_Boolean IFSelect_SelectSent::AtLeast () const
36 Interface_EntityIterator IFSelect_SelectSent::RootResult
37 (const Interface_Graph& G) const
39 Standard_Boolean direct = IsDirect();
40 Interface_EntityIterator res;
41 Interface_EntityIterator inp = InputResult(G);
43 for (inp.Start(); inp.More(); inp.Next()) {
44 Standard_Integer num = G.EntityNumber(inp.Value());
45 if (num == 0) continue;
46 Standard_Integer nb = G.Status(num); // nb sent
48 if (thecnt == 0) ok = (nb == 0);
49 else if (thelst) ok = (nb >= thecnt);
50 else ok = (nb == thecnt);
51 if (ok == direct) res.AddItem (G.Entity(num));
56 Standard_Boolean IFSelect_SelectSent::Sort
57 (const Standard_Integer ,
58 const Handle(Standard_Transient)&,
59 const Handle(Interface_InterfaceModel)& ) const
60 { return Standard_False; }
63 TCollection_AsciiString IFSelect_SelectSent::ExtractLabel () const
66 TCollection_AsciiString lab;
67 if (thecnt == 0) lab.AssignCat ("Remaining (non-sent) entities");
68 if (thecnt == 1 && thelst) lab.AssignCat ("Sent entities");
69 if (thecnt == 1 && !thelst) lab.AssignCat ("Sent once (non-duplicated) entities");
70 if (thecnt == 2 && thelst) lab.AssignCat ("Sent several times entities");
71 if (thecnt == 2 && !thelst) lab.AssignCat ("Sent just twice entities");
73 if (thelst) sprintf (lb,"Sent at least %d times entities", thecnt);
74 else sprintf (lb,"Sent just %d times entities", thecnt);