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 | |
7fd59977 |
15 | #include <IGESData_IGESEntity.hxx> |
42cf5bc1 |
16 | #include <IGESSelect_SelectName.hxx> |
17 | #include <Interface_InterfaceModel.hxx> |
7fd59977 |
18 | #include <Interface_Macros.hxx> |
42cf5bc1 |
19 | #include <Standard_Transient.hxx> |
20 | #include <Standard_Type.hxx> |
21 | #include <TCollection_AsciiString.hxx> |
22 | #include <TCollection_HAsciiString.hxx> |
7fd59977 |
23 | |
42cf5bc1 |
24 | #include <stdio.h> |
92efcf78 |
25 | IMPLEMENT_STANDARD_RTTIEXT(IGESSelect_SelectName,IFSelect_SelectExtract) |
26 | |
b311480e |
27 | IGESSelect_SelectName::IGESSelect_SelectName () { } |
7fd59977 |
28 | |
29 | |
30 | void IGESSelect_SelectName::SetName |
31 | (const Handle(TCollection_HAsciiString)& levnum) |
32 | { thename = levnum; } |
33 | |
34 | Handle(TCollection_HAsciiString) IGESSelect_SelectName::Name () const |
35 | { return thename; } |
36 | |
37 | |
38 | Standard_Boolean IGESSelect_SelectName::Sort |
35e08fe8 |
39 | (const Standard_Integer /*rank*/, |
40 | const Handle(Standard_Transient)& ent, |
41 | const Handle(Interface_InterfaceModel)& /*model*/) const |
7fd59977 |
42 | { |
43 | DeclareAndCast(IGESData_IGESEntity,igesent,ent); |
44 | if (igesent.IsNull()) return Standard_False; |
45 | if (!igesent->HasName()) return Standard_False; |
46 | if (thename.IsNull()) return Standard_False; |
47 | Handle(TCollection_HAsciiString) name = igesent->NameValue(); |
48 | // cout<<"SelectName:"<<thename->ToCString()<<",with:"<<name->ToCString()<<",IsSameString="<<thename->IsSameString (name,Standard_False)<<endl; |
49 | Standard_Integer nb0 = thename->Length(); |
50 | Standard_Integer nb1 = name->Length(); |
51 | Standard_Integer nbf = (nb1 <= nb0 ? nb1 : nb0); |
52 | Standard_Integer nbt = (nb1 >= nb0 ? nb1 : nb0); |
53 | Standard_Integer i; // svv Jan11 2000 : porting on DEC |
54 | for (i = 1; i <= nbf; i ++) { |
55 | if (name->Value(i) != thename->Value(i)) return Standard_False; |
56 | } |
57 | if (nb0 > nb1) name = thename; |
58 | for (i = nbf+1; i <= nbt; i ++) { |
59 | if (name->Value(i) != ' ') return Standard_False; |
60 | } |
61 | return Standard_True; |
62 | } |
63 | |
64 | |
65 | TCollection_AsciiString IGESSelect_SelectName::ExtractLabel () const |
66 | { |
67 | char labl [50]; |
68 | if (!thename.IsNull()) { |
69 | sprintf (labl,"IGES Entity, Name : %s",thename->ToCString()); |
70 | return TCollection_AsciiString(labl); |
71 | } |
72 | else return TCollection_AsciiString ("IGES Entity, Name : (undefined)"); |
73 | } |