summaryrefslogtreecommitdiff
path: root/src/IGESGeom/IGESGeom_ToolCurveOnSurface.cxx
blob: 9cef90c33810fe6f61cfaee3e371d3305103b056 (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
268
269
270
271
272
273
274
275
276
277
278
//--------------------------------------------------------------------
//
//  File Name : IGESGeom_CurveOnSurface.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESGeom_ToolCurveOnSurface.ixx>
#include <IGESData_ParamCursor.hxx>
#include <IGESData_IGESEntity.hxx>
#include <Interface_Macros.hxx>

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

//=======================================================================
//function : IGESGeom_ToolCurveOnSurface
//purpose  : 
//=======================================================================

IGESGeom_ToolCurveOnSurface::IGESGeom_ToolCurveOnSurface ()
{
}


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

void IGESGeom_ToolCurveOnSurface::ReadOwnParams
  (const Handle(IGESGeom_CurveOnSurface)& ent,
   const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
{

  // MGE 30/07/98

  Standard_Integer aMode, aPreference;
  Handle(IGESData_IGESEntity) aSurface;
  Handle(IGESData_IGESEntity) aCurveUV;
  Handle(IGESData_IGESEntity) aCurve3D;
  IGESData_Status aStatus;

  //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed

  if (!PR.ReadInteger(PR.Current(), aMode)){ //szv#4:S4163:12Mar99 `st=` not needed
    Message_Msg Msg276("XSTEP_276");
    PR.SendFail(Msg276);
  }
  if (!PR.ReadEntity(IR, PR.Current(),aStatus, aSurface)){
    Message_Msg Msg131("XSTEP_131");
    switch(aStatus) {
    case IGESData_ReferenceError: {  
      Message_Msg Msg216 ("IGES_216");
      Msg131.Arg(Msg216.Value());
      PR.SendFail(Msg131);
      break; }
    case IGESData_EntityError: {
      Message_Msg Msg217 ("IGES_217");
      Msg131.Arg(Msg217.Value());
      PR.SendFail(Msg131);
      break; }
    default:{
    }
    }
  } //szv#4:S4163:12Mar99 `st=` not needed

  if (!PR.ReadEntity(IR, PR.Current(), aStatus, aCurveUV, Standard_True)){
    Message_Msg Msg132("XSTEP_132");
    switch(aStatus) {
    case IGESData_ReferenceError: {  
      Message_Msg Msg216 ("IGES_216");
      Msg132.Arg(Msg216.Value());
      PR.SendFail(Msg132);
      break; }
    case IGESData_EntityError: {
      Message_Msg Msg217 ("IGES_217");
      Msg132.Arg(Msg217.Value());
      PR.SendFail(Msg132);
      break; }
    default:{
    }
    }
  } //szv#4:S4163:12Mar99 `st=` not needed
  if (!PR.ReadEntity(IR, PR.Current(), aStatus, aCurve3D, Standard_True)){; //szv#4:S4163:12Mar99 `st=` not needed
      Message_Msg Msg133("XSTEP_133");
      switch(aStatus) {
      case IGESData_ReferenceError: {  
	Message_Msg Msg216 ("IGES_216");
	Msg133.Arg(Msg216.Value());
	PR.SendFail(Msg133);
	break; }
      case IGESData_EntityError: {
	Message_Msg Msg217 ("IGES_217");
	Msg133.Arg(Msg217.Value());
	PR.SendFail(Msg133);
	break; }
      default:{
      }
      }
  }
  if (!PR.ReadInteger(PR.Current(), aPreference)){ //szv#4:S4163:12Mar99 `st=` not needed
    Message_Msg Msg277("XSTEP_277");  
    PR.SendFail(Msg277);
  }
/*
  st = PR.ReadInteger(PR.Current(), "Creation mode of curve", aMode);
  st = PR.ReadEntity(IR, PR.Current(), "Surface (on which curve lies)", aSurface);
  st = PR.ReadEntity(IR, PR.Current(), "Curve UV", aCurveUV, Standard_True);
  st = PR.ReadEntity(IR, PR.Current(), "Curve 3D", aCurve3D, Standard_True);
  st = PR.ReadInteger(PR.Current(), "Preferred representation", aPreference);
*/
  DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
  ent->Init
    (aMode, aSurface, aCurveUV, aCurve3D, aPreference);
}


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

void IGESGeom_ToolCurveOnSurface::WriteOwnParams
  (const Handle(IGESGeom_CurveOnSurface)& ent, IGESData_IGESWriter& IW)  const
{
  IW.Send(ent->CreationMode());
  IW.Send(ent->Surface());
  IW.Send(ent->CurveUV());
  IW.Send(ent->Curve3D());
  IW.Send(ent->PreferenceMode());
}


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

void IGESGeom_ToolCurveOnSurface::OwnShared(const Handle(IGESGeom_CurveOnSurface)& ent,
                                            Interface_EntityIterator& iter) const
{
  iter.GetOneItem(ent->Surface());
  iter.GetOneItem(ent->CurveUV());
  iter.GetOneItem(ent->Curve3D());
}


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

void IGESGeom_ToolCurveOnSurface::OwnCopy(const Handle(IGESGeom_CurveOnSurface)& another,
                                          const Handle(IGESGeom_CurveOnSurface)& ent,
                                          Interface_CopyTool& TC) const
{
  DeclareAndCast(IGESData_IGESEntity, aSurface, TC.Transferred(another->Surface()));
  DeclareAndCast(IGESData_IGESEntity, aCurveUV, TC.Transferred(another->CurveUV()));
  DeclareAndCast(IGESData_IGESEntity, aCurve3D, TC.Transferred(another->Curve3D()));

  Standard_Integer aMode = another->CreationMode();
  Standard_Integer aPreference = another->PreferenceMode();

  ent->Init(aMode, aSurface, aCurveUV, aCurve3D, aPreference);
}


//=======================================================================
//function : OwnCorrect
//purpose  : 
//=======================================================================

Standard_Boolean IGESGeom_ToolCurveOnSurface::OwnCorrect
  (const Handle(IGESGeom_CurveOnSurface)& ent) const
{
  Handle(IGESData_IGESEntity) c2d = ent->CurveUV();
  if (c2d.IsNull()) return Standard_False;
  Standard_Integer uf = c2d->UseFlag();
  if (uf == 5) return Standard_False;
  c2d->InitStatus
    (c2d->BlankStatus(),c2d->SubordinateStatus(),5,c2d->HierarchyStatus());
  return Standard_True;
}


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

IGESData_DirChecker IGESGeom_ToolCurveOnSurface::DirChecker
  (const Handle(IGESGeom_CurveOnSurface)& /* ent */ )  const
{
  IGESData_DirChecker DC(142, 0);
  DC.Structure(IGESData_DefVoid);
  DC.LineFont(IGESData_DefAny);
//  DC.LineWeight(IGESData_DefValue);
  DC.Color(IGESData_DefAny);

  DC.UseFlagRequired (5);
  DC.HierarchyStatusIgnored ();
  return DC;
}


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

void IGESGeom_ToolCurveOnSurface::OwnCheck(const Handle(IGESGeom_CurveOnSurface)& ent,
                                           const Interface_ShareTool&,
                                           Handle(Interface_Check)& ach)  const
{
  // MGE 30/07/98
  // Building of messages
  //========================================
  //Message_Msg Msg134 = Message_Msg("XSTEP_134");
  //========================================

//  if (ent->CreationMode() < 0 || ent->CreationMode() > 3)
//    ach.SendFail("Incorrect value for the Creation Mode");
//  Standard_Integer pref = ent->PreferenceMode();
//  if (pref < 0 || pref > 3)
//    ach.SendFail("Incorrect value for the Preference Mode");
//  tolerance a la norme
//  if (pref == 1 && ent->CurveUV().IsNull())
//    ach.AddWarning("Preference Mode asks UV and Curve UV not defined");
//  if (pref == 2 && ent->Curve3D().IsNull())
//    ach.AddWarning("Preference Mode asks UV and Curve UV not defined");
  if (ent->CurveUV().IsNull() && ent->Curve3D().IsNull()) {
    Message_Msg Msg134 = Message_Msg("XSTEP_134");
    ach->SendFail(Msg134);
  }
}


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

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

  Standard_Integer crem = ent->CreationMode();
  S << "Creation Mode : " << crem << "  i.e. ";
  if      (crem == 0) S << " <Unspecified>" << endl;
  else if (crem == 1) S << " Projection of a Curve on a Surface" << endl;
  else if (crem == 2) S << " Intersection of two Surfaces" << endl;
  else if (crem == 3) S << " Isoparametric Curve (either U or V)" << endl;
  else S << " <Incorrect Value>" << endl;
  S << "The Surface on which the curve lies : ";
  dumper.Dump(ent->Surface(),S, sublevel);
  S << endl;
  S << "The curve B (in the parametric space (u, v))  : ";
  dumper.Dump(ent->CurveUV(),S, sublevel);
  S << endl;
  S << "The curve C (in the 3D Space) : ";
  dumper.Dump(ent->Curve3D(),S, sublevel);
  S << endl;
  Standard_Integer pref = ent->PreferenceMode();
  S << "Preferred representation mode : " << pref << "  i.e. ";
  if      (pref == 0) S << " <Unspecified>" << endl;
  else if (pref == 1) S << " Curve B on Surface" << endl;
  else if (pref == 2) S << " Curve C in 3D Space" << endl;
  else if (pref == 3) S << " Curves B & C equally preferred" << endl;
  else S << " <Incorrect Value>" << endl;
}