summaryrefslogtreecommitdiff
path: root/src/IGESDraw/IGESDraw_ToolNetworkSubfigure.cxx
blob: f8c4f7ee989a0ae28a456612b6b8eedd7442cad8 (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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
//--------------------------------------------------------------------
//
//  File Name : IGESDraw_NetworkSubfigure.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESDraw_ToolNetworkSubfigure.ixx>
#include <IGESData_ParamCursor.hxx>
#include <IGESDraw_ConnectPoint.hxx>
#include <gp_XYZ.hxx>
#include <IGESDraw_HArray1OfConnectPoint.hxx>
#include <IGESGraph_TextDisplayTemplate.hxx>
#include <TCollection_HAsciiString.hxx>
#include <IGESDraw_NetworkSubfigureDef.hxx>
#include <IGESData_Dump.hxx>
#include <Interface_Macros.hxx>


IGESDraw_ToolNetworkSubfigure::IGESDraw_ToolNetworkSubfigure ()    {  }


void IGESDraw_ToolNetworkSubfigure::ReadOwnParams
  (const Handle(IGESDraw_NetworkSubfigure)& ent,
   const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
{
  //Standard_Boolean                           st; //szv#4:S4163:12Mar99 not needed
  Standard_Integer                           nbval;

  Handle(IGESDraw_NetworkSubfigureDef)       definition; 
  gp_XYZ                                     translation;
  gp_XYZ                                     scale;
  Standard_Integer                           typeflag; 
  Handle(TCollection_HAsciiString)           designator; 
  Handle(IGESGraph_TextDisplayTemplate)      textTemplate; 
  Handle(IGESDraw_HArray1OfConnectPoint) connectPoints;

  Standard_Real                              scaleX; 
  Standard_Real                              scaleY; 
  Standard_Real                              scaleZ; 

  // Reading definition(Instance of NetworkSubfigureDef)
  PR.ReadEntity(IR, PR.Current(), "Instance of NetworkSubfigureDef",
		STANDARD_TYPE(IGESDraw_NetworkSubfigureDef), definition); //szv#4:S4163:12Mar99 `st=` not needed

  // Reading translation(XYZ)
  PR.ReadXYZ( PR.CurrentList(1, 3), "Translation data", translation); //szv#4:S4163:12Mar99 `st=` not needed

  // Reading scale(XYZ)
  if (PR.DefinedElseSkip())        // Reading scale(X)
    PR.ReadReal(PR.Current(), "Scale factors(X)", scaleX); //szv#4:S4163:12Mar99 `st=` not needed
  else
    scaleX = 1.0; // Default Value

  if (PR.DefinedElseSkip())        // Reading scale(Y)
    PR.ReadReal(PR.Current(), "Scale factors(Y)", scaleY); //szv#4:S4163:12Mar99 `st=` not needed
  else
    scaleY = scaleX; // Default Value

  if (PR.DefinedElseSkip())        // Reading scale(Z)
    PR.ReadReal(PR.Current(), "Scale factors(Z)", scaleZ); //szv#4:S4163:12Mar99 `st=` not needed
  else
    scaleZ = scaleX; // Default Value

  scale.SetCoord(scaleX, scaleY, scaleZ);

  if (PR.DefinedElseSkip())       // Reading typeflag(Integer)
    PR.ReadInteger(PR.Current(), "Type flag", typeflag); //szv#4:S4163:12Mar99 `st=` not needed
  else
    typeflag = 0; // Default Value

  // Reading designator(String)
  if (PR.DefinedElseSkip())
    PR.ReadText(PR.Current(), "Primary reference designator", designator); //szv#4:S4163:12Mar99 `st=` not needed
  else PR.AddWarning("Primary reference designator : Null definition");

  // Reading textTemplate(Instance of TextDisplayTemplate or Null)
  Standard_Boolean st = PR.ReadEntity(IR, PR.Current(), "Instance of TextDisplayTemplate",
				      STANDARD_TYPE(IGESGraph_TextDisplayTemplate), textTemplate,
				      Standard_True);

  // Reading nbval(Integer)
  if (PR.DefinedElseSkip()) 
    st = PR.ReadInteger(PR.Current(),"Count of Connect Points", nbval); //szv#4:S4163:12Mar99 `st=` not needed
  else nbval = 0;
  if (st && nbval > 0)
    {
      // Reading connectPoints(HArray1OfConnectPoint)
      connectPoints = new IGESDraw_HArray1OfConnectPoint(1, nbval);
      Handle(IGESDraw_ConnectPoint) tempConnectPoint;
      for (Standard_Integer i = 1; i <= nbval; i++)
	{
	  //st = PR.ReadEntity(IR, PR.Current(), "ConnectPoint entity",
			       //STANDARD_TYPE(IGESDraw_ConnectPoint),tempConnectPoint,
			       //Standard_True); //szv#4:S4163:12Mar99 moved in if
	  if (PR.ReadEntity(IR, PR.Current(), "ConnectPoint entity",
			    STANDARD_TYPE(IGESDraw_ConnectPoint),tempConnectPoint, Standard_True))
	  connectPoints->SetValue(i, tempConnectPoint);
	}
    }
  else if (nbval < 0)
    PR.AddFail ("Count of Connect point entities : Less than Zero");

  DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
  ent->Init
    (definition, translation, scale, typeflag,
     designator, textTemplate, connectPoints);
}

void IGESDraw_ToolNetworkSubfigure::WriteOwnParams
  (const Handle(IGESDraw_NetworkSubfigure)& ent, IGESData_IGESWriter& IW)  const
{
  IW.Send( ent->SubfigureDefinition() );
  IW.Send( ent->Translation().X() );
  IW.Send( ent->Translation().Y() );
  IW.Send( ent->Translation().Z() );
  IW.Send( ent->ScaleFactors().X() );
  IW.Send( ent->ScaleFactors().Y() );
  IW.Send( ent->ScaleFactors().Z() );
  IW.Send( ent->TypeFlag() );
  IW.Send( ent->ReferenceDesignator() );

  IW.Send( ent->DesignatorTemplate() );

  IW.Send( ent->NbConnectPoints() );

  Standard_Integer Up  = ent->NbConnectPoints();
  for ( Standard_Integer i = 1; i <= Up; i++)
    IW.Send( ent->ConnectPoint(i) );
}

void  IGESDraw_ToolNetworkSubfigure::OwnShared
  (const Handle(IGESDraw_NetworkSubfigure)& ent, Interface_EntityIterator& iter) const
{
  iter.GetOneItem( ent->SubfigureDefinition() );
  iter.GetOneItem( ent->DesignatorTemplate() );
  Standard_Integer Up  = ent->NbConnectPoints();
  for ( Standard_Integer i = 1; i <= Up; i++)
    iter.GetOneItem( ent->ConnectPoint(i) );
}

void IGESDraw_ToolNetworkSubfigure::OwnCopy
  (const Handle(IGESDraw_NetworkSubfigure)& another,
   const Handle(IGESDraw_NetworkSubfigure)& ent, Interface_CopyTool& TC) const
{
  Standard_Integer                       nbval;
  gp_XYZ                                 translation;
  gp_XYZ                                 scale;
  Standard_Integer                       typeflag; 
  Handle(TCollection_HAsciiString)       designator; 
  Handle(IGESDraw_HArray1OfConnectPoint) connectPoints;
 
  nbval         = another->NbConnectPoints();

  DeclareAndCast(IGESDraw_NetworkSubfigureDef, definition, 
                 TC.Transferred(another->SubfigureDefinition()));

  translation   = another->Translation();
  scale         = another->ScaleFactors();
  typeflag      = another->TypeFlag();
  if (!another->ReferenceDesignator().IsNull())
    designator  = new TCollection_HAsciiString
      (another->ReferenceDesignator());

  DeclareAndCast(IGESGraph_TextDisplayTemplate, textTemplate, 
                 TC.Transferred(another->DesignatorTemplate()));

  if (nbval > 0) connectPoints = new IGESDraw_HArray1OfConnectPoint(1, nbval);
  for (Standard_Integer i = 1; i <= nbval; i++)
    {
      DeclareAndCast(IGESDraw_ConnectPoint, tempconnectPoint, 
                     TC.Transferred(another->ConnectPoint(i)) );
      connectPoints->SetValue( i, tempconnectPoint );
    }

  ent->Init(definition, translation, scale, typeflag,
	    designator, textTemplate, connectPoints);
}

IGESData_DirChecker IGESDraw_ToolNetworkSubfigure::DirChecker
  (const Handle(IGESDraw_NetworkSubfigure)& /*ent*/)  const
{ 
  IGESData_DirChecker DC (420, 0);
  DC.Structure(IGESData_DefVoid);
  DC.LineFont(IGESData_DefAny);
  DC.LineWeight(IGESData_DefValue);
  DC.Color(IGESData_DefAny);
  return DC;
}

void IGESDraw_ToolNetworkSubfigure::OwnCheck
  (const Handle(IGESDraw_NetworkSubfigure)& ent,
   const Interface_ShareTool& , Handle(Interface_Check)& ach)  const
{
  if ( ent->TypeFlag() != 0 &&
      ent->TypeFlag() != 1 &&
      ent->TypeFlag() != 2 )
    ach->AddFail("Type Flag : Value != 0/1/2");
  if (ent->NbConnectPoints() != ent->SubfigureDefinition()->NbPointEntities())
    ach->AddFail("Count of associated Connect Points inconsistent with Definition");
  if (ent->ReferenceDesignator().IsNull())
    ach->AddFail("Primary Reference Designator : not defined");
}

void IGESDraw_ToolNetworkSubfigure::OwnDump
  (const Handle(IGESDraw_NetworkSubfigure)& ent, const IGESData_IGESDumper& dumper,
   const Handle(Message_Messenger)& S, const Standard_Integer level)  const
{
  Standard_Integer sublevel = (level <= 4) ? 0 : 1;

  S << "IGESDraw_NetworkSubfigure" << endl;

  S << "Network Subfigure Definition Entity : ";
  dumper.Dump(ent->SubfigureDefinition(),S, sublevel);
  S << endl << "Translation Data : ";
  IGESData_DumpXYZL(S,level, ent->Translation(), ent->Location());
  S << endl << "Scale Factors    : ";
  IGESData_DumpXYZ(S, ent->ScaleFactors());
  S << endl << "Type Flag : " << ent->TypeFlag() << endl;
  S << "Primary Reference Designator : ";
  IGESData_DumpString(S,ent->ReferenceDesignator());
  S << endl << "Text Display Template Entity : ";
  dumper.Dump(ent->DesignatorTemplate(),S, sublevel);
  S << endl << "Connect Points  : ";
  IGESData_DumpEntities(S,dumper ,level,1, ent->NbConnectPoints(),ent->ConnectPoint);
  S << endl;
}