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_Pnt.hxx> |
42cf5bc1 |
20 | #include <gp_XYZ.hxx> |
21 | #include <IGESData_DirChecker.hxx> |
7fd59977 |
22 | #include <IGESData_Dump.hxx> |
42cf5bc1 |
23 | #include <IGESData_IGESDumper.hxx> |
24 | #include <IGESData_IGESReaderData.hxx> |
25 | #include <IGESData_IGESWriter.hxx> |
26 | #include <IGESData_ParamCursor.hxx> |
27 | #include <IGESData_ParamReader.hxx> |
28 | #include <IGESSolid_Cylinder.hxx> |
29 | #include <IGESSolid_ToolCylinder.hxx> |
30 | #include <Interface_Check.hxx> |
31 | #include <Interface_CopyTool.hxx> |
32 | #include <Interface_EntityIterator.hxx> |
33 | #include <Interface_ShareTool.hxx> |
34 | #include <Message_Messenger.hxx> |
35 | #include <Standard_DomainError.hxx> |
7fd59977 |
36 | |
37 | IGESSolid_ToolCylinder::IGESSolid_ToolCylinder () { } |
38 | |
39 | |
40 | void IGESSolid_ToolCylinder::ReadOwnParams |
41 | (const Handle(IGESSolid_Cylinder)& ent, |
42 | const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const |
43 | { |
44 | Standard_Real tempHeight, tempRadius, tempreal; |
45 | gp_XYZ tempCenter, tempAxis; |
46 | //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed |
47 | |
48 | PR.ReadReal(PR.Current(), "Height", tempHeight); //szv#4:S4163:12Mar99 `st=` not needed |
49 | |
50 | PR.ReadReal(PR.Current(), "Radius", tempRadius); //szv#4:S4163:12Mar99 `st=` not needed |
51 | |
52 | if (PR.DefinedElseSkip()) |
53 | { |
54 | //st = PR.ReadReal(PR.Current(), "Face center (X)", tempreal); //szv#4:S4163:12Mar99 moved in if |
55 | if (PR.ReadReal(PR.Current(), "Face center (X)", tempreal)) |
56 | tempCenter.SetX(tempreal); |
57 | } |
58 | else tempCenter.SetX(0.0); |
59 | |
60 | if (PR.DefinedElseSkip()) |
61 | { |
62 | //st = PR.ReadReal(PR.Current(), "Face center (Y)", tempreal); //szv#4:S4163:12Mar99 moved in if |
63 | if (PR.ReadReal(PR.Current(), "Face center (Y)", tempreal)) |
64 | tempCenter.SetY(tempreal); |
65 | } |
66 | else tempCenter.SetY(0.0); |
67 | |
68 | if (PR.DefinedElseSkip()) |
69 | { |
70 | //st = PR.ReadReal(PR.Current(), "Face center (Z)", tempreal); //szv#4:S4163:12Mar99 moved in if |
71 | if (PR.ReadReal(PR.Current(), "Face center (Z)", tempreal)) |
72 | tempCenter.SetZ(tempreal); |
73 | } |
74 | else tempCenter.SetZ(0.0); |
75 | |
76 | if (PR.DefinedElseSkip()) |
77 | { |
78 | //st = PR.ReadReal(PR.Current(), "Axis direction (I)", tempreal); //szv#4:S4163:12Mar99 moved in if |
79 | if (PR.ReadReal(PR.Current(), "Axis direction (I)", tempreal)) |
80 | tempAxis.SetX(tempreal); |
81 | } |
82 | else tempAxis.SetX(0.0); |
83 | |
84 | if (PR.DefinedElseSkip()) |
85 | { |
86 | //st = PR.ReadReal(PR.Current(), "Axis direction (J)", tempreal); //szv#4:S4163:12Mar99 moved in if |
87 | if (PR.ReadReal(PR.Current(), "Axis direction (J)", tempreal)) |
88 | tempAxis.SetY(tempreal); |
89 | } |
90 | else tempAxis.SetY(0.0); |
91 | |
92 | if (PR.DefinedElseSkip()) |
93 | { |
94 | //st = PR.ReadReal(PR.Current(), "Axis direction (K)", tempreal); //szv#4:S4163:12Mar99 moved in if |
95 | if (PR.ReadReal(PR.Current(), "Axis direction (K)", tempreal)) |
96 | tempAxis.SetZ(tempreal); |
97 | } |
98 | else tempAxis.SetZ(1.0); |
99 | |
100 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
101 | ent->Init |
102 | (tempHeight, tempRadius, tempCenter, tempAxis); |
103 | Standard_Real eps = 1.E-05; |
104 | if (!tempAxis.IsEqual(ent->Axis().XYZ(),eps)) PR.AddWarning |
105 | ("Axis poorly unitary, normalized"); |
106 | } |
107 | |
108 | void IGESSolid_ToolCylinder::WriteOwnParams |
109 | (const Handle(IGESSolid_Cylinder)& ent, IGESData_IGESWriter& IW) const |
110 | { |
111 | IW.Send(ent->Height()); |
112 | IW.Send(ent->Radius()); |
113 | IW.Send(ent->FaceCenter().X()); |
114 | IW.Send(ent->FaceCenter().Y()); |
115 | IW.Send(ent->FaceCenter().Z()); |
116 | IW.Send(ent->Axis().X()); |
117 | IW.Send(ent->Axis().Y()); |
118 | IW.Send(ent->Axis().Z()); |
119 | } |
120 | |
121 | void IGESSolid_ToolCylinder::OwnShared |
122 | (const Handle(IGESSolid_Cylinder)& /* ent */, Interface_EntityIterator& /* iter */) const |
123 | { |
124 | } |
125 | |
126 | void IGESSolid_ToolCylinder::OwnCopy |
127 | (const Handle(IGESSolid_Cylinder)& another, |
128 | const Handle(IGESSolid_Cylinder)& ent, Interface_CopyTool& /* TC */) const |
129 | { |
130 | ent->Init |
131 | (another->Height(), another->Radius(), another->FaceCenter().XYZ(), |
132 | another->Axis().XYZ()); |
133 | } |
134 | |
135 | IGESData_DirChecker IGESSolid_ToolCylinder::DirChecker |
136 | (const Handle(IGESSolid_Cylinder)& /* ent */ ) const |
137 | { |
138 | IGESData_DirChecker DC(154, 0); |
139 | |
140 | DC.Structure (IGESData_DefVoid); |
141 | DC.LineFont (IGESData_DefAny); |
142 | DC.Color (IGESData_DefAny); |
143 | |
144 | DC.UseFlagRequired (0); |
145 | DC.HierarchyStatusIgnored (); |
146 | return DC; |
147 | } |
148 | |
149 | void IGESSolid_ToolCylinder::OwnCheck |
150 | (const Handle(IGESSolid_Cylinder)& ent, |
151 | const Interface_ShareTool& , Handle(Interface_Check)& ach) const |
152 | { |
153 | if (ent->Height() <= 0.0) |
154 | ach->AddFail("Height : Value < 0"); |
155 | if (ent->Radius() <= 0.0) |
156 | ach->AddFail("Radius : Value < 0"); |
157 | } |
158 | |
159 | void IGESSolid_ToolCylinder::OwnDump |
160 | (const Handle(IGESSolid_Cylinder)& ent, const IGESData_IGESDumper& /* dumper */, |
161 | const Handle(Message_Messenger)& S, const Standard_Integer level) const |
162 | { |
163 | |
164 | // Standard_Boolean locprint = (ent->HasTransf() && level >=6); |
165 | // gp_Pnt TCenter = ent->TransformedFaceCenter(); |
166 | // gp_Dir TAxis = ent->TransformedAxis(); |
167 | |
168 | S << "IGESSolid_Cylinder" << endl; |
169 | |
170 | S << "Height : " << ent->Height() << " "; |
171 | S << "Radius : " << ent->Radius() << endl; |
172 | S << "Center : "; |
173 | IGESData_DumpXYZL(S,level, ent->FaceCenter(), ent->Location()); |
174 | S << endl << "Axis : "; |
175 | IGESData_DumpXYZL(S,level, ent->Axis(), ent->VectorLocation()); |
176 | S << endl; |
177 | } |