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 <IGESAppli_LineWidening.hxx>
20 #include <IGESAppli_ToolLineWidening.hxx>
21 #include <IGESData_DirChecker.hxx>
22 #include <IGESData_IGESDumper.hxx>
23 #include <IGESData_IGESReaderData.hxx>
24 #include <IGESData_IGESWriter.hxx>
25 #include <IGESData_LevelListEntity.hxx>
26 #include <IGESData_ParamCursor.hxx>
27 #include <IGESData_ParamReader.hxx>
28 #include <Interface_Check.hxx>
29 #include <Interface_CopyTool.hxx>
30 #include <Interface_EntityIterator.hxx>
31 #include <Interface_ShareTool.hxx>
32 #include <Standard_DomainError.hxx>
34 IGESAppli_ToolLineWidening::IGESAppli_ToolLineWidening () { }
37 void IGESAppli_ToolLineWidening::ReadOwnParams
38 (const Handle(IGESAppli_LineWidening)& ent,
39 const Handle(IGESData_IGESReaderData)& /*IR*/, IGESData_ParamReader& PR) const
41 Standard_Integer tempNbPropertyValues;
42 Standard_Real tempWidth;
43 Standard_Integer tempCorneringCode;
44 Standard_Integer tempExtensionFlag;
45 Standard_Integer tempJustificationFlag;
46 Standard_Real tempExtensionValue = 0.;
47 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
49 //szv#4:S4163:12Mar99 `st=` not needed
50 PR.ReadInteger(PR.Current(),"No. of Property values",tempNbPropertyValues);
51 PR.ReadReal(PR.Current(),"Width of metalization",tempWidth);
52 PR.ReadInteger(PR.Current(),"Cornering code",tempCorneringCode);
53 PR.ReadInteger(PR.Current(),"Extension Flag",tempExtensionFlag);
54 PR.ReadInteger(PR.Current(),"Justification Flag",tempJustificationFlag);
55 if (PR.IsParamDefined(PR.CurrentNumber()))
56 PR.ReadReal(PR.Current(),"Extension value",tempExtensionValue);
57 else if (tempExtensionFlag == 2)
58 PR.AddFail("Extension Value not defined while Extension Flag = 2");
60 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
61 ent->Init(tempNbPropertyValues,tempWidth,tempCorneringCode,tempExtensionFlag,
62 tempJustificationFlag,tempExtensionValue);
65 void IGESAppli_ToolLineWidening::WriteOwnParams
66 (const Handle(IGESAppli_LineWidening)& ent, IGESData_IGESWriter& IW) const
68 IW.Send(ent->NbPropertyValues());
69 IW.Send(ent->WidthOfMetalization());
70 IW.Send(ent->CorneringCode());
71 IW.Send(ent->ExtensionFlag());
72 IW.Send(ent->JustificationFlag());
73 IW.Send(ent->ExtensionValue());
76 void IGESAppli_ToolLineWidening::OwnShared
77 (const Handle(IGESAppli_LineWidening)& /*ent*/, Interface_EntityIterator& /*iter*/) const
81 void IGESAppli_ToolLineWidening::OwnCopy
82 (const Handle(IGESAppli_LineWidening)& another,
83 const Handle(IGESAppli_LineWidening)& ent, Interface_CopyTool& /*TC*/) const
86 (5,another->WidthOfMetalization(),another->CorneringCode(),
87 another->ExtensionFlag(),another->JustificationFlag(),
88 another->ExtensionValue());
91 Standard_Boolean IGESAppli_ToolLineWidening::OwnCorrect
92 (const Handle(IGESAppli_LineWidening)& ent) const
94 Standard_Boolean res = (ent->NbPropertyValues() != 5);
96 (5,ent->WidthOfMetalization(),ent->CorneringCode(),ent->ExtensionFlag(),
97 ent->JustificationFlag(),ent->ExtensionValue());
98 if (ent->SubordinateStatus() != 0) {
99 Handle(IGESData_LevelListEntity) nulevel;
100 ent->InitLevel(nulevel,0);
103 return res; // nbpropertyvalues = 5 + RAZ level selon subordinate
106 IGESData_DirChecker IGESAppli_ToolLineWidening::DirChecker
107 (const Handle(IGESAppli_LineWidening)& /*ent*/ ) const
109 IGESData_DirChecker DC(406,5); //Form no = 5 & Type = 406
110 DC.Structure(IGESData_DefVoid);
111 DC.GraphicsIgnored();
112 DC.BlankStatusIgnored();
114 DC.HierarchyStatusIgnored();
118 void IGESAppli_ToolLineWidening::OwnCheck
119 (const Handle(IGESAppli_LineWidening)& ent,
120 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
122 if (ent->SubordinateStatus() != 0)
123 if (ent->DefLevel() == IGESData_DefOne ||
124 ent->DefLevel() == IGESData_DefSeveral)
125 ach->AddWarning("Level type: defined while ignored");
126 if (ent->NbPropertyValues() != 5)
127 ach->AddFail("Number of Property Values != 5");
128 if (ent->CorneringCode() != 0 && ent->CorneringCode() != 1)
129 ach->AddFail("Cornering Code incorrect");
130 if (ent->ExtensionFlag() < 0 || ent->ExtensionFlag() > 2)
131 ach->AddFail("Extension Flag value incorrect");
132 if (ent->JustificationFlag() < 0 || ent->JustificationFlag() > 2)
133 ach->AddFail("Justification Flag value incorrect");
136 void IGESAppli_ToolLineWidening::OwnDump
137 (const Handle(IGESAppli_LineWidening)& ent, const IGESData_IGESDumper& /*dumper*/,
138 Standard_OStream& S, const Standard_Integer /*level*/) const
140 S << "IGESAppli_LineWidening\n";
142 S << "Number of property values : " << ent->NbPropertyValues() << "\n";
143 S << "Width of metalization : " << ent->WidthOfMetalization() << "\n";
144 S << "Cornering Code : " ;
145 if (ent->CorneringCode() == 0) S << "0 (rounded)\n";
146 else if (ent->CorneringCode() == 1) S << "1 (squared)\n";
147 else S << "incorrect value\n";
149 S << "Extension Flag : " ;
150 if (ent->ExtensionFlag() == 0) S << "0 (No Extension)\n";
151 else if (ent->ExtensionFlag() == 1) S << "1 (One-half width extension)\n";
152 else if (ent->ExtensionFlag() == 2) S << "2 (Extension set by ExtensionValue)\n";
153 else S << "incorrect value\n";
155 S << "Justification Flag : " ;
156 if (ent->JustificationFlag() == 0)
157 S << "0 (Centre justified)\n";
158 else if (ent->JustificationFlag() == 1)
159 S << "1 (left justified)\n";
160 else if (ent->JustificationFlag() == 2)
161 S << "2 (right justified)\n";
163 S << "incorrect value\n";
165 if (ent->ExtensionFlag() == 2)
166 S << "Extension Value : " << ent->ExtensionValue() << std::endl;
168 S << "No Extension Value (Extension Flag != 2)" << std::endl;