0027961: Visualization - remove unused and no more working OpenGl_AVIWriter
[occt.git] / src / IGESGeom / IGESGeom_ToolTrimmedSurface.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_Dump.hxx>
21 #include <IGESData_IGESDumper.hxx>
22 #include <IGESData_IGESEntity.hxx>
23 #include <IGESData_IGESReaderData.hxx>
24 #include <IGESData_IGESWriter.hxx>
25 #include <IGESData_ParamCursor.hxx>
26 #include <IGESData_ParamReader.hxx>
27 #include <IGESData_Status.hxx>
28 #include <IGESGeom_CurveOnSurface.hxx>
29 #include <IGESGeom_HArray1OfCurveOnSurface.hxx>
30 #include <IGESGeom_ToolTrimmedSurface.hxx>
31 #include <IGESGeom_TrimmedSurface.hxx>
32 #include <Interface_Check.hxx>
33 #include <Interface_CopyTool.hxx>
34 #include <Interface_EntityIterator.hxx>
35 #include <Interface_Macros.hxx>
36 #include <Interface_ShareTool.hxx>
37 #include <Message_Messenger.hxx>
38 #include <Message_Msg.hxx>
39 #include <Standard_DomainError.hxx>
40
41 // MGE 31/07/98
42 //=======================================================================
43 //function : IGESGeom_ToolTrimmedSurface
44 //purpose  : 
45 //=======================================================================
46 IGESGeom_ToolTrimmedSurface::IGESGeom_ToolTrimmedSurface ()
47 {
48 }
49
50
51 //=======================================================================
52 //function : ReadOwnParams
53 //purpose  : 
54 //=======================================================================
55
56 void IGESGeom_ToolTrimmedSurface::ReadOwnParams
57   (const Handle(IGESGeom_TrimmedSurface)& ent,
58    const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
59 {
60   // MGE 31/07/98
61   // Building of messages
62   //========================================
63   //========================================
64
65   //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
66   Standard_Integer aFlag;
67   Standard_Integer count;
68   Handle(IGESData_IGESEntity) aSurface;
69   Handle(IGESGeom_CurveOnSurface) anOuter;
70   Handle(IGESGeom_HArray1OfCurveOnSurface) anInner;
71   IGESData_Status aStatus;
72
73   //szv#4:S4163:12Mar99 `st=` not needed
74   if (!PR.ReadEntity(IR, PR.Current(), aStatus, aSurface)){
75     Message_Msg Msg169("XSTEP_169");
76     switch(aStatus) {
77     case IGESData_ReferenceError: {  
78       Message_Msg Msg216 ("IGES_216");
79       Msg169.Arg(Msg216.Value());
80       PR.SendFail(Msg169);
81       break; }
82     case IGESData_EntityError: {
83       Message_Msg Msg217 ("IGES_217");
84       Msg169.Arg(Msg217.Value());
85       PR.SendFail(Msg169);
86       break; }
87     default:{
88     }
89     }
90   }
91   if (!PR.ReadInteger(PR.Current(), aFlag)){
92     Message_Msg Msg170("XSTEP_170");
93     PR.SendFail(Msg170);
94   }
95   //st = PR.ReadInteger(PR.Current(), Msg171, count); //szv#4:S4163:12Mar99 moved in if
96
97 /*
98   st = PR.ReadEntity(IR, PR.Current(), "Surface to be trimmed", aSurface);
99   st = PR.ReadInteger(PR.Current(), "Outer boundary type", aFlag);
100   st = PR.ReadInteger(PR.Current(), "Number of inner boundary closed curves", count);
101 */
102   if (PR.ReadInteger(PR.Current(), count)) {
103     if (count < 0){
104       Message_Msg Msg171("XSTEP_171");
105       PR.SendFail (Msg171);
106     }
107     else  if (count > 0) anInner =
108       new IGESGeom_HArray1OfCurveOnSurface(1, count);
109   }
110   else {
111     Message_Msg Msg171("XSTEP_171");
112     PR.SendFail(Msg171);
113   }
114
115   if (!PR.ReadEntity(IR, PR.Current(), aStatus,
116                 STANDARD_TYPE(IGESGeom_CurveOnSurface), anOuter,Standard_True)){
117     Message_Msg Msg172("XSTEP_172");
118     switch(aStatus) {
119     case IGESData_ReferenceError: {  
120       Message_Msg Msg216 ("IGES_216");
121       Msg172.Arg(Msg216.Value());
122       PR.SendFail(Msg172);
123       break; }
124     case IGESData_EntityError: {
125       Message_Msg Msg217 ("IGES_217");
126       Msg172.Arg(Msg217.Value());
127       PR.SendFail(Msg172);
128       break; }
129     case IGESData_TypeError: {
130       Message_Msg Msg218 ("IGES_218");
131       Msg172.Arg(Msg218.Value());
132       PR.SendFail(Msg172);
133       break; }
134     default:{
135     }
136     }
137   } //szv#4:S4163:12Mar99 `st=` not needed
138 /*  st = PR.ReadEntity(IR, PR.Current(), "Outer boundary curve",
139                      STANDARD_TYPE(IGESGeom_CurveOnSurface), anOuter,Standard_True);
140 */
141   if (! anInner.IsNull()) {
142     Standard_Integer I;
143     for (I = 1; I <= count; I++ ) {
144       Handle(IGESGeom_CurveOnSurface) tempEnt;
145       //st = PR.ReadEntity(IR, PR.Current(), Msg173,
146                            //STANDARD_TYPE(IGESGeom_CurveOnSurface), tempEnt); //szv#4:S4163:12Mar99 moved in if
147 /*      st = PR.ReadEntity(IR, PR.Current(), "Inner boundary curves",
148                          STANDARD_TYPE(IGESGeom_CurveOnSurface), tempEnt);
149 */
150       if (PR.ReadEntity(IR, PR.Current(), aStatus, STANDARD_TYPE(IGESGeom_CurveOnSurface), tempEnt))
151         anInner->SetValue(I, tempEnt);
152       else{
153         Message_Msg Msg173("XSTEP_173");
154         switch(aStatus) {
155         case IGESData_ReferenceError: {  
156           Message_Msg Msg216 ("IGES_216");
157           Msg173.Arg(Msg216.Value());
158           PR.SendFail(Msg173);
159           break; }
160         case IGESData_EntityError: {
161           Message_Msg Msg217 ("IGES_217");
162           Msg173.Arg(Msg217.Value());
163           PR.SendFail(Msg173);
164           break; }
165         case IGESData_TypeError: {
166           Message_Msg Msg218 ("IGES_218");
167           Msg173.Arg(Msg218.Value());
168           PR.SendFail(Msg173);
169           break; }
170         default:{
171         }
172         }
173       }
174     }
175   }
176
177   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
178   ent->Init(aSurface, aFlag, anOuter, anInner);
179 }
180
181
182 //=======================================================================
183 //function : WriteOwnParams
184 //purpose  : 
185 //=======================================================================
186
187 void IGESGeom_ToolTrimmedSurface::WriteOwnParams
188   (const Handle(IGESGeom_TrimmedSurface)& ent, IGESData_IGESWriter& IW)  const
189 {
190   Standard_Integer up  = ent->NbInnerContours();
191   IW.Send(ent->Surface());
192   IW.Send(ent->OuterBoundaryType());
193   IW.Send(up);
194
195   if (ent->OuterBoundaryType())
196     IW.Send(ent->OuterContour());
197   else 
198     IW.Send(0);
199   Standard_Integer I;
200   for (I = 1; I <= up; I ++)
201     IW.Send(ent->InnerContour(I));
202 }
203
204
205 //=======================================================================
206 //function : OwnShared
207 //purpose  : 
208 //=======================================================================
209
210 void IGESGeom_ToolTrimmedSurface::OwnShared(const Handle(IGESGeom_TrimmedSurface)& ent,
211                                             Interface_EntityIterator& iter) const
212 {
213   Standard_Integer up  = ent->NbInnerContours();
214   iter.GetOneItem(ent->Surface());
215   iter.GetOneItem(ent->OuterContour());
216   Standard_Integer I;
217   for (I = 1; I <= up; I ++)  iter.GetOneItem(ent->InnerContour(I));
218 }
219
220
221 //=======================================================================
222 //function : OwnCopy
223 //purpose  : 
224 //=======================================================================
225
226 void IGESGeom_ToolTrimmedSurface::OwnCopy(const Handle(IGESGeom_TrimmedSurface)& another,
227                                           const Handle(IGESGeom_TrimmedSurface)& ent,
228                                           Interface_CopyTool& TC) const
229 {
230   Handle(IGESGeom_HArray1OfCurveOnSurface) anInner;
231
232   DeclareAndCast(IGESData_IGESEntity, aSurface,
233                  TC.Transferred(another->Surface()));
234   Standard_Integer aFlag = another->OuterBoundaryType();
235   DeclareAndCast(IGESGeom_CurveOnSurface, anOuter,
236                  TC.Transferred(another->OuterContour()));
237   Standard_Integer count = another->NbInnerContours();
238
239   if (count > 0) {
240     anInner = new IGESGeom_HArray1OfCurveOnSurface(1, count);
241     Standard_Integer I;
242     for (I = 1; I <= count; I++) {
243       DeclareAndCast(IGESGeom_CurveOnSurface, temp,
244                      TC.Transferred(another->InnerContour(I)));
245       anInner->SetValue(I, temp);
246     }
247   }
248
249   ent->Init(aSurface, aFlag, anOuter, anInner);
250 }
251
252
253 //=======================================================================
254 //function : DirChecker
255 //purpose  : 
256 //=======================================================================
257
258 IGESData_DirChecker IGESGeom_ToolTrimmedSurface::DirChecker
259   (const Handle(IGESGeom_TrimmedSurface)& /* ent */ )   const
260 {
261   IGESData_DirChecker DC(144, 0);
262   DC.Structure(IGESData_DefVoid);
263   DC.LineFont(IGESData_DefAny);
264 //  DC.LineWeight(IGESData_DefValue);
265   DC.Color(IGESData_DefAny);
266   DC.UseFlagRequired (0);
267   DC.HierarchyStatusIgnored();
268
269   return DC;
270 }
271
272
273 //=======================================================================
274 //function : OwnCheck
275 //purpose  : 
276 //=======================================================================
277
278 void IGESGeom_ToolTrimmedSurface::OwnCheck(const Handle(IGESGeom_TrimmedSurface)& ent,
279                                            const Interface_ShareTool&,
280                                            Handle(Interface_Check)& ach)  const
281 {
282   // MGE 31/07/98
283   // Building of messages
284   //========================================
285   //Message_Msg Msg172("XSTEP_172");
286   //========================================
287
288   if (ent->OuterBoundaryType() != 0 &&   ent->OuterBoundaryType() != 1) {
289     Message_Msg Msg172("XSTEP_172");
290     ach->SendFail(Msg172);
291   }
292 }
293
294
295 //=======================================================================
296 //function : OwnDump
297 //purpose  : 
298 //=======================================================================
299
300 void IGESGeom_ToolTrimmedSurface::OwnDump(const Handle(IGESGeom_TrimmedSurface)& ent,
301                                           const IGESData_IGESDumper& dumper,
302                                           const Handle(Message_Messenger)& S,
303                                           const Standard_Integer level)  const
304 {
305   Standard_Integer tempSubLevel = (level <= 4) ? 0 : 1;
306
307   S << "IGESGeom_TrimmedSurface" << endl;
308
309   S << "Surface to be trimmed : ";
310   dumper.Dump(ent->Surface(),S, tempSubLevel);
311   S << endl;
312   S << "Boundary type    : " << ent->OuterBoundaryType() << endl;
313   S << "Outer Boundary   : ";
314   dumper.Dump(ent->OuterContour(),S, tempSubLevel);
315   S << endl;
316   S << "Inner Boundaries : ";
317   IGESData_DumpEntities(S,dumper ,level,1, ent->NbInnerContours(),ent->InnerContour);
318   S << endl;
319 }