b7a7d71fc6f37b41db300a4892eea8bb30a9783d
[occt.git] / src / IGESGraph / IGESGraph_ToolNominalSize.cxx
1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
18
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>
24 #include <IGESData_ParamCursor.hxx>
25 #include <IGESData_ParamReader.hxx>
26 #include <IGESGraph_NominalSize.hxx>
27 #include <IGESGraph_ToolNominalSize.hxx>
28 #include <Interface_Check.hxx>
29 #include <Interface_CopyTool.hxx>
30 #include <Interface_EntityIterator.hxx>
31 #include <Interface_Macros.hxx>
32 #include <Interface_ShareTool.hxx>
33 #include <Message_Messenger.hxx>
34 #include <Standard_DomainError.hxx>
35 #include <TCollection_HAsciiString.hxx>
36
37 IGESGraph_ToolNominalSize::IGESGraph_ToolNominalSize ()    {  }
38
39
40 void IGESGraph_ToolNominalSize::ReadOwnParams
41   (const Handle(IGESGraph_NominalSize)& ent,
42    const Handle(IGESData_IGESReaderData)& /*IR*/, IGESData_ParamReader& PR) const
43
44   //Standard_Boolean          st; //szv#4:S4163:12Mar99 not needed
45
46   Standard_Integer          nbPropertyValues;
47   Standard_Real             nominalSizeValue; 
48   Handle(TCollection_HAsciiString) nominalSizeName; 
49   Handle(TCollection_HAsciiString) standardName; 
50
51   // Reading nbPropertyValues(Integer)
52   PR.ReadInteger(PR.Current(), "No. of property values", nbPropertyValues); //szv#4:S4163:12Mar99 `st=` not needed
53   if ( (nbPropertyValues != 2) && (nbPropertyValues != 3) )
54     PR.AddFail("No. of Property values : Value is not 2/3");
55
56   // Reading nominalSizeValue(Real)
57   PR.ReadReal (PR.Current(), "Nominal size value", nominalSizeValue); //szv#4:S4163:12Mar99 `st=` not needed
58
59   // Reading nominalSizeName(String)
60   PR.ReadText (PR.Current(), "Nominal size name", nominalSizeName); //szv#4:S4163:12Mar99 `st=` not needed
61
62   if ( PR.NbParams() >= PR.CurrentNumber() )
63     {
64       Standard_Integer num = PR.CurrentNumber(); 
65       if ( PR.ParamType(num) == Interface_ParamText )
66         // Reading standardName(String)
67         PR.ReadText (PR.Current(), "Name of relevant engg. standard", 
68                      standardName); //szv#4:S4163:12Mar99 `st=` not needed
69     }
70
71   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
72   ent->Init
73     (nbPropertyValues, nominalSizeValue, nominalSizeName,  standardName);
74 }
75
76 void IGESGraph_ToolNominalSize::WriteOwnParams
77   (const Handle(IGESGraph_NominalSize)& ent, IGESData_IGESWriter& IW)  const
78
79   IW.Send( ent->NbPropertyValues() );
80   IW.Send( ent->NominalSizeValue() );
81   IW.Send( ent->NominalSizeName() );
82
83   if (ent->HasStandardName() )
84     IW.Send( ent->StandardName() );  // optionnal
85 }
86
87 void  IGESGraph_ToolNominalSize::OwnShared
88   (const Handle(IGESGraph_NominalSize)& /*ent*/, Interface_EntityIterator& /*iter*/) const
89 {
90 }
91
92 void IGESGraph_ToolNominalSize::OwnCopy
93   (const Handle(IGESGraph_NominalSize)& another,
94    const Handle(IGESGraph_NominalSize)& ent, Interface_CopyTool& /*TC*/) const
95
96   Standard_Integer          nbPropertyValues; 
97   Standard_Real             nominalSizeValue; 
98   Handle(TCollection_HAsciiString) nominalSizeName; 
99   Handle(TCollection_HAsciiString) standardName;
100
101   nbPropertyValues = another->NbPropertyValues();
102   nominalSizeValue = another->NominalSizeValue();
103   nominalSizeName  = new TCollection_HAsciiString(another->NominalSizeName());
104   if (another->HasStandardName()) standardName     =
105     new TCollection_HAsciiString(another->StandardName());
106
107   ent->Init(nbPropertyValues, nominalSizeValue, nominalSizeName, standardName);
108 }
109
110 Standard_Boolean  IGESGraph_ToolNominalSize::OwnCorrect
111   (const Handle(IGESGraph_NominalSize)& ent) const
112 {
113   Standard_Integer nbp = 2;
114   if (ent->HasStandardName()) nbp = 3;
115   Standard_Boolean res = ( ent->NbPropertyValues() != nbp);
116   if (res) ent->Init
117     (nbp,ent->NominalSizeValue(),ent->NominalSizeName(),ent->StandardName());
118   return res;    // nbpropertyvalues=2/3 selon standard
119 }
120
121 IGESData_DirChecker IGESGraph_ToolNominalSize::DirChecker
122   (const Handle(IGESGraph_NominalSize)& /*ent*/)  const
123
124   IGESData_DirChecker DC (406, 13);
125   DC.Structure(IGESData_DefVoid);
126   DC.LineFont(IGESData_DefVoid);
127   DC.LineWeight(IGESData_DefVoid);
128   DC.Color(IGESData_DefVoid);
129   DC.BlankStatusIgnored();
130   DC.UseFlagIgnored();
131   DC.HierarchyStatusIgnored();
132   return DC;
133 }
134
135 void IGESGraph_ToolNominalSize::OwnCheck
136   (const Handle(IGESGraph_NominalSize)& ent,
137    const Interface_ShareTool& , Handle(Interface_Check)& ach)  const
138 {
139   Standard_Integer nbp = 2;
140   if (ent->HasStandardName()) nbp = 3;
141   if ( ent->NbPropertyValues() != nbp)  ach->AddFail
142     ("No. of Property values : Value != 2/3 according Standard Name Status");
143 }
144
145 void IGESGraph_ToolNominalSize::OwnDump
146   (const Handle(IGESGraph_NominalSize)& ent, const IGESData_IGESDumper& /*dumper*/,
147    Standard_OStream& S, const Standard_Integer /*level*/)  const
148 {
149   S << "IGESGraph_NominalSize\n"
150     << "No. of property values : " << ent->NbPropertyValues() << "\n"
151     << "Nominal size value : "     << ent->NominalSizeValue() << "\n"
152     << "Nominal size name  : ";
153   IGESData_DumpString(S,ent->NominalSizeName());
154   S << "\n"
155     << "Name of relevant engineering standard : ";
156   IGESData_DumpString(S,ent->StandardName());
157   S << std::endl;
158 }