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