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 <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>
28 IGESDraw_ToolPlanar::IGESDraw_ToolPlanar () { }
31 void IGESDraw_ToolPlanar::ReadOwnParams
32 (const Handle(IGESDraw_Planar)& ent,
33 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
36 Standard_Integer nbval;
38 Standard_Integer nbMatrices;
39 Handle(IGESGeom_TransformationMatrix) transformationMatrix;
40 Handle(IGESData_HArray1OfIGESEntity) entities;
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");
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");
52 // Reading transformationMatrix(Instance of TransformationMatrix or Null)
53 st = PR.ReadEntity(IR,PR.Current(), "Instance of TransformationMatrix",
54 STANDARD_TYPE(IGESGeom_TransformationMatrix), transformationMatrix,
58 st = PR.ReadEnts (IR, PR.CurrentList(nbval), "Planar Entities", entities);
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++)
66 st = PR.ReadEntity(IR, PR.Current(), "Plane entity", tempEntity);
67 if (st) entities->SetValue(i, tempEntity);
72 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
73 ent->Init(nbMatrices,transformationMatrix, entities);
76 void IGESDraw_ToolPlanar::WriteOwnParams
77 (const Handle(IGESDraw_Planar)& ent, IGESData_IGESWriter& IW) const
79 Standard_Integer Up = ent->NbEntities();
80 IW.Send( ent->NbMatrices() );
83 IW.Send( ent->TransformMatrix() );
85 for ( Standard_Integer i = 1; i <= Up; i++)
86 IW.Send( ent->Entity(i) );
89 void IGESDraw_ToolPlanar::OwnShared
90 (const Handle(IGESDraw_Planar)& ent, Interface_EntityIterator& iter) const
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) );
98 void IGESDraw_ToolPlanar::OwnCopy
99 (const Handle(IGESDraw_Planar)& another,
100 const Handle(IGESDraw_Planar)& ent, Interface_CopyTool& TC) const
102 Standard_Integer nbval;
103 Standard_Integer nbMatrices;
104 Handle(IGESData_HArray1OfIGESEntity) entities;
106 nbval = another->NbEntities();
107 nbMatrices = another->NbMatrices();
108 DeclareAndCast(IGESGeom_TransformationMatrix, transformationMatrix,
109 TC.Transferred(another->TransformMatrix()));
111 entities = new IGESData_HArray1OfIGESEntity(1, nbval);
112 for (Standard_Integer i = 1; i <= nbval; i++)
114 DeclareAndCast(IGESData_IGESEntity, tempEntity,
115 TC.Transferred(another->Entity(i)));
116 entities->SetValue( i, tempEntity );
119 ent->Init(nbMatrices, transformationMatrix, entities);
122 Standard_Boolean IGESDraw_ToolPlanar::OwnCorrect
123 (const Handle(IGESDraw_Planar)& ent) const
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;
136 IGESData_DirChecker IGESDraw_ToolPlanar::DirChecker
137 (const Handle(IGESDraw_Planar)& /*ent*/) const
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();
150 void IGESDraw_ToolPlanar::OwnCheck
151 (const Handle(IGESDraw_Planar)& ent,
152 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
154 if ( ent->NbMatrices() != 1 )
155 ach->AddFail("No. of Transformation matrices : Value != 1");
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
162 Standard_Integer sublevel = (level <= 4) ? 0 : 1;
164 S << "IGESDraw_Planar" << endl;
166 S << "No. of Transformation Matrices : " << ent->NbMatrices() << " ";
168 if ( ent->TransformMatrix().IsNull() )
171 dumper.OwnDump (ent->TransformMatrix(),S, sublevel);
173 S << "Array of Entities on the specified plane : ";
174 IGESData_DumpEntities(S,dumper ,level,1, ent->NbEntities(),ent->Entity);