summaryrefslogtreecommitdiff
path: root/src/IGESGeom/IGESGeom_ToolPlane.cxx
blob: 94b53f7b9bb897f8614163024f5a125b1d26ba10 (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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
//--------------------------------------------------------------------
//
//  File Name : IGESGeom_Plane.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESGeom_ToolPlane.ixx>
#include <IGESData_ParamCursor.hxx>
#include <gp_XYZ.hxx>
#include <gp_Pnt.hxx>
#include <IGESData_IGESEntity.hxx>
#include <IGESData_Dump.hxx>
#include <Interface_MSG.hxx>
#include <Interface_Macros.hxx>
#include <stdio.h>

// MGE 30/07/98
#include <Message_Msg.hxx>
#include <IGESData_Status.hxx>

//=======================================================================
//function : IGESGeom_ToolPlane
//purpose  : 
//=======================================================================

IGESGeom_ToolPlane::IGESGeom_ToolPlane ()
{
}


//=======================================================================
//function : ReadOwnParams
//purpose  : 
//=======================================================================

void IGESGeom_ToolPlane::ReadOwnParams(const Handle(IGESGeom_Plane)& ent,
                                       const Handle(IGESData_IGESReaderData)& IR,
                                       IGESData_ParamReader& PR) const
{
  // MGE 30/07/98

  Standard_Real A = 0.0 , B = 0.0, C = 0.0, D = 0.0, aSize = 0.;
  Handle(IGESData_IGESEntity) aCurve;
  gp_XYZ attach (0.,0.,0.);
  IGESData_Status aStatus;
  //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed

/*  PR.ReadReal(PR.Current(), Msg135, A); //szv#4:S4163:12Mar99 `st=` not needed
  PR.ReadReal(PR.Current(), Msg135, B); //szv#4:S4163:12Mar99 `st=` not needed
  PR.ReadReal(PR.Current(), Msg135, C); //szv#4:S4163:12Mar99 `st=` not needed
  PR.ReadReal(PR.Current(), Msg135, D); //szv#4:S4163:12Mar99 `st=` not needed
*/
  if ((!PR.ReadReal(PR.Current(),A)) || (!PR.ReadReal(PR.Current(),B)) ||
      (!PR.ReadReal(PR.Current(),C)) || (!PR.ReadReal(PR.Current(),D))){
    Message_Msg Msg135("XSTEP_135");
    PR.SendFail(Msg135);
  }
/*
  st = PR.ReadReal(PR.Current(), "Coefficient Of Plane", A);
  st = PR.ReadReal(PR.Current(), "Coefficient Of Plane", B);
  st = PR.ReadReal(PR.Current(), "Coefficient Of Plane", C);
  st = PR.ReadReal(PR.Current(), "Coefficient Of Plane", D);
*/
  if (PR.IsParamDefined(PR.CurrentNumber())) {
    if (!PR.ReadEntity(IR, PR.Current(), aStatus, aCurve,Standard_True)){
      Message_Msg Msg136("XSTEP_136");
      switch(aStatus) {
      case IGESData_ReferenceError: {  
	Message_Msg Msg216 ("IGES_216");
	Msg136.Arg(Msg216.Value());
	PR.SendFail(Msg136);
	break; }
      case IGESData_EntityError: {
	Message_Msg Msg217 ("IGES_217");
	Msg136.Arg(Msg217.Value());
	PR.SendFail(Msg136);
	break; }
      default:{
      }
      }
    }
  } //szv#4:S4163:12Mar99 `st=` not needed
    //st = PR.ReadEntity(IR, PR.Current(), "Bounding Curve", aCurve,Standard_True);
//  en principe exige si FormNumber != 0 ... cf OwnCheck (Load accepte)

  if (PR.IsParamDefined(PR.CurrentNumber())) {
    Message_Msg Msg139("XSTEP_139");
   
    PR.ReadXYZ(PR.CurrentList(1, 3), Msg139, attach); //szv#4:S4163:12Mar99 `st=` not needed
    //st = PR.ReadXYZ(PR.CurrentList(1, 3), "Coord of DisplaySymbol", attach);

    if (!PR.ReadReal(PR.Current(), aSize)){
      Message_Msg Msg138("XSTEP_138");
      PR.SendFail(Msg138);
    } //szv#4:S4163:12Mar99 `st=` not needed
    //st = PR.ReadReal(PR.Current(), "DisplaySymbol Size", aSize);
  }// else {
   /* for (int i = 1; i <= 4; i ++) st = PR.DefinedElseSkip();
    PR.AddWarning("Display Symbol not defined at all");
   */ 
 // }

  DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
  ent->Init(A, B, C, D, aCurve, attach, aSize);
}


//=======================================================================
//function : WriteOwnParams
//purpose  : 
//=======================================================================

void IGESGeom_ToolPlane::WriteOwnParams(const Handle(IGESGeom_Plane)& ent,
                                        IGESData_IGESWriter& IW)  const
{
  Standard_Real A,B,C,D;
  ent->Equation(A,B,C,D);
  IW.Send(A);
  IW.Send(B);
  IW.Send(C);
  IW.Send(D);

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

  IW.Send(ent->SymbolAttach().X());
  IW.Send(ent->SymbolAttach().Y());
  IW.Send(ent->SymbolAttach().Z());
  IW.Send(ent->SymbolSize());
}


//=======================================================================
//function : OwnShared
//purpose  : 
//=======================================================================

void IGESGeom_ToolPlane::OwnShared(const Handle(IGESGeom_Plane)& ent,
                                   Interface_EntityIterator& iter) const
{
  iter.GetOneItem(ent->BoundingCurve());
}


//=======================================================================
//function : OwnCopy
//purpose  : 
//=======================================================================

void IGESGeom_ToolPlane::OwnCopy(const Handle(IGESGeom_Plane)& another,
                                 const Handle(IGESGeom_Plane)& ent,
                                 Interface_CopyTool& TC) const
{
  Standard_Real A, B, C, D;
  another->Equation(A, B, C, D);
  gp_XYZ attach = (another->SymbolAttach()).XYZ();
  Standard_Real aSize = another->SymbolSize();
  DeclareAndCast(IGESData_IGESEntity,aCurve,
		 TC.Transferred(another->BoundingCurve()));
  ent->Init(A, B, C, D, aCurve, attach, aSize);
  ent->SetFormNumber(another->FormNumber());
}


//=======================================================================
//function : DirChecker
//purpose  : 
//=======================================================================

IGESData_DirChecker IGESGeom_ToolPlane::DirChecker
  (const Handle(IGESGeom_Plane)& ent )  const
{
  IGESData_DirChecker DC(108,-1,1);
  DC.Structure(IGESData_DefVoid);
  if (ent->FormNumber() != 0)
    {
      DC.LineFont(IGESData_DefAny);
//      DC.LineWeight(IGESData_DefValue);
    }
  else
    {
      DC.LineFont(IGESData_DefVoid);
      DC.LineWeight(IGESData_DefVoid);
      DC.HierarchyStatusIgnored();
    }
  DC.Color(IGESData_DefAny);
  return DC;
}


//=======================================================================
//function : OwnCheck
//purpose  : 
//=======================================================================

void IGESGeom_ToolPlane::OwnCheck(const Handle(IGESGeom_Plane)& ent,
                                  const Interface_ShareTool&,
                                  Handle(Interface_Check)& ach)  const
{
  // MGE 30/07/98
  // Building of messages
  //========================================
  //Message_Msg Msg71("XSTEP_71");
  //Message_Msg Msg137("XSTEP_137");
  //========================================

  //szv#4:S4163:12Mar99 not needed
  //Standard_Real eps = 1.E-06;  // ?? Precision
  //Standard_Real A,B,C,D;
  //ent->Equation(A,B,C,D);
  if (ent->FormNumber() < -1 || ent->FormNumber() > 1) {
    Message_Msg Msg71("XSTEP_71");
    ach->SendFail(Msg71);
  }
  //szv#4:S4163:12Mar99 `!=` wrong operation on Standard_Boolean
  Standard_Boolean unbounded1 = ent->BoundingCurve().IsNull();
  Standard_Boolean unbounded2 = (ent->FormNumber() == 0);
  if ( (unbounded1 && !unbounded2) || (!unbounded1 && unbounded2) ) {
    Message_Msg Msg137("XSTEP_137");
    ach->SendFail(Msg137);
  }
// These messages are transfered in the translation procedure
//  if ( (A*A + B*B + C*C) < eps)    //  pas nul !
//    ach.SendFail("Incorrect Coefficients for the Plane");
  if ( !ent->HasBoundingCurve()) return;
//  Symbol : verifie si Size defini > 0 (sinon, n a pas de signification)
/*  Standard_Real ec = 0.;
  if (ent->SymbolSize() > 0.) ec = A*ent->SymbolAttach().X() + B*ent->SymbolAttach().Y() +
      C * ent->SymbolAttach().Z() - D;
  if ( ec > eps || ec < -eps) {
    char mess[80];
    sprintf(mess,"Symbol Attach not in the Plane, gap/equation over %f",
	    Interface_MSG::Intervalled(ec));
    ach.SendWarning(mess,"Symbol Attach not in the Plane");

  }
*/
}


//=======================================================================
//function : OwnDump
//purpose  : 
//=======================================================================

void IGESGeom_ToolPlane::OwnDump(const Handle(IGESGeom_Plane)& ent,
                                 const IGESData_IGESDumper& dumper,
                                 const Handle(Message_Messenger)& S,
                                 const Standard_Integer level)  const
{
  S << "IGESGeom_Plane" << endl;
  Standard_Real A,B,C,D;
  ent->Equation(A,B,C,D);

  S << "Plane Coefficient A : " << A << endl;
  S << "Plane Coefficient B : " << B << endl;
  S << "Plane Coefficient C : " << C << endl;
  S << "Plane Coefficient D : " << D << endl;
  S << "The Bounding Curve  : " ;
  dumper.Dump(ent->BoundingCurve(),S, (level <= 4) ? 0 : 1);
  S << endl;
  S << "Display Symbol Location : ";
  IGESData_DumpXYZL(S,level, ent->SymbolAttach(), ent->Location());
  S << "  Size  : " << ent->SymbolSize() << endl;
}