0029915: Porting to VC 2017 : Regressions in Modeling Algorithms on VC 2017
[occt.git] / src / IGESSolid / IGESSolid_ToolBlock.cxx
CommitLineData
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_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>
7fd59977 37
38IGESSolid_ToolBlock::IGESSolid_ToolBlock () { }
39
40
41void IGESSolid_ToolBlock::ReadOwnParams
42 (const Handle(IGESSolid_Block)& ent,
43 const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const
44{
45 gp_XYZ tempSize, tempCorner, tempXAxis, tempZAxis;
46 Standard_Real tempreal;
47 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
48
49 PR.ReadXYZ(PR.CurrentList(1, 3), "Size of Block", tempSize); //szv#4:S4163:12Mar99 `st=` not needed
50
51 if (PR.DefinedElseSkip())
52 {
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);
56 }
57 else tempCorner.SetX(0.0);
58
59 if (PR.DefinedElseSkip())
60 {
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);
64 }
65 else tempCorner.SetY(0.0);
66
67 if (PR.DefinedElseSkip())
68 {
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);
72 }
73 else tempCorner.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, 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");
130}
131
132void IGESSolid_ToolBlock::WriteOwnParams
133 (const Handle(IGESSolid_Block)& 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->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());
147}
148
149void IGESSolid_ToolBlock::OwnShared
150 (const Handle(IGESSolid_Block)& /* ent */, Interface_EntityIterator& /* iter */) const
151{
152}
153
154void IGESSolid_ToolBlock::OwnCopy
155 (const Handle(IGESSolid_Block)& another,
156 const Handle(IGESSolid_Block)& ent, Interface_CopyTool& /* TC */) const
157{
158 ent->Init(another->Size(), another->Corner().XYZ(),
159 another->XAxis().XYZ(), another->ZAxis().XYZ());
160}
161
162IGESData_DirChecker IGESSolid_ToolBlock::DirChecker
163 (const Handle(IGESSolid_Block)& /* ent */ ) const
164{
165 IGESData_DirChecker DC(150, 0);
166 DC.Structure (IGESData_DefVoid);
167 DC.LineFont (IGESData_DefAny);
168 DC.Color (IGESData_DefAny);
169
170 DC.UseFlagRequired (0);
171 return DC;
172}
173
174void IGESSolid_ToolBlock::OwnCheck
175 (const Handle(IGESSolid_Block)& ent,
176 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
177{
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");
184}
185
186void IGESSolid_ToolBlock::OwnDump
187 (const Handle(IGESSolid_Block)& ent, const IGESData_IGESDumper& /* dumper */,
188 const Handle(Message_Messenger)& S, const Standard_Integer level) const
189{
190 S << "IGESSolid_Block" << endl;
191
192 S << "Size : ";
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());
200 S << endl;
201}