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 //--------------------------------------------------------------------
21 #include <IGESData_DirChecker.hxx>
22 #include <IGESData_Dump.hxx>
23 #include <IGESData_IGESDumper.hxx>
24 #include <IGESData_IGESEntity.hxx>
25 #include <IGESData_IGESReaderData.hxx>
26 #include <IGESData_IGESWriter.hxx>
27 #include <IGESData_ParamCursor.hxx>
28 #include <IGESData_ParamReader.hxx>
29 #include <IGESData_Status.hxx>
30 #include <IGESGeom_Plane.hxx>
31 #include <IGESGeom_ToolPlane.hxx>
32 #include <Interface_Check.hxx>
33 #include <Interface_CopyTool.hxx>
34 #include <Interface_EntityIterator.hxx>
35 #include <Interface_Macros.hxx>
36 #include <Interface_MSG.hxx>
37 #include <Interface_ShareTool.hxx>
38 #include <Message_Messenger.hxx>
39 #include <Message_Msg.hxx>
40 #include <Standard_DomainError.hxx>
44 //=======================================================================
45 //function : IGESGeom_ToolPlane
47 //=======================================================================
48 IGESGeom_ToolPlane::IGESGeom_ToolPlane ()
53 //=======================================================================
54 //function : ReadOwnParams
56 //=======================================================================
58 void IGESGeom_ToolPlane::ReadOwnParams(const Handle(IGESGeom_Plane)& ent,
59 const Handle(IGESData_IGESReaderData)& IR,
60 IGESData_ParamReader& PR) const
64 Standard_Real A, B = 0., C = 0., D = 0., aSize = 0.;
65 Handle(IGESData_IGESEntity) aCurve;
66 gp_XYZ attach (0.,0.,0.);
67 IGESData_Status aStatus;
68 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
70 /* PR.ReadReal(PR.Current(), Msg135, A); //szv#4:S4163:12Mar99 `st=` not needed
71 PR.ReadReal(PR.Current(), Msg135, B); //szv#4:S4163:12Mar99 `st=` not needed
72 PR.ReadReal(PR.Current(), Msg135, C); //szv#4:S4163:12Mar99 `st=` not needed
73 PR.ReadReal(PR.Current(), Msg135, D); //szv#4:S4163:12Mar99 `st=` not needed
75 if ((!PR.ReadReal(PR.Current(),A)) || (!PR.ReadReal(PR.Current(),B)) ||
76 (!PR.ReadReal(PR.Current(),C)) || (!PR.ReadReal(PR.Current(),D))){
77 Message_Msg Msg135("XSTEP_135");
81 st = PR.ReadReal(PR.Current(), "Coefficient Of Plane", A);
82 st = PR.ReadReal(PR.Current(), "Coefficient Of Plane", B);
83 st = PR.ReadReal(PR.Current(), "Coefficient Of Plane", C);
84 st = PR.ReadReal(PR.Current(), "Coefficient Of Plane", D);
86 if (PR.IsParamDefined(PR.CurrentNumber())) {
87 if (!PR.ReadEntity(IR, PR.Current(), aStatus, aCurve,Standard_True)){
88 Message_Msg Msg136("XSTEP_136");
90 case IGESData_ReferenceError: {
91 Message_Msg Msg216 ("IGES_216");
92 Msg136.Arg(Msg216.Value());
95 case IGESData_EntityError: {
96 Message_Msg Msg217 ("IGES_217");
97 Msg136.Arg(Msg217.Value());
104 } //szv#4:S4163:12Mar99 `st=` not needed
105 //st = PR.ReadEntity(IR, PR.Current(), "Bounding Curve", aCurve,Standard_True);
106 // en principe exige si FormNumber != 0 ... cf OwnCheck (Load accepte)
108 if (PR.IsParamDefined(PR.CurrentNumber())) {
109 Message_Msg Msg139("XSTEP_139");
111 PR.ReadXYZ(PR.CurrentList(1, 3), Msg139, attach); //szv#4:S4163:12Mar99 `st=` not needed
112 //st = PR.ReadXYZ(PR.CurrentList(1, 3), "Coord of DisplaySymbol", attach);
114 if (!PR.ReadReal(PR.Current(), aSize)){
115 Message_Msg Msg138("XSTEP_138");
117 } //szv#4:S4163:12Mar99 `st=` not needed
118 //st = PR.ReadReal(PR.Current(), "DisplaySymbol Size", aSize);
120 /* for (int i = 1; i <= 4; i ++) st = PR.DefinedElseSkip();
121 PR.AddWarning("Display Symbol not defined at all");
125 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
126 ent->Init(A, B, C, D, aCurve, attach, aSize);
130 //=======================================================================
131 //function : WriteOwnParams
133 //=======================================================================
135 void IGESGeom_ToolPlane::WriteOwnParams(const Handle(IGESGeom_Plane)& ent,
136 IGESData_IGESWriter& IW) const
138 Standard_Real A,B,C,D;
139 ent->Equation(A,B,C,D);
145 IW.Send(ent->BoundingCurve());
147 IW.Send(ent->SymbolAttach().X());
148 IW.Send(ent->SymbolAttach().Y());
149 IW.Send(ent->SymbolAttach().Z());
150 IW.Send(ent->SymbolSize());
154 //=======================================================================
155 //function : OwnShared
157 //=======================================================================
159 void IGESGeom_ToolPlane::OwnShared(const Handle(IGESGeom_Plane)& ent,
160 Interface_EntityIterator& iter) const
162 iter.GetOneItem(ent->BoundingCurve());
166 //=======================================================================
169 //=======================================================================
171 void IGESGeom_ToolPlane::OwnCopy(const Handle(IGESGeom_Plane)& another,
172 const Handle(IGESGeom_Plane)& ent,
173 Interface_CopyTool& TC) const
175 Standard_Real A, B, C, D;
176 another->Equation(A, B, C, D);
177 gp_XYZ attach = (another->SymbolAttach()).XYZ();
178 Standard_Real aSize = another->SymbolSize();
179 DeclareAndCast(IGESData_IGESEntity,aCurve,
180 TC.Transferred(another->BoundingCurve()));
181 ent->Init(A, B, C, D, aCurve, attach, aSize);
182 ent->SetFormNumber(another->FormNumber());
186 //=======================================================================
187 //function : DirChecker
189 //=======================================================================
191 IGESData_DirChecker IGESGeom_ToolPlane::DirChecker
192 (const Handle(IGESGeom_Plane)& ent ) const
194 IGESData_DirChecker DC(108,-1,1);
195 DC.Structure(IGESData_DefVoid);
196 if (ent->FormNumber() != 0)
198 DC.LineFont(IGESData_DefAny);
199 // DC.LineWeight(IGESData_DefValue);
203 DC.LineFont(IGESData_DefVoid);
204 DC.LineWeight(IGESData_DefVoid);
205 DC.HierarchyStatusIgnored();
207 DC.Color(IGESData_DefAny);
212 //=======================================================================
213 //function : OwnCheck
215 //=======================================================================
217 void IGESGeom_ToolPlane::OwnCheck(const Handle(IGESGeom_Plane)& ent,
218 const Interface_ShareTool&,
219 Handle(Interface_Check)& ach) const
222 // Building of messages
223 //========================================
224 //Message_Msg Msg71("XSTEP_71");
225 //Message_Msg Msg137("XSTEP_137");
226 //========================================
228 //szv#4:S4163:12Mar99 not needed
229 //Standard_Real eps = 1.E-06; // ?? Precision
230 //Standard_Real A,B,C,D;
231 //ent->Equation(A,B,C,D);
232 if (ent->FormNumber() < -1 || ent->FormNumber() > 1) {
233 Message_Msg Msg71("XSTEP_71");
234 ach->SendFail(Msg71);
236 //szv#4:S4163:12Mar99 `!=` wrong operation on Standard_Boolean
237 Standard_Boolean unbounded1 = ent->BoundingCurve().IsNull();
238 Standard_Boolean unbounded2 = (ent->FormNumber() == 0);
239 if ( (unbounded1 && !unbounded2) || (!unbounded1 && unbounded2) ) {
240 Message_Msg Msg137("XSTEP_137");
241 ach->SendFail(Msg137);
243 // These messages are transfered in the translation procedure
244 // if ( (A*A + B*B + C*C) < eps) // pas nul !
245 // ach.SendFail("Incorrect Coefficients for the Plane");
246 if ( !ent->HasBoundingCurve()) return;
247 // Symbol : verifie si Size defini > 0 (sinon, n a pas de signification)
248 /* Standard_Real ec = 0.;
249 if (ent->SymbolSize() > 0.) ec = A*ent->SymbolAttach().X() + B*ent->SymbolAttach().Y() +
250 C * ent->SymbolAttach().Z() - D;
251 if ( ec > eps || ec < -eps) {
253 Sprintf(mess,"Symbol Attach not in the Plane, gap/equation over %f",
254 Interface_MSG::Intervalled(ec));
255 ach.SendWarning(mess,"Symbol Attach not in the Plane");
262 //=======================================================================
265 //=======================================================================
267 void IGESGeom_ToolPlane::OwnDump(const Handle(IGESGeom_Plane)& ent,
268 const IGESData_IGESDumper& dumper,
269 const Handle(Message_Messenger)& S,
270 const Standard_Integer level) const
272 S << "IGESGeom_Plane" << endl;
273 Standard_Real A,B,C,D;
274 ent->Equation(A,B,C,D);
276 S << "Plane Coefficient A : " << A << endl;
277 S << "Plane Coefficient B : " << B << endl;
278 S << "Plane Coefficient C : " << C << endl;
279 S << "Plane Coefficient D : " << D << endl;
280 S << "The Bounding Curve : " ;
281 dumper.Dump(ent->BoundingCurve(),S, (level <= 4) ? 0 : 1);
283 S << "Display Symbol Location : ";
284 IGESData_DumpXYZL(S,level, ent->SymbolAttach(), ent->Location());
285 S << " Size : " << ent->SymbolSize() << endl;