1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
19 #include <IGESBasic_ToolSingleParent.ixx>
20 #include <IGESData_ParamCursor.hxx>
21 #include <IGESData_IGESEntity.hxx>
22 #include <IGESData_HArray1OfIGESEntity.hxx>
23 #include <IGESData_Dump.hxx>
24 #include <Interface_Macros.hxx>
27 #include <Message_Msg.hxx>
28 #include <IGESData_Status.hxx>
31 IGESBasic_ToolSingleParent::IGESBasic_ToolSingleParent () { }
34 void IGESBasic_ToolSingleParent::ReadOwnParams
35 (const Handle(IGESBasic_SingleParent)& ent,
36 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
39 // Building of messages
40 //========================================
41 Message_Msg Msg207("XSTEP_207");
42 //========================================
44 Standard_Integer tempNbParentEntities;
45 Handle(IGESData_IGESEntity) tempParent;
46 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
47 Standard_Integer nbval = 0;
48 Handle(IGESData_HArray1OfIGESEntity) tempChildren;
49 IGESData_Status aStatus;
51 if(!PR.ReadInteger (PR.Current(),tempNbParentEntities)){ //szv#4:S4163:12Mar99 `st=` not needed
52 Message_Msg Msg204("XSTEP_204");
55 //st = PR.ReadInteger(PR.Current(), Msg205, nbval); //szv#4:S4163:12Mar99 moved down
57 // st = PR.ReadInteger (PR.Current(),"Number of Parent entities",tempNbParentEntities);
58 // st = PR.ReadInteger(PR.Current(), "Count of Children", nbval);
59 if (!PR.ReadInteger(PR.Current(), nbval)){
60 Message_Msg Msg205("XSTEP_205");
64 if (!PR.ReadEntity(IR,PR.Current(),aStatus,tempParent)){ //szv#4:S4163:12Mar99 `st=` not needed
65 //st = PR.ReadEntity(IR,PR.Current(),"ParentEntity",tempParent);
66 Message_Msg Msg206("XSTEP_206");
68 case IGESData_ReferenceError: {
69 Message_Msg Msg216 ("IGES_216");
70 Msg206.Arg(Msg216.Value());
73 case IGESData_EntityError: {
74 Message_Msg Msg217 ("IGES_217");
75 Msg206.Arg(Msg217.Value());
83 if (nbval > 0) PR.ReadEnts (IR,PR.CurrentList(nbval),Msg207,tempChildren); //szv#4:S4163:12Mar99 `st=` not needed
84 //st = PR.ReadEnts (IR,PR.CurrentList(nbval),"Child Entities",tempChildren);
85 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
86 ent->Init(tempNbParentEntities,tempParent,tempChildren);
89 void IGESBasic_ToolSingleParent::WriteOwnParams
90 (const Handle(IGESBasic_SingleParent)& ent, IGESData_IGESWriter& IW) const
92 Standard_Integer upper = ent->NbChildren();
93 IW.Send(ent->NbParentEntities());
95 IW.Send(ent->SingleParent());
96 for (Standard_Integer i = 1; i <= upper; i ++)
97 IW.Send(ent->Child(i));
100 void IGESBasic_ToolSingleParent::OwnShared
101 (const Handle(IGESBasic_SingleParent)& ent, Interface_EntityIterator& iter) const
103 iter.GetOneItem(ent->SingleParent());
104 Standard_Integer upper = ent->NbChildren();
105 for (Standard_Integer i = 1; i <= upper; i ++)
106 iter.GetOneItem(ent->Child(i));
109 void IGESBasic_ToolSingleParent::OwnCopy
110 (const Handle(IGESBasic_SingleParent)& another,
111 const Handle(IGESBasic_SingleParent)& ent, Interface_CopyTool& TC) const
113 Standard_Integer aNbParentEntities = another->NbParentEntities();
114 DeclareAndCast(IGESData_IGESEntity,aparent,
115 TC.Transferred(another->SingleParent()));
116 Standard_Integer upper = another->NbChildren();
117 Handle(IGESData_HArray1OfIGESEntity) EntArray = new
118 IGESData_HArray1OfIGESEntity(1,upper);
119 for (Standard_Integer i = 1; i <= upper; i ++)
122 (IGESData_IGESEntity,myentity,TC.Transferred(another->Child(i)));
123 EntArray->SetValue(i,myentity);
125 ent->Init(aNbParentEntities,aparent,EntArray);
128 Standard_Boolean IGESBasic_ToolSingleParent::OwnCorrect
129 (const Handle(IGESBasic_SingleParent)& ent) const
131 if (ent->NbParentEntities() == 1) return Standard_False;
132 Standard_Integer nb = ent->NbChildren();
133 Handle(IGESData_HArray1OfIGESEntity) EntArray = new
134 IGESData_HArray1OfIGESEntity (1,nb);
135 for (Standard_Integer i = 1; i <= nb; i ++)
136 EntArray->SetValue(i,ent->Child(i));
137 ent->Init (1,ent->SingleParent(),EntArray);
138 return Standard_True; // nbparents = 1
141 IGESData_DirChecker IGESBasic_ToolSingleParent::DirChecker
142 (const Handle(IGESBasic_SingleParent)& /* ent */ ) const
144 IGESData_DirChecker DC(402,9); //Form no = 9 & Type = 402
145 DC.Structure(IGESData_DefVoid);
146 DC.GraphicsIgnored();
147 DC.BlankStatusIgnored();
148 DC.HierarchyStatusIgnored();
152 void IGESBasic_ToolSingleParent::OwnCheck
153 (const Handle(IGESBasic_SingleParent)& ent,
154 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
157 // Building of messages
158 //========================================
159 // Message_Msg Msg204("XSTEP_204");
160 //========================================
161 if (ent->NbParentEntities() != 1){
162 Message_Msg Msg204("XSTEP_204");
163 ach->SendFail(Msg204);
167 void IGESBasic_ToolSingleParent::OwnDump
168 (const Handle(IGESBasic_SingleParent)& ent, const IGESData_IGESDumper& dumper,
169 const Handle(Message_Messenger)& S, const Standard_Integer level) const
171 S << "IGESBasic_SingleParent" << endl;
173 S << "Number of ParentEntities : " << ent->NbParentEntities() << endl;
174 S << "ParentEntity : ";
175 dumper.Dump(ent->SingleParent(),S,(level <= 4) ? 0 : 1);
178 IGESData_DumpEntities(S,dumper ,level,1, ent->NbChildren(),ent->Child);