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_Block.hxx>
30 #include <IGESSolid_ToolBlock.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_ToolBlock::IGESSolid_ToolBlock () { }
41 void IGESSolid_ToolBlock::ReadOwnParams
42 (const Handle(IGESSolid_Block)& ent,
43 const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const
45 gp_XYZ tempSize, tempCorner, tempXAxis, tempZAxis;
46 Standard_Real tempreal;
47 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
49 PR.ReadXYZ(PR.CurrentList(1, 3), "Size of Block", tempSize); //szv#4:S4163:12Mar99 `st=` not needed
51 if (PR.DefinedElseSkip())
53 //st = PR.ReadReal(PR.Current(), "Corner Point (X)", tempreal); //szv#4:S4163:12Mar99 moved in if
54 if (PR.ReadReal(PR.Current(), "Corner Point (X)", tempreal))
55 tempCorner.SetX(tempreal);
57 else tempCorner.SetX(0.0);
59 if (PR.DefinedElseSkip())
61 //st = PR.ReadReal(PR.Current(), "Corner Point (Y)", tempreal); //szv#4:S4163:12Mar99 moved in if
62 if (PR.ReadReal(PR.Current(), "Corner Point (Y)", tempreal))
63 tempCorner.SetY(tempreal);
65 else tempCorner.SetY(0.0);
67 if (PR.DefinedElseSkip())
69 //st = PR.ReadReal(PR.Current(), "Corner Point (Z)", tempreal); //szv#4:S4163:12Mar99 moved in if
70 if (PR.ReadReal(PR.Current(), "Corner Point (Z)", tempreal))
71 tempCorner.SetZ(tempreal);
73 else tempCorner.SetZ(0.0);
75 if (PR.DefinedElseSkip())
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);
81 else tempXAxis.SetX(1.0);
83 if (PR.DefinedElseSkip())
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);
89 else tempXAxis.SetY(0.0);
91 if (PR.DefinedElseSkip())
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);
97 else tempXAxis.SetZ(0.0);
99 if (PR.DefinedElseSkip())
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);
105 else tempZAxis.SetX(0.0);
107 if (PR.DefinedElseSkip())
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);
113 else tempZAxis.SetY(0.0);
115 if (PR.DefinedElseSkip())
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);
121 else tempZAxis.SetZ(1.0);
123 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
124 ent->Init(tempSize, tempCorner, 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");
132 void IGESSolid_ToolBlock::WriteOwnParams
133 (const Handle(IGESSolid_Block)& ent, IGESData_IGESWriter& IW) const
135 IW.Send(ent->Size().X());
136 IW.Send(ent->Size().Y());
137 IW.Send(ent->Size().Z());
138 IW.Send(ent->Corner().X());
139 IW.Send(ent->Corner().Y());
140 IW.Send(ent->Corner().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());
149 void IGESSolid_ToolBlock::OwnShared
150 (const Handle(IGESSolid_Block)& /* ent */, Interface_EntityIterator& /* iter */) const
154 void IGESSolid_ToolBlock::OwnCopy
155 (const Handle(IGESSolid_Block)& another,
156 const Handle(IGESSolid_Block)& ent, Interface_CopyTool& /* TC */) const
158 ent->Init(another->Size(), another->Corner().XYZ(),
159 another->XAxis().XYZ(), another->ZAxis().XYZ());
162 IGESData_DirChecker IGESSolid_ToolBlock::DirChecker
163 (const Handle(IGESSolid_Block)& /* ent */ ) const
165 IGESData_DirChecker DC(150, 0);
166 DC.Structure (IGESData_DefVoid);
167 DC.LineFont (IGESData_DefAny);
168 DC.Color (IGESData_DefAny);
170 DC.UseFlagRequired (0);
174 void IGESSolid_ToolBlock::OwnCheck
175 (const Handle(IGESSolid_Block)& ent,
176 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
178 Standard_Real eps = 1.E-04;
179 Standard_Real prosca = ent->XAxis() * ent->ZAxis();
180 if (prosca < -eps || prosca > eps)
181 ach->AddFail("Local Z axis : Not orthogonal to X axis");
182 if (ent->Size().X() <= 0. || ent->Size().Y() <= 0. || ent->Size().Z() <= 0.)
183 ach->AddFail("Size : Not positive lengths");
186 void IGESSolid_ToolBlock::OwnDump
187 (const Handle(IGESSolid_Block)& ent, const IGESData_IGESDumper& /* dumper */,
188 const Handle(Message_Messenger)& S, const Standard_Integer level) const
190 S << "IGESSolid_Block" << endl;
193 IGESData_DumpXYZ(S, ent->Size());
194 S << endl << "Corner : ";
195 IGESData_DumpXYZL(S,level, ent->Corner(), ent->Location());
196 S << endl << "XAxis : ";
197 IGESData_DumpXYZL(S,level, ent->XAxis(), ent->VectorLocation());
198 S << endl << "ZAxis : ";
199 IGESData_DumpXYZL(S,level, ent->ZAxis(), ent->VectorLocation());