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 | #include <IFSelect_SelectSent.ixx> |
15 | #include <stdio.h> |
16 | |
17 | |
b311480e |
18 | IFSelect_SelectSent::IFSelect_SelectSent |
7fd59977 |
19 | (const Standard_Integer sentcount, const Standard_Boolean atleast) |
20 | { thecnt = sentcount; thelst = atleast; } |
21 | |
22 | Standard_Integer IFSelect_SelectSent::SentCount () const |
23 | { return thecnt; } |
24 | |
25 | Standard_Boolean IFSelect_SelectSent::AtLeast () const |
26 | { return thelst; } |
27 | |
28 | Interface_EntityIterator IFSelect_SelectSent::RootResult |
29 | (const Interface_Graph& G) const |
30 | { |
31 | Standard_Boolean direct = IsDirect(); |
32 | Interface_EntityIterator res; |
33 | Interface_EntityIterator inp = InputResult(G); |
34 | |
35 | for (inp.Start(); inp.More(); inp.Next()) { |
36 | Standard_Integer num = G.EntityNumber(inp.Value()); |
37 | if (num == 0) continue; |
38 | Standard_Integer nb = G.Status(num); // nb sent |
39 | Standard_Boolean ok; |
40 | if (thecnt == 0) ok = (nb == 0); |
41 | else if (thelst) ok = (nb >= thecnt); |
42 | else ok = (nb == thecnt); |
43 | if (ok == direct) res.AddItem (G.Entity(num)); |
44 | } |
45 | return res; |
46 | } |
47 | |
48 | Standard_Boolean IFSelect_SelectSent::Sort |
49 | (const Standard_Integer , |
50 | const Handle(Standard_Transient)&, |
51 | const Handle(Interface_InterfaceModel)& ) const |
52 | { return Standard_False; } |
53 | |
54 | |
55 | TCollection_AsciiString IFSelect_SelectSent::ExtractLabel () const |
56 | { |
57 | char lb[80]; |
58 | TCollection_AsciiString lab; |
59 | if (thecnt == 0) lab.AssignCat ("Remaining (non-sent) entities"); |
60 | if (thecnt == 1 && thelst) lab.AssignCat ("Sent entities"); |
61 | if (thecnt == 1 && !thelst) lab.AssignCat ("Sent once (non-duplicated) entities"); |
62 | if (thecnt == 2 && thelst) lab.AssignCat ("Sent several times entities"); |
63 | if (thecnt == 2 && !thelst) lab.AssignCat ("Sent just twice entities"); |
64 | if (thecnt > 2) { |
65 | if (thelst) sprintf (lb,"Sent at least %d times entities", thecnt); |
66 | else sprintf (lb,"Sent just %d times entities", thecnt); |
67 | lab.AssignCat (lb); |
68 | } |
69 | return lab; |
70 | } |