summaryrefslogtreecommitdiff
path: root/src/IGESSolid/IGESSolid_ToolShell.cxx
blob: be3f3842a66fee9b06a715fbefd8e48d059e9521 (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
//--------------------------------------------------------------------
//
//  File Name : IGESSolid_Shell.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESSolid_ToolShell.ixx>
#include <IGESData_ParamCursor.hxx>
#include <IGESSolid_Face.hxx>
#include <IGESSolid_HArray1OfFace.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <IGESData_Dump.hxx>
#include <Interface_Macros.hxx>
#include <IGESSolid.hxx>

// MGE 03/08/98
#include <Message_Msg.hxx>
#include <IGESData_Status.hxx>

//=======================================================================
//function : IGESSolid_ToolShell
//purpose  : 
//=======================================================================

IGESSolid_ToolShell::IGESSolid_ToolShell ()
{
}


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

void IGESSolid_ToolShell::ReadOwnParams(const Handle(IGESSolid_Shell)& ent,
                                        const Handle(IGESData_IGESReaderData)& IR,
                                        IGESData_ParamReader& PR) const
{

  // MGE 03/08/98

  //Standard_Boolean abool; //szv#4:S4163:12Mar99 moved down
  Standard_Integer nbfaces=0;; //szv#4:S4163:12Mar99 `i` moved in for
  //Handle(IGESSolid_Face) aface; //szv#4:S4163:12Mar99 moved down
  Handle(IGESSolid_HArray1OfFace) tempFaces;
  Handle(TColStd_HArray1OfInteger) tempOrientation;

  //st = PR.ReadInteger(PR.Current(), Msg200, nbfaces); //szv#4:S4163:12Mar99 moved in if
  //st = PR.ReadInteger(PR.Current(), "Number of faces", nbfaces);
  Standard_Boolean sb = PR.ReadInteger(PR.Current(), nbfaces);
  if (sb && nbfaces > 0 ) {
    Message_Msg Msg180("XSTEP_180");
    
    Standard_Boolean abool;
    Handle(IGESSolid_Face) aface;
    tempFaces = new IGESSolid_HArray1OfFace(1, nbfaces);
    tempOrientation = new TColStd_HArray1OfInteger(1, nbfaces);
    IGESData_Status aStatus;
    for (Standard_Integer i=1; i<=nbfaces; i++) {
      //st = PR.ReadEntity(IR, PR.Current(),Msg201, STANDARD_TYPE(IGESSolid_Face), aface); //szv#4:S4163:12Mar99 moved in if
      //st = PR.ReadEntity(IR, PR.Current(), "Faces", STANDARD_TYPE(IGESSolid_Face), aface);
      if (PR.ReadEntity(IR, PR.Current(),aStatus, STANDARD_TYPE(IGESSolid_Face), aface))
	tempFaces->SetValue(i, aface);
      else{
	Message_Msg Msg201("XSTEP_201");
	switch(aStatus) {
	case IGESData_ReferenceError: {  
	  Message_Msg Msg216 ("IGES_216");
	  Msg201.Arg(Msg216.Value());
	  PR.SendFail(Msg201);
	  break; }
	case IGESData_EntityError: {
	  Message_Msg Msg217 ("IGES_217");
	  Msg201.Arg(Msg217.Value());
	  PR.SendFail(Msg201);
	  break; }
	case IGESData_TypeError: {
	  Message_Msg Msg218 ("IGES_218");
	  Msg201.Arg(Msg218.Value());
	  PR.SendFail(Msg201);
	  break; }
	default:{
	}
	}
      }
      //st = PR.ReadBoolean(PR.Current(), Msg180, abool); //szv#4:S4163:12Mar99 moved in if
      //st = PR.ReadBoolean(PR.Current(), "Orientation flags", abool);
      if (PR.ReadBoolean(PR.Current(), Msg180, abool))
	tempOrientation->SetValue(i, (abool ? 1 : 0) );
    }
  }
  else {
    Message_Msg Msg200("XSTEP_200");
    PR.SendFail(Msg200);
  }
  
  DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
  ent->Init (tempFaces, tempOrientation);
}


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

void IGESSolid_ToolShell::WriteOwnParams(const Handle(IGESSolid_Shell)& ent,
                                         IGESData_IGESWriter& IW) const
{
  Standard_Integer i, nbfaces = ent->NbFaces();

  IW.Send(nbfaces);
  for (i = 1; i <= nbfaces; i ++)
    {
      IW.Send(ent->Face(i));
      IW.SendBoolean(ent->Orientation(i));
    }
}


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

void IGESSolid_ToolShell::OwnShared(const Handle(IGESSolid_Shell)& ent,
                                    Interface_EntityIterator& iter) const
{
  Standard_Integer nbfaces = ent->NbFaces();
  for (Standard_Integer i = 1; i <= nbfaces; i ++)
    iter.GetOneItem(ent->Face(i));
}


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

void IGESSolid_ToolShell::OwnCopy(const Handle(IGESSolid_Shell)& another,
                                  const Handle(IGESSolid_Shell)& ent,
                                  Interface_CopyTool& TC) const
{
  Standard_Integer nbfaces = another->NbFaces();

  Handle(IGESSolid_HArray1OfFace) tempFaces = new
    IGESSolid_HArray1OfFace(1, nbfaces);
  Handle(TColStd_HArray1OfInteger) tempOrientation = new
    TColStd_HArray1OfInteger(1, nbfaces);
  for (Standard_Integer i=1; i<=nbfaces; i++)
    {
      DeclareAndCast(IGESSolid_Face, face,
		     TC.Transferred(another->Face(i)));
      tempFaces->SetValue(i, face);
      tempOrientation->SetValue(i, (another->Orientation(i) ? 1 : 0) );
    }
  ent->Init (tempFaces, tempOrientation);
}


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

IGESData_DirChecker IGESSolid_ToolShell::DirChecker
  (const Handle(IGESSolid_Shell)& /* ent */ ) const
{
  IGESData_DirChecker DC(514, 1,2);

  DC.Structure  (IGESData_DefVoid);
  DC.LineFont   (IGESData_DefVoid);
  DC.LineWeight (IGESData_DefVoid);
  DC.Color      (IGESData_DefVoid);

  DC.SubordinateStatusRequired(1);
  return DC;
}


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

void IGESSolid_ToolShell::OwnCheck(const Handle(IGESSolid_Shell)& ent,
                                   const Interface_ShareTool&,
                                   Handle(Interface_Check)& ach) const
{
  // MGE 03/08/98
  // Building of messages
  //========================================
  //Message_Msg Msg200("XSTEP_200");
  //========================================

  if (ent->NbFaces() <= 0) {
    Message_Msg Msg200("XSTEP_200");
    ach->SendFail(Msg200);
  }
}


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

void IGESSolid_ToolShell::OwnDump(const Handle(IGESSolid_Shell)& ent,
                                  const IGESData_IGESDumper& dumper,
                                  const Handle(Message_Messenger)& S,
                                  const Standard_Integer level) const
{
  S << "IGESSolid_Shell" << endl;
  Standard_Integer upper = ent->NbFaces();
  Standard_Integer sublevel = (level <= 4) ? 0 : 1;

  S << "Faces : " << endl << "Orientation flags : ";
  IGESData_DumpEntities(S,dumper,-level,1, ent->NbFaces(),ent->Face);
  S << endl;
  if (level > 4)
    {
      S << "[" << endl;
      for (Standard_Integer i = 1; i <= upper; i ++)
	{
          S << "[" << i << "]:  ";
          S << "Face : ";
          dumper.Dump (ent->Face(i),S, sublevel);
          S << "  - Orientation flag : ";
          if (ent->Orientation(i)) S << "True" << endl;
          else                     S << "False" << endl;
	}
    }
  S << endl;
}