b311480e |
1 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
2 | // |
3 | // The content of this file is subject to the Open CASCADE Technology Public |
4 | // License Version 6.5 (the "License"). You may not use the content of this file |
5 | // except in compliance with the License. Please obtain a copy of the License |
6 | // at http://www.opencascade.org and read it completely before using this file. |
7 | // |
8 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
9 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
10 | // |
11 | // The Original Code and all software distributed under the License is |
12 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
13 | // Initial Developer hereby disclaims all such warranties, including without |
14 | // limitation, any warranties of merchantability, fitness for a particular |
15 | // purpose or non-infringement. Please see the License for the specific terms |
16 | // and conditions governing the rights and limitations under the License. |
17 | |
7fd59977 |
18 | #include <IGESSelect_SelectLevelNumber.ixx> |
19 | #include <IGESData_IGESEntity.hxx> |
20 | #include <IGESGraph_DefinitionLevel.hxx> |
21 | #include <Interface_Macros.hxx> |
22 | #include <stdio.h> |
23 | |
24 | |
25 | |
b311480e |
26 | IGESSelect_SelectLevelNumber::IGESSelect_SelectLevelNumber () { } |
7fd59977 |
27 | |
28 | |
29 | void IGESSelect_SelectLevelNumber::SetLevelNumber |
30 | (const Handle(IFSelect_IntParam)& levnum) |
31 | { thelevnum = levnum; } |
32 | |
33 | Handle(IFSelect_IntParam) IGESSelect_SelectLevelNumber::LevelNumber () const |
34 | { return thelevnum; } |
35 | |
36 | |
37 | Standard_Boolean IGESSelect_SelectLevelNumber::Sort |
35e08fe8 |
38 | (const Standard_Integer /*rank*/, |
39 | const Handle(Standard_Transient)& ent, |
40 | const Handle(Interface_InterfaceModel)& /*model*/) const |
7fd59977 |
41 | { |
42 | DeclareAndCast(IGESData_IGESEntity,igesent,ent); |
43 | if (igesent.IsNull()) return Standard_False; |
44 | Standard_Integer numlev = 0; |
45 | if (!thelevnum.IsNull()) numlev = thelevnum->Value(); |
46 | DeclareAndCast(IGESGraph_DefinitionLevel,levelist,igesent->LevelList()); |
47 | Standard_Integer level = igesent->Level(); |
48 | if (levelist.IsNull()) return (level == numlev); |
49 | // Cas d une liste |
50 | if (numlev == 0) return Standard_False; |
51 | Standard_Integer nb = levelist->NbPropertyValues(); |
52 | for (Standard_Integer i = 1; i <= nb; i ++) { |
53 | level = levelist->LevelNumber(i); |
54 | if (level == numlev) return Standard_True; |
55 | } |
56 | return Standard_False; |
57 | } |
58 | |
59 | |
60 | TCollection_AsciiString IGESSelect_SelectLevelNumber::ExtractLabel |
61 | () const |
62 | { |
63 | char labl [50]; |
64 | Standard_Integer numlev = 0; |
65 | if (!thelevnum.IsNull()) numlev = thelevnum->Value(); |
66 | if (numlev == 0) return TCollection_AsciiString |
67 | ("IGES Entity attached to no Level"); |
68 | |
69 | sprintf(labl,"IGES Entity, Level Number admitting %d",numlev); |
70 | return TCollection_AsciiString (labl); |
71 | } |