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_SingleParent.hxx>
20 #include <IGESBasic_ToolSingleParent.hxx>
21 #include <IGESData_DirChecker.hxx>
22 #include <IGESData_Dump.hxx>
23 #include <IGESData_HArray1OfIGESEntity.hxx>
24 #include <IGESData_IGESDumper.hxx>
25 #include <IGESData_IGESEntity.hxx>
26 #include <IGESData_IGESReaderData.hxx>
27 #include <IGESData_IGESWriter.hxx>
28 #include <IGESData_ParamReader.hxx>
29 #include <IGESData_Status.hxx>
30 #include <Interface_Check.hxx>
31 #include <Interface_CopyTool.hxx>
32 #include <Interface_EntityIterator.hxx>
33 #include <Interface_Macros.hxx>
34 #include <Interface_ShareTool.hxx>
35 #include <Message_Messenger.hxx>
36 #include <Message_Msg.hxx>
37 #include <Standard_DomainError.hxx>
40 IGESBasic_ToolSingleParent::IGESBasic_ToolSingleParent () { }
43 void IGESBasic_ToolSingleParent::ReadOwnParams
44 (const Handle(IGESBasic_SingleParent)& ent,
45 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
48 // Building of messages
49 //========================================
50 Message_Msg Msg207("XSTEP_207");
51 //========================================
53 Standard_Integer tempNbParentEntities;
54 Handle(IGESData_IGESEntity) tempParent;
55 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
56 Standard_Integer nbval = 0;
57 Handle(IGESData_HArray1OfIGESEntity) tempChildren;
58 IGESData_Status aStatus;
60 if(!PR.ReadInteger (PR.Current(),tempNbParentEntities)){ //szv#4:S4163:12Mar99 `st=` not needed
61 Message_Msg Msg204("XSTEP_204");
64 //st = PR.ReadInteger(PR.Current(), Msg205, nbval); //szv#4:S4163:12Mar99 moved down
66 // st = PR.ReadInteger (PR.Current(),"Number of Parent entities",tempNbParentEntities);
67 // st = PR.ReadInteger(PR.Current(), "Count of Children", nbval);
68 if (!PR.ReadInteger(PR.Current(), nbval)){
69 Message_Msg Msg205("XSTEP_205");
73 if (!PR.ReadEntity(IR,PR.Current(),aStatus,tempParent)){ //szv#4:S4163:12Mar99 `st=` not needed
74 //st = PR.ReadEntity(IR,PR.Current(),"ParentEntity",tempParent);
75 Message_Msg Msg206("XSTEP_206");
77 case IGESData_ReferenceError: {
78 Message_Msg Msg216 ("IGES_216");
79 Msg206.Arg(Msg216.Value());
82 case IGESData_EntityError: {
83 Message_Msg Msg217 ("IGES_217");
84 Msg206.Arg(Msg217.Value());
92 if (nbval > 0) PR.ReadEnts (IR,PR.CurrentList(nbval),Msg207,tempChildren); //szv#4:S4163:12Mar99 `st=` not needed
93 //st = PR.ReadEnts (IR,PR.CurrentList(nbval),"Child Entities",tempChildren);
94 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
95 ent->Init(tempNbParentEntities,tempParent,tempChildren);
98 void IGESBasic_ToolSingleParent::WriteOwnParams
99 (const Handle(IGESBasic_SingleParent)& ent, IGESData_IGESWriter& IW) const
101 Standard_Integer upper = ent->NbChildren();
102 IW.Send(ent->NbParentEntities());
104 IW.Send(ent->SingleParent());
105 for (Standard_Integer i = 1; i <= upper; i ++)
106 IW.Send(ent->Child(i));
109 void IGESBasic_ToolSingleParent::OwnShared
110 (const Handle(IGESBasic_SingleParent)& ent, Interface_EntityIterator& iter) const
112 iter.GetOneItem(ent->SingleParent());
113 Standard_Integer upper = ent->NbChildren();
114 for (Standard_Integer i = 1; i <= upper; i ++)
115 iter.GetOneItem(ent->Child(i));
118 void IGESBasic_ToolSingleParent::OwnCopy
119 (const Handle(IGESBasic_SingleParent)& another,
120 const Handle(IGESBasic_SingleParent)& ent, Interface_CopyTool& TC) const
122 Standard_Integer aNbParentEntities = another->NbParentEntities();
123 DeclareAndCast(IGESData_IGESEntity,aparent,
124 TC.Transferred(another->SingleParent()));
125 Standard_Integer upper = another->NbChildren();
126 Handle(IGESData_HArray1OfIGESEntity) EntArray = new
127 IGESData_HArray1OfIGESEntity(1,upper);
128 for (Standard_Integer i = 1; i <= upper; i ++)
131 (IGESData_IGESEntity,myentity,TC.Transferred(another->Child(i)));
132 EntArray->SetValue(i,myentity);
134 ent->Init(aNbParentEntities,aparent,EntArray);
137 Standard_Boolean IGESBasic_ToolSingleParent::OwnCorrect
138 (const Handle(IGESBasic_SingleParent)& ent) const
140 if (ent->NbParentEntities() == 1) return Standard_False;
141 Standard_Integer nb = ent->NbChildren();
142 Handle(IGESData_HArray1OfIGESEntity) EntArray = new
143 IGESData_HArray1OfIGESEntity (1,nb);
144 for (Standard_Integer i = 1; i <= nb; i ++)
145 EntArray->SetValue(i,ent->Child(i));
146 ent->Init (1,ent->SingleParent(),EntArray);
147 return Standard_True; // nbparents = 1
150 IGESData_DirChecker IGESBasic_ToolSingleParent::DirChecker
151 (const Handle(IGESBasic_SingleParent)& /* ent */ ) const
153 IGESData_DirChecker DC(402,9); //Form no = 9 & Type = 402
154 DC.Structure(IGESData_DefVoid);
155 DC.GraphicsIgnored();
156 DC.BlankStatusIgnored();
157 DC.HierarchyStatusIgnored();
161 void IGESBasic_ToolSingleParent::OwnCheck
162 (const Handle(IGESBasic_SingleParent)& ent,
163 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
166 // Building of messages
167 //========================================
168 // Message_Msg Msg204("XSTEP_204");
169 //========================================
170 if (ent->NbParentEntities() != 1){
171 Message_Msg Msg204("XSTEP_204");
172 ach->SendFail(Msg204);
176 void IGESBasic_ToolSingleParent::OwnDump
177 (const Handle(IGESBasic_SingleParent)& ent, const IGESData_IGESDumper& dumper,
178 Standard_OStream& S, const Standard_Integer level) const
180 S << "IGESBasic_SingleParent\n"
181 << "Number of ParentEntities : " << ent->NbParentEntities() << "\n"
182 << "ParentEntity : ";
183 dumper.Dump(ent->SingleParent(),S,(level <= 4) ? 0 : 1);
186 IGESData_DumpEntities(S,dumper ,level,1, ent->NbChildren(),ent->Child);