summaryrefslogtreecommitdiff
path: root/src/IGESBasic/IGESBasic_ToolSingleParent.cxx
blob: 91ddd0472b89d42b585d61acd285d067c288bae3 (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
//--------------------------------------------------------------------
//
//  File Name : IGESBasic_SingleParent.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESBasic_ToolSingleParent.ixx>
#include <IGESData_ParamCursor.hxx>
#include <IGESData_IGESEntity.hxx>
#include <IGESData_HArray1OfIGESEntity.hxx>
#include <IGESData_Dump.hxx>
#include <Interface_Macros.hxx>

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


IGESBasic_ToolSingleParent::IGESBasic_ToolSingleParent ()    {  }


void  IGESBasic_ToolSingleParent::ReadOwnParams
  (const Handle(IGESBasic_SingleParent)& ent,
   const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
{
  // MGE 03/08/98
  // Building of messages
  //========================================
  Message_Msg Msg207("XSTEP_207");
  //========================================

  Standard_Integer tempNbParentEntities;
  Handle(IGESData_IGESEntity) tempParent;
  //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
  Standard_Integer nbval = 0;
  Handle(IGESData_HArray1OfIGESEntity)  tempChildren;
  IGESData_Status aStatus;

  if(!PR.ReadInteger (PR.Current(),tempNbParentEntities)){ //szv#4:S4163:12Mar99 `st=` not needed
    Message_Msg Msg204("XSTEP_204");
    PR.SendFail(Msg204);
  }
  //st = PR.ReadInteger(PR.Current(), Msg205, nbval); //szv#4:S4163:12Mar99 moved down

//  st = PR.ReadInteger (PR.Current(),"Number of Parent entities",tempNbParentEntities);
//  st = PR.ReadInteger(PR.Current(), "Count of Children", nbval);
  if (!PR.ReadInteger(PR.Current(), nbval)){
    Message_Msg Msg205("XSTEP_205");
    PR.SendFail(Msg205);
    nbval = -1;
  }
  if (!PR.ReadEntity(IR,PR.Current(),aStatus,tempParent)){ //szv#4:S4163:12Mar99 `st=` not needed
  //st = PR.ReadEntity(IR,PR.Current(),"ParentEntity",tempParent);
    Message_Msg Msg206("XSTEP_206");
    switch(aStatus) {
    case IGESData_ReferenceError: {  
      Message_Msg Msg216 ("IGES_216");
      Msg206.Arg(Msg216.Value());
      PR.SendFail(Msg206);
      break; }
    case IGESData_EntityError: {
      Message_Msg Msg217 ("IGES_217");
      Msg206.Arg(Msg217.Value());
      PR.SendFail(Msg206);
      break; }
    default:{
    }
    }
  }

  if (nbval > 0) PR.ReadEnts (IR,PR.CurrentList(nbval),Msg207,tempChildren); //szv#4:S4163:12Mar99 `st=` not needed
  //st = PR.ReadEnts (IR,PR.CurrentList(nbval),"Child Entities",tempChildren);
  DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
  ent->Init(tempNbParentEntities,tempParent,tempChildren);
}

void  IGESBasic_ToolSingleParent::WriteOwnParams
  (const Handle(IGESBasic_SingleParent)& ent, IGESData_IGESWriter& IW) const
{
  Standard_Integer upper = ent->NbChildren();
  IW.Send(ent->NbParentEntities());
  IW.Send(upper);
  IW.Send(ent->SingleParent());
  for (Standard_Integer i = 1; i <= upper; i ++)
    IW.Send(ent->Child(i));
}

void  IGESBasic_ToolSingleParent::OwnShared
  (const Handle(IGESBasic_SingleParent)& ent, Interface_EntityIterator& iter) const
{
  iter.GetOneItem(ent->SingleParent());
  Standard_Integer upper = ent->NbChildren();
  for (Standard_Integer i = 1; i <= upper; i ++)
    iter.GetOneItem(ent->Child(i));
}

void  IGESBasic_ToolSingleParent::OwnCopy
  (const Handle(IGESBasic_SingleParent)& another,
   const Handle(IGESBasic_SingleParent)& ent, Interface_CopyTool& TC) const
{
  Standard_Integer aNbParentEntities = another->NbParentEntities();
  DeclareAndCast(IGESData_IGESEntity,aparent,
		 TC.Transferred(another->SingleParent()));
  Standard_Integer upper = another->NbChildren();
  Handle(IGESData_HArray1OfIGESEntity)  EntArray = new
    IGESData_HArray1OfIGESEntity(1,upper);
  for (Standard_Integer i = 1; i <= upper; i ++)
    {
      DeclareAndCast
	(IGESData_IGESEntity,myentity,TC.Transferred(another->Child(i)));
      EntArray->SetValue(i,myentity);
    }
  ent->Init(aNbParentEntities,aparent,EntArray);
}

Standard_Boolean  IGESBasic_ToolSingleParent::OwnCorrect
  (const Handle(IGESBasic_SingleParent)& ent) const
{
  if (ent->NbParentEntities() == 1) return Standard_False;
  Standard_Integer nb = ent->NbChildren();
  Handle(IGESData_HArray1OfIGESEntity)  EntArray = new
    IGESData_HArray1OfIGESEntity (1,nb);
  for (Standard_Integer i = 1; i <= nb; i ++)
    EntArray->SetValue(i,ent->Child(i));
  ent->Init (1,ent->SingleParent(),EntArray);
  return Standard_True;    // nbparents = 1
}

IGESData_DirChecker  IGESBasic_ToolSingleParent::DirChecker
  (const Handle(IGESBasic_SingleParent)& /* ent */ ) const
{
  IGESData_DirChecker DC(402,9);  //Form no = 9 & Type = 402
  DC.Structure(IGESData_DefVoid);
  DC.GraphicsIgnored();
  DC.BlankStatusIgnored();
  DC.HierarchyStatusIgnored();
  return DC;
}

void  IGESBasic_ToolSingleParent::OwnCheck
  (const Handle(IGESBasic_SingleParent)& ent,
   const Interface_ShareTool& , Handle(Interface_Check)& ach) const
{
   // MGE 03/08/98
  // Building of messages
  //========================================
//  Message_Msg Msg204("XSTEP_204");
  //========================================
  if (ent->NbParentEntities() != 1){
    Message_Msg Msg204("XSTEP_204");
    ach->SendFail(Msg204);
  }
}

void  IGESBasic_ToolSingleParent::OwnDump
  (const Handle(IGESBasic_SingleParent)& ent, const IGESData_IGESDumper& dumper,
   const Handle(Message_Messenger)& S, const Standard_Integer level) const
{
  S << "IGESBasic_SingleParent" << endl;

  S << "Number of ParentEntities : " << ent->NbParentEntities() << endl;
  S << "ParentEntity : ";
  dumper.Dump(ent->SingleParent(),S,(level <= 4) ? 0 : 1);
  S << endl;
  S << "Children : ";
  IGESData_DumpEntities(S,dumper ,level,1, ent->NbChildren(),ent->Child);
  S << endl;
}