0031501: Foundation Classes, Message_Printer - remove theToPutEndl argument -- prepar...
[occt.git] / src / IGESDefs / IGESDefs_ToolUnitsData.cxx
CommitLineData
b311480e 1// Created by: CKY / Contract Toubro-Larsen
2// Copyright (c) 1993-1999 Matra Datavision
973c2be1 3// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
7fd59977 6//
d5f74e42 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
973c2be1 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.
7fd59977 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
16//--------------------------------------------------------------------
7fd59977 17//--------------------------------------------------------------------
18
42cf5bc1 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>
7fd59977 24#include <IGESData_ParamCursor.hxx>
42cf5bc1 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>
7fd59977 31#include <Interface_HArray1OfHAsciiString.hxx>
7fd59977 32#include <Interface_Macros.hxx>
42cf5bc1 33#include <Interface_ShareTool.hxx>
42cf5bc1 34#include <Standard_DomainError.hxx>
35#include <TCollection_HAsciiString.hxx>
36#include <TColStd_HArray1OfReal.hxx>
7fd59977 37
38IGESDefs_ToolUnitsData::IGESDefs_ToolUnitsData () { }
39
40
41void IGESDefs_ToolUnitsData::ReadOwnParams
42 (const Handle(IGESDefs_UnitsData)& ent,
43 const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const
44{
45 //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
46
47 Standard_Integer nbval;
48 Handle(Interface_HArray1OfHAsciiString) unitTypes;
49 Handle(Interface_HArray1OfHAsciiString) unitValues;
50 Handle(TColStd_HArray1OfReal) unitScales;
51
52 Standard_Boolean st = PR.ReadInteger(PR.Current(), "Number of Units", nbval);
53 if (st && nbval > 0)
54 {
55 unitTypes = new Interface_HArray1OfHAsciiString(1, nbval);
56 unitValues = new Interface_HArray1OfHAsciiString(1, nbval);
57 unitScales = new TColStd_HArray1OfReal(1, nbval);
58 }
59 else PR.AddFail("Number of Units: Less than or Equal or zero");
60
61 if (! unitTypes.IsNull())
62 for (Standard_Integer i = 1; i <= nbval; i++)
63 {
64 Handle(TCollection_HAsciiString) unitType;
65 Handle(TCollection_HAsciiString) unitValue;
66 Standard_Real unitScale;
67
68 //st = PR.ReadText(PR.Current(), "Type of Unit", unitType); //szv#4:S4163:12Mar99 moved in if
69 if (PR.ReadText(PR.Current(), "Type of Unit", unitType))
70 unitTypes->SetValue(i, unitType);
71
72 //st = PR.ReadText(PR.Current(), "Value of Unit", unitValue); //szv#4:S4163:12Mar99 moved in if
73 if (PR.ReadText(PR.Current(), "Value of Unit", unitValue))
74 unitValues->SetValue(i, unitValue);
75
76 //st = PR.ReadReal(PR.Current(), "Scale of Unit", unitScale); //szv#4:S4163:12Mar99 moved in if
77 if (PR.ReadReal(PR.Current(), "Scale of Unit", unitScale))
78 unitScales->SetValue(i, unitScale);
79 }
80
81 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
82 ent->Init(unitTypes, unitValues, unitScales);
83}
84
85void IGESDefs_ToolUnitsData::WriteOwnParams
86 (const Handle(IGESDefs_UnitsData)& ent, IGESData_IGESWriter& IW) const
87{
88 Standard_Integer upper = ent->NbUnits();
89 IW.Send(upper);
90
91 for (Standard_Integer i = 1; i <= upper; i++)
92 {
93 IW.Send(ent->UnitType(i));
94 IW.Send(ent->UnitValue(i));
95 IW.Send(ent->ScaleFactor(i));
96 }
97}
98
99void IGESDefs_ToolUnitsData::OwnShared
100 (const Handle(IGESDefs_UnitsData)& /* ent */, Interface_EntityIterator& /* iter */) const
101{
102}
103
104void IGESDefs_ToolUnitsData::OwnCopy
105 (const Handle(IGESDefs_UnitsData)& another,
106 const Handle(IGESDefs_UnitsData)& ent, Interface_CopyTool& /* TC */) const
107{
108 Handle(Interface_HArray1OfHAsciiString) unitTypes;
109 Handle(Interface_HArray1OfHAsciiString) unitValues;
110 Handle(TColStd_HArray1OfReal) unitScales;
111
112 Standard_Integer nbval = another->NbUnits();
113
114 unitTypes = new Interface_HArray1OfHAsciiString(1, nbval);
115 unitValues = new Interface_HArray1OfHAsciiString(1, nbval);
116 unitScales = new TColStd_HArray1OfReal(1, nbval);
117
118 for (Standard_Integer i = 1; i <= nbval; i++)
119 {
120 Handle(TCollection_HAsciiString) unitType =
121 new TCollection_HAsciiString(another->UnitType(i));
122 unitTypes->SetValue(i, unitType);
123 Handle(TCollection_HAsciiString) unitValue =
124 new TCollection_HAsciiString(another->UnitValue(i));
125 unitValues->SetValue(i, unitValue);
126 Standard_Real unitScale = another->ScaleFactor(i);
127 unitScales->SetValue(i, unitScale);
128 }
129 ent->Init(unitTypes, unitValues, unitScales);
130}
131
132IGESData_DirChecker IGESDefs_ToolUnitsData::DirChecker
133 (const Handle(IGESDefs_UnitsData)& /* ent */ ) const
134{
135 IGESData_DirChecker DC (316, 0);
136 DC.Structure(IGESData_DefVoid);
137 DC.LineFont(IGESData_DefVoid);
138 DC.LineWeight(IGESData_DefVoid);
139 DC.Color(IGESData_DefVoid);
140 DC.BlankStatusIgnored();
141 DC.SubordinateStatusRequired(0);
142 DC.UseFlagRequired(2);
143 DC.HierarchyStatusIgnored();
144 return DC;
145}
146
147void IGESDefs_ToolUnitsData::OwnCheck
148 (const Handle(IGESDefs_UnitsData)& /* ent */,
149 const Interface_ShareTool& , Handle(Interface_Check)& /* ach */) const
150{
151}
152
153void IGESDefs_ToolUnitsData::OwnDump
154 (const Handle(IGESDefs_UnitsData)& ent, const IGESData_IGESDumper& /* dumper */,
0ebe5b0a 155 Standard_OStream& S, const Standard_Integer level) const
7fd59977 156{
0ebe5b0a 157 S << "IGESDefs_UnitsData\n"
158 << "Number of Units : " << ent->NbUnits() << "\n"
159 << "Type of Unit :\n"
160 << "Value of Unit :\n"
161 << "Scale Factor :\n";
7fd59977 162 IGESData_DumpStrings(S,-level,1, ent->NbUnits(),ent->UnitType);
0ebe5b0a 163 S << "\n";
7fd59977 164 if (level > 4)
165 {
0ebe5b0a 166 S << "Details of the Units\n";
7fd59977 167 Standard_Integer upper = ent->NbUnits();
168 for (Standard_Integer i = 1; i <= upper; i++)
169 {
170 S << "[" << i << "] Type : ";
171 IGESData_DumpString(S,ent->UnitType(i));
0ebe5b0a 172 S << "\n"
173 << " Value : ";
7fd59977 174 IGESData_DumpString(S,ent->UnitValue(i));
0ebe5b0a 175 S << "\n"
176 << " ScaleFactor: " << ent->ScaleFactor(i) << "\n";
7fd59977 177 }
178 }
0ebe5b0a 179 S << std::endl;
7fd59977 180}