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 //--------------------------------------------------------------------
19 #include <IGESData_DirChecker.hxx>
20 #include <IGESData_IGESDumper.hxx>
21 #include <IGESData_IGESReaderData.hxx>
22 #include <IGESData_IGESWriter.hxx>
23 #include <IGESData_ParamCursor.hxx>
24 #include <IGESData_ParamReader.hxx>
25 #include <IGESData_Status.hxx>
26 #include <IGESGeom_Direction.hxx>
27 #include <IGESGeom_Point.hxx>
28 #include <IGESSolid_PlaneSurface.hxx>
29 #include <IGESSolid_ToolPlaneSurface.hxx>
30 #include <Interface_Check.hxx>
31 #include <Interface_CopyTool.hxx>
32 #include <Interface_EntityIterator.hxx>
33 #include <Interface_Macros.hxx>
34 #include <Interface_ShareTool.hxx>
35 #include <Message_Messenger.hxx>
36 #include <Message_Msg.hxx>
37 #include <Standard_DomainError.hxx>
40 //=======================================================================
41 //function : IGESSolid_ToolPlaneSurface
43 //=======================================================================
44 IGESSolid_ToolPlaneSurface::IGESSolid_ToolPlaneSurface ()
49 //=======================================================================
50 //function : ReadOwnParams
52 //=======================================================================
54 void IGESSolid_ToolPlaneSurface::ReadOwnParams(const Handle(IGESSolid_PlaneSurface)& ent,
55 const Handle(IGESData_IGESReaderData)& IR,
56 IGESData_ParamReader& PR) const
58 Handle(IGESGeom_Point) tempLocation;
59 Handle(IGESGeom_Direction) tempNormal;
60 Handle(IGESGeom_Direction) tempRefdir; // default Unparametrised
61 IGESData_Status aStatus;
62 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
64 if (!PR.ReadEntity(IR, PR.Current(),aStatus,STANDARD_TYPE(IGESGeom_Point), tempLocation)){ //szv#4:S4163:12Mar99 `st=` not needed
65 Message_Msg Msg174("XSTEP_174");
67 case IGESData_ReferenceError: {
68 Message_Msg Msg216 ("IGES_216");
69 Msg174.Arg(Msg216.Value());
72 case IGESData_EntityError: {
73 Message_Msg Msg217 ("IGES_217");
74 Msg174.Arg(Msg217.Value());
77 case IGESData_TypeError: {
78 Message_Msg Msg218 ("IGES_218");
79 Msg174.Arg(Msg218.Value());
87 st = PR.ReadEntity(IR, PR.Current(), "Point on axis",
88 STANDARD_TYPE(IGESGeom_Point), tempLocation);
90 if (!PR.ReadEntity(IR, PR.Current(),aStatus,STANDARD_TYPE(IGESGeom_Direction), tempNormal)){ //szv#4:S4163:12Mar99 `st=` not needed
91 Message_Msg Msg175("XSTEP_175");
93 case IGESData_ReferenceError: {
94 Message_Msg Msg216 ("IGES_216");
95 Msg175.Arg(Msg216.Value());
98 case IGESData_EntityError: {
99 Message_Msg Msg217 ("IGES_217");
100 Msg175.Arg(Msg217.Value());
103 case IGESData_TypeError: {
104 Message_Msg Msg218 ("IGES_218");
105 Msg175.Arg(Msg218.Value());
113 st = PR.ReadEntity(IR, PR.Current(), "Normal direction",
114 STANDARD_TYPE(IGESGeom_Direction), tempNormal);
116 if (ent->FormNumber() == 1){
117 // Parametrised surface
118 if (!PR.ReadEntity(IR, PR.Current(), aStatus, STANDARD_TYPE(IGESGeom_Direction), tempRefdir)){ //szv#4:S4163:12Mar99 `st=` not needed
119 Message_Msg Msg176("XSTEP_176");
121 case IGESData_ReferenceError: {
122 Message_Msg Msg216 ("IGES_216");
123 Msg176.Arg(Msg216.Value());
126 case IGESData_EntityError: {
127 Message_Msg Msg217 ("IGES_217");
128 Msg176.Arg(Msg217.Value());
131 case IGESData_TypeError: {
132 Message_Msg Msg218 ("IGES_218");
133 Msg176.Arg(Msg218.Value());
142 st = PR.ReadEntity(IR, PR.Current(), "Reference direction",
143 STANDARD_TYPE(IGESGeom_Direction), tempRefdir);
145 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
146 ent->Init (tempLocation, tempNormal, tempRefdir);
150 //=======================================================================
151 //function : WriteOwnParams
153 //=======================================================================
155 void IGESSolid_ToolPlaneSurface::WriteOwnParams
156 (const Handle(IGESSolid_PlaneSurface)& ent, IGESData_IGESWriter& IW) const
158 IW.Send(ent->LocationPoint());
159 IW.Send(ent->Normal());
160 if (ent->IsParametrised()) IW.Send(ent->ReferenceDir());
164 //=======================================================================
165 //function : OwnShared
167 //=======================================================================
169 void IGESSolid_ToolPlaneSurface::OwnShared(const Handle(IGESSolid_PlaneSurface)& ent,
170 Interface_EntityIterator& iter) const
172 iter.GetOneItem(ent->LocationPoint());
173 iter.GetOneItem(ent->Normal());
174 iter.GetOneItem(ent->ReferenceDir());
178 //=======================================================================
181 //=======================================================================
183 void IGESSolid_ToolPlaneSurface::OwnCopy
184 (const Handle(IGESSolid_PlaneSurface)& another,
185 const Handle(IGESSolid_PlaneSurface)& ent, Interface_CopyTool& TC) const
187 DeclareAndCast(IGESGeom_Point, tempLocation,
188 TC.Transferred(another->LocationPoint()));
189 DeclareAndCast(IGESGeom_Direction, tempNormal,
190 TC.Transferred(another->Normal()));
191 if (another->IsParametrised())
193 DeclareAndCast(IGESGeom_Direction, tempRefdir,
194 TC.Transferred(another->ReferenceDir()));
195 ent->Init (tempLocation, tempNormal, tempRefdir);
199 Handle(IGESGeom_Direction) tempRefdir;
200 ent->Init (tempLocation, tempNormal, tempRefdir);
205 //=======================================================================
206 //function : DirChecker
208 //=======================================================================
210 IGESData_DirChecker IGESSolid_ToolPlaneSurface::DirChecker
211 (const Handle(IGESSolid_PlaneSurface)& /*ent*/) const
213 IGESData_DirChecker DC(190, 0, 1);
215 DC.Structure (IGESData_DefVoid);
216 DC.LineFont (IGESData_DefAny);
217 DC.Color (IGESData_DefAny);
219 DC.BlankStatusIgnored ();
220 DC.HierarchyStatusIgnored ();
225 //=======================================================================
226 //function : OwnCheck
228 //=======================================================================
230 void IGESSolid_ToolPlaneSurface::OwnCheck(const Handle(IGESSolid_PlaneSurface)& ent,
231 const Interface_ShareTool&,
232 Handle(Interface_Check)& ach) const
236 // Building of messages
237 //========================================
238 //Message_Msg Msg177("XSTEP_177");
239 //========================================
241 Standard_Integer fn = 0;
242 if (ent->IsParametrised()) fn = 1;
243 if (fn != ent->FormNumber()) {
244 Message_Msg Msg177("XSTEP_177");
245 ach->SendFail (Msg177);
250 //=======================================================================
253 //=======================================================================
255 void IGESSolid_ToolPlaneSurface::OwnDump(const Handle(IGESSolid_PlaneSurface)& ent,
256 const IGESData_IGESDumper& dumper,
258 const Standard_Integer level) const
260 S << "IGESSolid_PlaneSurface\n";
262 Standard_Integer sublevel = (level <= 4) ? 0 : 1;
263 S << "Point on axis : ";
264 dumper.Dump(ent->LocationPoint(),S, sublevel);
266 << "Normal direction : ";
267 dumper.Dump(ent->Normal(),S, sublevel);
269 if (ent->IsParametrised())
271 S << "Surface is Parametrised - Reference direction : ";
272 dumper.Dump(ent->ReferenceDir(),S, sublevel);
275 else S << "Surface is UnParametrised" << std::endl;