0031501: Foundation Classes, Message_Printer - remove theToPutEndl argument -- prepar...
[occt.git] / src / IGESDraw / IGESDraw_ToolNetworkSubfigure.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 <gp_XYZ.hxx>
20#include <IGESData_DirChecker.hxx>
21#include <IGESData_Dump.hxx>
22#include <IGESData_IGESDumper.hxx>
23#include <IGESData_IGESReaderData.hxx>
24#include <IGESData_IGESWriter.hxx>
7fd59977 25#include <IGESData_ParamCursor.hxx>
42cf5bc1 26#include <IGESData_ParamReader.hxx>
7fd59977 27#include <IGESDraw_ConnectPoint.hxx>
7fd59977 28#include <IGESDraw_HArray1OfConnectPoint.hxx>
42cf5bc1 29#include <IGESDraw_NetworkSubfigure.hxx>
7fd59977 30#include <IGESDraw_NetworkSubfigureDef.hxx>
42cf5bc1 31#include <IGESDraw_ToolNetworkSubfigure.hxx>
32#include <IGESGraph_TextDisplayTemplate.hxx>
33#include <Interface_Check.hxx>
34#include <Interface_CopyTool.hxx>
35#include <Interface_EntityIterator.hxx>
7fd59977 36#include <Interface_Macros.hxx>
42cf5bc1 37#include <Interface_ShareTool.hxx>
38#include <Message_Messenger.hxx>
39#include <Standard_DomainError.hxx>
40#include <TCollection_HAsciiString.hxx>
7fd59977 41
42IGESDraw_ToolNetworkSubfigure::IGESDraw_ToolNetworkSubfigure () { }
43
44
45void IGESDraw_ToolNetworkSubfigure::ReadOwnParams
46 (const Handle(IGESDraw_NetworkSubfigure)& ent,
47 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
48{
49 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
50 Standard_Integer nbval;
51
52 Handle(IGESDraw_NetworkSubfigureDef) definition;
53 gp_XYZ translation;
54 gp_XYZ scale;
55 Standard_Integer typeflag;
56 Handle(TCollection_HAsciiString) designator;
57 Handle(IGESGraph_TextDisplayTemplate) textTemplate;
58 Handle(IGESDraw_HArray1OfConnectPoint) connectPoints;
59
60 Standard_Real scaleX;
61 Standard_Real scaleY;
62 Standard_Real scaleZ;
63
64 // Reading definition(Instance of NetworkSubfigureDef)
65 PR.ReadEntity(IR, PR.Current(), "Instance of NetworkSubfigureDef",
66 STANDARD_TYPE(IGESDraw_NetworkSubfigureDef), definition); //szv#4:S4163:12Mar99 `st=` not needed
67
68 // Reading translation(XYZ)
69 PR.ReadXYZ( PR.CurrentList(1, 3), "Translation data", translation); //szv#4:S4163:12Mar99 `st=` not needed
70
71 // Reading scale(XYZ)
72 if (PR.DefinedElseSkip()) // Reading scale(X)
73 PR.ReadReal(PR.Current(), "Scale factors(X)", scaleX); //szv#4:S4163:12Mar99 `st=` not needed
74 else
75 scaleX = 1.0; // Default Value
76
77 if (PR.DefinedElseSkip()) // Reading scale(Y)
78 PR.ReadReal(PR.Current(), "Scale factors(Y)", scaleY); //szv#4:S4163:12Mar99 `st=` not needed
79 else
80 scaleY = scaleX; // Default Value
81
82 if (PR.DefinedElseSkip()) // Reading scale(Z)
83 PR.ReadReal(PR.Current(), "Scale factors(Z)", scaleZ); //szv#4:S4163:12Mar99 `st=` not needed
84 else
85 scaleZ = scaleX; // Default Value
86
87 scale.SetCoord(scaleX, scaleY, scaleZ);
88
89 if (PR.DefinedElseSkip()) // Reading typeflag(Integer)
90 PR.ReadInteger(PR.Current(), "Type flag", typeflag); //szv#4:S4163:12Mar99 `st=` not needed
91 else
92 typeflag = 0; // Default Value
93
94 // Reading designator(String)
95 if (PR.DefinedElseSkip())
96 PR.ReadText(PR.Current(), "Primary reference designator", designator); //szv#4:S4163:12Mar99 `st=` not needed
97 else PR.AddWarning("Primary reference designator : Null definition");
98
99 // Reading textTemplate(Instance of TextDisplayTemplate or Null)
100 Standard_Boolean st = PR.ReadEntity(IR, PR.Current(), "Instance of TextDisplayTemplate",
101 STANDARD_TYPE(IGESGraph_TextDisplayTemplate), textTemplate,
102 Standard_True);
103
104 // Reading nbval(Integer)
105 if (PR.DefinedElseSkip())
106 st = PR.ReadInteger(PR.Current(),"Count of Connect Points", nbval); //szv#4:S4163:12Mar99 `st=` not needed
107 else nbval = 0;
108 if (st && nbval > 0)
109 {
110 // Reading connectPoints(HArray1OfConnectPoint)
111 connectPoints = new IGESDraw_HArray1OfConnectPoint(1, nbval);
112 Handle(IGESDraw_ConnectPoint) tempConnectPoint;
113 for (Standard_Integer i = 1; i <= nbval; i++)
114 {
115 //st = PR.ReadEntity(IR, PR.Current(), "ConnectPoint entity",
116 //STANDARD_TYPE(IGESDraw_ConnectPoint),tempConnectPoint,
117 //Standard_True); //szv#4:S4163:12Mar99 moved in if
118 if (PR.ReadEntity(IR, PR.Current(), "ConnectPoint entity",
119 STANDARD_TYPE(IGESDraw_ConnectPoint),tempConnectPoint, Standard_True))
120 connectPoints->SetValue(i, tempConnectPoint);
121 }
122 }
123 else if (nbval < 0)
124 PR.AddFail ("Count of Connect point entities : Less than Zero");
125
126 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
127 ent->Init
128 (definition, translation, scale, typeflag,
129 designator, textTemplate, connectPoints);
130}
131
132void IGESDraw_ToolNetworkSubfigure::WriteOwnParams
133 (const Handle(IGESDraw_NetworkSubfigure)& ent, IGESData_IGESWriter& IW) const
134{
135 IW.Send( ent->SubfigureDefinition() );
136 IW.Send( ent->Translation().X() );
137 IW.Send( ent->Translation().Y() );
138 IW.Send( ent->Translation().Z() );
139 IW.Send( ent->ScaleFactors().X() );
140 IW.Send( ent->ScaleFactors().Y() );
141 IW.Send( ent->ScaleFactors().Z() );
142 IW.Send( ent->TypeFlag() );
143 IW.Send( ent->ReferenceDesignator() );
144
145 IW.Send( ent->DesignatorTemplate() );
146
147 IW.Send( ent->NbConnectPoints() );
148
149 Standard_Integer Up = ent->NbConnectPoints();
150 for ( Standard_Integer i = 1; i <= Up; i++)
151 IW.Send( ent->ConnectPoint(i) );
152}
153
154void IGESDraw_ToolNetworkSubfigure::OwnShared
155 (const Handle(IGESDraw_NetworkSubfigure)& ent, Interface_EntityIterator& iter) const
156{
157 iter.GetOneItem( ent->SubfigureDefinition() );
158 iter.GetOneItem( ent->DesignatorTemplate() );
159 Standard_Integer Up = ent->NbConnectPoints();
160 for ( Standard_Integer i = 1; i <= Up; i++)
161 iter.GetOneItem( ent->ConnectPoint(i) );
162}
163
164void IGESDraw_ToolNetworkSubfigure::OwnCopy
165 (const Handle(IGESDraw_NetworkSubfigure)& another,
166 const Handle(IGESDraw_NetworkSubfigure)& ent, Interface_CopyTool& TC) const
167{
168 Standard_Integer nbval;
169 gp_XYZ translation;
170 gp_XYZ scale;
171 Standard_Integer typeflag;
172 Handle(TCollection_HAsciiString) designator;
173 Handle(IGESDraw_HArray1OfConnectPoint) connectPoints;
174
175 nbval = another->NbConnectPoints();
176
177 DeclareAndCast(IGESDraw_NetworkSubfigureDef, definition,
178 TC.Transferred(another->SubfigureDefinition()));
179
180 translation = another->Translation();
181 scale = another->ScaleFactors();
182 typeflag = another->TypeFlag();
183 if (!another->ReferenceDesignator().IsNull())
184 designator = new TCollection_HAsciiString
185 (another->ReferenceDesignator());
186
187 DeclareAndCast(IGESGraph_TextDisplayTemplate, textTemplate,
188 TC.Transferred(another->DesignatorTemplate()));
189
190 if (nbval > 0) connectPoints = new IGESDraw_HArray1OfConnectPoint(1, nbval);
191 for (Standard_Integer i = 1; i <= nbval; i++)
192 {
193 DeclareAndCast(IGESDraw_ConnectPoint, tempconnectPoint,
194 TC.Transferred(another->ConnectPoint(i)) );
195 connectPoints->SetValue( i, tempconnectPoint );
196 }
197
198 ent->Init(definition, translation, scale, typeflag,
199 designator, textTemplate, connectPoints);
200}
201
202IGESData_DirChecker IGESDraw_ToolNetworkSubfigure::DirChecker
203 (const Handle(IGESDraw_NetworkSubfigure)& /*ent*/) const
204{
205 IGESData_DirChecker DC (420, 0);
206 DC.Structure(IGESData_DefVoid);
207 DC.LineFont(IGESData_DefAny);
208 DC.LineWeight(IGESData_DefValue);
209 DC.Color(IGESData_DefAny);
210 return DC;
211}
212
213void IGESDraw_ToolNetworkSubfigure::OwnCheck
214 (const Handle(IGESDraw_NetworkSubfigure)& ent,
215 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
216{
217 if ( ent->TypeFlag() != 0 &&
218 ent->TypeFlag() != 1 &&
219 ent->TypeFlag() != 2 )
220 ach->AddFail("Type Flag : Value != 0/1/2");
221 if (ent->NbConnectPoints() != ent->SubfigureDefinition()->NbPointEntities())
222 ach->AddFail("Count of associated Connect Points inconsistent with Definition");
223 if (ent->ReferenceDesignator().IsNull())
224 ach->AddFail("Primary Reference Designator : not defined");
225}
226
227void IGESDraw_ToolNetworkSubfigure::OwnDump
228 (const Handle(IGESDraw_NetworkSubfigure)& ent, const IGESData_IGESDumper& dumper,
0ebe5b0a 229 Standard_OStream& S, const Standard_Integer level) const
7fd59977 230{
231 Standard_Integer sublevel = (level <= 4) ? 0 : 1;
232
0ebe5b0a 233 S << "IGESDraw_NetworkSubfigure\n"
234 << "Network Subfigure Definition Entity : ";
7fd59977 235 dumper.Dump(ent->SubfigureDefinition(),S, sublevel);
0ebe5b0a 236 S << "\nTranslation Data : ";
7fd59977 237 IGESData_DumpXYZL(S,level, ent->Translation(), ent->Location());
0ebe5b0a 238 S << "\nScale Factors : ";
7fd59977 239 IGESData_DumpXYZ(S, ent->ScaleFactors());
0ebe5b0a 240 S << "\nType Flag : " << ent->TypeFlag() << "\n"
241 << "Primary Reference Designator : ";
7fd59977 242 IGESData_DumpString(S,ent->ReferenceDesignator());
0ebe5b0a 243 S << "\nText Display Template Entity : ";
7fd59977 244 dumper.Dump(ent->DesignatorTemplate(),S, sublevel);
0ebe5b0a 245 S << "\nConnect Points : ";
7fd59977 246 IGESData_DumpEntities(S,dumper ,level,1, ent->NbConnectPoints(),ent->ConnectPoint);
0ebe5b0a 247 S << std::endl;
7fd59977 248}