0031501: Foundation Classes, Message_Printer - remove theToPutEndl argument -- prepar...
[occt.git] / src / IGESBasic / IGESBasic_ToolGroup.cxx
CommitLineData
b311480e 1// Created by: CKY / Contract Toubro-Larsen
2// Copyright (c) 1993-1999 Matra Datavision
973c2be1 3// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
7fd59977 6//
d5f74e42 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
973c2be1 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.
7fd59977 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
16//--------------------------------------------------------------------
7fd59977 17//--------------------------------------------------------------------
18
42cf5bc1 19#include <IGESBasic_Group.hxx>
20#include <IGESBasic_ToolGroup.hxx>
21#include <IGESData_DirChecker.hxx>
7fd59977 22#include <IGESData_Dump.hxx>
42cf5bc1 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_ParamCursor.hxx>
29#include <IGESData_ParamReader.hxx>
30#include <Interface_Check.hxx>
31#include <Interface_CopyTool.hxx>
32#include <Interface_EntityIterator.hxx>
7fd59977 33#include <Interface_Macros.hxx>
42cf5bc1 34#include <Interface_ShareTool.hxx>
7fd59977 35#include <Message_Msg.hxx>
42cf5bc1 36#include <Standard_DomainError.hxx>
7fd59977 37
42cf5bc1 38// MGE 03/08/98
7fd59977 39IGESBasic_ToolGroup::IGESBasic_ToolGroup () { }
40
41
42void IGESBasic_ToolGroup::ReadOwnParams
43 (const Handle(IGESBasic_Group)& ent,
44 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
45{
46 // MGE 03/08/98
47 // Building of messages
48 //========================================
49// Message_Msg Msg202("XSTEP_202");
50// Message_Msg Msg203("XSTEP_203");
51 //========================================
52
53 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
54 Standard_Integer nbval = 0;
55// Msg202.Arg(1);
56 //st = PR.ReadInteger( PR.Current(), Msg202, nbval); //szv#4:S4163:12Mar99 moved down
57 //st = PR.ReadInteger( PR.Current(), "Count of Entities", nbval);
58
59 Handle(IGESData_HArray1OfIGESEntity) EntArray;
60 if ( PR.ReadInteger( PR.Current(), nbval) ) { //szv#4:S4163:12Mar99 `st=` not needed
61 Message_Msg Msg203("XSTEP_203");
62 Msg203.Arg(1);
63 PR.ReadEnts (IR,PR.CurrentList(nbval),Msg203,EntArray); //szv#4:S4163:12Mar99 `st=` not needed
64 }
65 else {
66 Message_Msg Msg202("XSTEP_202");
67 Msg202.Arg(1);
68 PR.SendFail(Msg202);
69 }
70
71
72 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
73 ent->Init(EntArray);
74}
75
76void IGESBasic_ToolGroup::WriteOwnParams
77 (const Handle(IGESBasic_Group)& ent, IGESData_IGESWriter& IW) const
78{
79 Standard_Integer upper = ent->NbEntities();
80 IW.Send(upper);
81 for (Standard_Integer i = 1; i <= upper;i++)
82 IW.Send(ent->Entity(i));
83}
84
85void IGESBasic_ToolGroup::OwnShared
86 (const Handle(IGESBasic_Group)& ent, Interface_EntityIterator& iter) const
87{
88 Standard_Integer upper = ent->NbEntities();
89 for (Standard_Integer i = 1; i <= upper;i++)
90 iter.GetOneItem(ent->Entity(i));
91}
92
93void IGESBasic_ToolGroup::OwnCopy
94 (const Handle(IGESBasic_Group)& another,
95 const Handle(IGESBasic_Group)& ent, Interface_CopyTool& TC) const
96{
97 Standard_Integer lower,upper;
98 lower = 1;
99 upper = another->NbEntities();
100 Handle(IGESData_HArray1OfIGESEntity) EntArray = new
101 IGESData_HArray1OfIGESEntity(lower,upper);
102 for (Standard_Integer i = lower;i <= upper;i++)
103 {
104 DeclareAndCast
105 (IGESData_IGESEntity,myentity,TC.Transferred(another->Entity(i)));
106 EntArray->SetValue(i,myentity);
107 }
108 ent->Init(EntArray);
109}
110
111Standard_Boolean IGESBasic_ToolGroup::OwnCorrect
112 (const Handle(IGESBasic_Group)& ent ) const
113{
114 Standard_Integer ianul = 0;
115 Standard_Integer i, nbtrue = 0, nb = ent->NbEntities();
116 for (i = 1; i <= nb; i ++) {
117 Handle(IGESData_IGESEntity) val = ent->Entity(i);
118 if (val.IsNull()) ianul ++;
119 else if (val->TypeNumber() == 0) ianul ++;
120 }
121 if (ianul == 0) return Standard_False;
122 Handle(IGESData_HArray1OfIGESEntity) EntArray;
123 if (ianul < nb) EntArray = new IGESData_HArray1OfIGESEntity(1,nb-ianul);
124 for (i = 1; i <= nb; i ++) {
125 Handle(IGESData_IGESEntity) val = ent->Entity(i);
126 if (val.IsNull()) continue;
127 else if (val->TypeNumber() == 0) continue;
128 nbtrue ++;
129 EntArray->SetValue (nbtrue,ent->Entity(i));
130 }
131 ent->Init(EntArray);
132 return Standard_True;
133}
134
135
136IGESData_DirChecker IGESBasic_ToolGroup::DirChecker
137 (const Handle(IGESBasic_Group)& /* ent */ ) const
138{
139 IGESData_DirChecker DC(402,1); //TypeNo. 402, Form no. 1
140 DC.Structure(IGESData_DefVoid);
141 DC.GraphicsIgnored();
142 DC.BlankStatusIgnored();
143 DC.HierarchyStatusIgnored();
144 return DC;
145}
146
147void IGESBasic_ToolGroup::OwnCheck(const Handle(IGESBasic_Group)& ent,
148 const Interface_ShareTool&,
149 Handle(Interface_Check)& /* ach */) const
150{
151 Standard_Boolean ianul = Standard_False;
152 Standard_Integer i, nb = ent->NbEntities();
153 for (i = 1; i <= nb; i ++) {
154 Handle(IGESData_IGESEntity) val = ent->Entity(i);
155 if (val.IsNull()) ianul = Standard_True;
156 else if (val->TypeNumber() == 0) ianul = Standard_True;
157 if (ianul) {
158 break;
159 }
160 }
161}
162
163void IGESBasic_ToolGroup::OwnDump
164 (const Handle(IGESBasic_Group)& ent, const IGESData_IGESDumper& dumper,
0ebe5b0a 165 Standard_OStream& S, const Standard_Integer level) const
7fd59977 166{
0ebe5b0a 167 S << "IGESBasic_Group\n"
168 << "Entries in the Group : ";
7fd59977 169 IGESData_DumpEntities(S,dumper ,level,1, ent->NbEntities(),ent->Entity);
0ebe5b0a 170 S << std::endl;
7fd59977 171}
172