b311480e |
1 | // Created by: CKY / Contract Toubro-Larsen |
2 | // Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
3 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
7fd59977 |
6 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
7fd59977 |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
b311480e |
15 | |
16 | //-------------------------------------------------------------------- |
7fd59977 |
17 | //-------------------------------------------------------------------- |
18 | |
42cf5bc1 |
19 | #include <IGESData_DirChecker.hxx> |
20 | #include <IGESData_Dump.hxx> |
7fd59977 |
21 | #include <IGESData_HArray1OfIGESEntity.hxx> |
42cf5bc1 |
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> |
7fd59977 |
28 | #include <IGESGeom_HArray1OfTransformationMatrix.hxx> |
42cf5bc1 |
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> |
7fd59977 |
35 | #include <Interface_Macros.hxx> |
42cf5bc1 |
36 | #include <Interface_ShareTool.hxx> |
37 | #include <Message_Messenger.hxx> |
38 | #include <Standard_DomainError.hxx> |
7fd59977 |
39 | |
40 | IGESSolid_ToolSolidAssembly::IGESSolid_ToolSolidAssembly () { } |
41 | |
42 | |
43 | void IGESSolid_ToolSolidAssembly::ReadOwnParams |
44 | (const Handle(IGESSolid_SolidAssembly)& ent, |
45 | const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const |
46 | { |
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; |
53 | |
54 | Standard_Boolean st = PR.ReadInteger(PR.Current(), "Number of Items", nbitems); |
55 | if (st && nbitems > 0) |
56 | { |
57 | tempItems = new IGESData_HArray1OfIGESEntity(1, nbitems); |
58 | tempMatrices = new IGESGeom_HArray1OfTransformationMatrix(1, nbitems); |
59 | |
60 | Handle(IGESData_IGESEntity) anent; |
61 | Standard_Integer i; // svv Jan 10 2000 : porting on DEC |
62 | for (i = 1; i <= nbitems; i++) |
63 | { |
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); |
67 | } |
68 | |
69 | Handle(IGESGeom_TransformationMatrix) amatr; |
70 | for (i = 1; i <= nbitems; i++) |
71 | { |
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); |
78 | } |
79 | } |
80 | else PR.AddFail("Number of Items : Not Positive"); |
81 | |
82 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
83 | ent->Init (tempItems, tempMatrices); |
84 | } |
85 | |
86 | void IGESSolid_ToolSolidAssembly::WriteOwnParams |
87 | (const Handle(IGESSolid_SolidAssembly)& ent, IGESData_IGESWriter& IW) const |
88 | { |
89 | Standard_Integer nbitems = ent->NbItems(); |
90 | Standard_Integer i; |
91 | |
92 | IW.Send(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)); |
97 | } |
98 | |
99 | void IGESSolid_ToolSolidAssembly::OwnShared |
100 | (const Handle(IGESSolid_SolidAssembly)& ent, Interface_EntityIterator& iter) const |
101 | { |
102 | Standard_Integer nbitems = ent->NbItems(); |
103 | Standard_Integer i; |
104 | for (i = 1; i <= nbitems; i ++) iter.GetOneItem(ent->Item(i)); |
105 | for (i = 1; i <= nbitems; i ++) iter.GetOneItem(ent->TransfMatrix(i)); |
106 | } |
107 | |
108 | void IGESSolid_ToolSolidAssembly::OwnCopy |
109 | (const Handle(IGESSolid_SolidAssembly)& another, |
110 | const Handle(IGESSolid_SolidAssembly)& ent, Interface_CopyTool& TC) const |
111 | { |
112 | Standard_Integer nbitems, i; |
113 | Handle(IGESData_IGESEntity) anent; |
114 | |
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); |
120 | |
121 | for (i=1; i<=nbitems; i++) |
122 | { |
123 | DeclareAndCast(IGESData_IGESEntity, localent, |
124 | TC.Transferred(another->Item(i))); |
125 | tempItems->SetValue(i, localent); |
126 | } |
127 | for (i=1; i<=nbitems; i++) |
128 | { |
129 | DeclareAndCast(IGESGeom_TransformationMatrix, newlocalent, |
130 | TC.Transferred(another->TransfMatrix(i))); |
131 | tempMatrices->SetValue(i, newlocalent); |
132 | } |
133 | |
134 | ent->Init(tempItems, tempMatrices); |
135 | } |
136 | |
137 | IGESData_DirChecker IGESSolid_ToolSolidAssembly::DirChecker |
138 | (const Handle(IGESSolid_SolidAssembly)& /* ent */ ) const |
139 | { |
140 | IGESData_DirChecker DC(184, 0,1); |
141 | |
142 | DC.Structure (IGESData_DefVoid); |
143 | DC.LineFont (IGESData_DefAny); |
144 | DC.Color (IGESData_DefAny); |
145 | |
146 | DC.UseFlagRequired (2); |
147 | DC.GraphicsIgnored (1); |
148 | return DC; |
149 | } |
150 | |
151 | void IGESSolid_ToolSolidAssembly::OwnCheck |
152 | (const Handle(IGESSolid_SolidAssembly)& /* ent */, |
153 | const Interface_ShareTool& , Handle(Interface_Check)& /* ach */) const |
154 | { |
155 | } |
156 | |
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 |
160 | { |
161 | // Standard_Integer upper = ent->NbItems(); |
162 | |
163 | S << "IGESSolid_SolidAssembly" << endl; |
164 | |
165 | S << "Items : "; |
166 | IGESData_DumpEntities(S,dumper ,level,1, ent->NbItems(),ent->Item); |
167 | S << endl; |
168 | S << "Matrices : "; |
169 | IGESData_DumpEntities(S,dumper ,level,1, ent->NbItems(),ent->TransfMatrix); |
170 | S << endl; |
171 | } |