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 | |
7fd59977 |
19 | #include <gp_Dir.hxx> |
42cf5bc1 |
20 | #include <gp_Pnt.hxx> |
21 | #include <gp_XYZ.hxx> |
22 | #include <IGESData_DirChecker.hxx> |
7fd59977 |
23 | #include <IGESData_Dump.hxx> |
42cf5bc1 |
24 | #include <IGESData_IGESDumper.hxx> |
25 | #include <IGESData_IGESReaderData.hxx> |
26 | #include <IGESData_IGESWriter.hxx> |
27 | #include <IGESData_ParamCursor.hxx> |
28 | #include <IGESData_ParamReader.hxx> |
29 | #include <IGESSolid_RightAngularWedge.hxx> |
30 | #include <IGESSolid_ToolRightAngularWedge.hxx> |
31 | #include <Interface_Check.hxx> |
32 | #include <Interface_CopyTool.hxx> |
33 | #include <Interface_EntityIterator.hxx> |
34 | #include <Interface_ShareTool.hxx> |
35 | #include <Message_Messenger.hxx> |
36 | #include <Standard_DomainError.hxx> |
7fd59977 |
37 | |
38 | IGESSolid_ToolRightAngularWedge::IGESSolid_ToolRightAngularWedge () { } |
39 | |
40 | |
41 | void IGESSolid_ToolRightAngularWedge::ReadOwnParams |
42 | (const Handle(IGESSolid_RightAngularWedge)& ent, |
43 | const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const |
44 | { |
45 | gp_XYZ tempSize, tempCorner, tempXAxis, tempZAxis; |
46 | Standard_Real lowX; |
47 | Standard_Real tempreal; |
48 | //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed |
49 | |
50 | PR.ReadXYZ(PR.CurrentList(1, 3), "Size of RightAngularWedge", tempSize); //szv#4:S4163:12Mar99 `st=` not needed |
51 | |
52 | PR.ReadReal(PR.Current(), "Small X length", lowX); //szv#4:S4163:12Mar99 `st=` not needed |
53 | |
54 | if (PR.DefinedElseSkip()) |
55 | { |
56 | //st = PR.ReadReal(PR.Current(), "Corner Point (X)", tempreal); //szv#4:S4163:12Mar99 moved in if |
57 | if (PR.ReadReal(PR.Current(), "Corner Point (X)", tempreal)) |
58 | tempCorner.SetX(tempreal); |
59 | } |
60 | else tempCorner.SetX(0.0); |
61 | |
62 | if (PR.DefinedElseSkip()) |
63 | { |
64 | //st = PR.ReadReal(PR.Current(), "Corner Point (Y)", tempreal); //szv#4:S4163:12Mar99 moved in if |
65 | if (PR.ReadReal(PR.Current(), "Corner Point (Y)", tempreal)) |
66 | tempCorner.SetY(tempreal); |
67 | } |
68 | else tempCorner.SetY(0.0); |
69 | |
70 | if (PR.DefinedElseSkip()) |
71 | { |
72 | //st = PR.ReadReal(PR.Current(), "Corner Point (Z)", tempreal); //szv#4:S4163:12Mar99 moved in if |
73 | if (PR.ReadReal(PR.Current(), "Corner Point (Z)", tempreal)) |
74 | tempCorner.SetZ(tempreal); |
75 | } |
76 | else tempCorner.SetZ(0.0); |
77 | |
78 | if (PR.DefinedElseSkip()) |
79 | { |
80 | //st = PR.ReadReal(PR.Current(), "Local X axis (I)", tempreal); //szv#4:S4163:12Mar99 moved in if |
81 | if (PR.ReadReal(PR.Current(), "Local X axis (I)", tempreal)) |
82 | tempXAxis.SetX(tempreal); |
83 | } |
84 | else tempXAxis.SetX(1.0); |
85 | |
86 | if (PR.DefinedElseSkip()) |
87 | { |
88 | //st = PR.ReadReal(PR.Current(), "Local X axis (J)", tempreal); //szv#4:S4163:12Mar99 moved in if |
89 | if (PR.ReadReal(PR.Current(), "Local X axis (J)", tempreal)) |
90 | tempXAxis.SetY(tempreal); |
91 | } |
92 | else tempXAxis.SetY(0.0); |
93 | |
94 | if (PR.DefinedElseSkip()) |
95 | { |
96 | //st = PR.ReadReal(PR.Current(), "Local X axis (K)", tempreal); //szv#4:S4163:12Mar99 moved in if |
97 | if (PR.ReadReal(PR.Current(), "Local X axis (K)", tempreal)) |
98 | tempXAxis.SetZ(tempreal); |
99 | } |
100 | else tempXAxis.SetZ(0.0); |
101 | |
102 | if (PR.DefinedElseSkip()) |
103 | { |
104 | //st = PR.ReadReal(PR.Current(), "Local Z axis (I)", tempreal); //szv#4:S4163:12Mar99 moved in if |
105 | if (PR.ReadReal(PR.Current(), "Local Z axis (I)", tempreal)) |
106 | tempZAxis.SetX(tempreal); |
107 | } |
108 | else tempZAxis.SetX(0.0); |
109 | |
110 | if (PR.DefinedElseSkip()) |
111 | { |
112 | //st = PR.ReadReal(PR.Current(), "Local Z axis (J)", tempreal); //szv#4:S4163:12Mar99 moved in if |
113 | if (PR.ReadReal(PR.Current(), "Local Z axis (J)", tempreal)) |
114 | tempZAxis.SetY(tempreal); |
115 | } |
116 | else tempZAxis.SetY(0.0); |
117 | |
118 | if (PR.DefinedElseSkip()) |
119 | { |
120 | //st = PR.ReadReal(PR.Current(), "Local Z axis (K)", tempreal); //szv#4:S4163:12Mar99 moved in if |
121 | if (PR.ReadReal(PR.Current(), "Local Z axis (K)", tempreal)) |
122 | tempZAxis.SetZ(tempreal); |
123 | } |
124 | else tempZAxis.SetZ(1.0); |
125 | |
126 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
127 | ent->Init (tempSize, lowX, tempCorner, tempXAxis, tempZAxis); |
128 | Standard_Real eps = 1.E-05; |
129 | if (!tempXAxis.IsEqual(ent->XAxis().XYZ(),eps)) PR.AddWarning |
130 | ("XAxis poorly unitary, normalized"); |
131 | if (!tempZAxis.IsEqual(ent->ZAxis().XYZ(),eps)) PR.AddWarning |
132 | ("ZAxis poorly unitary, normalized"); |
133 | } |
134 | |
135 | void IGESSolid_ToolRightAngularWedge::WriteOwnParams |
136 | (const Handle(IGESSolid_RightAngularWedge)& ent, IGESData_IGESWriter& IW) const |
137 | { |
138 | IW.Send(ent->Size().X()); |
139 | IW.Send(ent->Size().Y()); |
140 | IW.Send(ent->Size().Z()); |
141 | IW.Send(ent->XSmallLength()); |
142 | IW.Send(ent->Corner().X()); |
143 | IW.Send(ent->Corner().Y()); |
144 | IW.Send(ent->Corner().Z()); |
145 | IW.Send(ent->XAxis().X()); |
146 | IW.Send(ent->XAxis().Y()); |
147 | IW.Send(ent->XAxis().Z()); |
148 | IW.Send(ent->ZAxis().X()); |
149 | IW.Send(ent->ZAxis().Y()); |
150 | IW.Send(ent->ZAxis().Z()); |
151 | } |
152 | |
153 | void IGESSolid_ToolRightAngularWedge::OwnShared |
154 | (const Handle(IGESSolid_RightAngularWedge)& /* ent */, Interface_EntityIterator& /* iter */) const |
155 | { |
156 | } |
157 | |
158 | void IGESSolid_ToolRightAngularWedge::OwnCopy |
159 | (const Handle(IGESSolid_RightAngularWedge)& another, |
160 | const Handle(IGESSolid_RightAngularWedge)& ent, Interface_CopyTool& /* TC */) const |
161 | { |
162 | ent->Init(another->Size(), another->XSmallLength(), another->Corner().XYZ(), |
163 | another->XAxis().XYZ(), another->ZAxis().XYZ()); |
164 | } |
165 | |
166 | IGESData_DirChecker IGESSolid_ToolRightAngularWedge::DirChecker |
167 | (const Handle(IGESSolid_RightAngularWedge)& /* ent */ ) const |
168 | { |
169 | IGESData_DirChecker DC(152, 0); |
170 | DC.Structure (IGESData_DefVoid); |
171 | DC.LineFont (IGESData_DefAny); |
172 | DC.Color (IGESData_DefAny); |
173 | |
174 | DC.UseFlagRequired (0); |
175 | DC.HierarchyStatusIgnored (); |
176 | return DC; |
177 | } |
178 | |
179 | void IGESSolid_ToolRightAngularWedge::OwnCheck |
180 | (const Handle(IGESSolid_RightAngularWedge)& ent, |
181 | const Interface_ShareTool& , Handle(Interface_Check)& ach) const |
182 | { |
183 | Standard_Real eps = 1.E-04; |
184 | Standard_Real prosca = ent->XAxis() * ent->ZAxis(); |
185 | if (prosca < -eps || prosca > eps) |
186 | ach->AddFail("Local Z axis : Not orthogonal to X axis"); |
187 | if (ent->Size().X() <= 0. || ent->Size().Y() <= 0. || ent->Size().Z() <= 0.) |
188 | ach->AddFail("Size : Values are not positive"); |
189 | if (ent->XSmallLength() <= 0.0) |
190 | ach->AddFail("Small X Length : Not Positive"); |
191 | if (ent->XSmallLength() >= ent->Size().X()) |
192 | ach->AddFail("Small X Length : Value not < LX"); |
193 | } |
194 | |
195 | void IGESSolid_ToolRightAngularWedge::OwnDump |
196 | (const Handle(IGESSolid_RightAngularWedge)& ent, const IGESData_IGESDumper& /* dumper */, |
0ebe5b0a |
197 | Standard_OStream& S, const Standard_Integer level) const |
7fd59977 |
198 | { |
0ebe5b0a |
199 | S << "IGESSolid_RightAngularWedge\n" |
200 | << "Size : "; |
7fd59977 |
201 | IGESData_DumpXYZ(S, ent->Size()); S << " "; |
0ebe5b0a |
202 | S << "XSmall : " << ent->XSmallLength() << "\n" |
203 | << "Corner : "; |
7fd59977 |
204 | IGESData_DumpXYZL(S,level, ent->Corner(), ent->Location()); |
0ebe5b0a |
205 | S << "\nXAxis : "; |
7fd59977 |
206 | IGESData_DumpXYZL(S,level, ent->XAxis(), ent->VectorLocation()); |
0ebe5b0a |
207 | S << "\nZAxis : "; |
7fd59977 |
208 | IGESData_DumpXYZL(S,level, ent->ZAxis(), ent->VectorLocation()); |
0ebe5b0a |
209 | S << std::endl; |
7fd59977 |
210 | } |