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_IGESEntity.hxx>
22 #include <IGESData_IGESReaderData.hxx>
23 #include <IGESData_IGESWriter.hxx>
24 #include <IGESData_ParamCursor.hxx>
25 #include <IGESData_ParamReader.hxx>
26 #include <IGESData_Status.hxx>
27 #include <IGESGeom_Line.hxx>
28 #include <IGESGeom_SurfaceOfRevolution.hxx>
29 #include <IGESGeom_ToolSurfaceOfRevolution.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 IGESGeom_ToolSurfaceOfRevolution::IGESGeom_ToolSurfaceOfRevolution () { }
43 void IGESGeom_ToolSurfaceOfRevolution::ReadOwnParams
44 (const Handle(IGESGeom_SurfaceOfRevolution)& ent,
45 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
49 Handle(IGESGeom_Line) anAxis;
50 Handle(IGESData_IGESEntity) aGeneratrix;
51 Standard_Real aStartAngle, anEndAngle;
52 IGESData_Status aStatus;
53 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
55 if (!PR.ReadEntity(IR, PR.Current(), aStatus, STANDARD_TYPE(IGESGeom_Line), anAxis)){ //szv#4:S4163:12Mar99 `st=` not needed
56 Message_Msg Msg152("XSTEP_152");
58 case IGESData_ReferenceError: {
59 Message_Msg Msg216 ("IGES_216");
60 Msg152.Arg(Msg216.Value());
63 case IGESData_EntityError: {
64 Message_Msg Msg217 ("IGES_217");
65 Msg152.Arg(Msg217.Value());
68 case IGESData_TypeError: {
69 Message_Msg Msg218 ("IGES_218");
70 Msg152.Arg(Msg218.Value());
77 if (!PR.ReadEntity(IR, PR.Current(), aStatus, aGeneratrix)){ //szv#4:S4163:12Mar99 `st=` not needed
78 Message_Msg Msg153("XSTEP_153");
80 case IGESData_ReferenceError: {
81 Message_Msg Msg216 ("IGES_216");
82 Msg153.Arg(Msg216.Value());
85 case IGESData_EntityError: {
86 Message_Msg Msg217 ("IGES_217");
87 Msg153.Arg(Msg217.Value());
94 if (!PR.ReadReal(PR.Current(), aStartAngle)){ //szv#4:S4163:12Mar99 `st=` not needed
95 Message_Msg Msg154("XSTEP_154");
98 if (!PR.ReadReal(PR.Current(), anEndAngle)){ //szv#4:S4163:12Mar99 `st=` not needed
99 Message_Msg Msg155("XSTEP_155");
103 st = PR.ReadEntity(IR, PR.Current(), "Axis", STANDARD_TYPE(IGESGeom_Line), anAxis);
104 st = PR.ReadEntity(IR, PR.Current(), "Generatrix", aGeneratrix);
105 st = PR.ReadReal(PR.Current(), "StartAngle", aStartAngle);
106 st = PR.ReadReal(PR.Current(), "EndAngle", anEndAngle);
108 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
109 ent->Init(anAxis, aGeneratrix, aStartAngle, anEndAngle);
112 void IGESGeom_ToolSurfaceOfRevolution::WriteOwnParams
113 (const Handle(IGESGeom_SurfaceOfRevolution)& ent, IGESData_IGESWriter& IW) const
115 IW.Send(ent->AxisOfRevolution());
116 IW.Send(ent->Generatrix());
117 IW.Send(ent->StartAngle());
118 IW.Send(ent->EndAngle());
121 void IGESGeom_ToolSurfaceOfRevolution::OwnShared
122 (const Handle(IGESGeom_SurfaceOfRevolution)& ent, Interface_EntityIterator& iter) const
124 iter.GetOneItem(ent->AxisOfRevolution());
125 iter.GetOneItem(ent->Generatrix());
128 void IGESGeom_ToolSurfaceOfRevolution::OwnCopy
129 (const Handle(IGESGeom_SurfaceOfRevolution)& another,
130 const Handle(IGESGeom_SurfaceOfRevolution)& ent, Interface_CopyTool& TC) const
132 DeclareAndCast(IGESGeom_Line, anAxis,
133 TC.Transferred(another->AxisOfRevolution()));
134 DeclareAndCast(IGESData_IGESEntity, aGeneratrix,
135 TC.Transferred(another->Generatrix()));
136 Standard_Real aStartAngle = another->StartAngle();
137 Standard_Real anEndAngle = another->EndAngle();
139 ent->Init(anAxis, aGeneratrix, aStartAngle, anEndAngle);
143 IGESData_DirChecker IGESGeom_ToolSurfaceOfRevolution::DirChecker
144 (const Handle(IGESGeom_SurfaceOfRevolution)& /*ent*/ ) const
146 IGESData_DirChecker DC(120, 0);
147 DC.Structure(IGESData_DefVoid);
148 DC.LineFont(IGESData_DefAny);
149 // DC.LineWeight(IGESData_DefValue);
150 DC.Color(IGESData_DefAny);
152 DC.HierarchyStatusIgnored ();
156 void IGESGeom_ToolSurfaceOfRevolution::OwnCheck
157 (const Handle(IGESGeom_SurfaceOfRevolution)& /*ent*/,
158 const Interface_ShareTool& , Handle(Interface_Check)& /*ach*/) const
160 // Standard_Real diffang = ent->EndAngle() - ent->StartAngle();
161 // if (diffang <= 0.0 || diffang > 2.0 * M_PI)
162 // ach.AddFail("0 < TA - SA <= 2Pi is not satisfied");
165 void IGESGeom_ToolSurfaceOfRevolution::OwnDump
166 (const Handle(IGESGeom_SurfaceOfRevolution)& ent, const IGESData_IGESDumper& dumper,
167 const Handle(Message_Messenger)& S, const Standard_Integer level) const
170 S << "IGESGeom_SurfaceOfRevolution" << endl << endl;
171 Standard_Integer sublevel = (level <= 4) ? 0 : 1;
173 S << "Axis Of Revolution : ";
174 dumper.Dump(ent->AxisOfRevolution(),S, sublevel);
176 S << "Generatrix : ";
177 dumper.Dump(ent->Generatrix(),S, sublevel);
179 S << "Start Angle : " << ent->StartAngle() << " ";
180 S << "End Angle : " << ent->EndAngle() << endl;