0022627: Change OCCT memory management defaults
[occt.git] / src / IGESBasic / IGESBasic_ToolSingleParent.cxx
CommitLineData
7fd59977 1//--------------------------------------------------------------------
2//
3// File Name : IGESBasic_SingleParent.cxx
4// Date :
5// Author : CKY / Contract Toubro-Larsen
6// Copyright : MATRA-DATAVISION 1993
7//
8//--------------------------------------------------------------------
9
10#include <IGESBasic_ToolSingleParent.ixx>
11#include <IGESData_ParamCursor.hxx>
12#include <IGESData_IGESEntity.hxx>
13#include <IGESData_HArray1OfIGESEntity.hxx>
14#include <IGESData_Dump.hxx>
15#include <Interface_Macros.hxx>
16
17// MGE 03/08/98
18#include <Message_Msg.hxx>
19#include <IGESData_Status.hxx>
20
21
22IGESBasic_ToolSingleParent::IGESBasic_ToolSingleParent () { }
23
24
25void IGESBasic_ToolSingleParent::ReadOwnParams
26 (const Handle(IGESBasic_SingleParent)& ent,
27 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
28{
29 // MGE 03/08/98
30 // Building of messages
31 //========================================
32 Message_Msg Msg207("XSTEP_207");
33 //========================================
34
35 Standard_Integer tempNbParentEntities;
36 Handle(IGESData_IGESEntity) tempParent;
37 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
38 Standard_Integer nbval = 0;
39 Handle(IGESData_HArray1OfIGESEntity) tempChildren;
40 IGESData_Status aStatus;
41
42 if(!PR.ReadInteger (PR.Current(),tempNbParentEntities)){ //szv#4:S4163:12Mar99 `st=` not needed
43 Message_Msg Msg204("XSTEP_204");
44 PR.SendFail(Msg204);
45 }
46 //st = PR.ReadInteger(PR.Current(), Msg205, nbval); //szv#4:S4163:12Mar99 moved down
47
48// st = PR.ReadInteger (PR.Current(),"Number of Parent entities",tempNbParentEntities);
49// st = PR.ReadInteger(PR.Current(), "Count of Children", nbval);
50 if (!PR.ReadInteger(PR.Current(), nbval)){
51 Message_Msg Msg205("XSTEP_205");
52 PR.SendFail(Msg205);
53 nbval = -1;
54 }
55 if (!PR.ReadEntity(IR,PR.Current(),aStatus,tempParent)){ //szv#4:S4163:12Mar99 `st=` not needed
56 //st = PR.ReadEntity(IR,PR.Current(),"ParentEntity",tempParent);
57 Message_Msg Msg206("XSTEP_206");
58 switch(aStatus) {
59 case IGESData_ReferenceError: {
60 Message_Msg Msg216 ("IGES_216");
61 Msg206.Arg(Msg216.Value());
62 PR.SendFail(Msg206);
63 break; }
64 case IGESData_EntityError: {
65 Message_Msg Msg217 ("IGES_217");
66 Msg206.Arg(Msg217.Value());
67 PR.SendFail(Msg206);
68 break; }
69 default:{
70 }
71 }
72 }
73
74 if (nbval > 0) PR.ReadEnts (IR,PR.CurrentList(nbval),Msg207,tempChildren); //szv#4:S4163:12Mar99 `st=` not needed
75 //st = PR.ReadEnts (IR,PR.CurrentList(nbval),"Child Entities",tempChildren);
76 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
77 ent->Init(tempNbParentEntities,tempParent,tempChildren);
78}
79
80void IGESBasic_ToolSingleParent::WriteOwnParams
81 (const Handle(IGESBasic_SingleParent)& ent, IGESData_IGESWriter& IW) const
82{
83 Standard_Integer upper = ent->NbChildren();
84 IW.Send(ent->NbParentEntities());
85 IW.Send(upper);
86 IW.Send(ent->SingleParent());
87 for (Standard_Integer i = 1; i <= upper; i ++)
88 IW.Send(ent->Child(i));
89}
90
91void IGESBasic_ToolSingleParent::OwnShared
92 (const Handle(IGESBasic_SingleParent)& ent, Interface_EntityIterator& iter) const
93{
94 iter.GetOneItem(ent->SingleParent());
95 Standard_Integer upper = ent->NbChildren();
96 for (Standard_Integer i = 1; i <= upper; i ++)
97 iter.GetOneItem(ent->Child(i));
98}
99
100void IGESBasic_ToolSingleParent::OwnCopy
101 (const Handle(IGESBasic_SingleParent)& another,
102 const Handle(IGESBasic_SingleParent)& ent, Interface_CopyTool& TC) const
103{
104 Standard_Integer aNbParentEntities = another->NbParentEntities();
105 DeclareAndCast(IGESData_IGESEntity,aparent,
106 TC.Transferred(another->SingleParent()));
107 Standard_Integer upper = another->NbChildren();
108 Handle(IGESData_HArray1OfIGESEntity) EntArray = new
109 IGESData_HArray1OfIGESEntity(1,upper);
110 for (Standard_Integer i = 1; i <= upper; i ++)
111 {
112 DeclareAndCast
113 (IGESData_IGESEntity,myentity,TC.Transferred(another->Child(i)));
114 EntArray->SetValue(i,myentity);
115 }
116 ent->Init(aNbParentEntities,aparent,EntArray);
117}
118
119Standard_Boolean IGESBasic_ToolSingleParent::OwnCorrect
120 (const Handle(IGESBasic_SingleParent)& ent) const
121{
122 if (ent->NbParentEntities() == 1) return Standard_False;
123 Standard_Integer nb = ent->NbChildren();
124 Handle(IGESData_HArray1OfIGESEntity) EntArray = new
125 IGESData_HArray1OfIGESEntity (1,nb);
126 for (Standard_Integer i = 1; i <= nb; i ++)
127 EntArray->SetValue(i,ent->Child(i));
128 ent->Init (1,ent->SingleParent(),EntArray);
129 return Standard_True; // nbparents = 1
130}
131
132IGESData_DirChecker IGESBasic_ToolSingleParent::DirChecker
133 (const Handle(IGESBasic_SingleParent)& /* ent */ ) const
134{
135 IGESData_DirChecker DC(402,9); //Form no = 9 & Type = 402
136 DC.Structure(IGESData_DefVoid);
137 DC.GraphicsIgnored();
138 DC.BlankStatusIgnored();
139 DC.HierarchyStatusIgnored();
140 return DC;
141}
142
143void IGESBasic_ToolSingleParent::OwnCheck
144 (const Handle(IGESBasic_SingleParent)& ent,
145 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
146{
147 // MGE 03/08/98
148 // Building of messages
149 //========================================
150// Message_Msg Msg204("XSTEP_204");
151 //========================================
152 if (ent->NbParentEntities() != 1){
153 Message_Msg Msg204("XSTEP_204");
154 ach->SendFail(Msg204);
155 }
156}
157
158void IGESBasic_ToolSingleParent::OwnDump
159 (const Handle(IGESBasic_SingleParent)& ent, const IGESData_IGESDumper& dumper,
160 const Handle(Message_Messenger)& S, const Standard_Integer level) const
161{
162 S << "IGESBasic_SingleParent" << endl;
163
164 S << "Number of ParentEntities : " << ent->NbParentEntities() << endl;
165 S << "ParentEntity : ";
166 dumper.Dump(ent->SingleParent(),S,(level <= 4) ? 0 : 1);
167 S << endl;
168 S << "Children : ";
169 IGESData_DumpEntities(S,dumper ,level,1, ent->NbChildren(),ent->Child);
170 S << endl;
171}