7fd59977 |
1 | //-------------------------------------------------------------------- |
2 | // |
3 | // File Name : IGESSolid_Ellipsoid.cxx |
4 | // Date : |
5 | // Author : CKY / Contract Toubro-Larsen |
6 | // Copyright : MATRA-DATAVISION 1993 |
7 | // |
8 | //-------------------------------------------------------------------- |
9 | |
10 | #include <IGESSolid_ToolEllipsoid.ixx> |
11 | #include <IGESData_ParamCursor.hxx> |
12 | #include <gp_XYZ.hxx> |
13 | #include <gp_Pnt.hxx> |
14 | #include <gp_Dir.hxx> |
15 | #include <IGESData_Dump.hxx> |
16 | |
17 | |
18 | IGESSolid_ToolEllipsoid::IGESSolid_ToolEllipsoid () { } |
19 | |
20 | |
21 | void IGESSolid_ToolEllipsoid::ReadOwnParams |
22 | (const Handle(IGESSolid_Ellipsoid)& ent, |
23 | const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const |
24 | { |
25 | gp_XYZ tempSize, tempCenter, tempXAxis, tempZAxis; |
26 | //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed |
27 | Standard_Real tempreal; |
28 | |
29 | PR.ReadXYZ(PR.CurrentList(1, 3), "Size", tempSize); //szv#4:S4163:12Mar99 `st=` not needed |
30 | |
31 | if (PR.DefinedElseSkip()) |
32 | { |
33 | //st = PR.ReadReal(PR.Current(), "Center Point (X)", tempreal); //szv#4:S4163:12Mar99 moved in if |
34 | if (PR.ReadReal(PR.Current(), "Center Point (X)", tempreal)) |
35 | tempCenter.SetX(tempreal); |
36 | } |
37 | else tempCenter.SetX(0.0); |
38 | |
39 | if (PR.DefinedElseSkip()) |
40 | { |
41 | //st = PR.ReadReal(PR.Current(), "Center Point (Y)", tempreal); //szv#4:S4163:12Mar99 moved in if |
42 | if (PR.ReadReal(PR.Current(), "Center Point (Y)", tempreal)) |
43 | tempCenter.SetY(tempreal); |
44 | } |
45 | else tempCenter.SetY(0.0); |
46 | |
47 | if (PR.DefinedElseSkip()) |
48 | { |
49 | //st = PR.ReadReal(PR.Current(), "Center Point (Z)", tempreal); //szv#4:S4163:12Mar99 moved in if |
50 | if (PR.ReadReal(PR.Current(), "Center Point (Z)", tempreal)) |
51 | tempCenter.SetZ(tempreal); |
52 | } |
53 | else tempCenter.SetZ(0.0); |
54 | |
55 | if (PR.DefinedElseSkip()) |
56 | { |
57 | //st = PR.ReadReal(PR.Current(), "Local X axis (I)", tempreal); //szv#4:S4163:12Mar99 moved in if |
58 | if (PR.ReadReal(PR.Current(), "Local X axis (I)", tempreal)) |
59 | tempXAxis.SetX(tempreal); |
60 | } |
61 | else tempXAxis.SetX(1.0); |
62 | |
63 | if (PR.DefinedElseSkip()) |
64 | { |
65 | //st = PR.ReadReal(PR.Current(), "Local X axis (J)", tempreal); //szv#4:S4163:12Mar99 moved in if |
66 | if (PR.ReadReal(PR.Current(), "Local X axis (J)", tempreal)) |
67 | tempXAxis.SetY(tempreal); |
68 | } |
69 | else tempXAxis.SetY(0.0); |
70 | |
71 | if (PR.DefinedElseSkip()) |
72 | { |
73 | //st = PR.ReadReal(PR.Current(), "Local X axis (K)", tempreal); //szv#4:S4163:12Mar99 moved in if |
74 | if (PR.ReadReal(PR.Current(), "Local X axis (K)", tempreal)) |
75 | tempXAxis.SetZ(tempreal); |
76 | } |
77 | else tempXAxis.SetZ(0.0); |
78 | |
79 | if (PR.DefinedElseSkip()) |
80 | { |
81 | //st = PR.ReadReal(PR.Current(), "Local Z axis (I)", tempreal); //szv#4:S4163:12Mar99 moved in if |
82 | if (PR.ReadReal(PR.Current(), "Local Z axis (I)", tempreal)) |
83 | tempZAxis.SetX(tempreal); |
84 | } |
85 | else tempZAxis.SetX(0.0); |
86 | |
87 | if (PR.DefinedElseSkip()) |
88 | { |
89 | //st = PR.ReadReal(PR.Current(), "Local Z axis (J)", tempreal); //szv#4:S4163:12Mar99 moved in if |
90 | if (PR.ReadReal(PR.Current(), "Local Z axis (J)", tempreal)) |
91 | tempZAxis.SetY(tempreal); |
92 | } |
93 | else tempZAxis.SetY(0.0); |
94 | |
95 | if (PR.DefinedElseSkip()) |
96 | { |
97 | //st = PR.ReadReal(PR.Current(), "Local Z axis (K)", tempreal); //szv#4:S4163:12Mar99 moved in if |
98 | if (PR.ReadReal(PR.Current(), "Local Z axis (K)", tempreal)) |
99 | tempZAxis.SetZ(tempreal); |
100 | } |
101 | else tempZAxis.SetZ(1.0); |
102 | |
103 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
104 | ent->Init(tempSize, tempCenter, tempXAxis, tempZAxis); |
105 | Standard_Real eps = 1.E-05; |
106 | if (!tempXAxis.IsEqual(ent->XAxis().XYZ(),eps)) PR.AddWarning |
107 | ("XAxis poorly unitary, normalized"); |
108 | if (!tempZAxis.IsEqual(ent->ZAxis().XYZ(),eps)) PR.AddWarning |
109 | ("ZAxis poorly unitary, normalized"); |
110 | } |
111 | |
112 | void IGESSolid_ToolEllipsoid::WriteOwnParams |
113 | (const Handle(IGESSolid_Ellipsoid)& ent, IGESData_IGESWriter& IW) const |
114 | { |
115 | IW.Send(ent->Size().X()); |
116 | IW.Send(ent->Size().Y()); |
117 | IW.Send(ent->Size().Z()); |
118 | IW.Send(ent->Center().X()); |
119 | IW.Send(ent->Center().Y()); |
120 | IW.Send(ent->Center().Z()); |
121 | IW.Send(ent->XAxis().X()); |
122 | IW.Send(ent->XAxis().Y()); |
123 | IW.Send(ent->XAxis().Z()); |
124 | IW.Send(ent->ZAxis().X()); |
125 | IW.Send(ent->ZAxis().Y()); |
126 | IW.Send(ent->ZAxis().Z()); |
127 | } |
128 | |
129 | void IGESSolid_ToolEllipsoid::OwnShared |
130 | (const Handle(IGESSolid_Ellipsoid)& /* ent */, Interface_EntityIterator& /* iter */) const |
131 | { |
132 | } |
133 | |
134 | void IGESSolid_ToolEllipsoid::OwnCopy |
135 | (const Handle(IGESSolid_Ellipsoid)& another, |
136 | const Handle(IGESSolid_Ellipsoid)& ent, Interface_CopyTool& /* TC */) const |
137 | { |
138 | ent->Init(another->Size(), another->Center().XYZ(), |
139 | another->XAxis().XYZ(), another->ZAxis().XYZ()); |
140 | } |
141 | |
142 | IGESData_DirChecker IGESSolid_ToolEllipsoid::DirChecker |
143 | (const Handle(IGESSolid_Ellipsoid)& /* ent */ ) const |
144 | { |
145 | IGESData_DirChecker DC(168, 0); |
146 | DC.Structure (IGESData_DefVoid); |
147 | DC.LineFont (IGESData_DefAny); |
148 | DC.Color (IGESData_DefAny); |
149 | |
150 | DC.UseFlagRequired (0); |
151 | DC.HierarchyStatusIgnored (); |
152 | return DC; |
153 | } |
154 | |
155 | void IGESSolid_ToolEllipsoid::OwnCheck |
156 | (const Handle(IGESSolid_Ellipsoid)& ent, |
157 | const Interface_ShareTool& , Handle(Interface_Check)& ach) const |
158 | { |
159 | Standard_Real eps = 1.E-04; |
160 | Standard_Real prosca = ent->XAxis().Dot(ent->ZAxis()); |
161 | if (prosca < -eps || prosca > eps) |
162 | ach->AddFail("Local Z axis : Not orthogonal to X axis"); |
163 | if (! (ent->Size().X() >= ent->Size().Y() |
164 | && ent->Size().Y() >= ent->Size().Z() |
165 | && ent->Size().Z() > 0)) |
166 | ach->AddFail("Size : The values does not satisfy LX >= LY >= LZ > 0"); |
167 | } |
168 | |
169 | void IGESSolid_ToolEllipsoid::OwnDump |
170 | (const Handle(IGESSolid_Ellipsoid)& ent, const IGESData_IGESDumper& /* dumper */, |
171 | const Handle(Message_Messenger)& S, const Standard_Integer level) const |
172 | { |
173 | S << "IGESSolid_Ellipsoid" << endl; |
174 | |
175 | S << "Size : "; |
176 | IGESData_DumpXYZ(S, ent->Size()); |
177 | S << endl << "Center : "; |
178 | IGESData_DumpXYZL(S,level, ent->Center(), ent->Location()); |
179 | S << endl << "XAxis : "; |
180 | IGESData_DumpXYZL(S,level, ent->XAxis(), ent->VectorLocation()); |
181 | S << endl << "ZAxis : "; |
182 | IGESData_DumpXYZL(S,level, ent->ZAxis(), ent->VectorLocation()); |
183 | S << endl; |
184 | } |