summaryrefslogtreecommitdiff
path: root/src/IGESDimen/IGESDimen_ToolGeneralSymbol.cxx
blob: 8405824a7f5ffd960e9e5ebf95bcde470388acaa (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
162
163
164
165
166
167
//--------------------------------------------------------------------
//
//  File Name : IGESDimen_GeneralSymbol.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESDimen_ToolGeneralSymbol.ixx>
#include <IGESData_ParamCursor.hxx>
#include <IGESData_IGESEntity.hxx>
#include <IGESDimen_LeaderArrow.hxx>
#include <IGESDimen_GeneralNote.hxx>
#include <IGESData_HArray1OfIGESEntity.hxx>
#include <IGESDimen_HArray1OfLeaderArrow.hxx>
#include <IGESData_Dump.hxx>
#include <Interface_Macros.hxx>


IGESDimen_ToolGeneralSymbol::IGESDimen_ToolGeneralSymbol ()    {  }


void  IGESDimen_ToolGeneralSymbol::ReadOwnParams
  (const Handle(IGESDimen_GeneralSymbol)& ent,
   const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
{
  //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
  Standard_Integer i, num;
  Handle(IGESData_HArray1OfIGESEntity) tempGeoms;
  Handle(IGESDimen_HArray1OfLeaderArrow) tempLeaders;
  Handle(IGESDimen_GeneralNote) tempNote;

  if ((ent->FormNumber() == 0) && (!PR.IsParamEntity(PR.CurrentNumber())))
    PR.SetCurrentNumber(PR.CurrentNumber()+1);
  else
    PR.ReadEntity(IR, PR.Current(), "General Note Entity",
		  STANDARD_TYPE(IGESDimen_GeneralNote), tempNote); //szv#4:S4163:12Mar99 `st=` not needed

  Standard_Boolean st = PR.ReadInteger(PR.Current(), "Number of Geometries", num);
  if (!st || num <= 0) PR.AddFail("Number of Geometries: Not Positive");
  if (num > 0) {
    PR.ReadEnts (IR,PR.CurrentList(num),"Geometry Entities",tempGeoms); //szv#4:S4163:12Mar99 `st=` not needed
/*
    tempGeoms = new IGESData_HArray1OfIGESEntity(1, num);
    for ( i = 1; i <= num; i++)
      {
	Handle(IGESData_IGESEntity) tempEnt;
	st = PR.ReadEntity(IR, PR.Current(), "Geometry Entity", tempEnt);
	if (st) tempGeoms->SetValue(i, tempEnt);
      }
*/
  }
  else {
    return;
  }
  st = PR.ReadInteger(PR.Current(), "Number of Leaders", num);
  if (st && num > 0)  tempLeaders = new IGESDimen_HArray1OfLeaderArrow(1, num);
  else if (num < 0)  PR.AddFail("Number of Leaders: Less than zero");
  if (!tempLeaders.IsNull())
    for ( i = 1; i <= num; i++)
      {
	Handle(IGESDimen_LeaderArrow) tempEnt;
	//st = PR.ReadEntity(IR, PR.Current(), "Leader Entity",
			     //STANDARD_TYPE(IGESDimen_LeaderArrow), tempEnt); //szv#4:S4163:12Mar99 moved in if
	if (PR.ReadEntity(IR, PR.Current(), "Leader Entity", STANDARD_TYPE(IGESDimen_LeaderArrow), tempEnt))
	  tempLeaders->SetValue(i, tempEnt);
      }

  DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
  ent->Init (tempNote, tempGeoms, tempLeaders);
}

void  IGESDimen_ToolGeneralSymbol::WriteOwnParams
  (const Handle(IGESDimen_GeneralSymbol)& ent, IGESData_IGESWriter& IW) const
{
  Standard_Integer i, num;
  IW.Send(ent->Note());
  IW.Send(ent->NbGeomEntities());
  for (num = ent->NbGeomEntities(), i = 1; i <= num; i++)
    IW.Send(ent->GeomEntity(i));
  IW.Send(ent->NbLeaders());
  for (num = ent->NbLeaders(), i = 1; i <= num; i++)
    IW.Send(ent->LeaderArrow(i));
}

void  IGESDimen_ToolGeneralSymbol::OwnShared
  (const Handle(IGESDimen_GeneralSymbol)& ent, Interface_EntityIterator& iter) const
{
  Standard_Integer i, num;
  iter.GetOneItem(ent->Note());
  for (num = ent->NbGeomEntities(), i = 1; i <= num; i++)
    iter.GetOneItem(ent->GeomEntity(i));
  for (num = ent->NbLeaders(), i = 1; i <= num; i++)
    iter.GetOneItem(ent->LeaderArrow(i));
}

void  IGESDimen_ToolGeneralSymbol::OwnCopy
  (const Handle(IGESDimen_GeneralSymbol)& another,
   const Handle(IGESDimen_GeneralSymbol)& ent, Interface_CopyTool& TC) const
{
  DeclareAndCast(IGESDimen_GeneralNote, tempNote,
		 TC.Transferred(another->Note()));
  Standard_Integer num = another->NbGeomEntities();
  Handle(IGESData_HArray1OfIGESEntity) tempGeoms =
    new IGESData_HArray1OfIGESEntity(1, num);
  Standard_Integer i;
  for (i = 1; i <= num; i++)
    {
      DeclareAndCast(IGESData_IGESEntity, new_item,
		     TC.Transferred(another->GeomEntity(i)));
      tempGeoms->SetValue(i, new_item);
    }
  Handle(IGESDimen_HArray1OfLeaderArrow) tempLeaders;
  num = another->NbLeaders();
  if (num > 0)
    {
      tempLeaders = new IGESDimen_HArray1OfLeaderArrow(1, num);
      for (i = 1; i <= num; i++)
	{
          DeclareAndCast(IGESDimen_LeaderArrow, new_item,
			 TC.Transferred(another->LeaderArrow(i)));
          tempLeaders->SetValue(i, new_item);
	}
    }
  ent->Init (tempNote, tempGeoms, tempLeaders);
  ent->SetFormNumber (another->FormNumber());
}

IGESData_DirChecker  IGESDimen_ToolGeneralSymbol::DirChecker
  (const Handle(IGESDimen_GeneralSymbol)& /* ent */ ) const
{
  IGESData_DirChecker DC(228, 0, 9999);
  DC.Structure(IGESData_DefVoid);
  DC.GraphicsIgnored();
  DC.LineFont(IGESData_DefAny);
  DC.LineWeight(IGESData_DefValue);
  DC.Color(IGESData_DefAny);
  DC.UseFlagRequired(1);
  return DC;
}

void  IGESDimen_ToolGeneralSymbol::OwnCheck
  (const Handle(IGESDimen_GeneralSymbol)& ent,
   const Interface_ShareTool& , Handle(Interface_Check)& ach) const
{
  if ( (ent->FormNumber() <    0 || ent->FormNumber() >    3) &&
      ( ent->FormNumber() < 5001 || ent->FormNumber() > 9999 ) )
    ach->AddFail("Invalid Form Number");
  if (ent->FormNumber() != 0)   if (ent->Note().IsNull())
    ach->AddFail("No General Note defined for form number non 0");
}

void  IGESDimen_ToolGeneralSymbol::OwnDump
  (const Handle(IGESDimen_GeneralSymbol)& ent, const IGESData_IGESDumper& dumper,
   const Handle(Message_Messenger)& S, const Standard_Integer level) const
{
  Standard_Integer sublevel = (level > 4) ? 1 : 0;
  S << "IGESDimen_GeneralSymbol" << endl;
  S << "General Note : ";
  dumper.Dump(ent->Note(),S, sublevel);
  S << endl << "Geometric Entities : ";
  IGESData_DumpEntities(S,dumper ,level,1, ent->NbGeomEntities(),ent->GeomEntity);
  S << endl << "Leader Arrows : ";
  IGESData_DumpEntities(S,dumper ,level,1, ent->NbLeaders(),ent->LeaderArrow);
  S << endl;
}