1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <RWStepGeom_RWCartesianPoint.ixx>
15 //#include <TColStd_HArray1OfReal.hxx>
16 #include <TCollection_HAsciiString.hxx>
19 RWStepGeom_RWCartesianPoint::RWStepGeom_RWCartesianPoint () {}
21 void RWStepGeom_RWCartesianPoint::ReadStep
22 (const Handle(StepData_StepReaderData)& data,
23 const Standard_Integer num,
24 Handle(Interface_Check)& ach,
25 const Handle(StepGeom_CartesianPoint)& ent) const
29 // --- Number of Parameter Control ---
31 if (!data->CheckNbParams(num,2,ach,"cartesian_point")) return;
33 // --- inherited field : name ---
35 Handle(TCollection_HAsciiString) aName;
36 //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
38 if (!data->ReadString (num,1,"name",ach,aName)) {
39 ach->Mend("Set to empty string");
40 aName = new TCollection_HAsciiString;
43 // --- own field : coordinates ---
44 // OPTIMISED : X Y Z directly read and set
46 // Handle(TColStd_HArray1OfReal) aCoordinates;
47 Standard_Real aCoordinatesItem;
48 Standard_Integer nsub2, nbcoord=0;
49 Standard_Real XYZ[3] = {0.,0.,0.};
50 if (data->ReadSubList (num,2,"coordinates",ach,nsub2)) {
51 Standard_Integer nb2 = data->NbParams(nsub2);
53 ach->AddWarning("More than 3 coordinates, ignored");
55 nbcoord = Min (nb2, 3);
56 for (Standard_Integer i2 = 0; i2 < nbcoord; i2 ++) {
57 if (data->ReadReal (nsub2,i2+1,"coordinates",ach,aCoordinatesItem)) {
58 XYZ[i2] = aCoordinatesItem;
63 //--- Initialisation of the read entity ---
66 // ent->Init(aName, aCoordinates);
67 if (nbcoord == 3) ent->Init3D (aName, XYZ[0],XYZ[1],XYZ[2]);
68 else ent->Init2D (aName, XYZ[0],XYZ[1]);
72 void RWStepGeom_RWCartesianPoint::WriteStep
73 (StepData_StepWriter& SW,
74 const Handle(StepGeom_CartesianPoint)& ent) const
77 // --- inherited field name ---
81 // --- own field : coordinates ---
84 for (Standard_Integer i2 = 1; i2 <= ent->NbCoordinates(); i2 ++) {
85 SW.Send(ent->CoordinatesValue(i2));