summaryrefslogtreecommitdiff
path: root/src/IGESGeom/IGESGeom_ToolTrimmedSurface.cxx
blob: 428bfcd85b99bed6aa359366ad2e022980a67f1c (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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
//--------------------------------------------------------------------
//
//  File Name : IGESGeom_TrimmedSurface.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESGeom_ToolTrimmedSurface.ixx>
#include <IGESData_ParamCursor.hxx>
#include <IGESData_IGESEntity.hxx>
#include <IGESGeom_CurveOnSurface.hxx>
#include <IGESGeom_HArray1OfCurveOnSurface.hxx>
#include <IGESData_Dump.hxx>
#include <Interface_Macros.hxx>

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

//=======================================================================
//function : IGESGeom_ToolTrimmedSurface
//purpose  : 
//=======================================================================

IGESGeom_ToolTrimmedSurface::IGESGeom_ToolTrimmedSurface ()
{
}


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

void IGESGeom_ToolTrimmedSurface::ReadOwnParams
  (const Handle(IGESGeom_TrimmedSurface)& ent,
   const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
{
  // MGE 31/07/98
  // Building of messages
  //========================================
  //========================================

  //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
  Standard_Integer aFlag;
  Standard_Integer count;
  Handle(IGESData_IGESEntity) aSurface;
  Handle(IGESGeom_CurveOnSurface) anOuter;
  Handle(IGESGeom_HArray1OfCurveOnSurface) anInner;
  IGESData_Status aStatus;

  //szv#4:S4163:12Mar99 `st=` not needed
  if (!PR.ReadEntity(IR, PR.Current(), aStatus, aSurface)){
    Message_Msg Msg169("XSTEP_169");
    switch(aStatus) {
    case IGESData_ReferenceError: {  
      Message_Msg Msg216 ("IGES_216");
      Msg169.Arg(Msg216.Value());
      PR.SendFail(Msg169);
      break; }
    case IGESData_EntityError: {
      Message_Msg Msg217 ("IGES_217");
      Msg169.Arg(Msg217.Value());
      PR.SendFail(Msg169);
      break; }
    default:{
    }
    }
  }
  if (!PR.ReadInteger(PR.Current(), aFlag)){
    Message_Msg Msg170("XSTEP_170");
    PR.SendFail(Msg170);
  }
  //st = PR.ReadInteger(PR.Current(), Msg171, count); //szv#4:S4163:12Mar99 moved in if

/*
  st = PR.ReadEntity(IR, PR.Current(), "Surface to be trimmed", aSurface);
  st = PR.ReadInteger(PR.Current(), "Outer boundary type", aFlag);
  st = PR.ReadInteger(PR.Current(), "Number of inner boundary closed curves", count);
*/
  if (PR.ReadInteger(PR.Current(), count)) {
    if (count < 0){
      Message_Msg Msg171("XSTEP_171");
      PR.SendFail (Msg171);
    }
    else  if (count > 0) anInner =
      new IGESGeom_HArray1OfCurveOnSurface(1, count);
  }
  else {
    Message_Msg Msg171("XSTEP_171");
    PR.SendFail(Msg171);
  }

  if (!PR.ReadEntity(IR, PR.Current(), aStatus,
		STANDARD_TYPE(IGESGeom_CurveOnSurface), anOuter,Standard_True)){
    Message_Msg Msg172("XSTEP_172");
    switch(aStatus) {
    case IGESData_ReferenceError: {  
      Message_Msg Msg216 ("IGES_216");
      Msg172.Arg(Msg216.Value());
      PR.SendFail(Msg172);
      break; }
    case IGESData_EntityError: {
      Message_Msg Msg217 ("IGES_217");
      Msg172.Arg(Msg217.Value());
      PR.SendFail(Msg172);
      break; }
    case IGESData_TypeError: {
      Message_Msg Msg218 ("IGES_218");
      Msg172.Arg(Msg218.Value());
      PR.SendFail(Msg172);
      break; }
    default:{
    }
    }
  } //szv#4:S4163:12Mar99 `st=` not needed
/*  st = PR.ReadEntity(IR, PR.Current(), "Outer boundary curve",
		     STANDARD_TYPE(IGESGeom_CurveOnSurface), anOuter,Standard_True);
*/
  if (! anInner.IsNull()) {
    Standard_Integer I;
    for (I = 1; I <= count; I++ ) {
      Handle(IGESGeom_CurveOnSurface) tempEnt;
      //st = PR.ReadEntity(IR, PR.Current(), Msg173,
			   //STANDARD_TYPE(IGESGeom_CurveOnSurface), tempEnt); //szv#4:S4163:12Mar99 moved in if
/*      st = PR.ReadEntity(IR, PR.Current(), "Inner boundary curves",
			 STANDARD_TYPE(IGESGeom_CurveOnSurface), tempEnt);
*/
      if (PR.ReadEntity(IR, PR.Current(), aStatus, STANDARD_TYPE(IGESGeom_CurveOnSurface), tempEnt))
	anInner->SetValue(I, tempEnt);
      else{
	Message_Msg Msg173("XSTEP_173");
	switch(aStatus) {
	case IGESData_ReferenceError: {  
	  Message_Msg Msg216 ("IGES_216");
	  Msg173.Arg(Msg216.Value());
	  PR.SendFail(Msg173);
	  break; }
	case IGESData_EntityError: {
	  Message_Msg Msg217 ("IGES_217");
	  Msg173.Arg(Msg217.Value());
	  PR.SendFail(Msg173);
	  break; }
	case IGESData_TypeError: {
	  Message_Msg Msg218 ("IGES_218");
	  Msg173.Arg(Msg218.Value());
	  PR.SendFail(Msg173);
	  break; }
	default:{
	}
	}
      }
    }
  }

  DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
  ent->Init(aSurface, aFlag, anOuter, anInner);
}


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

void IGESGeom_ToolTrimmedSurface::WriteOwnParams
  (const Handle(IGESGeom_TrimmedSurface)& ent, IGESData_IGESWriter& IW)  const
{
  Standard_Integer up  = ent->NbInnerContours();
  IW.Send(ent->Surface());
  IW.Send(ent->OuterBoundaryType());
  IW.Send(up);

  IW.Send(ent->OuterContour());
  Standard_Integer I;
  for (I = 1; I <= up; I ++)
    IW.Send(ent->InnerContour(I));
}


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

void IGESGeom_ToolTrimmedSurface::OwnShared(const Handle(IGESGeom_TrimmedSurface)& ent,
                                            Interface_EntityIterator& iter) const
{
  Standard_Integer up  = ent->NbInnerContours();
  iter.GetOneItem(ent->Surface());
  iter.GetOneItem(ent->OuterContour());
  Standard_Integer I;
  for (I = 1; I <= up; I ++)  iter.GetOneItem(ent->InnerContour(I));
}


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

void IGESGeom_ToolTrimmedSurface::OwnCopy(const Handle(IGESGeom_TrimmedSurface)& another,
                                          const Handle(IGESGeom_TrimmedSurface)& ent,
                                          Interface_CopyTool& TC) const
{
  Handle(IGESGeom_HArray1OfCurveOnSurface) anInner;

  DeclareAndCast(IGESData_IGESEntity, aSurface,
                 TC.Transferred(another->Surface()));
  Standard_Integer aFlag = another->OuterBoundaryType();
  DeclareAndCast(IGESGeom_CurveOnSurface, anOuter,
                 TC.Transferred(another->OuterContour()));
  Standard_Integer count = another->NbInnerContours();

  if (count > 0) {
    anInner = new IGESGeom_HArray1OfCurveOnSurface(1, count);
    Standard_Integer I;
    for (I = 1; I <= count; I++) {
      DeclareAndCast(IGESGeom_CurveOnSurface, temp,
		     TC.Transferred(another->InnerContour(I)));
      anInner->SetValue(I, temp);
    }
  }

  ent->Init(aSurface, aFlag, anOuter, anInner);
}


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

IGESData_DirChecker IGESGeom_ToolTrimmedSurface::DirChecker
  (const Handle(IGESGeom_TrimmedSurface)& /* ent */ )   const
{
  IGESData_DirChecker DC(144, 0);
  DC.Structure(IGESData_DefVoid);
  DC.LineFont(IGESData_DefAny);
//  DC.LineWeight(IGESData_DefValue);
  DC.Color(IGESData_DefAny);
  DC.UseFlagRequired (0);
  DC.HierarchyStatusIgnored();

  return DC;
}


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

void IGESGeom_ToolTrimmedSurface::OwnCheck(const Handle(IGESGeom_TrimmedSurface)& ent,
                                           const Interface_ShareTool&,
                                           Handle(Interface_Check)& ach)  const
{
  // MGE 31/07/98
  // Building of messages
  //========================================
  //Message_Msg Msg172("XSTEP_172");
  //========================================

  if (ent->OuterBoundaryType() != 0 &&   ent->OuterBoundaryType() != 1) {
    Message_Msg Msg172("XSTEP_172");
    ach->SendFail(Msg172);
  }
}


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

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

  S << "IGESGeom_TrimmedSurface" << endl;

  S << "Surface to be trimmed : ";
  dumper.Dump(ent->Surface(),S, tempSubLevel);
  S << endl;
  S << "Boundary type    : " << ent->OuterBoundaryType() << endl;
  S << "Outer Boundary   : ";
  dumper.Dump(ent->OuterContour(),S, tempSubLevel);
  S << endl;
  S << "Inner Boundaries : ";
  IGESData_DumpEntities(S,dumper ,level,1, ent->NbInnerContours(),ent->InnerContour);
  S << endl;
}