0031682: Visualization - Prs3d_ShadingAspect::SetTransparency() has no effect with...
[occt.git] / src / IGESGeom / IGESGeom_ToolSurfaceOfRevolution.cxx
1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
18
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_Msg.hxx>
36 #include <Standard_DomainError.hxx>
37
38 // MGE 31/07/98
39 IGESGeom_ToolSurfaceOfRevolution::IGESGeom_ToolSurfaceOfRevolution ()    {  }
40
41
42 void IGESGeom_ToolSurfaceOfRevolution::ReadOwnParams
43   (const Handle(IGESGeom_SurfaceOfRevolution)& ent,
44    const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
45 {
46   // MGE 31/07/98
47
48   Handle(IGESGeom_Line) anAxis;
49   Handle(IGESData_IGESEntity) aGeneratrix;
50   Standard_Real aStartAngle, anEndAngle;
51   IGESData_Status aStatus;
52   //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
53
54   if (!PR.ReadEntity(IR, PR.Current(), aStatus, STANDARD_TYPE(IGESGeom_Line), anAxis)){ //szv#4:S4163:12Mar99 `st=` not needed
55     Message_Msg Msg152("XSTEP_152");
56     switch(aStatus) {
57     case IGESData_ReferenceError: {  
58       Message_Msg Msg216 ("IGES_216");
59       Msg152.Arg(Msg216.Value());
60       PR.SendFail(Msg152);
61       break; }
62     case IGESData_EntityError: {
63       Message_Msg Msg217 ("IGES_217");
64       Msg152.Arg(Msg217.Value());
65       PR.SendFail(Msg152);
66       break; }
67     case IGESData_TypeError: {
68       Message_Msg Msg218 ("IGES_218");
69       Msg152.Arg(Msg218.Value());
70       PR.SendFail(Msg152);
71       break; }
72     default:{
73     }
74     }
75   }
76   if (!PR.ReadEntity(IR, PR.Current(), aStatus, aGeneratrix)){ //szv#4:S4163:12Mar99 `st=` not needed
77     Message_Msg Msg153("XSTEP_153");
78     switch(aStatus) {
79     case IGESData_ReferenceError: {  
80       Message_Msg Msg216 ("IGES_216");
81       Msg153.Arg(Msg216.Value());
82       PR.SendFail(Msg153);
83       break; }
84     case IGESData_EntityError: {
85       Message_Msg Msg217 ("IGES_217");
86       Msg153.Arg(Msg217.Value());
87       PR.SendFail(Msg153);
88       break; }
89     default:{
90     }
91     }
92   }
93   if (!PR.ReadReal(PR.Current(),  aStartAngle)){ //szv#4:S4163:12Mar99 `st=` not needed
94     Message_Msg Msg154("XSTEP_154");
95     PR.SendFail(Msg154);
96   }
97   if (!PR.ReadReal(PR.Current(), anEndAngle)){ //szv#4:S4163:12Mar99 `st=` not needed
98     Message_Msg Msg155("XSTEP_155");
99     PR.SendFail(Msg155);
100   }
101 /*
102   st = PR.ReadEntity(IR, PR.Current(), "Axis", STANDARD_TYPE(IGESGeom_Line), anAxis);
103   st = PR.ReadEntity(IR, PR.Current(), "Generatrix", aGeneratrix);
104   st = PR.ReadReal(PR.Current(), "StartAngle", aStartAngle);
105   st = PR.ReadReal(PR.Current(), "EndAngle", anEndAngle);
106 */
107   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
108   ent->Init(anAxis, aGeneratrix, aStartAngle, anEndAngle);
109 }
110
111 void IGESGeom_ToolSurfaceOfRevolution::WriteOwnParams
112   (const Handle(IGESGeom_SurfaceOfRevolution)& ent, IGESData_IGESWriter& IW)  const
113 {
114   IW.Send(ent->AxisOfRevolution());
115   IW.Send(ent->Generatrix());
116   IW.Send(ent->StartAngle());
117   IW.Send(ent->EndAngle());
118 }
119
120 void  IGESGeom_ToolSurfaceOfRevolution::OwnShared
121   (const Handle(IGESGeom_SurfaceOfRevolution)& ent, Interface_EntityIterator& iter) const
122 {
123   iter.GetOneItem(ent->AxisOfRevolution());
124   iter.GetOneItem(ent->Generatrix());
125 }
126
127 void IGESGeom_ToolSurfaceOfRevolution::OwnCopy
128   (const Handle(IGESGeom_SurfaceOfRevolution)& another,
129    const Handle(IGESGeom_SurfaceOfRevolution)& ent, Interface_CopyTool& TC) const
130 {
131   DeclareAndCast(IGESGeom_Line, anAxis,
132                  TC.Transferred(another->AxisOfRevolution()));
133   DeclareAndCast(IGESData_IGESEntity, aGeneratrix,
134                  TC.Transferred(another->Generatrix()));
135   Standard_Real aStartAngle = another->StartAngle();
136   Standard_Real anEndAngle = another->EndAngle();
137
138   ent->Init(anAxis, aGeneratrix, aStartAngle, anEndAngle);
139 }
140
141
142 IGESData_DirChecker IGESGeom_ToolSurfaceOfRevolution::DirChecker
143   (const Handle(IGESGeom_SurfaceOfRevolution)& /*ent*/ )   const
144 {
145   IGESData_DirChecker DC(120, 0);
146   DC.Structure(IGESData_DefVoid);
147   DC.LineFont(IGESData_DefAny);
148 //  DC.LineWeight(IGESData_DefValue);
149   DC.Color(IGESData_DefAny);
150
151   DC.HierarchyStatusIgnored ();
152   return DC;
153 }
154
155 void IGESGeom_ToolSurfaceOfRevolution::OwnCheck
156   (const Handle(IGESGeom_SurfaceOfRevolution)& /*ent*/,
157    const Interface_ShareTool& , Handle(Interface_Check)& /*ach*/)  const
158 {
159 //  Standard_Real diffang = ent->EndAngle() - ent->StartAngle();
160 //  if (diffang <= 0.0 || diffang > 2.0 * M_PI)
161 //    ach.AddFail("0 < TA - SA <=  2Pi is not satisfied");
162 }
163
164 void IGESGeom_ToolSurfaceOfRevolution::OwnDump
165   (const Handle(IGESGeom_SurfaceOfRevolution)& ent, const IGESData_IGESDumper& dumper,
166    Standard_OStream& S, const Standard_Integer level)  const
167 {
168   S << "IGESGeom_SurfaceOfRevolution\n\n";
169   Standard_Integer sublevel = (level <= 4) ? 0 : 1;
170
171   S << "Axis Of Revolution : ";
172   dumper.Dump(ent->AxisOfRevolution(),S, sublevel);
173   S << "\n"
174     << "Generatrix         : ";
175   dumper.Dump(ent->Generatrix(),S, sublevel);
176   S << "\n"
177     << "Start Angle        : " << ent->StartAngle() << "  "
178     << "End Angle   : " << ent->EndAngle() << std::endl;
179 }