summaryrefslogtreecommitdiff
path: root/src/IGESDefs/IGESDefs_ToolUnitsData.cxx
blob: e2aaf500fbcc1645017afb95698dee2ed44e6a06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
//--------------------------------------------------------------------
//
//  File Name : IGESDefs_UnitsData.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESDefs_ToolUnitsData.ixx>
#include <IGESData_ParamCursor.hxx>
#include <TCollection_HAsciiString.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <Interface_HArray1OfHAsciiString.hxx>
#include <IGESData_Dump.hxx>
#include <Interface_Macros.hxx>


IGESDefs_ToolUnitsData::IGESDefs_ToolUnitsData ()    {  }


void  IGESDefs_ToolUnitsData::ReadOwnParams
  (const Handle(IGESDefs_UnitsData)& ent,
   const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const
{ 
  //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down

  Standard_Integer nbval;
  Handle(Interface_HArray1OfHAsciiString) unitTypes;
  Handle(Interface_HArray1OfHAsciiString) unitValues;
  Handle(TColStd_HArray1OfReal) unitScales;

  Standard_Boolean st = PR.ReadInteger(PR.Current(), "Number of Units", nbval);
  if (st && nbval > 0)
    {
      unitTypes = new Interface_HArray1OfHAsciiString(1, nbval); 
      unitValues = new Interface_HArray1OfHAsciiString(1, nbval); 
      unitScales = new TColStd_HArray1OfReal(1, nbval); 
    }
  else  PR.AddFail("Number of Units: Less than or Equal or zero");

  if (! unitTypes.IsNull())
    for (Standard_Integer i = 1; i <= nbval; i++)
      {
	Handle(TCollection_HAsciiString) unitType;
	Handle(TCollection_HAsciiString) unitValue;
	Standard_Real unitScale;

	//st = PR.ReadText(PR.Current(), "Type of Unit", unitType); //szv#4:S4163:12Mar99 moved in if
	if (PR.ReadText(PR.Current(), "Type of Unit", unitType))
	  unitTypes->SetValue(i, unitType);

	//st = PR.ReadText(PR.Current(), "Value of Unit", unitValue); //szv#4:S4163:12Mar99 moved in if
	if (PR.ReadText(PR.Current(), "Value of Unit", unitValue))
	  unitValues->SetValue(i, unitValue);

	//st = PR.ReadReal(PR.Current(), "Scale of Unit", unitScale); //szv#4:S4163:12Mar99 moved in if
	if (PR.ReadReal(PR.Current(), "Scale of Unit", unitScale))
	  unitScales->SetValue(i, unitScale);
      }

  DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
  ent->Init(unitTypes, unitValues, unitScales);
}

void  IGESDefs_ToolUnitsData::WriteOwnParams
  (const Handle(IGESDefs_UnitsData)& ent, IGESData_IGESWriter& IW) const 
{ 
  Standard_Integer upper = ent->NbUnits();
  IW.Send(upper);

  for (Standard_Integer i = 1; i <= upper; i++)
    {
      IW.Send(ent->UnitType(i));
      IW.Send(ent->UnitValue(i));
      IW.Send(ent->ScaleFactor(i));
    }
}

void  IGESDefs_ToolUnitsData::OwnShared
  (const Handle(IGESDefs_UnitsData)& /* ent */, Interface_EntityIterator& /* iter */) const
{
}

void  IGESDefs_ToolUnitsData::OwnCopy
  (const Handle(IGESDefs_UnitsData)& another,
   const Handle(IGESDefs_UnitsData)& ent, Interface_CopyTool& /* TC */) const
{
  Handle(Interface_HArray1OfHAsciiString) unitTypes;
  Handle(Interface_HArray1OfHAsciiString) unitValues;
  Handle(TColStd_HArray1OfReal) unitScales;

  Standard_Integer nbval = another->NbUnits();

  unitTypes  = new Interface_HArray1OfHAsciiString(1, nbval); 
  unitValues = new Interface_HArray1OfHAsciiString(1, nbval); 
  unitScales = new TColStd_HArray1OfReal(1, nbval); 

  for (Standard_Integer i = 1; i <= nbval; i++)
    {
      Handle(TCollection_HAsciiString) unitType =
	new TCollection_HAsciiString(another->UnitType(i));
      unitTypes->SetValue(i, unitType);
      Handle(TCollection_HAsciiString) unitValue =
	new TCollection_HAsciiString(another->UnitValue(i));
      unitValues->SetValue(i, unitValue);
      Standard_Real unitScale = another->ScaleFactor(i);
      unitScales->SetValue(i, unitScale);
    }
  ent->Init(unitTypes, unitValues, unitScales);
}

IGESData_DirChecker  IGESDefs_ToolUnitsData::DirChecker
  (const Handle(IGESDefs_UnitsData)& /* ent */ ) const 
{ 
  IGESData_DirChecker DC (316, 0);
  DC.Structure(IGESData_DefVoid);
  DC.LineFont(IGESData_DefVoid);
  DC.LineWeight(IGESData_DefVoid);
  DC.Color(IGESData_DefVoid);
  DC.BlankStatusIgnored();
  DC.SubordinateStatusRequired(0);
  DC.UseFlagRequired(2);
  DC.HierarchyStatusIgnored();
  return DC;
}

void  IGESDefs_ToolUnitsData::OwnCheck
  (const Handle(IGESDefs_UnitsData)& /* ent */,
   const Interface_ShareTool& , Handle(Interface_Check)& /* ach */) const 
{
}

void  IGESDefs_ToolUnitsData::OwnDump
  (const Handle(IGESDefs_UnitsData)& ent, const IGESData_IGESDumper& /* dumper */,
   const Handle(Message_Messenger)& S, const Standard_Integer level) const 
{ 
  S << "IGESDefs_UnitsData" << endl;
  S << "Number of Units : " << ent->NbUnits() << endl;
  S << "Type of Unit : " << endl;
  S << "Value of Unit : " << endl;
  S << "Scale Factor : " << endl;
  IGESData_DumpStrings(S,-level,1, ent->NbUnits(),ent->UnitType);
  S << endl;
  if (level > 4)
    {
      S << "Details of the Units" << endl;
      Standard_Integer upper = ent->NbUnits();
      for (Standard_Integer i = 1; i <= upper; i++)
	{
          S << "[" << i << "] Type  : ";
          IGESData_DumpString(S,ent->UnitType(i));
          S << endl;
          S << "     Value : ";
          IGESData_DumpString(S,ent->UnitValue(i));
          S << endl;
          S << "     ScaleFactor: " << ent->ScaleFactor(i) << endl;
	}
    }
  S << endl;
}