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_RuledSurface.hxx>
28 #include <IGESGeom_ToolRuledSurface.hxx>
29 #include <Interface_Check.hxx>
30 #include <Interface_CopyTool.hxx>
31 #include <Interface_EntityIterator.hxx>
32 #include <Interface_Macros.hxx>
33 #include <Interface_ShareTool.hxx>
34 #include <Message_Messenger.hxx>
35 #include <Message_Msg.hxx>
36 #include <Standard_DomainError.hxx>
37 
38 // MGE 31/07/98
IGESGeom_ToolRuledSurface()39 IGESGeom_ToolRuledSurface::IGESGeom_ToolRuledSurface ()    {  }
40 
41 
ReadOwnParams(const Handle (IGESGeom_RuledSurface)& ent,const Handle (IGESData_IGESReaderData)& IR,IGESData_ParamReader & PR) const42 void IGESGeom_ToolRuledSurface::ReadOwnParams
43   (const Handle(IGESGeom_RuledSurface)& ent,
44    const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
45 {
46   // MGE 31/07/98
47 
48   //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
49   Standard_Integer aDirFlag, aDevFlag;
50   Handle(IGESData_IGESEntity) aCurve, anotherCurve;
51   IGESData_Status aStatus;
52 
53   if (!PR.ReadEntity(IR, PR.Current(), aStatus, aCurve)){ //szv#4:S4163:12Mar99 `st=` not needed
54     Message_Msg Msg148("XSTEP_148");
55     switch(aStatus) {
56     case IGESData_ReferenceError: {
57       Message_Msg Msg216 ("IGES_216");
58       Msg148.Arg(Msg216.Value());
59       PR.SendFail(Msg148);
60       break; }
61     case IGESData_EntityError: {
62       Message_Msg Msg217 ("IGES_217");
63       Msg148.Arg(Msg217.Value());
64       PR.SendFail(Msg148);
65       break; }
66     default:{
67     }
68     }
69   }
70   if (!PR.ReadEntity(IR, PR.Current(), aStatus, anotherCurve)){ //szv#4:S4163:12Mar99 `st=` not needed
71     Message_Msg Msg149("XSTEP_149");
72     switch(aStatus) {
73     case IGESData_ReferenceError: {
74       Message_Msg Msg216 ("IGES_216");
75       Msg149.Arg(Msg216.Value());
76       PR.SendFail(Msg149);
77       break; }
78     case IGESData_EntityError: {
79       Message_Msg Msg217 ("IGES_217");
80       Msg149.Arg(Msg217.Value());
81       PR.SendFail(Msg149);
82       break; }
83     default:{
84     }
85     }
86   }
87   if (!PR.ReadInteger(PR.Current(), aDirFlag)){ //szv#4:S4163:12Mar99 `st=` not needed
88     Message_Msg Msg150("XSTEP_150");
89     PR.SendFail(Msg150);
90   }
91   if (!PR.ReadInteger(PR.Current(), aDevFlag)){ //szv#4:S4163:12Mar99 `st=` not needed
92     Message_Msg Msg151("XSTEP_151");
93     PR.SendFail(Msg151);
94   }
95 /*
96   st = PR.ReadEntity(IR, PR.Current(), "First Curve", aCurve);
97   st = PR.ReadEntity(IR, PR.Current(), "Second Curve", anotherCurve);
98   st = PR.ReadInteger(PR.Current(), "DirFlag", aDirFlag);
99   st = PR.ReadInteger(PR.Current(), "DevFlag ", aDevFlag);
100 */
101   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
102   ent->Init(aCurve, anotherCurve, aDirFlag, aDevFlag);
103 }
104 
WriteOwnParams(const Handle (IGESGeom_RuledSurface)& ent,IGESData_IGESWriter & IW) const105 void IGESGeom_ToolRuledSurface::WriteOwnParams
106   (const Handle(IGESGeom_RuledSurface)& ent, IGESData_IGESWriter& IW)  const
107 {
108   IW.Send(ent->FirstCurve());
109   IW.Send(ent->SecondCurve());
110   IW.Send(ent->DirectionFlag());
111   IW.SendBoolean(ent->IsDevelopable());
112 }
113 
OwnShared(const Handle (IGESGeom_RuledSurface)& ent,Interface_EntityIterator & iter) const114 void  IGESGeom_ToolRuledSurface::OwnShared
115   (const Handle(IGESGeom_RuledSurface)& ent, Interface_EntityIterator& iter) const
116 {
117   iter.GetOneItem(ent->FirstCurve());
118   iter.GetOneItem(ent->SecondCurve());
119 }
120 
OwnCopy(const Handle (IGESGeom_RuledSurface)& another,const Handle (IGESGeom_RuledSurface)& ent,Interface_CopyTool & TC) const121 void IGESGeom_ToolRuledSurface::OwnCopy
122   (const Handle(IGESGeom_RuledSurface)& another,
123    const Handle(IGESGeom_RuledSurface)& ent, Interface_CopyTool& TC) const
124 {
125   DeclareAndCast(IGESData_IGESEntity, aCurve,
126 		 TC.Transferred(another->FirstCurve()));
127   DeclareAndCast(IGESData_IGESEntity, anotherCurve,
128 		 TC.Transferred(another->SecondCurve()));
129   Standard_Integer aDirFlag = another->DirectionFlag();
130   Standard_Integer aDevFlag = (another->IsDevelopable() ? 1 : 0);
131 
132   ent->Init(aCurve, anotherCurve, aDirFlag, aDevFlag);
133 }
134 
DirChecker(const Handle (IGESGeom_RuledSurface)&) const135 IGESData_DirChecker IGESGeom_ToolRuledSurface::DirChecker
136   (const Handle(IGESGeom_RuledSurface)& /*ent*/ )   const
137 {
138   IGESData_DirChecker DC(118, 0, 1);
139   DC.Structure(IGESData_DefVoid);
140   DC.LineFont(IGESData_DefAny);
141 //  DC.LineWeight(IGESData_DefValue);
142   DC.Color(IGESData_DefAny);
143   DC.HierarchyStatusIgnored();
144 
145   return DC;
146 }
147 
OwnCheck(const Handle (IGESGeom_RuledSurface)&,const Interface_ShareTool &,Handle (Interface_Check)&) const148 void IGESGeom_ToolRuledSurface::OwnCheck
149   (const Handle(IGESGeom_RuledSurface)& /*ent*/,
150    const Interface_ShareTool& , Handle(Interface_Check)& /*ach*/)  const
151 {
152 }
153 
OwnDump(const Handle (IGESGeom_RuledSurface)& ent,const IGESData_IGESDumper & dumper,Standard_OStream & S,const Standard_Integer level) const154 void IGESGeom_ToolRuledSurface::OwnDump
155   (const Handle(IGESGeom_RuledSurface)& ent, const IGESData_IGESDumper& dumper,
156    Standard_OStream& S, const Standard_Integer level)  const
157 {
158   Standard_Integer tempSubLevel = (level <= 4) ? 0 : 1;
159 
160   S << "IGESGeom_RuledSurface\n"
161     << "First  Curve   : ";
162   dumper.Dump(ent->FirstCurve(),S, tempSubLevel);
163   S << "\n"
164     << "Second Curve   : ";
165   dumper.Dump(ent->SecondCurve(),S, tempSubLevel);
166   S << "\n"
167     << "Direction Flag : " << ent->DirectionFlag() << "  i.e.";
168   if (ent->DirectionFlag() == 0) S << "Join First to First, Last to Last\n";
169   else                           S << "Join First to Last, Last to First\n";
170   if (ent->IsDevelopable()) S << " .. Is Developable\n";
171   else                      S << " .. Is possibly not developable ..\n";
172 }
173