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 <IGESData_DirChecker.hxx> |
20 | #include <IGESData_IGESDumper.hxx> |
21 | #include <IGESData_IGESReaderData.hxx> |
22 | #include <IGESData_IGESWriter.hxx> |
7fd59977 |
23 | #include <IGESData_ParamCursor.hxx> |
42cf5bc1 |
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> |
7fd59977 |
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" << endl; |
159 | S << "Number of property values : " << ent->NbPropertyValues() << endl; |
160 | S << "Secondary Tolerance Flag : " << ent->SecondaryToleranceFlag() << endl; |
161 | S << "Tolerance Type : " << ent->ToleranceType() << endl; |
162 | S << "Tolerance Placement Flag : " << ent->TolerancePlacementFlag() << endl; |
163 | S << "Upper Tolerance : " << ent->UpperTolerance() << endl; |
164 | S << "Lower Tolerance : " << ent->LowerTolerance() << endl; |
165 | S << "Sign Suppression Flag : " << ( ent->SignSuppressionFlag() ? "True" : "False" ) << endl; |
166 | S << "Fraction Flag : " << ent->FractionFlag() << endl; |
167 | S << "Precision : " << ent->Precision() << endl; |
168 | } |
169 | |