0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / RWStepGeom / RWStepGeom_RWDirection.cxx
CommitLineData
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
7fd59977 14
42cf5bc1 15#include <Interface_Check.hxx>
16#include <Interface_ShareTool.hxx>
17#include <RWStepGeom_RWDirection.hxx>
18#include <StepData_StepReaderData.hxx>
19#include <StepData_StepWriter.hxx>
20#include <StepGeom_Direction.hxx>
21#include <TColStd_HArray1OfReal.hxx>
7fd59977 22
23RWStepGeom_RWDirection::RWStepGeom_RWDirection () {}
24
25void RWStepGeom_RWDirection::ReadStep
26 (const Handle(StepData_StepReaderData)& data,
27 const Standard_Integer num,
28 Handle(Interface_Check)& ach,
29 const Handle(StepGeom_Direction)& ent) const
30{
31
32
33 // --- Number of Parameter Control ---
34
35 if (!data->CheckNbParams(num,2,ach,"direction")) return;
36
37 // --- inherited field : name ---
38
39 Handle(TCollection_HAsciiString) aName;
40 //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
41 data->ReadString (num,1,"name",ach,aName);
42
43 // --- own field : directionRatios ---
44
45 Handle(TColStd_HArray1OfReal) aDirectionRatios;
46 Standard_Real aDirectionRatiosItem;
47 Standard_Integer nsub2;
48 if (data->ReadSubList (num,2,"direction_ratios",ach,nsub2)) {
49 Standard_Integer nb2 = data->NbParams(nsub2);
50 aDirectionRatios = new TColStd_HArray1OfReal (1, nb2);
51 for (Standard_Integer i2 = 1; i2 <= nb2; i2 ++) {
52 //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
53 if (data->ReadReal (nsub2,i2,"direction_ratios",ach,aDirectionRatiosItem))
54 aDirectionRatios->SetValue(i2,aDirectionRatiosItem);
55 }
56 }
57
58 //--- Initialisation of the read entity ---
59
60
61 ent->Init(aName, aDirectionRatios);
62}
63
64
65void RWStepGeom_RWDirection::WriteStep
66 (StepData_StepWriter& SW,
67 const Handle(StepGeom_Direction)& ent) const
68{
69
70 // --- inherited field name ---
71
72 SW.Send(ent->Name());
73
74 // --- own field : directionRatios ---
75
76 SW.OpenSub();
77 for (Standard_Integer i2 = 1; i2 <= ent->NbDirectionRatios(); i2 ++) {
78 SW.Send(ent->DirectionRatiosValue(i2));
79 }
80 SW.CloseSub();
81}
82
83
84void RWStepGeom_RWDirection::Check
85 (const Handle(StepGeom_Direction)& ent,
86 const Interface_ShareTool& ,
87 Handle(Interface_Check)& ach) const
88{
89 Standard_Integer nbVal = ent->NbDirectionRatios();
90 Standard_Integer i;
91 for(i=1; i<=nbVal; i++) {
92 if(Abs(ent->DirectionRatiosValue(i)) >= RealEpsilon()) break;
93 }
94 if(i>nbVal) ach->AddFail("ERROR: DirectionRatios all 0.0");
95}