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_IntParam.hxx> |
7fd59977 |
16 | #include <IGESData_IGESEntity.hxx> |
17 | #include <IGESGraph_DefinitionLevel.hxx> |
42cf5bc1 |
18 | #include <IGESSelect_SelectLevelNumber.hxx> |
19 | #include <Interface_InterfaceModel.hxx> |
7fd59977 |
20 | #include <Interface_Macros.hxx> |
42cf5bc1 |
21 | #include <Standard_Transient.hxx> |
22 | #include <Standard_Type.hxx> |
23 | #include <TCollection_AsciiString.hxx> |
7fd59977 |
24 | |
42cf5bc1 |
25 | #include <stdio.h> |
92efcf78 |
26 | IMPLEMENT_STANDARD_RTTIEXT(IGESSelect_SelectLevelNumber,IFSelect_SelectExtract) |
27 | |
b311480e |
28 | IGESSelect_SelectLevelNumber::IGESSelect_SelectLevelNumber () { } |
7fd59977 |
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 |
35e08fe8 |
40 | (const Standard_Integer /*rank*/, |
41 | const Handle(Standard_Transient)& ent, |
42 | const Handle(Interface_InterfaceModel)& /*model*/) const |
7fd59977 |
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 | } |