0024947: Redesign OCCT legacy type system -- final corrections
[occt.git] / src / IFSelect / IFSelect_GraphCounter.cxx
CommitLineData
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_GraphCounter.ixx>
15#include <Interface_EntityIterator.hxx>
16#include <IFSelect_SelectPointed.hxx>
17#include <stdio.h>
18#include <string.h>
19
20
b311480e 21IFSelect_GraphCounter::IFSelect_GraphCounter
7fd59977 22 (const Standard_Boolean withmap, const Standard_Boolean withlist)
23 : IFSelect_SignCounter (withmap,withlist) { }
24
25 Handle(IFSelect_SelectDeduct) IFSelect_GraphCounter::Applied () const
26 { return theapplied; }
27
28 void IFSelect_GraphCounter::SetApplied
29 (const Handle(IFSelect_SelectDeduct)& applied)
30 { theapplied = applied; }
31
32 void IFSelect_GraphCounter::AddWithGraph
33 (const Handle(TColStd_HSequenceOfTransient)& list,
34 const Interface_Graph& graph)
35{
36 if (theapplied.IsNull()) { AddList (list,graph.Model()); return; }
37 if (list.IsNull()) return;
38 Standard_Integer i, nb = list->Length();
39 for (i = 1; i <= nb; i ++) {
40 char val[12];
41 Handle(Standard_Transient) ent = list->Value(i);
42 theapplied->Alternate()->SetEntity (ent);
43 Interface_EntityIterator iter = theapplied->UniqueResult(graph);
44 Standard_Integer n = iter.NbEntities();
45 switch (n) {
46 case 0: Add (ent,"0"); break;
47 case 1: Add (ent,"1"); break;
48 case 2: Add (ent,"2"); break;
49 case 3: Add (ent,"3"); break;
50 case 4: Add (ent,"4"); break;
51 case 5: Add (ent,"5"); break;
52 case 6: Add (ent,"6"); break;
53 case 7: Add (ent,"7"); break;
54 case 8: Add (ent,"8"); break;
55 case 9: Add (ent,"9"); break;
56 default :
57 sprintf (val,"%d",n);
58 Add (ent,val);
59 break;
60 }
61 }
62}