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 <IGESData_DirChecker.hxx>
20 #include <IGESData_Dump.hxx>
21 #include <IGESData_HArray1OfIGESEntity.hxx>
22 #include <IGESData_IGESDumper.hxx>
23 #include <IGESData_IGESEntity.hxx>
24 #include <IGESData_IGESReaderData.hxx>
25 #include <IGESData_IGESWriter.hxx>
26 #include <IGESData_ParamCursor.hxx>
27 #include <IGESData_ParamReader.hxx>
28 #include <IGESGeom_HArray1OfTransformationMatrix.hxx>
29 #include <IGESGeom_TransformationMatrix.hxx>
30 #include <IGESSolid_SolidAssembly.hxx>
31 #include <IGESSolid_ToolSolidAssembly.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 <Standard_DomainError.hxx>
40 IGESSolid_ToolSolidAssembly::IGESSolid_ToolSolidAssembly () { }
43 void IGESSolid_ToolSolidAssembly::ReadOwnParams
44 (const Handle(IGESSolid_SolidAssembly)& ent,
45 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
47 //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
48 Standard_Integer nbitems; //szv#4:S4163:12Mar99 `i` moved in for
49 //Handle(IGESData_IGESEntity) anent; //szv#4:S4163:12Mar99 moved down
50 //Handle(IGESGeom_TransformationMatrix) amatr; //szv#4:S4163:12Mar99 moved down
51 Handle(IGESData_HArray1OfIGESEntity) tempItems;
52 Handle(IGESGeom_HArray1OfTransformationMatrix) tempMatrices;
54 Standard_Boolean st = PR.ReadInteger(PR.Current(), "Number of Items", nbitems);
55 if (st && nbitems > 0)
57 tempItems = new IGESData_HArray1OfIGESEntity(1, nbitems);
58 tempMatrices = new IGESGeom_HArray1OfTransformationMatrix(1, nbitems);
60 Handle(IGESData_IGESEntity) anent;
61 Standard_Integer i; // svv Jan 10 2000 : porting on DEC
62 for (i = 1; i <= nbitems; i++)
64 //st = PR.ReadEntity(IR,PR.Current(), "Solid assembly items", anent); //szv#4:S4163:12Mar99 moved in if
65 if (PR.ReadEntity(IR,PR.Current(), "Solid assembly items", anent))
66 tempItems->SetValue(i, anent);
69 Handle(IGESGeom_TransformationMatrix) amatr;
70 for (i = 1; i <= nbitems; i++)
72 //st = PR.ReadEntity(IR,PR.Current(), "Matrices",
73 //STANDARD_TYPE(IGESGeom_TransformationMatrix),
74 //amatr, Standard_True); //szv#4:S4163:12Mar99 moved in if
75 if (PR.ReadEntity(IR,PR.Current(), "Matrices",
76 STANDARD_TYPE(IGESGeom_TransformationMatrix), amatr, Standard_True))
77 tempMatrices->SetValue(i, amatr);
80 else PR.AddFail("Number of Items : Not Positive");
82 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
83 ent->Init (tempItems, tempMatrices);
86 void IGESSolid_ToolSolidAssembly::WriteOwnParams
87 (const Handle(IGESSolid_SolidAssembly)& ent, IGESData_IGESWriter& IW) const
89 Standard_Integer nbitems = ent->NbItems();
93 for (i = 1; i <= nbitems; i ++)
94 IW.Send(ent->Item(i));
95 for (i = 1; i <= nbitems; i ++)
96 IW.Send(ent->TransfMatrix(i));
99 void IGESSolid_ToolSolidAssembly::OwnShared
100 (const Handle(IGESSolid_SolidAssembly)& ent, Interface_EntityIterator& iter) const
102 Standard_Integer nbitems = ent->NbItems();
104 for (i = 1; i <= nbitems; i ++) iter.GetOneItem(ent->Item(i));
105 for (i = 1; i <= nbitems; i ++) iter.GetOneItem(ent->TransfMatrix(i));
108 void IGESSolid_ToolSolidAssembly::OwnCopy
109 (const Handle(IGESSolid_SolidAssembly)& another,
110 const Handle(IGESSolid_SolidAssembly)& ent, Interface_CopyTool& TC) const
112 Standard_Integer nbitems, i;
113 Handle(IGESData_IGESEntity) anent;
115 nbitems = another->NbItems();
116 Handle(IGESData_HArray1OfIGESEntity) tempItems = new
117 IGESData_HArray1OfIGESEntity(1, nbitems);
118 Handle(IGESGeom_HArray1OfTransformationMatrix) tempMatrices = new
119 IGESGeom_HArray1OfTransformationMatrix(1, nbitems);
121 for (i=1; i<=nbitems; i++)
123 DeclareAndCast(IGESData_IGESEntity, localent,
124 TC.Transferred(another->Item(i)));
125 tempItems->SetValue(i, localent);
127 for (i=1; i<=nbitems; i++)
129 DeclareAndCast(IGESGeom_TransformationMatrix, newlocalent,
130 TC.Transferred(another->TransfMatrix(i)));
131 tempMatrices->SetValue(i, newlocalent);
134 ent->Init(tempItems, tempMatrices);
137 IGESData_DirChecker IGESSolid_ToolSolidAssembly::DirChecker
138 (const Handle(IGESSolid_SolidAssembly)& /* ent */ ) const
140 IGESData_DirChecker DC(184, 0,1);
142 DC.Structure (IGESData_DefVoid);
143 DC.LineFont (IGESData_DefAny);
144 DC.Color (IGESData_DefAny);
146 DC.UseFlagRequired (2);
147 DC.GraphicsIgnored (1);
151 void IGESSolid_ToolSolidAssembly::OwnCheck
152 (const Handle(IGESSolid_SolidAssembly)& /* ent */,
153 const Interface_ShareTool& , Handle(Interface_Check)& /* ach */) const
157 void IGESSolid_ToolSolidAssembly::OwnDump
158 (const Handle(IGESSolid_SolidAssembly)& ent, const IGESData_IGESDumper& dumper,
159 const Handle(Message_Messenger)& S, const Standard_Integer level) const
161 // Standard_Integer upper = ent->NbItems();
163 S << "IGESSolid_SolidAssembly" << endl;
166 IGESData_DumpEntities(S,dumper ,level,1, ent->NbItems(),ent->Item);
169 IGESData_DumpEntities(S,dumper ,level,1, ent->NbItems(),ent->TransfMatrix);