7fd59977 |
1 | #include <IGESSelect_SelectName.ixx> |
2 | #include <IGESData_IGESEntity.hxx> |
3 | #include <Interface_Macros.hxx> |
4 | #include <stdio.h> |
5 | |
6 | |
7 | IGESSelect_SelectName::IGESSelect_SelectName () { } |
8 | |
9 | |
10 | void IGESSelect_SelectName::SetName |
11 | (const Handle(TCollection_HAsciiString)& levnum) |
12 | { thename = levnum; } |
13 | |
14 | Handle(TCollection_HAsciiString) IGESSelect_SelectName::Name () const |
15 | { return thename; } |
16 | |
17 | |
18 | Standard_Boolean IGESSelect_SelectName::Sort |
19 | (const Standard_Integer rank, const Handle(Standard_Transient)& ent, |
20 | const Handle(Interface_InterfaceModel)& model) const |
21 | { |
22 | DeclareAndCast(IGESData_IGESEntity,igesent,ent); |
23 | if (igesent.IsNull()) return Standard_False; |
24 | if (!igesent->HasName()) return Standard_False; |
25 | if (thename.IsNull()) return Standard_False; |
26 | Handle(TCollection_HAsciiString) name = igesent->NameValue(); |
27 | // cout<<"SelectName:"<<thename->ToCString()<<",with:"<<name->ToCString()<<",IsSameString="<<thename->IsSameString (name,Standard_False)<<endl; |
28 | Standard_Integer nb0 = thename->Length(); |
29 | Standard_Integer nb1 = name->Length(); |
30 | Standard_Integer nbf = (nb1 <= nb0 ? nb1 : nb0); |
31 | Standard_Integer nbt = (nb1 >= nb0 ? nb1 : nb0); |
32 | Standard_Integer i; // svv Jan11 2000 : porting on DEC |
33 | for (i = 1; i <= nbf; i ++) { |
34 | if (name->Value(i) != thename->Value(i)) return Standard_False; |
35 | } |
36 | if (nb0 > nb1) name = thename; |
37 | for (i = nbf+1; i <= nbt; i ++) { |
38 | if (name->Value(i) != ' ') return Standard_False; |
39 | } |
40 | return Standard_True; |
41 | } |
42 | |
43 | |
44 | TCollection_AsciiString IGESSelect_SelectName::ExtractLabel () const |
45 | { |
46 | char labl [50]; |
47 | if (!thename.IsNull()) { |
48 | sprintf (labl,"IGES Entity, Name : %s",thename->ToCString()); |
49 | return TCollection_AsciiString(labl); |
50 | } |
51 | else return TCollection_AsciiString ("IGES Entity, Name : (undefined)"); |
52 | } |