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 //--------------------------------------------------------------------
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>
25 #include <IGESData_ParamCursor.hxx>
26 #include <IGESData_ParamReader.hxx>
27 #include <IGESDraw_ConnectPoint.hxx>
28 #include <IGESDraw_HArray1OfConnectPoint.hxx>
29 #include <IGESDraw_NetworkSubfigure.hxx>
30 #include <IGESDraw_NetworkSubfigureDef.hxx>
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>
36 #include <Interface_Macros.hxx>
37 #include <Interface_ShareTool.hxx>
38 #include <Message_Messenger.hxx>
39 #include <Standard_DomainError.hxx>
40 #include <TCollection_HAsciiString.hxx>
42 IGESDraw_ToolNetworkSubfigure::IGESDraw_ToolNetworkSubfigure () { }
45 void IGESDraw_ToolNetworkSubfigure::ReadOwnParams
46 (const Handle(IGESDraw_NetworkSubfigure)& ent,
47 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
49 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
50 Standard_Integer nbval;
52 Handle(IGESDraw_NetworkSubfigureDef) definition;
55 Standard_Integer typeflag;
56 Handle(TCollection_HAsciiString) designator;
57 Handle(IGESGraph_TextDisplayTemplate) textTemplate;
58 Handle(IGESDraw_HArray1OfConnectPoint) connectPoints;
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
68 // Reading translation(XYZ)
69 PR.ReadXYZ( PR.CurrentList(1, 3), "Translation data", translation); //szv#4:S4163:12Mar99 `st=` not needed
72 if (PR.DefinedElseSkip()) // Reading scale(X)
73 PR.ReadReal(PR.Current(), "Scale factors(X)", scaleX); //szv#4:S4163:12Mar99 `st=` not needed
75 scaleX = 1.0; // Default Value
77 if (PR.DefinedElseSkip()) // Reading scale(Y)
78 PR.ReadReal(PR.Current(), "Scale factors(Y)", scaleY); //szv#4:S4163:12Mar99 `st=` not needed
80 scaleY = scaleX; // Default Value
82 if (PR.DefinedElseSkip()) // Reading scale(Z)
83 PR.ReadReal(PR.Current(), "Scale factors(Z)", scaleZ); //szv#4:S4163:12Mar99 `st=` not needed
85 scaleZ = scaleX; // Default Value
87 scale.SetCoord(scaleX, scaleY, scaleZ);
89 if (PR.DefinedElseSkip()) // Reading typeflag(Integer)
90 PR.ReadInteger(PR.Current(), "Type flag", typeflag); //szv#4:S4163:12Mar99 `st=` not needed
92 typeflag = 0; // Default Value
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");
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,
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
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++)
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);
124 PR.AddFail ("Count of Connect point entities : Less than Zero");
126 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
128 (definition, translation, scale, typeflag,
129 designator, textTemplate, connectPoints);
132 void IGESDraw_ToolNetworkSubfigure::WriteOwnParams
133 (const Handle(IGESDraw_NetworkSubfigure)& ent, IGESData_IGESWriter& IW) const
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() );
145 IW.Send( ent->DesignatorTemplate() );
147 IW.Send( ent->NbConnectPoints() );
149 Standard_Integer Up = ent->NbConnectPoints();
150 for ( Standard_Integer i = 1; i <= Up; i++)
151 IW.Send( ent->ConnectPoint(i) );
154 void IGESDraw_ToolNetworkSubfigure::OwnShared
155 (const Handle(IGESDraw_NetworkSubfigure)& ent, Interface_EntityIterator& iter) const
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) );
164 void IGESDraw_ToolNetworkSubfigure::OwnCopy
165 (const Handle(IGESDraw_NetworkSubfigure)& another,
166 const Handle(IGESDraw_NetworkSubfigure)& ent, Interface_CopyTool& TC) const
168 Standard_Integer nbval;
171 Standard_Integer typeflag;
172 Handle(TCollection_HAsciiString) designator;
173 Handle(IGESDraw_HArray1OfConnectPoint) connectPoints;
175 nbval = another->NbConnectPoints();
177 DeclareAndCast(IGESDraw_NetworkSubfigureDef, definition,
178 TC.Transferred(another->SubfigureDefinition()));
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());
187 DeclareAndCast(IGESGraph_TextDisplayTemplate, textTemplate,
188 TC.Transferred(another->DesignatorTemplate()));
190 if (nbval > 0) connectPoints = new IGESDraw_HArray1OfConnectPoint(1, nbval);
191 for (Standard_Integer i = 1; i <= nbval; i++)
193 DeclareAndCast(IGESDraw_ConnectPoint, tempconnectPoint,
194 TC.Transferred(another->ConnectPoint(i)) );
195 connectPoints->SetValue( i, tempconnectPoint );
198 ent->Init(definition, translation, scale, typeflag,
199 designator, textTemplate, connectPoints);
202 IGESData_DirChecker IGESDraw_ToolNetworkSubfigure::DirChecker
203 (const Handle(IGESDraw_NetworkSubfigure)& /*ent*/) const
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);
213 void IGESDraw_ToolNetworkSubfigure::OwnCheck
214 (const Handle(IGESDraw_NetworkSubfigure)& ent,
215 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
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");
227 void IGESDraw_ToolNetworkSubfigure::OwnDump
228 (const Handle(IGESDraw_NetworkSubfigure)& ent, const IGESData_IGESDumper& dumper,
229 Standard_OStream& S, const Standard_Integer level) const
231 Standard_Integer sublevel = (level <= 4) ? 0 : 1;
233 S << "IGESDraw_NetworkSubfigure\n"
234 << "Network Subfigure Definition Entity : ";
235 dumper.Dump(ent->SubfigureDefinition(),S, sublevel);
236 S << "\nTranslation Data : ";
237 IGESData_DumpXYZL(S,level, ent->Translation(), ent->Location());
238 S << "\nScale Factors : ";
239 IGESData_DumpXYZ(S, ent->ScaleFactors());
240 S << "\nType Flag : " << ent->TypeFlag() << "\n"
241 << "Primary Reference Designator : ";
242 IGESData_DumpString(S,ent->ReferenceDesignator());
243 S << "\nText Display Template Entity : ";
244 dumper.Dump(ent->DesignatorTemplate(),S, sublevel);
245 S << "\nConnect Points : ";
246 IGESData_DumpEntities(S,dumper ,level,1, ent->NbConnectPoints(),ent->ConnectPoint);