summaryrefslogtreecommitdiff
path: root/src/IGESGeom/IGESGeom_ToolBoundedSurface.cxx
blob: 26f089fcc4b5e042fbfb5b98b54094dd67b3df51 (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
//--------------------------------------------------------------------
//
//  File Name : IGESGeom_BoundedSurface.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESGeom_ToolBoundedSurface.ixx>
#include <IGESData_ParamCursor.hxx>
#include <IGESGeom_Boundary.hxx>
#include <IGESData_IGESEntity.hxx>
#include <IGESGeom_HArray1OfBoundary.hxx>
#include <IGESData_Dump.hxx>
#include <Interface_Macros.hxx>

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

//=======================================================================
//function : IGESGeom_ToolBoundedSurface
//purpose  : 
//=======================================================================

IGESGeom_ToolBoundedSurface::IGESGeom_ToolBoundedSurface ()
{
}


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

void IGESGeom_ToolBoundedSurface::ReadOwnParams(const Handle(IGESGeom_BoundedSurface)& ent,
                                                const Handle(IGESData_IGESReaderData)& IR,
                                                IGESData_ParamReader& PR) const
{
  // MGE 31/07/98

  //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
  Standard_Integer num, i;
  Standard_Integer tempType;
  Handle(IGESData_IGESEntity) tempSurface;
  Handle(IGESGeom_HArray1OfBoundary) tempBounds;
  IGESData_Status aStatus;

  //szv#4:S4163:12Mar99 `st=` not needed
  if (!PR.ReadInteger(PR.Current(), tempType)){
    Message_Msg Msg165("XTSEP_165");
    PR.SendFail(Msg165);
  }
  if (!PR.ReadEntity(IR, PR.Current(), aStatus, tempSurface)){
    Message_Msg Msg166("XTSEP_166");
    switch(aStatus) {
    case IGESData_ReferenceError: {  
      Message_Msg Msg216 ("IGES_216");
      Msg166.Arg(Msg216.Value());
      PR.SendFail(Msg166);
      break; }
    case IGESData_EntityError: {
      Message_Msg Msg217 ("IGES_217");
      Msg166.Arg(Msg217.Value());
      PR.SendFail(Msg166);
      break; }
    default:{
    }
    }
  }
  //st = PR.ReadInteger(PR.Current(), Msg167, num); //szv#4:S4163:12Mar99 moved in if
/*
  st = PR.ReadInteger(PR.Current(), "Bounded Surface Representation Type", tempType);
  st = PR.ReadEntity(IR, PR.Current(), "Surface to be Bounded", tempSurface);
  st = PR.ReadInteger(PR.Current(), "Number Of Boundary Entities", num);
*/

  //szv#4:S4163:12Mar99 optimized
  //if (st && num > 0)  tempBounds = new IGESGeom_HArray1OfBoundary(1, num);
  //if (st && num <= 0)  PR.SendFail(Msg167);
  if (PR.ReadInteger(PR.Current(), num) && (num > 0)) {
    tempBounds = new IGESGeom_HArray1OfBoundary(1, num);
  }
  else{ 
    Message_Msg Msg167("XTSEP_167");
    PR.SendFail(Msg167);
  }

  if (!tempBounds.IsNull()){
    for ( i = 1; i <= num; i++ )
      {
	Handle(IGESGeom_Boundary) tempEnt;
	//st = PR.ReadEntity(IR, PR.Current(), Msg168, tempEnt); //szv#4:S4163:12Mar99 moved in if
	//st = PR.ReadEntity(IR, PR.Current(), "Boundary Entities", tempEnt);
	if (PR.ReadEntity(IR, PR.Current(), aStatus, tempEnt))
	  tempBounds->SetValue(i, tempEnt);
	else{
	  Message_Msg Msg168("XTSEP_168");
	  switch(aStatus) {
	  case IGESData_ReferenceError: {  
	    Message_Msg Msg216 ("IGES_216");
	    Msg168.Arg(Msg216.Value());
	    PR.SendFail(Msg168);
	    break; }
	  case IGESData_EntityError: {
	    Message_Msg Msg217 ("IGES_217");
	    Msg168.Arg(Msg217.Value());
	    PR.SendFail(Msg168);
	    break; }
	  default:{
	  }
	  }
	}
      }
  }
    //sln 28.09.2001, BUC61004, If(tempBounds.IsNull()) function ent->Init is not called in order to avoid exception
  if(!tempBounds.IsNull())
    {
      DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
      ent->Init(tempType, tempSurface, tempBounds);
    }
}


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

void IGESGeom_ToolBoundedSurface::WriteOwnParams(const Handle(IGESGeom_BoundedSurface)& ent,
                                                 IGESData_IGESWriter& IW)  const
{
  Standard_Integer i, num;
  IW.Send(ent->RepresentationType());
  IW.Send(ent->Surface());
  IW.Send(ent->NbBoundaries());
  for ( num = ent->NbBoundaries(), i = 1; i <= num; i++ )
    IW.Send(ent->Boundary(i));
}


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

void IGESGeom_ToolBoundedSurface::OwnShared(const Handle(IGESGeom_BoundedSurface)& ent,
                                            Interface_EntityIterator& iter) const
{
  Standard_Integer i, num;
  iter.GetOneItem(ent->Surface());
  for ( num = ent->NbBoundaries(), i = 1; i <= num; i++ )
    iter.GetOneItem(ent->Boundary(i));
}


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

void IGESGeom_ToolBoundedSurface::OwnCopy(const Handle(IGESGeom_BoundedSurface)& another,
                                          const Handle(IGESGeom_BoundedSurface)& ent,
                                          Interface_CopyTool& TC) const
{
  Standard_Integer i, num;

  Standard_Integer tempType = another->RepresentationType();
  DeclareAndCast(IGESData_IGESEntity, tempSurface,
		 TC.Transferred(another->Surface()));
  num = another->NbBoundaries();
  Handle(IGESGeom_HArray1OfBoundary) tempBounds;
  if (num > 0) tempBounds = new IGESGeom_HArray1OfBoundary(1, num);
  for (i = 1; i <= num; i++)
    {
      DeclareAndCast(IGESGeom_Boundary, tempBoundary,
		     TC.Transferred(another->Boundary(i)));
      tempBounds->SetValue(i, tempBoundary);
    }
  ent->Init(tempType, tempSurface, tempBounds);
}


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

IGESData_DirChecker IGESGeom_ToolBoundedSurface::DirChecker
  (const Handle(IGESGeom_BoundedSurface)& /* ent */ )  const
{
  IGESData_DirChecker DC(143,0);
  DC.Structure(IGESData_DefVoid);
  DC.GraphicsIgnored();
  DC.LineFont(IGESData_DefAny);
//  DC.LineWeight(IGESData_DefValue);
  DC.Color(IGESData_DefAny);
  DC.UseFlagRequired(0);
  DC.HierarchyStatusIgnored();
  return DC;
}


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

void IGESGeom_ToolBoundedSurface::OwnCheck(const Handle(IGESGeom_BoundedSurface)& ent,
                                           const Interface_ShareTool&,
                                           Handle(Interface_Check)& ach)  const
{
  // MGE 31/07/98
  // Building of messages
  //========================================
  //Message_Msg Msg165("XTSEP_165");
  //========================================

  if ((ent->RepresentationType() != 0) && (ent->RepresentationType() != 1)) {
    Message_Msg Msg165("XTSEP_165");
    ach->SendFail(Msg165);
  }
}


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

void IGESGeom_ToolBoundedSurface::OwnDump(const Handle(IGESGeom_BoundedSurface)& ent,
                                          const IGESData_IGESDumper& dumper,
                                          const Handle(Message_Messenger)& S,
                                          const Standard_Integer level)  const
{
  Standard_Integer sublevel = (level > 4) ? 1 : 0;
  S << "IGESGeom_BoundedSurface" << endl;
  S << "Representation Type   : " << ent->RepresentationType() << endl;
  S << "Surface to be Bounded : ";
  dumper.Dump(ent->Surface(),S, sublevel);
  S << endl;
  S << "Boundary Entities     : ";
  IGESData_DumpEntities(S,dumper ,level,1, ent->NbBoundaries(),ent->Boundary);
  S << endl;
}