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 //--------------------------------------------------------------------
20 #include <IGESData_DirChecker.hxx>
21 #include <IGESData_Dump.hxx>
22 #include <IGESData_IGESDumper.hxx>
23 #include <IGESData_IGESReaderData.hxx>
24 #include <IGESData_IGESWriter.hxx>
25 #include <IGESData_ParamCursor.hxx>
26 #include <IGESData_ParamReader.hxx>
27 #include <IGESGeom_CopiousData.hxx>
28 #include <IGESGeom_ToolCopiousData.hxx>
29 #include <Interface_Check.hxx>
30 #include <Interface_CopyTool.hxx>
31 #include <Interface_EntityIterator.hxx>
32 #include <Interface_Macros.hxx>
33 #include <Interface_ShareTool.hxx>
34 #include <Message_Messenger.hxx>
35 #include <Message_Msg.hxx>
36 #include <Standard_DomainError.hxx>
37 #include <TColStd_HArray1OfReal.hxx>
40 //=======================================================================
41 //function : IGESGeom_ToolCopiousData
43 //=======================================================================
44 IGESGeom_ToolCopiousData::IGESGeom_ToolCopiousData ()
49 //=======================================================================
50 //function : ReadOwnParams
52 //=======================================================================
54 void IGESGeom_ToolCopiousData::ReadOwnParams(const Handle(IGESGeom_CopiousData)& ent,
55 const Handle(IGESData_IGESReaderData)& /* IR */,
56 IGESData_ParamReader& PR) const
59 // Building of messages
61 Standard_Integer aDataType, nbData;
62 Standard_Real aZPlane = 0;
63 Handle(TColStd_HArray1OfReal) allData;
65 Standard_Integer upper;
66 //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
67 Standard_Boolean data = Standard_False;
69 if (!PR.ReadInteger(PR.Current(), aDataType)){ //szv#4:S4163:12Mar99 `st=` not needed
70 //st = PR.ReadInteger(PR.Current(), "Data Type", aDataType);
71 Message_Msg Msg85("XSTEP_85");
75 Standard_Boolean st = PR.ReadInteger(PR.Current(), nbData);
76 //st = PR.ReadInteger(PR.Current(), "Number of n-tuples", nbData);
77 if (st && (nbData > 0)) data = Standard_True;
79 Message_Msg Msg86("XSTEP_86");
84 if (!PR.ReadReal(PR.Current(), aZPlane)){ //szv#4:S4163:12Mar99 `st=` not needed
85 Message_Msg Msg87("XSTEP_87");
88 //if (aDataType == 1) st = PR.ReadReal(PR.Current(), "Z Plane", aZPlane);
93 if (aDataType == 1) upper = 2*nbData;
94 else if (aDataType == 2) upper = 3*nbData;
95 else upper = 6*nbData;
97 Message_Msg Msg88("XSTEP_88");
98 //allData = new TColStd_HArray1OfReal(1, upper) then fill it :
99 PR.ReadReals(PR.CurrentList(upper),Msg88, allData); //szv#4:S4163:12Mar99 `st=` not needed
100 //st = PR.ReadReals(PR.CurrentList(upper), "Tuples", allData);
103 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
104 ent->Init(aDataType, aZPlane, allData);
108 //=======================================================================
109 //function : WriteOwnParams
111 //=======================================================================
113 void IGESGeom_ToolCopiousData::WriteOwnParams(const Handle(IGESGeom_CopiousData)& ent,
114 IGESData_IGESWriter& IW) const
116 Standard_Integer upper = ent->NbPoints();
117 Standard_Integer dtype = ent->DataType();
120 if (ent->DataType() == 1)
121 IW.Send(ent->ZPlane());
122 for (Standard_Integer I = 1; I <= upper; I++) {
123 // DataType = 1 : XY , 2 : XYZ , 3 : XYZ*2
124 IW.Send( ent->Data(I,1) );
125 IW.Send( ent->Data(I,2) );
126 if (dtype > 1) IW.Send( ent->Data(I,3) );
127 if (dtype <= 2) continue;
128 IW.Send( ent->Data(I,4) );
129 IW.Send( ent->Data(I,5) );
130 IW.Send( ent->Data(I,6) );
135 //=======================================================================
136 //function : OwnShared
138 //=======================================================================
140 void IGESGeom_ToolCopiousData::OwnShared(const Handle(IGESGeom_CopiousData)& /* ent */,
141 Interface_EntityIterator& /* iter */) const
146 //=======================================================================
149 //=======================================================================
151 void IGESGeom_ToolCopiousData::OwnCopy(const Handle(IGESGeom_CopiousData)& another,
152 const Handle(IGESGeom_CopiousData)& ent,
153 Interface_CopyTool& /* TC */) const
155 Standard_Integer upper;
156 Standard_Real aZPlane = 0;
157 Standard_Integer nbTuples = another->NbPoints();
158 Standard_Integer aDataType = another->DataType();
159 Handle(TColStd_HArray1OfReal) allData;
161 if (aDataType == 1) upper = 2*nbTuples;
162 else if (aDataType == 2) upper = 3*nbTuples;
163 else upper = 6*nbTuples;
165 allData = new TColStd_HArray1OfReal(1, upper);
167 if (aDataType == 1) aZPlane = another->ZPlane();
169 for (Standard_Integer I = 1; I <= nbTuples; I++) {
173 allData->SetValue(2*I-1, another->Data(I,1));
174 allData->SetValue(2*I , another->Data(I,2));
177 allData->SetValue(3*I-2, another->Data(I,1));
178 allData->SetValue(3*I-1, another->Data(I,2));
179 allData->SetValue(3*I , another->Data(I,3));
182 allData->SetValue(6*I-5, another->Data(I,1));
183 allData->SetValue(6*I-4, another->Data(I,2));
184 allData->SetValue(6*I-3, another->Data(I,3));
185 allData->SetValue(6*I-2, another->Data(I,4));
186 allData->SetValue(6*I-1, another->Data(I,5));
187 allData->SetValue(6*I , another->Data(I,6));
192 ent->Init(aDataType, aZPlane, allData);
193 if (another->IsClosedPath2D()) ent->SetClosedPath2D();
194 else ent->SetPolyline (another->IsPolyline());
198 //=======================================================================
199 //function : DirChecker
201 //=======================================================================
203 IGESData_DirChecker IGESGeom_ToolCopiousData::DirChecker
204 (const Handle(IGESGeom_CopiousData)& ent ) const
206 IGESData_DirChecker DC(106, 1, 63);
207 DC.Structure(IGESData_DefVoid);
208 if (ent->FormNumber() <= 3)
210 DC.LineFont(IGESData_DefVoid);
211 DC.LineWeight(IGESData_DefVoid);
215 DC.LineFont(IGESData_DefAny);
216 DC.LineWeight(IGESData_DefValue);
218 DC.Color(IGESData_DefAny);
219 DC.HierarchyStatusIgnored ();
224 //=======================================================================
225 //function : OwnCheck
227 //=======================================================================
229 void IGESGeom_ToolCopiousData::OwnCheck(const Handle(IGESGeom_CopiousData)& ent,
230 const Interface_ShareTool&,
231 Handle(Interface_Check)& ach) const
234 // Building of messages
235 //======================================
236 Message_Msg Msg71("XSTEP_71");
237 //Message_Msg Msg85("XSTEP_85");
238 //======================================
240 Standard_Integer fn = ent->FormNumber();
241 if ( (fn > 3 && fn < 11) || (fn > 14 && fn < 63)) {
242 // Message_Msg Msg71("XSTEP_71");
243 ach->SendFail(Msg71);
245 Standard_Integer dt = ent->DataType();
246 if (dt < 1 || dt > 3) {
247 Message_Msg Msg85("XSTEP_85");
248 ach->SendFail(Msg85);
250 if ((dt == 1 && (fn != 1 && fn != 11 && fn != 63)) ||
251 (dt == 2 && (fn != 2 && fn != 12)) || (dt == 3 && (fn != 3 && fn != 13))) {
252 // Message_Msg Msg71("XSTEP_71");
253 ach->SendFail(Msg71);
258 //=======================================================================
261 //=======================================================================
263 void IGESGeom_ToolCopiousData::OwnDump(const Handle(IGESGeom_CopiousData)& ent,
264 const IGESData_IGESDumper& /* dumper */,
265 const Handle(Message_Messenger)& S,
266 const Standard_Integer level) const
268 Standard_Integer nbPnts = ent->NbPoints();
269 Standard_Integer dtype = ent->DataType();
271 gp_GTrsf loca = ent->Location();
272 gp_GTrsf locv = ent->VectorLocation();
273 Standard_Boolean yatr = (level > 5 && ent->HasTransf());
275 S << "IGESGeom_CopiousData" << Message_EndLine;
277 if (ent->IsPointSet()) S << "Point Set ";
278 else if (ent->IsPolyline()) S << "Polyline ";
279 else if (ent->IsClosedPath2D()) S << "Closed Path 2D ";
280 S << "DataType " << ent->DataType() << " ";
281 S << "Number of T-uples = " << nbPnts << " ";
284 S << "ZPlane = " << ent->ZPlane() << Message_EndLine;
287 S << "(Points 3D)" << Message_EndLine;
289 S << "(Points 3D + Vectors 3D)" << Message_EndLine;
292 for (i = 1; i <= nbPnts; i ++) {
293 gp_XYZ T = ent->Point(i).XYZ();
295 S << "[" << i << "] (" << T.X() << "," << T.Y() << ")";
297 S << "[" << i << "] (" << T.X() << "," << T.Y() << "," << T.Z() << ")";
301 S << " Transformed ("<< T.X() << "," << T.Y() << "," << T.Z() << ")";
305 // gp_XYZ P = ent->Vector(i).XYZ();
306 S << "\n Vector (" << T.X() << "," << T.Y() << "," << T.Z() << ")";
309 S << " Transformed ("<< T.X() << "," << T.Y() << "," << T.Z() << ")";
312 S << Message_EndLine;
315 else S << " [ for content, ask level > 4 ]";
316 S << Message_EndLine;