0023024: Update headers of OCCT files
[occt.git] / src / IFSelect / IFSelect_SelectSent.cxx
CommitLineData
b311480e 1// Copyright (c) 1999-2012 OPEN CASCADE SAS
2//
3// The content of this file is subject to the Open CASCADE Technology Public
4// License Version 6.5 (the "License"). You may not use the content of this file
5// except in compliance with the License. Please obtain a copy of the License
6// at http://www.opencascade.org and read it completely before using this file.
7//
8// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10//
11// The Original Code and all software distributed under the License is
12// distributed on an "AS IS" basis, without warranty of any kind, and the
13// Initial Developer hereby disclaims all such warranties, including without
14// limitation, any warranties of merchantability, fitness for a particular
15// purpose or non-infringement. Please see the License for the specific terms
16// and conditions governing the rights and limitations under the License.
17
7fd59977 18#include <IFSelect_SelectSent.ixx>
19#include <stdio.h>
20
21
b311480e 22IFSelect_SelectSent::IFSelect_SelectSent
7fd59977 23 (const Standard_Integer sentcount, const Standard_Boolean atleast)
24 { thecnt = sentcount; thelst = atleast; }
25
26 Standard_Integer IFSelect_SelectSent::SentCount () const
27 { return thecnt; }
28
29 Standard_Boolean IFSelect_SelectSent::AtLeast () const
30 { return thelst; }
31
32 Interface_EntityIterator IFSelect_SelectSent::RootResult
33 (const Interface_Graph& G) const
34{
35 Standard_Boolean direct = IsDirect();
36 Interface_EntityIterator res;
37 Interface_EntityIterator inp = InputResult(G);
38
39 for (inp.Start(); inp.More(); inp.Next()) {
40 Standard_Integer num = G.EntityNumber(inp.Value());
41 if (num == 0) continue;
42 Standard_Integer nb = G.Status(num); // nb sent
43 Standard_Boolean ok;
44 if (thecnt == 0) ok = (nb == 0);
45 else if (thelst) ok = (nb >= thecnt);
46 else ok = (nb == thecnt);
47 if (ok == direct) res.AddItem (G.Entity(num));
48 }
49 return res;
50}
51
52 Standard_Boolean IFSelect_SelectSent::Sort
53 (const Standard_Integer ,
54 const Handle(Standard_Transient)&,
55 const Handle(Interface_InterfaceModel)& ) const
56 { return Standard_False; }
57
58
59 TCollection_AsciiString IFSelect_SelectSent::ExtractLabel () const
60{
61 char lb[80];
62 TCollection_AsciiString lab;
63 if (thecnt == 0) lab.AssignCat ("Remaining (non-sent) entities");
64 if (thecnt == 1 && thelst) lab.AssignCat ("Sent entities");
65 if (thecnt == 1 && !thelst) lab.AssignCat ("Sent once (non-duplicated) entities");
66 if (thecnt == 2 && thelst) lab.AssignCat ("Sent several times entities");
67 if (thecnt == 2 && !thelst) lab.AssignCat ("Sent just twice entities");
68 if (thecnt > 2) {
69 if (thelst) sprintf (lb,"Sent at least %d times entities", thecnt);
70 else sprintf (lb,"Sent just %d times entities", thecnt);
71 lab.AssignCat (lb);
72 }
73 return lab;
74}