1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License 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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
19 #include <IGESData_DirChecker.hxx>
20 #include <IGESData_Dump.hxx>
21 #include <IGESData_IGESDumper.hxx>
22 #include <IGESData_IGESReaderData.hxx>
23 #include <IGESData_IGESWriter.hxx>
24 #include <IGESData_ParamCursor.hxx>
25 #include <IGESData_ParamReader.hxx>
26 #include <IGESDefs_ToolUnitsData.hxx>
27 #include <IGESDefs_UnitsData.hxx>
28 #include <Interface_Check.hxx>
29 #include <Interface_CopyTool.hxx>
30 #include <Interface_EntityIterator.hxx>
31 #include <Interface_HArray1OfHAsciiString.hxx>
32 #include <Interface_Macros.hxx>
33 #include <Interface_ShareTool.hxx>
34 #include <Message_Messenger.hxx>
35 #include <Standard_DomainError.hxx>
36 #include <TCollection_HAsciiString.hxx>
37 #include <TColStd_HArray1OfReal.hxx>
39 IGESDefs_ToolUnitsData::IGESDefs_ToolUnitsData () { }
42 void IGESDefs_ToolUnitsData::ReadOwnParams
43 (const Handle(IGESDefs_UnitsData)& ent,
44 const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const
46 //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
48 Standard_Integer nbval;
49 Handle(Interface_HArray1OfHAsciiString) unitTypes;
50 Handle(Interface_HArray1OfHAsciiString) unitValues;
51 Handle(TColStd_HArray1OfReal) unitScales;
53 Standard_Boolean st = PR.ReadInteger(PR.Current(), "Number of Units", nbval);
56 unitTypes = new Interface_HArray1OfHAsciiString(1, nbval);
57 unitValues = new Interface_HArray1OfHAsciiString(1, nbval);
58 unitScales = new TColStd_HArray1OfReal(1, nbval);
60 else PR.AddFail("Number of Units: Less than or Equal or zero");
62 if (! unitTypes.IsNull())
63 for (Standard_Integer i = 1; i <= nbval; i++)
65 Handle(TCollection_HAsciiString) unitType;
66 Handle(TCollection_HAsciiString) unitValue;
67 Standard_Real unitScale;
69 //st = PR.ReadText(PR.Current(), "Type of Unit", unitType); //szv#4:S4163:12Mar99 moved in if
70 if (PR.ReadText(PR.Current(), "Type of Unit", unitType))
71 unitTypes->SetValue(i, unitType);
73 //st = PR.ReadText(PR.Current(), "Value of Unit", unitValue); //szv#4:S4163:12Mar99 moved in if
74 if (PR.ReadText(PR.Current(), "Value of Unit", unitValue))
75 unitValues->SetValue(i, unitValue);
77 //st = PR.ReadReal(PR.Current(), "Scale of Unit", unitScale); //szv#4:S4163:12Mar99 moved in if
78 if (PR.ReadReal(PR.Current(), "Scale of Unit", unitScale))
79 unitScales->SetValue(i, unitScale);
82 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
83 ent->Init(unitTypes, unitValues, unitScales);
86 void IGESDefs_ToolUnitsData::WriteOwnParams
87 (const Handle(IGESDefs_UnitsData)& ent, IGESData_IGESWriter& IW) const
89 Standard_Integer upper = ent->NbUnits();
92 for (Standard_Integer i = 1; i <= upper; i++)
94 IW.Send(ent->UnitType(i));
95 IW.Send(ent->UnitValue(i));
96 IW.Send(ent->ScaleFactor(i));
100 void IGESDefs_ToolUnitsData::OwnShared
101 (const Handle(IGESDefs_UnitsData)& /* ent */, Interface_EntityIterator& /* iter */) const
105 void IGESDefs_ToolUnitsData::OwnCopy
106 (const Handle(IGESDefs_UnitsData)& another,
107 const Handle(IGESDefs_UnitsData)& ent, Interface_CopyTool& /* TC */) const
109 Handle(Interface_HArray1OfHAsciiString) unitTypes;
110 Handle(Interface_HArray1OfHAsciiString) unitValues;
111 Handle(TColStd_HArray1OfReal) unitScales;
113 Standard_Integer nbval = another->NbUnits();
115 unitTypes = new Interface_HArray1OfHAsciiString(1, nbval);
116 unitValues = new Interface_HArray1OfHAsciiString(1, nbval);
117 unitScales = new TColStd_HArray1OfReal(1, nbval);
119 for (Standard_Integer i = 1; i <= nbval; i++)
121 Handle(TCollection_HAsciiString) unitType =
122 new TCollection_HAsciiString(another->UnitType(i));
123 unitTypes->SetValue(i, unitType);
124 Handle(TCollection_HAsciiString) unitValue =
125 new TCollection_HAsciiString(another->UnitValue(i));
126 unitValues->SetValue(i, unitValue);
127 Standard_Real unitScale = another->ScaleFactor(i);
128 unitScales->SetValue(i, unitScale);
130 ent->Init(unitTypes, unitValues, unitScales);
133 IGESData_DirChecker IGESDefs_ToolUnitsData::DirChecker
134 (const Handle(IGESDefs_UnitsData)& /* ent */ ) const
136 IGESData_DirChecker DC (316, 0);
137 DC.Structure(IGESData_DefVoid);
138 DC.LineFont(IGESData_DefVoid);
139 DC.LineWeight(IGESData_DefVoid);
140 DC.Color(IGESData_DefVoid);
141 DC.BlankStatusIgnored();
142 DC.SubordinateStatusRequired(0);
143 DC.UseFlagRequired(2);
144 DC.HierarchyStatusIgnored();
148 void IGESDefs_ToolUnitsData::OwnCheck
149 (const Handle(IGESDefs_UnitsData)& /* ent */,
150 const Interface_ShareTool& , Handle(Interface_Check)& /* ach */) const
154 void IGESDefs_ToolUnitsData::OwnDump
155 (const Handle(IGESDefs_UnitsData)& ent, const IGESData_IGESDumper& /* dumper */,
156 const Handle(Message_Messenger)& S, const Standard_Integer level) const
158 S << "IGESDefs_UnitsData" << Message_EndLine;
159 S << "Number of Units : " << ent->NbUnits() << Message_EndLine;
160 S << "Type of Unit : " << Message_EndLine;
161 S << "Value of Unit : " << Message_EndLine;
162 S << "Scale Factor : " << Message_EndLine;
163 IGESData_DumpStrings(S,-level,1, ent->NbUnits(),ent->UnitType);
164 S << Message_EndLine;
167 S << "Details of the Units" << Message_EndLine;
168 Standard_Integer upper = ent->NbUnits();
169 for (Standard_Integer i = 1; i <= upper; i++)
171 S << "[" << i << "] Type : ";
172 IGESData_DumpString(S,ent->UnitType(i));
173 S << Message_EndLine;
175 IGESData_DumpString(S,ent->UnitValue(i));
176 S << Message_EndLine;
177 S << " ScaleFactor: " << ent->ScaleFactor(i) << Message_EndLine;
180 S << Message_EndLine;