0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / IGESSelect / IGESSelect_SelectLevelNumber.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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
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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
15 #include <IFSelect_IntParam.hxx>
16 #include <IGESData_IGESEntity.hxx>
17 #include <IGESGraph_DefinitionLevel.hxx>
18 #include <IGESSelect_SelectLevelNumber.hxx>
19 #include <Interface_InterfaceModel.hxx>
20 #include <Interface_Macros.hxx>
21 #include <Standard_Transient.hxx>
22 #include <Standard_Type.hxx>
23 #include <TCollection_AsciiString.hxx>
24
25 #include <stdio.h>
26 IMPLEMENT_STANDARD_RTTIEXT(IGESSelect_SelectLevelNumber,IFSelect_SelectExtract)
27
28 IGESSelect_SelectLevelNumber::IGESSelect_SelectLevelNumber ()    {  }
29
30
31     void  IGESSelect_SelectLevelNumber::SetLevelNumber
32   (const Handle(IFSelect_IntParam)& levnum)
33       {  thelevnum = levnum;  }
34
35     Handle(IFSelect_IntParam)  IGESSelect_SelectLevelNumber::LevelNumber () const
36       {  return thelevnum;  }
37
38
39     Standard_Boolean  IGESSelect_SelectLevelNumber::Sort
40   (const Standard_Integer /*rank*/, 
41    const Handle(Standard_Transient)& ent,
42    const Handle(Interface_InterfaceModel)& /*model*/) const
43 {
44   DeclareAndCast(IGESData_IGESEntity,igesent,ent);
45   if (igesent.IsNull()) return Standard_False;
46   Standard_Integer numlev = 0;
47   if (!thelevnum.IsNull()) numlev = thelevnum->Value();
48   DeclareAndCast(IGESGraph_DefinitionLevel,levelist,igesent->LevelList());
49   Standard_Integer level = igesent->Level();
50   if (levelist.IsNull()) return (level == numlev);
51 //  Cas d une liste
52   if (numlev == 0) return Standard_False;
53   Standard_Integer nb = levelist->NbPropertyValues();
54   for (Standard_Integer i = 1; i <= nb; i ++) {
55     level = levelist->LevelNumber(i);
56     if (level == numlev) return Standard_True;
57   }
58   return Standard_False;
59 }
60
61
62     TCollection_AsciiString  IGESSelect_SelectLevelNumber::ExtractLabel
63   () const
64 {
65   char labl [50];
66   Standard_Integer numlev = 0;
67   if (!thelevnum.IsNull()) numlev = thelevnum->Value();
68   if (numlev == 0) return TCollection_AsciiString
69     ("IGES Entity attached to no Level");
70
71   sprintf(labl,"IGES Entity, Level Number admitting %d",numlev);
72   return TCollection_AsciiString (labl);
73 }