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