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