1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
22 #include <IGESData_DirChecker.hxx>
23 #include <IGESData_Dump.hxx>
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>
38 IGESSolid_ToolRightAngularWedge::IGESSolid_ToolRightAngularWedge () { }
41 void IGESSolid_ToolRightAngularWedge::ReadOwnParams
42 (const Handle(IGESSolid_RightAngularWedge)& ent,
43 const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const
45 gp_XYZ tempSize, tempCorner, tempXAxis, tempZAxis;
47 Standard_Real tempreal;
48 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
50 PR.ReadXYZ(PR.CurrentList(1, 3), "Size of RightAngularWedge", tempSize); //szv#4:S4163:12Mar99 `st=` not needed
52 PR.ReadReal(PR.Current(), "Small X length", lowX); //szv#4:S4163:12Mar99 `st=` not needed
54 if (PR.DefinedElseSkip())
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);
60 else tempCorner.SetX(0.0);
62 if (PR.DefinedElseSkip())
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);
68 else tempCorner.SetY(0.0);
70 if (PR.DefinedElseSkip())
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);
76 else tempCorner.SetZ(0.0);
78 if (PR.DefinedElseSkip())
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);
84 else tempXAxis.SetX(1.0);
86 if (PR.DefinedElseSkip())
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);
92 else tempXAxis.SetY(0.0);
94 if (PR.DefinedElseSkip())
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);
100 else tempXAxis.SetZ(0.0);
102 if (PR.DefinedElseSkip())
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);
108 else tempZAxis.SetX(0.0);
110 if (PR.DefinedElseSkip())
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);
116 else tempZAxis.SetY(0.0);
118 if (PR.DefinedElseSkip())
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);
124 else tempZAxis.SetZ(1.0);
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");
135 void IGESSolid_ToolRightAngularWedge::WriteOwnParams
136 (const Handle(IGESSolid_RightAngularWedge)& ent, IGESData_IGESWriter& IW) const
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());
153 void IGESSolid_ToolRightAngularWedge::OwnShared
154 (const Handle(IGESSolid_RightAngularWedge)& /* ent */, Interface_EntityIterator& /* iter */) const
158 void IGESSolid_ToolRightAngularWedge::OwnCopy
159 (const Handle(IGESSolid_RightAngularWedge)& another,
160 const Handle(IGESSolid_RightAngularWedge)& ent, Interface_CopyTool& /* TC */) const
162 ent->Init(another->Size(), another->XSmallLength(), another->Corner().XYZ(),
163 another->XAxis().XYZ(), another->ZAxis().XYZ());
166 IGESData_DirChecker IGESSolid_ToolRightAngularWedge::DirChecker
167 (const Handle(IGESSolid_RightAngularWedge)& /* ent */ ) const
169 IGESData_DirChecker DC(152, 0);
170 DC.Structure (IGESData_DefVoid);
171 DC.LineFont (IGESData_DefAny);
172 DC.Color (IGESData_DefAny);
174 DC.UseFlagRequired (0);
175 DC.HierarchyStatusIgnored ();
179 void IGESSolid_ToolRightAngularWedge::OwnCheck
180 (const Handle(IGESSolid_RightAngularWedge)& ent,
181 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
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");
195 void IGESSolid_ToolRightAngularWedge::OwnDump
196 (const Handle(IGESSolid_RightAngularWedge)& ent, const IGESData_IGESDumper& /* dumper */,
197 const Handle(Message_Messenger)& S, const Standard_Integer level) const
199 S << "IGESSolid_RightAngularWedge" << endl;
202 IGESData_DumpXYZ(S, ent->Size()); S << " ";
203 S << "XSmall : " << ent->XSmallLength() << endl;
205 IGESData_DumpXYZL(S,level, ent->Corner(), ent->Location());
206 S << endl << "XAxis : ";
207 IGESData_DumpXYZL(S,level, ent->XAxis(), ent->VectorLocation());
208 S << endl << "ZAxis : ";
209 IGESData_DumpXYZL(S,level, ent->ZAxis(), ent->VectorLocation());