summaryrefslogtreecommitdiff
path: root/src/IGESGeom/IGESGeom_ToolFlash.cxx
blob: 95ef9a1a488e6984cd90ae893200d3be0dc85b99 (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
//--------------------------------------------------------------------
//
//  File Name : IGESGeom_Flash.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESGeom_ToolFlash.ixx>
#include <IGESData_ParamCursor.hxx>
#include <gp_XY.hxx>
#include <gp_Pnt2d.hxx>
#include <IGESData_IGESEntity.hxx>
#include <IGESData_LineFontEntity.hxx>
#include <IGESData_Dump.hxx>
#include <Interface_Macros.hxx>


IGESGeom_ToolFlash::IGESGeom_ToolFlash ()    {  }


void IGESGeom_ToolFlash::ReadOwnParams
  (const Handle(IGESGeom_Flash)& ent,
   const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
{
  gp_XY aPoint;
  Standard_Real aDim1, aDim2, aRotation;
  Handle(IGESData_IGESEntity) aReference;
  Standard_Integer fn = ent->FormNumber();    // for default cases

  //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
  aDim1 = aDim2 = aRotation = 0.;    // default values

  // Reading reference of flash
  PR.ReadXY(PR.CurrentList(1, 2), "Reference of Flash", aPoint); //szv#4:S4163:12Mar99 `st=` not needed

  // Reading first flash sizing parameter
  if (PR.DefinedElseSkip())
    PR.ReadReal(PR.Current(), "First Flash sizing parameter", aDim1); //szv#4:S4163:12Mar99 `st=` not needed
  else if (fn > 0) PR.AddFail("Fist Flash sizing parameter : undefined");

  // Reading second flash sizing parameter
  if (PR.DefinedElseSkip())
    PR.ReadReal(PR.Current(), "Second Flash sizing parameter", aDim2); //szv#4:S4163:12Mar99 `st=` not needed
  else {
    if (fn > 1) PR.AddFail("Second Flash sizing parameter : not defined");
  }

  // Reading rotation of flash about reference point
  if (PR.DefinedElseSkip())
    PR.ReadReal(PR.Current(), "Rotation about ref. point", aRotation); //szv#4:S4163:12Mar99 `st=` not needed
  else {
    if (fn == 2 || fn == 4) PR.AddFail("Rotation about ref. point : not defined");
  }

  if ( PR.IsParamEntity(PR.CurrentNumber()) )
    // Reading the referenced entity
    PR.ReadEntity(IR, PR.Current(), "Referenced entity", aReference); //szv#4:S4163:12Mar99 `st=` not needed
  // "else" not necessary as this is the last field

  DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
  ent->Init (aPoint, aDim1, aDim2, aRotation, aReference);
}

void IGESGeom_ToolFlash::WriteOwnParams
  (const Handle(IGESGeom_Flash)& ent, IGESData_IGESWriter& IW)  const
{
  IW.Send( ent->ReferencePoint().X() );
  IW.Send( ent->ReferencePoint().Y() );
  IW.Send( ent->Dimension1() );
  IW.Send( ent->Dimension2() );
  IW.Send( ent->Rotation() );
  IW.Send( ent->ReferenceEntity() );
}

void  IGESGeom_ToolFlash::OwnShared
  (const Handle(IGESGeom_Flash)& ent, Interface_EntityIterator& iter) const
{
  iter.GetOneItem( ent->ReferenceEntity() );
}

void IGESGeom_ToolFlash::OwnCopy
  (const Handle(IGESGeom_Flash)& another,
   const Handle(IGESGeom_Flash)& ent, Interface_CopyTool& TC) const
{
  gp_XY aPoint = (another->ReferencePoint()).XY();
  Standard_Real aDim1 = another->Dimension1();
  Standard_Real aDim2 = another->Dimension2();
  Standard_Real aRotation = another->Rotation();

  DeclareAndCast(IGESData_IGESEntity, aReference,
		 TC.Transferred(another->ReferenceEntity()));

  ent->Init(aPoint, aDim1, aDim2, aRotation, aReference);
}

Standard_Boolean  IGESGeom_ToolFlash::OwnCorrect
  (const Handle(IGESGeom_Flash)& ent) const
{
  Standard_Integer fn = ent->FormNumber();
  Standard_Boolean res0 = (ent->RankLineFont() != 1);
  if (res0) {
    Handle(IGESData_LineFontEntity) nulfont;
    ent->InitLineFont(nulfont,1);    // ranklinefont force a 1
  }
  Standard_Boolean res1 = Standard_False;
  Handle(IGESData_IGESEntity) ref = ent->ReferenceEntity();
  if (fn != 0 && !ref.IsNull()) {
    ref.Nullify();
    res1 = Standard_True;
  }
  Standard_Real d1 = ent->Dimension1();
  Standard_Real d2 = ent->Dimension2();
  Standard_Real rt = ent->Rotation();
  if (fn == 0 && d1 != 0.) {  d1 = 0.; res1 = Standard_True;  }
  if (fn <= 1 && d2 != 0.) {  d2 = 0.; res1 = Standard_True;  }
  if ((fn <= 1 || fn == 3) && rt != 0.) {  rt = 0.; res1 = Standard_True;  }
  if (res1) ent->Init (ent->ReferencePoint().XY(), d1, d2, rt, ref);
  return (res0 || res1);
}

IGESData_DirChecker IGESGeom_ToolFlash::DirChecker
  (const Handle(IGESGeom_Flash)& /* ent */ )  const
{
  IGESData_DirChecker DC(125, 0, 4);
  DC.Structure(IGESData_DefVoid);
  DC.LineFont(IGESData_DefValue);
//  DC.LineWeight(IGESData_DefValue);
  DC.Color(IGESData_DefAny);
  DC.HierarchyStatusRequired(0);
  return DC;
}

void IGESGeom_ToolFlash::OwnCheck
  (const Handle(IGESGeom_Flash)& ent,
   const Interface_ShareTool& , Handle(Interface_Check)& ach)  const
{
  Standard_Integer fn = ent->FormNumber();
  if (ent->RankLineFont() != 1)
    ach->AddFail("LineFontPattern : Value != 1");
  if (ent->ReferenceEntity().IsNull()) {
    if (fn == 0)
      ach->AddFail("Flash defined by a Reference Entity, which is absent");
  }
  else if (fn != 0) ach->AddWarning("Reference Entity present though useless");
  if (fn == 1 && ent->Dimension2() != 0.)
    ach->AddWarning("Dimension 2 present though useless");
  if ((fn == 1 || fn == 3) && ent->Rotation() != 0.)
    ach->AddWarning("Rotation present though useless");
}


void IGESGeom_ToolFlash::OwnDump
  (const Handle(IGESGeom_Flash)& ent, const IGESData_IGESDumper& dumper,
   const Handle(Message_Messenger)& S, const Standard_Integer level)  const
{
  Standard_Integer sublevel = (level <= 4) ? 0 : 1;
  Standard_Integer fn = ent->FormNumber();

  S << "IGESGeom_Flash" << endl;
  switch (fn) {
    case 0 : S << " --    Form defined by reference entity   --" << endl; break;
    case 1 : S << " --    Circular    --  ";  break;
    case 2 : S << " --    Rectangle   --  ";  break;
    case 3 : S << " --    Donut    --  ";  break;
    case 4 : S << " --    Canoe    --  ";  break;
    default : break;
  }

  S << "Flash reference point    : ";
  IGESData_DumpXYL(S,level, ent->ReferencePoint(), ent->Location());
  S << " First sizing parameter  : " << ent->Dimension1() << "  ";
  S << " Second sizing parameter : " << ent->Dimension2() << endl;
  S << " Rotation about reference entity : " << ent->Rotation() << endl;
  S << "Reference Entity         : ";
  dumper.Dump(ent->ReferenceEntity(),S, sublevel);
  S << endl;
}