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 <IGESData_IGESEntity.hxx>
16 #include <IGESSelect_SelectName.hxx>
17 #include <Interface_InterfaceModel.hxx>
18 #include <Interface_Macros.hxx>
19 #include <Standard_Transient.hxx>
20 #include <Standard_Type.hxx>
21 #include <TCollection_AsciiString.hxx>
22 #include <TCollection_HAsciiString.hxx>
25 IMPLEMENT_STANDARD_RTTIEXT(IGESSelect_SelectName,IFSelect_SelectExtract)
27 IGESSelect_SelectName::IGESSelect_SelectName () { }
30 void IGESSelect_SelectName::SetName
31 (const Handle(TCollection_HAsciiString)& levnum)
34 Handle(TCollection_HAsciiString) IGESSelect_SelectName::Name () const
38 Standard_Boolean IGESSelect_SelectName::Sort
39 (const Standard_Integer /*rank*/,
40 const Handle(Standard_Transient)& ent,
41 const Handle(Interface_InterfaceModel)& /*model*/) const
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;
57 if (nb0 > nb1) name = thename;
58 for (i = nbf+1; i <= nbt; i ++) {
59 if (name->Value(i) != ' ') return Standard_False;
65 TCollection_AsciiString IGESSelect_SelectName::ExtractLabel () const
68 if (!thename.IsNull()) {
69 sprintf (labl,"IGES Entity, Name : %s",thename->ToCString());
70 return TCollection_AsciiString(labl);
72 else return TCollection_AsciiString ("IGES Entity, Name : (undefined)");