973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
7fd59977 |
13 | |
14 | #include <RWStepGeom_RWCartesianPoint.ixx> |
15 | //#include <TColStd_HArray1OfReal.hxx> |
16 | #include <TCollection_HAsciiString.hxx> |
17 | |
18 | |
19 | RWStepGeom_RWCartesianPoint::RWStepGeom_RWCartesianPoint () {} |
20 | |
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 |
26 | { |
27 | |
28 | |
29 | // --- Number of Parameter Control --- |
30 | |
31 | if (!data->CheckNbParams(num,2,ach,"cartesian_point")) return; |
32 | |
33 | // --- inherited field : name --- |
34 | |
35 | Handle(TCollection_HAsciiString) aName; |
36 | //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed |
37 | // Protected |
38 | if (!data->ReadString (num,1,"name",ach,aName)) { |
39 | ach->Mend("Set to empty string"); |
40 | aName = new TCollection_HAsciiString; |
41 | } |
42 | |
43 | // --- own field : coordinates --- |
44 | // OPTIMISED : X Y Z directly read and set |
45 | |
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); |
52 | if(nb2 > 3) { |
53 | ach->AddWarning("More than 3 coordinates, ignored"); |
54 | } |
4fc78302 |
55 | nbcoord = Min (nb2, 3); |
56 | for (Standard_Integer i2 = 0; i2 < nbcoord; i2 ++) { |
7fd59977 |
57 | if (data->ReadReal (nsub2,i2+1,"coordinates",ach,aCoordinatesItem)) { |
58 | XYZ[i2] = aCoordinatesItem; |
59 | } |
60 | } |
61 | } |
62 | |
63 | //--- Initialisation of the read entity --- |
64 | |
65 | |
66 | // ent->Init(aName, aCoordinates); |
4fc78302 |
67 | if (nbcoord == 3) ent->Init3D (aName, XYZ[0],XYZ[1],XYZ[2]); |
7fd59977 |
68 | else ent->Init2D (aName, XYZ[0],XYZ[1]); |
69 | } |
70 | |
71 | |
72 | void RWStepGeom_RWCartesianPoint::WriteStep |
73 | (StepData_StepWriter& SW, |
74 | const Handle(StepGeom_CartesianPoint)& ent) const |
75 | { |
76 | |
77 | // --- inherited field name --- |
78 | |
79 | SW.Send(ent->Name()); |
80 | |
81 | // --- own field : coordinates --- |
82 | |
83 | SW.OpenSub(); |
84 | for (Standard_Integer i2 = 1; i2 <= ent->NbCoordinates(); i2 ++) { |
85 | SW.Send(ent->CoordinatesValue(i2)); |
86 | } |
87 | SW.CloseSub(); |
88 | } |