1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
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>
26 IMPLEMENT_STANDARD_RTTIEXT(IGESSelect_SelectLevelNumber,IFSelect_SelectExtract)
28 IGESSelect_SelectLevelNumber::IGESSelect_SelectLevelNumber () { }
31 void IGESSelect_SelectLevelNumber::SetLevelNumber
32 (const Handle(IFSelect_IntParam)& levnum)
33 { thelevnum = levnum; }
35 Handle(IFSelect_IntParam) IGESSelect_SelectLevelNumber::LevelNumber () const
39 Standard_Boolean IGESSelect_SelectLevelNumber::Sort
40 (const Standard_Integer /*rank*/,
41 const Handle(Standard_Transient)& ent,
42 const Handle(Interface_InterfaceModel)& /*model*/) const
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);
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;
58 return Standard_False;
62 TCollection_AsciiString IGESSelect_SelectLevelNumber::ExtractLabel
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");
71 sprintf(labl,"IGES Entity, Level Number admitting %d",numlev);
72 return TCollection_AsciiString (labl);