1 // Created on: 2015-10-29
2 // Created by: Irina KRYLOVA
3 // Copyright (c) 2015 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.
17 #include <Interface_Check.hxx>
18 #include <Interface_EntityIterator.hxx>
19 #include <RWStepVisual_RWCoordinatesList.hxx>
20 #include <StepData_StepReaderData.hxx>
21 #include <StepData_StepWriter.hxx>
22 #include <StepRepr_RepresentationItem.hxx>
23 #include <StepVisual_HArray1OfPresentationStyleAssignment.hxx>
24 #include <StepVisual_PresentationStyleAssignment.hxx>
25 #include <StepVisual_CoordinatesList.hxx>
26 #include <TColgp_HArray1OfXYZ.hxx>
29 //=======================================================================
30 //function : RWStepVisual_RWCoordinatesList
32 //=======================================================================
33 RWStepVisual_RWCoordinatesList::RWStepVisual_RWCoordinatesList () {}
35 //=======================================================================
38 //=======================================================================
39 void RWStepVisual_RWCoordinatesList::ReadStep
40 (const Handle(StepData_StepReaderData)& data,
41 const Standard_Integer num,
42 Handle(Interface_Check)& ach,
43 const Handle(StepVisual_CoordinatesList)& ent) const
45 // Number of Parameter Control
46 if (!data->CheckNbParams(num, 3, ach, "coordinate list")) return;
48 // Inherited field : name
49 Handle(TCollection_HAsciiString) aName;
50 data->ReadString (num, 1, "name", ach, aName);
51 Standard_Integer nbP =0;
52 data->ReadInteger(num, 2, "number_points", ach,nbP);
54 Handle(TColgp_HArray1OfXYZ) aPoints;// = new TColgp_HArray1OfXYZ(1, nbP);
55 Standard_Integer nsub2;
56 if (data->ReadSubList (num,3,"items",ach,nsub2))
58 Standard_Integer nb2 = data->NbParams(nsub2);
61 aPoints = new TColgp_HArray1OfXYZ(1, nb2);
62 for (Standard_Integer i = 1; i <= nb2; i++)
64 gp_XYZ aXYZ(0.,0.,0.);
65 Standard_Integer nsub3;
66 if (data->ReadSubList (nsub2,i,"coordinates",ach,nsub3)) {
67 Standard_Integer nb3 = data->NbParams(nsub3);
69 ach->AddWarning("More than 3 coordinates, ignored");
71 Standard_Integer nbcoord = Min (nb3, 3);
72 for (Standard_Integer j = 1; j <= nbcoord; j++) {
73 Standard_Real aVal =0.;
74 if (data->ReadReal (nsub3,j,"coordinates",ach,aVal)) {
75 aXYZ.SetCoord(j, aVal);
80 aPoints->SetValue(i, aXYZ);
85 //--- Initialisation of the read entity ---
88 ent->Init(aName, aPoints);
91 //=======================================================================
92 //function : WriteStep
94 //=======================================================================
95 void RWStepVisual_RWCoordinatesList::WriteStep
96 (StepData_StepWriter& SW, const Handle(StepVisual_CoordinatesList)& ent) const
98 // Inherited field : name
101 // Own field : npoints
102 SW.Send(ent->Points()->Length());
104 // Own field : position_coords
106 for (Standard_Integer i = 1; i <= ent->Points()->Length(); i++) {
108 gp_XYZ aPoint = ent->Points()->Value(i);