0022735: Data races in BRepMesh working in parallel mode
[occt.git] / src / IFSelect / IFSelect_SelectSent.cxx
1 #include <IFSelect_SelectSent.ixx>
2 #include <stdio.h>
3
4
5     IFSelect_SelectSent::IFSelect_SelectSent
6   (const Standard_Integer sentcount, const Standard_Boolean atleast)
7       {  thecnt = sentcount;  thelst = atleast;  }
8
9     Standard_Integer  IFSelect_SelectSent::SentCount () const
10       {  return thecnt;  }
11
12     Standard_Boolean  IFSelect_SelectSent::AtLeast () const
13       {  return thelst;  }
14
15     Interface_EntityIterator IFSelect_SelectSent::RootResult
16   (const Interface_Graph& G) const
17 {
18   Standard_Boolean direct = IsDirect();
19   Interface_EntityIterator res;
20   Interface_EntityIterator inp = InputResult(G);
21
22   for (inp.Start(); inp.More(); inp.Next()) {
23     Standard_Integer num = G.EntityNumber(inp.Value());
24     if (num == 0) continue;
25     Standard_Integer nb = G.Status(num);   // nb sent
26     Standard_Boolean ok;
27     if (thecnt == 0)  ok = (nb == 0);
28     else if (thelst)  ok = (nb >= thecnt);
29     else              ok = (nb == thecnt);
30     if (ok == direct) res.AddItem (G.Entity(num));
31   }
32   return res;
33 }
34
35     Standard_Boolean  IFSelect_SelectSent::Sort
36   (const Standard_Integer ,
37    const Handle(Standard_Transient)&,
38    const Handle(Interface_InterfaceModel)& ) const
39       {  return Standard_False;  }
40
41
42     TCollection_AsciiString  IFSelect_SelectSent::ExtractLabel () const
43 {
44   char lb[80];
45   TCollection_AsciiString lab;
46   if (thecnt == 0) lab.AssignCat ("Remaining (non-sent) entities");
47   if (thecnt == 1 &&  thelst) lab.AssignCat ("Sent entities");
48   if (thecnt == 1 && !thelst) lab.AssignCat ("Sent once (non-duplicated) entities");
49   if (thecnt == 2 &&  thelst) lab.AssignCat ("Sent several times entities");
50   if (thecnt == 2 && !thelst) lab.AssignCat ("Sent just twice entities");
51   if (thecnt > 2) {
52     if (thelst) sprintf (lb,"Sent at least %d times entities", thecnt);
53     else        sprintf (lb,"Sent just %d times entities", thecnt);
54     lab.AssignCat (lb);
55   }
56   return lab;
57 }