0024428: Implementation of LGPL license
[occt.git] / src / IGESBasic / IGESBasic_ToolExternalRefFileIndex.cxx
1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and / or modify it
8 // under the terms of the GNU Lesser General Public version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
18
19 #include <IGESBasic_ToolExternalRefFileIndex.ixx>
20 #include <IGESData_ParamCursor.hxx>
21 #include <IGESData_IGESEntity.hxx>
22 #include <TCollection_HAsciiString.hxx>
23 #include <IGESData_HArray1OfIGESEntity.hxx>
24 #include <Interface_HArray1OfHAsciiString.hxx>
25 #include <IGESData_Dump.hxx>
26 #include <Interface_Macros.hxx>
27
28
29 IGESBasic_ToolExternalRefFileIndex::IGESBasic_ToolExternalRefFileIndex ()  {  }
30
31
32 void  IGESBasic_ToolExternalRefFileIndex::ReadOwnParams
33   (const Handle(IGESBasic_ExternalRefFileIndex)& ent,
34    const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
35 {
36   //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
37   Standard_Integer num, i;
38   Handle(Interface_HArray1OfHAsciiString) tempNames;
39   Handle(IGESData_HArray1OfIGESEntity) tempEntities;
40   Standard_Boolean st = PR.ReadInteger(PR.Current(), "Number of index entries", num);
41   if (st && num > 0)
42     {
43       tempNames = new Interface_HArray1OfHAsciiString(1, num);
44       tempEntities = new IGESData_HArray1OfIGESEntity(1, num);
45     }
46   else  PR.AddFail("Number of index entries: Not Positive");
47   if (!tempNames.IsNull() && !tempEntities.IsNull())
48     for ( i = 1; i <= num; i++ )
49       {
50         Handle(TCollection_HAsciiString) tempNam;
51         if (PR.ReadText(PR.Current(), "External Reference Entity", tempNam)) //szv#4:S4163:12Mar99 `st=` not needed
52           tempNames->SetValue(i, tempNam);
53         Handle(IGESData_IGESEntity) tempEnt;
54         if (PR.ReadEntity(IR, PR.Current(), "Internal Entity", tempEnt)) //szv#4:S4163:12Mar99 `st=` not needed
55           tempEntities->SetValue(i, tempEnt);
56       }
57   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
58   ent->Init(tempNames, tempEntities);
59 }
60
61 void  IGESBasic_ToolExternalRefFileIndex::WriteOwnParams
62   (const Handle(IGESBasic_ExternalRefFileIndex)& ent, IGESData_IGESWriter& IW) const
63 {
64   Standard_Integer i, num;
65   IW.Send(ent->NbEntries());
66   for ( num = ent->NbEntries(), i = 1; i <= num; i++ )
67     {
68       IW.Send(ent->Name(i));
69       IW.Send(ent->Entity(i));
70     }
71 }
72
73 void  IGESBasic_ToolExternalRefFileIndex::OwnShared
74   (const Handle(IGESBasic_ExternalRefFileIndex)& ent, Interface_EntityIterator& iter) const
75 {
76   Standard_Integer i, num;
77   for ( num = ent->NbEntries(), i = 1; i <= num; i++ )
78     iter.GetOneItem(ent->Entity(i));
79 }
80
81 void  IGESBasic_ToolExternalRefFileIndex::OwnCopy
82   (const Handle(IGESBasic_ExternalRefFileIndex)& another,
83    const Handle(IGESBasic_ExternalRefFileIndex)& ent, Interface_CopyTool& TC) const
84 {
85   Standard_Integer num = another->NbEntries();
86   Handle(Interface_HArray1OfHAsciiString) tempNames =
87     new Interface_HArray1OfHAsciiString(1, num);
88   Handle(IGESData_HArray1OfIGESEntity) tempEntities =
89     new IGESData_HArray1OfIGESEntity(1, num);
90   for ( Standard_Integer i = 1; i <= num; i++ )
91     {
92       tempNames->SetValue(i, new TCollection_HAsciiString
93                           (another->Name(i)));
94       DeclareAndCast(IGESData_IGESEntity, new_item,
95                      TC.Transferred(another->Entity(i)));
96       tempEntities->SetValue(i, new_item);
97     }
98   ent->Init(tempNames, tempEntities);
99 }
100
101 IGESData_DirChecker  IGESBasic_ToolExternalRefFileIndex::DirChecker
102   (const Handle(IGESBasic_ExternalRefFileIndex)& /* ent */ ) const
103 {
104   IGESData_DirChecker DC(402, 12);
105   DC.Structure(IGESData_DefVoid);
106   DC.GraphicsIgnored();
107   DC.LineFont(IGESData_DefVoid);
108   DC.LineWeight(IGESData_DefVoid);
109   DC.Color(IGESData_DefVoid);
110   DC.BlankStatusIgnored();
111   DC.UseFlagIgnored();
112   DC.HierarchyStatusIgnored();
113   return DC;
114 }
115
116 void  IGESBasic_ToolExternalRefFileIndex::OwnCheck
117   (const Handle(IGESBasic_ExternalRefFileIndex)& /* ent */,
118    const Interface_ShareTool& , Handle(Interface_Check)& /* ach */) const
119 {
120 }
121
122 void  IGESBasic_ToolExternalRefFileIndex::OwnDump
123   (const Handle(IGESBasic_ExternalRefFileIndex)& ent, const IGESData_IGESDumper& dumper,
124    const Handle(Message_Messenger)& S, const Standard_Integer level) const
125 {
126   Standard_Integer i, num;
127   S << "IGESBasic_ExternalRefFileIndex" << endl;
128   S << "External Reference Names : " << endl;
129   S << "Internal Entities : ";
130   IGESData_DumpEntities(S,dumper,-level,1, ent->NbEntries(),ent->Entity);
131   S << endl;
132   if (level > 4)
133     for ( num = ent->NbEntries(), i = 1; i <= num; i++ )
134       {
135         S << "[" << i << "]: ";
136         S << "External Reference Name : ";
137         IGESData_DumpString(S,ent->Name(i));
138         S << "  Internal Entity : ";
139         dumper.Dump (ent->Entity(i),S, 1);
140         S << endl;
141       }
142   S << endl;
143 }