0030895: Coding Rules - specify std namespace explicitly for std::cout and streams
[occt.git] / src / IGESDimen / IGESDimen_ToolDimensionTolerance.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_IGESDumper.hxx>
21 #include <IGESData_IGESReaderData.hxx>
22 #include <IGESData_IGESWriter.hxx>
23 #include <IGESData_ParamCursor.hxx>
24 #include <IGESData_ParamReader.hxx>
25 #include <IGESDimen_DimensionTolerance.hxx>
26 #include <IGESDimen_ToolDimensionTolerance.hxx>
27 #include <Interface_Check.hxx>
28 #include <Interface_CopyTool.hxx>
29 #include <Interface_EntityIterator.hxx>
30 #include <Interface_ShareTool.hxx>
31 #include <Message_Messenger.hxx>
32 #include <Standard_DomainError.hxx>
33
34 IGESDimen_ToolDimensionTolerance::IGESDimen_ToolDimensionTolerance ()    {  }
35
36
37 void  IGESDimen_ToolDimensionTolerance::ReadOwnParams
38   (const Handle(IGESDimen_DimensionTolerance)& ent,
39    const Handle(IGESData_IGESReaderData)& /*IR*/, IGESData_ParamReader& PR) const
40 {
41   //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
42   Standard_Integer tempNbProps;
43   Standard_Integer tempSecondTolFlag;
44   Standard_Integer tempTolTyp;
45   Standard_Integer tempTolPlaceFlag;
46   Standard_Real    tempUpperTol;
47   Standard_Real    tempLowerTol;
48   Standard_Boolean tempSignSupFlag;
49   Standard_Integer tempFracFlag;
50   Standard_Integer tempPrecision;
51
52   if (PR.DefinedElseSkip())
53     PR.ReadInteger(PR.Current(), "Number of properties", tempNbProps); //szv#4:S4163:12Mar99 `st=` not needed
54   else
55     tempNbProps = 8;
56
57   PR.ReadInteger(PR.Current(), "Secondary Tolerance Flag",
58                  tempSecondTolFlag); //szv#4:S4163:12Mar99 `st=` not needed
59   PR.ReadInteger(PR.Current(), "Tolerance Type", tempTolTyp); //szv#4:S4163:12Mar99 `st=` not needed
60   if (PR.DefinedElseSkip())
61     PR.ReadInteger(PR.Current(), "Tolerance Placement Flag",
62                    tempTolPlaceFlag); //szv#4:S4163:12Mar99 `st=` not needed
63   else
64     tempTolPlaceFlag = 2;
65
66   PR.ReadReal(PR.Current(), "Upper Tolerance", tempUpperTol); //szv#4:S4163:12Mar99 `st=` not needed
67   PR.ReadReal(PR.Current(), "Lower Tolerance", tempLowerTol); //szv#4:S4163:12Mar99 `st=` not needed
68   PR.ReadBoolean(PR.Current(), "Sign Suppression Flag",
69                  tempSignSupFlag); //szv#4:S4163:12Mar99 `st=` not needed
70   PR.ReadInteger(PR.Current(), "Fraction Flag", tempFracFlag); //szv#4:S4163:12Mar99 `st=` not needed
71   PR.ReadInteger(PR.Current(), "Precision", tempPrecision); //szv#4:S4163:12Mar99 `st=` not needed
72
73   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
74   ent->Init
75     (tempNbProps, tempSecondTolFlag, tempTolTyp, tempTolPlaceFlag,
76      tempUpperTol, tempLowerTol, tempSignSupFlag, tempFracFlag, tempPrecision);
77 }
78
79 void  IGESDimen_ToolDimensionTolerance::WriteOwnParams
80   (const Handle(IGESDimen_DimensionTolerance)& ent, IGESData_IGESWriter& IW) const
81 {
82   IW.Send(ent->NbPropertyValues());
83   IW.Send(ent->SecondaryToleranceFlag());
84   IW.Send(ent->ToleranceType());
85   IW.Send(ent->TolerancePlacementFlag());
86   IW.Send(ent->UpperTolerance());
87   IW.Send(ent->LowerTolerance());
88   IW.SendBoolean(ent->SignSuppressionFlag());
89   IW.Send(ent->FractionFlag());
90   IW.Send(ent->Precision());
91 }
92
93 void  IGESDimen_ToolDimensionTolerance::OwnShared
94   (const Handle(IGESDimen_DimensionTolerance)& /*ent*/, Interface_EntityIterator& /*iter*/) const
95 {
96 }
97
98 void  IGESDimen_ToolDimensionTolerance::OwnCopy
99   (const Handle(IGESDimen_DimensionTolerance)& another,
100    const Handle(IGESDimen_DimensionTolerance)& ent, Interface_CopyTool& /*TC*/) const
101 {
102   ent->Init
103     (8,another->SecondaryToleranceFlag(),another->ToleranceType(),
104      another->TolerancePlacementFlag(),
105      another->UpperTolerance(),another->LowerTolerance(),
106      (another->SignSuppressionFlag() ? 1 : 0),
107      another->FractionFlag(),another->Precision());
108 }
109
110 Standard_Boolean  IGESDimen_ToolDimensionTolerance::OwnCorrect
111   (const Handle(IGESDimen_DimensionTolerance)& ent) const
112 {
113   Standard_Boolean res = (ent->NbPropertyValues() != 8);
114   if (res) ent->Init
115     (8,ent->SecondaryToleranceFlag(),ent->ToleranceType(),
116      ent->TolerancePlacementFlag(),ent->UpperTolerance(),ent->LowerTolerance(),
117      (ent->SignSuppressionFlag() ? 1 : 0),
118      ent->FractionFlag(),ent->Precision());    // nbpropertyvalues=8
119   return res;
120 }
121
122 IGESData_DirChecker  IGESDimen_ToolDimensionTolerance::DirChecker
123   (const Handle(IGESDimen_DimensionTolerance)& /*ent*/) const
124 {
125   IGESData_DirChecker DC(406, 29);
126   DC.Structure(IGESData_DefVoid);
127   DC.GraphicsIgnored();
128   DC.LineFont(IGESData_DefVoid);
129   DC.LineWeight(IGESData_DefVoid);
130   DC.Color(IGESData_DefVoid);
131   DC.BlankStatusIgnored();
132   DC.SubordinateStatusRequired(2);
133   DC.UseFlagRequired(2);
134   DC.HierarchyStatusIgnored();
135   return DC;
136 }
137
138 void  IGESDimen_ToolDimensionTolerance::OwnCheck
139   (const Handle(IGESDimen_DimensionTolerance)& ent,
140    const Interface_ShareTool& , Handle(Interface_Check)& ach) const
141 {
142   if (ent->NbPropertyValues() != 8)
143     ach->AddFail("Number of properties != 8");
144   if ((ent->SecondaryToleranceFlag() < 0) || (ent->SecondaryToleranceFlag() > 2))
145     ach->AddFail("Secondary Tolerance Flag != 0-2");
146   if ((ent->ToleranceType() < 1) || (ent->ToleranceType() > 10))
147     ach->AddFail("Tolerance Type != 1-10");
148   if ((ent->TolerancePlacementFlag() < 1) || (ent->TolerancePlacementFlag() > 4))
149     ach->AddFail("Tolerance Placement Flag != 1-4");
150   if ((ent->FractionFlag() < 0) || (ent->FractionFlag() > 2))
151     ach->AddFail("Fraction Flag != 0-2");
152 }
153
154 void  IGESDimen_ToolDimensionTolerance::OwnDump
155   (const Handle(IGESDimen_DimensionTolerance)& ent, const IGESData_IGESDumper& /*dumper*/,
156    const Handle(Message_Messenger)& S, const Standard_Integer /*level*/) const
157 {
158   S << "IGESDimen_DimensionTolerance" << Message_EndLine;
159   S << "Number of property values : " << ent->NbPropertyValues() << Message_EndLine;
160   S << "Secondary Tolerance Flag : " << ent->SecondaryToleranceFlag() << Message_EndLine;
161   S << "Tolerance Type           : " << ent->ToleranceType() << Message_EndLine;
162   S << "Tolerance Placement Flag : " << ent->TolerancePlacementFlag() << Message_EndLine;
163   S << "Upper Tolerance          : " << ent->UpperTolerance() << Message_EndLine;
164   S << "Lower Tolerance          : " << ent->LowerTolerance() << Message_EndLine;
165   S << "Sign Suppression Flag    : " << ( ent->SignSuppressionFlag() ? "True" : "False" ) << Message_EndLine;
166   S << "Fraction Flag            : " << ent->FractionFlag() << Message_EndLine;
167   S << "Precision                : " << ent->Precision() << Message_EndLine;
168 }
169