0024624: Lost word in license statement in source files
[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
19#include <IGESDefs_ToolUnitsData.ixx>
20#include <IGESData_ParamCursor.hxx>
21#include <TCollection_HAsciiString.hxx>
22#include <TColStd_HArray1OfReal.hxx>
23#include <Interface_HArray1OfHAsciiString.hxx>
24#include <IGESData_Dump.hxx>
25#include <Interface_Macros.hxx>
26
27
28IGESDefs_ToolUnitsData::IGESDefs_ToolUnitsData () { }
29
30
31void IGESDefs_ToolUnitsData::ReadOwnParams
32 (const Handle(IGESDefs_UnitsData)& ent,
33 const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const
34{
35 //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
36
37 Standard_Integer nbval;
38 Handle(Interface_HArray1OfHAsciiString) unitTypes;
39 Handle(Interface_HArray1OfHAsciiString) unitValues;
40 Handle(TColStd_HArray1OfReal) unitScales;
41
42 Standard_Boolean st = PR.ReadInteger(PR.Current(), "Number of Units", nbval);
43 if (st && nbval > 0)
44 {
45 unitTypes = new Interface_HArray1OfHAsciiString(1, nbval);
46 unitValues = new Interface_HArray1OfHAsciiString(1, nbval);
47 unitScales = new TColStd_HArray1OfReal(1, nbval);
48 }
49 else PR.AddFail("Number of Units: Less than or Equal or zero");
50
51 if (! unitTypes.IsNull())
52 for (Standard_Integer i = 1; i <= nbval; i++)
53 {
54 Handle(TCollection_HAsciiString) unitType;
55 Handle(TCollection_HAsciiString) unitValue;
56 Standard_Real unitScale;
57
58 //st = PR.ReadText(PR.Current(), "Type of Unit", unitType); //szv#4:S4163:12Mar99 moved in if
59 if (PR.ReadText(PR.Current(), "Type of Unit", unitType))
60 unitTypes->SetValue(i, unitType);
61
62 //st = PR.ReadText(PR.Current(), "Value of Unit", unitValue); //szv#4:S4163:12Mar99 moved in if
63 if (PR.ReadText(PR.Current(), "Value of Unit", unitValue))
64 unitValues->SetValue(i, unitValue);
65
66 //st = PR.ReadReal(PR.Current(), "Scale of Unit", unitScale); //szv#4:S4163:12Mar99 moved in if
67 if (PR.ReadReal(PR.Current(), "Scale of Unit", unitScale))
68 unitScales->SetValue(i, unitScale);
69 }
70
71 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
72 ent->Init(unitTypes, unitValues, unitScales);
73}
74
75void IGESDefs_ToolUnitsData::WriteOwnParams
76 (const Handle(IGESDefs_UnitsData)& ent, IGESData_IGESWriter& IW) const
77{
78 Standard_Integer upper = ent->NbUnits();
79 IW.Send(upper);
80
81 for (Standard_Integer i = 1; i <= upper; i++)
82 {
83 IW.Send(ent->UnitType(i));
84 IW.Send(ent->UnitValue(i));
85 IW.Send(ent->ScaleFactor(i));
86 }
87}
88
89void IGESDefs_ToolUnitsData::OwnShared
90 (const Handle(IGESDefs_UnitsData)& /* ent */, Interface_EntityIterator& /* iter */) const
91{
92}
93
94void IGESDefs_ToolUnitsData::OwnCopy
95 (const Handle(IGESDefs_UnitsData)& another,
96 const Handle(IGESDefs_UnitsData)& ent, Interface_CopyTool& /* TC */) const
97{
98 Handle(Interface_HArray1OfHAsciiString) unitTypes;
99 Handle(Interface_HArray1OfHAsciiString) unitValues;
100 Handle(TColStd_HArray1OfReal) unitScales;
101
102 Standard_Integer nbval = another->NbUnits();
103
104 unitTypes = new Interface_HArray1OfHAsciiString(1, nbval);
105 unitValues = new Interface_HArray1OfHAsciiString(1, nbval);
106 unitScales = new TColStd_HArray1OfReal(1, nbval);
107
108 for (Standard_Integer i = 1; i <= nbval; i++)
109 {
110 Handle(TCollection_HAsciiString) unitType =
111 new TCollection_HAsciiString(another->UnitType(i));
112 unitTypes->SetValue(i, unitType);
113 Handle(TCollection_HAsciiString) unitValue =
114 new TCollection_HAsciiString(another->UnitValue(i));
115 unitValues->SetValue(i, unitValue);
116 Standard_Real unitScale = another->ScaleFactor(i);
117 unitScales->SetValue(i, unitScale);
118 }
119 ent->Init(unitTypes, unitValues, unitScales);
120}
121
122IGESData_DirChecker IGESDefs_ToolUnitsData::DirChecker
123 (const Handle(IGESDefs_UnitsData)& /* ent */ ) const
124{
125 IGESData_DirChecker DC (316, 0);
126 DC.Structure(IGESData_DefVoid);
127 DC.LineFont(IGESData_DefVoid);
128 DC.LineWeight(IGESData_DefVoid);
129 DC.Color(IGESData_DefVoid);
130 DC.BlankStatusIgnored();
131 DC.SubordinateStatusRequired(0);
132 DC.UseFlagRequired(2);
133 DC.HierarchyStatusIgnored();
134 return DC;
135}
136
137void IGESDefs_ToolUnitsData::OwnCheck
138 (const Handle(IGESDefs_UnitsData)& /* ent */,
139 const Interface_ShareTool& , Handle(Interface_Check)& /* ach */) const
140{
141}
142
143void IGESDefs_ToolUnitsData::OwnDump
144 (const Handle(IGESDefs_UnitsData)& ent, const IGESData_IGESDumper& /* dumper */,
145 const Handle(Message_Messenger)& S, const Standard_Integer level) const
146{
147 S << "IGESDefs_UnitsData" << endl;
148 S << "Number of Units : " << ent->NbUnits() << endl;
149 S << "Type of Unit : " << endl;
150 S << "Value of Unit : " << endl;
151 S << "Scale Factor : " << endl;
152 IGESData_DumpStrings(S,-level,1, ent->NbUnits(),ent->UnitType);
153 S << endl;
154 if (level > 4)
155 {
156 S << "Details of the Units" << endl;
157 Standard_Integer upper = ent->NbUnits();
158 for (Standard_Integer i = 1; i <= upper; i++)
159 {
160 S << "[" << i << "] Type : ";
161 IGESData_DumpString(S,ent->UnitType(i));
162 S << endl;
163 S << " Value : ";
164 IGESData_DumpString(S,ent->UnitValue(i));
165 S << endl;
166 S << " ScaleFactor: " << ent->ScaleFactor(i) << endl;
167 }
168 }
169 S << endl;
170}