0024830: Remove redundant keyword 'mutable' in CDL declarations
[occt.git] / src / IGESDraw / IGESDraw_ToolPlanar.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 <IGESDraw_ToolPlanar.ixx>
20 #include <IGESData_ParamCursor.hxx>
21 #include <IGESData_IGESEntity.hxx>
22 #include <IGESGeom_TransformationMatrix.hxx>
23 #include <IGESData_HArray1OfIGESEntity.hxx>
24 #include <IGESData_Dump.hxx>
25 #include <Interface_Macros.hxx>
26
27
28 IGESDraw_ToolPlanar::IGESDraw_ToolPlanar ()    {  }
29
30
31 void IGESDraw_ToolPlanar::ReadOwnParams
32   (const Handle(IGESDraw_Planar)& ent,
33    const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
34
35   Standard_Boolean                          st;
36   Standard_Integer                          nbval;
37
38   Standard_Integer                          nbMatrices; 
39   Handle(IGESGeom_TransformationMatrix)     transformationMatrix; 
40   Handle(IGESData_HArray1OfIGESEntity) entities; 
41
42   // Reading nbMatrices(Integer)
43   st = PR.ReadInteger(PR.Current(), "No. of Transformation matrices", nbMatrices);
44   if ( nbMatrices != 1 )
45     PR.AddFail("No. of Transformation matrices != 1");
46
47   // Reading nbval(Integer)
48   st = PR.ReadInteger(PR.Current(), "No. of Entities in this plane", nbval);
49   if (!st) nbval = 0; //szv#4:S4163:12Mar99 was bug: `nbval == 0`
50   if (nbval <= 0) PR.AddFail ("No. of Entities in this plane : Not Positive");
51
52   // Reading transformationMatrix(Instance of TransformationMatrix or Null)
53   st = PR.ReadEntity(IR,PR.Current(), "Instance of TransformationMatrix",
54                      STANDARD_TYPE(IGESGeom_TransformationMatrix), transformationMatrix,
55                      Standard_True);
56
57   if (nbval > 0)
58     st = PR.ReadEnts (IR, PR.CurrentList(nbval), "Planar Entities", entities);
59 /*
60     {
61       entities = new IGESData_HArray1OfIGESEntity(1, nbval);
62       // Reading entities(HArray1OfIGESEntity)
63       Handle(IGESData_IGESEntity) tempEntity;
64       for (Standard_Integer i = 1; i <= nbval; i++)
65         {
66           st = PR.ReadEntity(IR, PR.Current(), "Plane entity", tempEntity);
67           if (st) entities->SetValue(i, tempEntity);
68         }
69     }
70 */
71
72   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
73   ent->Init(nbMatrices,transformationMatrix, entities);
74 }
75
76 void IGESDraw_ToolPlanar::WriteOwnParams
77   (const Handle(IGESDraw_Planar)& ent, IGESData_IGESWriter& IW)  const
78
79   Standard_Integer Up  = ent->NbEntities();
80   IW.Send( ent->NbMatrices() );
81   IW.Send( Up );
82
83   IW.Send( ent->TransformMatrix() );
84
85   for ( Standard_Integer i = 1; i <= Up; i++)
86     IW.Send( ent->Entity(i) );
87 }
88
89 void  IGESDraw_ToolPlanar::OwnShared
90   (const Handle(IGESDraw_Planar)& ent, Interface_EntityIterator& iter) const
91 {
92   Standard_Integer Up  = ent->NbEntities();
93   iter.GetOneItem( ent->TransformMatrix() );
94   for ( Standard_Integer i = 1; i <= Up; i++)
95     iter.GetOneItem( ent->Entity(i) );
96 }
97
98 void IGESDraw_ToolPlanar::OwnCopy
99   (const Handle(IGESDraw_Planar)& another,
100    const Handle(IGESDraw_Planar)& ent, Interface_CopyTool& TC) const
101 {
102   Standard_Integer                          nbval;
103   Standard_Integer                          nbMatrices; 
104   Handle(IGESData_HArray1OfIGESEntity) entities; 
105  
106   nbval                = another->NbEntities();
107   nbMatrices           = another->NbMatrices();
108   DeclareAndCast(IGESGeom_TransformationMatrix, transformationMatrix, 
109                  TC.Transferred(another->TransformMatrix()));
110
111   entities = new IGESData_HArray1OfIGESEntity(1, nbval);
112   for (Standard_Integer i = 1; i <= nbval; i++)
113     {
114       DeclareAndCast(IGESData_IGESEntity, tempEntity, 
115                      TC.Transferred(another->Entity(i)));
116       entities->SetValue( i, tempEntity );
117     }
118
119   ent->Init(nbMatrices, transformationMatrix, entities);
120 }
121
122 Standard_Boolean  IGESDraw_ToolPlanar::OwnCorrect
123   (const Handle(IGESDraw_Planar)& ent) const
124 {
125   if (ent->NbMatrices() == 1) return Standard_False;
126 //  Forcer NbMNatrices a 1 -> Reconstruire
127   Standard_Integer nb = ent->NbEntities();
128   Handle(IGESData_HArray1OfIGESEntity) ents =
129     new IGESData_HArray1OfIGESEntity(1,nb);
130   for (Standard_Integer i = 1; i <= nb; i ++)
131     ents->SetValue(i,ent->Entity(i));
132   ent->Init (1,ent->TransformMatrix(),ents);
133   return Standard_True;
134 }
135
136 IGESData_DirChecker IGESDraw_ToolPlanar::DirChecker
137   (const Handle(IGESDraw_Planar)& /*ent*/)  const
138
139   IGESData_DirChecker DC (402, 16);
140   DC.Structure(IGESData_DefVoid);
141   DC.LineFont(IGESData_DefVoid);
142   DC.LineWeight(IGESData_DefVoid);
143   DC.Color(IGESData_DefVoid);
144   DC.BlankStatusIgnored();
145   DC.UseFlagRequired(5);
146   DC.HierarchyStatusIgnored();
147   return DC;
148 }
149
150 void IGESDraw_ToolPlanar::OwnCheck
151   (const Handle(IGESDraw_Planar)& ent,
152    const Interface_ShareTool& , Handle(Interface_Check)& ach)  const
153 {
154   if ( ent->NbMatrices() != 1 )
155     ach->AddFail("No. of Transformation matrices : Value != 1");
156 }
157
158 void IGESDraw_ToolPlanar::OwnDump
159   (const Handle(IGESDraw_Planar)& ent, const IGESData_IGESDumper& dumper,
160    const Handle(Message_Messenger)& S, const Standard_Integer level)  const
161 {
162   Standard_Integer sublevel = (level <= 4) ? 0 : 1;
163
164   S << "IGESDraw_Planar" << endl;
165
166   S << "No. of Transformation Matrices : " << ent->NbMatrices() << "  ";
167   S << "i.e. : ";
168   if ( ent->TransformMatrix().IsNull() )
169     S << "Null Handle";
170   else
171     dumper.OwnDump (ent->TransformMatrix(),S, sublevel);
172   S << endl;
173   S << "Array of Entities on the specified plane : ";
174   IGESData_DumpEntities(S,dumper ,level,1, ent->NbEntities(),ent->Entity);
175   S << endl;
176 }