0030895: Coding Rules - specify std namespace explicitly for std::cout and streams
[occt.git] / src / IGESSolid / IGESSolid_ToolManifoldSolid.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 <IGESData_DirChecker.hxx>
20#include <IGESData_Dump.hxx>
21#include <IGESData_IGESDumper.hxx>
22#include <IGESData_IGESReaderData.hxx>
23#include <IGESData_IGESWriter.hxx>
7fd59977 24#include <IGESData_ParamCursor.hxx>
42cf5bc1 25#include <IGESData_ParamReader.hxx>
26#include <IGESData_Status.hxx>
7fd59977 27#include <IGESSolid_HArray1OfShell.hxx>
42cf5bc1 28#include <IGESSolid_ManifoldSolid.hxx>
29#include <IGESSolid_Shell.hxx>
30#include <IGESSolid_ToolManifoldSolid.hxx>
31#include <Interface_Check.hxx>
32#include <Interface_CopyTool.hxx>
33#include <Interface_EntityIterator.hxx>
7fd59977 34#include <Interface_Macros.hxx>
42cf5bc1 35#include <Interface_ShareTool.hxx>
36#include <Message_Messenger.hxx>
7fd59977 37#include <Message_Msg.hxx>
42cf5bc1 38#include <Standard_DomainError.hxx>
39#include <TColStd_HArray1OfInteger.hxx>
7fd59977 40
42cf5bc1 41// MGE 31/07/98
7fd59977 42IGESSolid_ToolManifoldSolid::IGESSolid_ToolManifoldSolid () { }
43
44
45void IGESSolid_ToolManifoldSolid::ReadOwnParams
46 (const Handle(IGESSolid_ManifoldSolid)& ent,
47 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
48{
49
50 // MGE 31/07/98
51 // Building of messages
52 //========================================
53 Message_Msg Msg180("XSTEP_180");
54 //========================================
55
56 Standard_Boolean abool, shellFlag; //szv#4:S4163:12Mar99 `st` moved down
57 Standard_Integer nbshells, i;
58 Handle(TColStd_HArray1OfInteger) voidShellFlags;
aa00364d 59 Handle(IGESData_IGESEntity) shell;
7fd59977 60 Handle(IGESSolid_Shell) ashell;
61 Handle(IGESSolid_HArray1OfShell) voidShells;
62 IGESData_Status aStatus;
63
64 if (!PR.ReadEntity(IR, PR.Current(), aStatus, shell)){ //szv#4:S4163:12Mar99 `st=` not needed
65 Message_Msg Msg178("XSTEP_178");
66 switch(aStatus) {
67 case IGESData_ReferenceError: {
68 Message_Msg Msg216 ("IGES_216");
69 Msg178.Arg(Msg216.Value());
70 PR.SendFail(Msg178);
71 break; }
72 case IGESData_EntityError: {
73 Message_Msg Msg217 ("IGES_217");
74 Msg178.Arg(Msg217.Value());
75 PR.SendFail(Msg178);
76 break; }
77 default:{
78 }
79 }
80 }
81
82 PR.ReadBoolean(PR.Current(), Msg180, shellFlag); //szv#4:S4163:12Mar99 `st=` not needed
83 Standard_Boolean st = PR.ReadInteger(PR.Current(), nbshells);
84 if(!st){
85 Message_Msg Msg181("XSTEP_181");
86 PR.SendFail(Msg181);
87 }
88/*
89 st = PR.ReadEntity(IR, PR.Current(), "Shell", shell);
90 st = PR.ReadBoolean(PR.Current(), "Shell orientation", shellFlag);
91 st = PR.ReadInteger(PR.Current(), "Number of shells", nbshells);
92*/
93 if (st && nbshells > 0)
94 {
95 voidShells = new IGESSolid_HArray1OfShell(1, nbshells);
96 voidShellFlags = new TColStd_HArray1OfInteger(1, nbshells); voidShellFlags->Init(0);
97 for (i=1; i<=nbshells; i++)
98 {
99 //st = PR.ReadEntity(IR, PR.Current(), Msg179,
100 //STANDARD_TYPE(IGESSolid_Shell), ashell); //szv#4:S4163:12Mar99 moved in if
101 /*
102 st = PR.ReadEntity(IR, PR.Current(), "Void shells",
103 STANDARD_TYPE(IGESSolid_Shell), ashell);
104 */
105 if (PR.ReadEntity(IR, PR.Current(), aStatus, STANDARD_TYPE(IGESSolid_Shell), ashell))
106 voidShells->SetValue(i, ashell);
107 else {
108 Message_Msg Msg179("XSTEP_179");
109 switch(aStatus) {
110 case IGESData_ReferenceError: {
111 Message_Msg Msg216 ("IGES_216");
112 Msg179.Arg(Msg216.Value());
113 PR.SendFail(Msg179);
114 break; }
115 case IGESData_EntityError: {
116 Message_Msg Msg217 ("IGES_217");
117 Msg179.Arg(Msg217.Value());
118 PR.SendFail(Msg179);
119 break; }
120 case IGESData_TypeError: {
121 Message_Msg Msg218 ("IGES_218");
122 Msg179.Arg(Msg218.Value());
123 PR.SendFail(Msg179);
124 break; }
125 default:{
126 }
127 }
128 }
129
130 PR.ReadBoolean(PR.Current(), Msg180, abool); //szv#4:S4163:12Mar99 `st=` not needed
131 if (abool) voidShellFlags->SetValue(i, 1);
132 }
133 }
134 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
aa00364d 135 ent->Init (Handle(IGESSolid_Shell)::DownCast (shell), shellFlag, voidShells, voidShellFlags);
7fd59977 136}
137
138void IGESSolid_ToolManifoldSolid::WriteOwnParams
139 (const Handle(IGESSolid_ManifoldSolid)& ent, IGESData_IGESWriter& IW) const
140{
141 Standard_Integer i;
142 Standard_Integer nbshells = ent->NbVoidShells();
143
144 IW.Send(ent->Shell());
145 IW.SendBoolean(ent->OrientationFlag());
146 IW.Send(nbshells);
147 for (i = 1; i <= nbshells; i ++)
148 {
149 IW.Send(ent->VoidShell(i));
150 IW.SendBoolean(ent->VoidOrientationFlag(i));
151 }
152}
153
154void IGESSolid_ToolManifoldSolid::OwnShared
155 (const Handle(IGESSolid_ManifoldSolid)& ent, Interface_EntityIterator& iter) const
156{
157 Standard_Integer i;
158 Standard_Integer nbshells = ent->NbVoidShells();
159
160 iter.GetOneItem(ent->Shell());
161 for (i = 1; i <= nbshells; i ++) iter.GetOneItem(ent->VoidShell(i));
162}
163
164void IGESSolid_ToolManifoldSolid::OwnCopy
165 (const Handle(IGESSolid_ManifoldSolid)& another,
166 const Handle(IGESSolid_ManifoldSolid)& ent, Interface_CopyTool& TC) const
167{
168 DeclareAndCast(IGESSolid_Shell, shell, TC.Transferred(another->Shell()));
169 Standard_Boolean shellFlag = another->OrientationFlag();
170
171 Standard_Integer nbshells = another->NbVoidShells();
172 Handle(IGESSolid_HArray1OfShell) voidShells;
173 Handle(TColStd_HArray1OfInteger) voidFlags;
174 if (nbshells > 0)
175 {
176 voidShells = new IGESSolid_HArray1OfShell(1, nbshells);
177 voidFlags = new TColStd_HArray1OfInteger(1, nbshells);
178 for (Standard_Integer i = 1; i <= nbshells; i ++)
179 {
180 DeclareAndCast(IGESSolid_Shell, voidshell,
181 TC.Transferred(another->VoidShell(i)));
182 voidShells->SetValue(i, voidshell);
183 voidFlags->SetValue(i, (another->VoidOrientationFlag(i) ? 1 : 0));
184 }
185 }
186 ent->Init (shell, shellFlag, voidShells, voidFlags);
187}
188
189IGESData_DirChecker IGESSolid_ToolManifoldSolid::DirChecker
190 (const Handle(IGESSolid_ManifoldSolid)& /* ent */ ) const
191{
192 IGESData_DirChecker DC(186, 0);
193
194 DC.Structure (IGESData_DefVoid);
195 DC.LineFont (IGESData_DefVoid);
196 DC.LineWeight (IGESData_DefVoid);
06696fd8 197 DC.Color (IGESData_DefAny);
7fd59977 198
199 return DC;
200}
201
202void IGESSolid_ToolManifoldSolid::OwnCheck
203 (const Handle(IGESSolid_ManifoldSolid)& /* ent */,
204 const Interface_ShareTool& , Handle(Interface_Check)& /* ach */) const
205{
206}
207
208void IGESSolid_ToolManifoldSolid::OwnDump
209 (const Handle(IGESSolid_ManifoldSolid)& ent, const IGESData_IGESDumper& dumper,
210 const Handle(Message_Messenger)& S, const Standard_Integer level) const
211{
04232180 212 S << "IGESSolid_ManifoldSolid" << Message_EndLine;
7fd59977 213
214 Standard_Integer sublevel = (level <= 4) ? 0 : 1;
215 S << "Shell : ";
216 dumper.Dump(ent->Shell(),S, sublevel);
04232180 217 S << Message_EndLine;
7fd59977 218 if (ent->OrientationFlag())
04232180 219 S << "Orientation agrees with the underlying surface" << Message_EndLine;
7fd59977 220 else
04232180 221 S << "Orientation does not agrees with the underlying surface" << Message_EndLine;
222 S << "Void shells :" << Message_EndLine << "Orientation flags : ";
7fd59977 223 IGESData_DumpEntities(S,dumper,-level,1, ent->NbVoidShells(),ent->VoidShell);
04232180 224 S << Message_EndLine;
7fd59977 225 if (level > 4)
226 {
04232180 227 S << "[ " << Message_EndLine;
7fd59977 228 if (ent->NbVoidShells() > 0)
229 {
230 Standard_Integer upper = ent->NbVoidShells();
231 for (Standard_Integer i = 1; i <= upper; i ++)
232 {
233 S << "[" << i << "]: ";
234 S << "Void shell : ";
235 dumper.Dump (ent->VoidShell(i),S, sublevel);
236 S << " - Orientation flag : ";
04232180 237 if (ent->VoidOrientationFlag(i)) S << "True" << Message_EndLine;
238 else S << "False" << Message_EndLine;
7fd59977 239 }
240 }
04232180 241 S << " ]" << Message_EndLine;
7fd59977 242 }
04232180 243 S << Message_EndLine;
7fd59977 244}
245