0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / RWStepGeom / RWStepGeom_RWIntersectionCurve.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
42cf5bc1 14
15#include <Interface_Check.hxx>
16#include <Interface_EntityIterator.hxx>
17#include <RWStepGeom_RWIntersectionCurve.hxx>
18#include <StepData_StepReaderData.hxx>
19#include <StepData_StepWriter.hxx>
7fd59977 20#include <StepGeom_Curve.hxx>
21#include <StepGeom_HArray1OfPcurveOrSurface.hxx>
42cf5bc1 22#include <StepGeom_IntersectionCurve.hxx>
7fd59977 23#include <StepGeom_PcurveOrSurface.hxx>
24#include <StepGeom_PreferredSurfaceCurveRepresentation.hxx>
25
b311480e 26// --- Enum : PreferredSurfaceCurveRepresentation ---
7fd59977 27static TCollection_AsciiString pscrPcurveS2(".PCURVE_S2.");
28static TCollection_AsciiString pscrPcurveS1(".PCURVE_S1.");
29static TCollection_AsciiString pscrCurve3d(".CURVE_3D.");
30
31RWStepGeom_RWIntersectionCurve::RWStepGeom_RWIntersectionCurve () {}
32
33void RWStepGeom_RWIntersectionCurve::ReadStep
34 (const Handle(StepData_StepReaderData)& data,
35 const Standard_Integer num,
36 Handle(Interface_Check)& ach,
37 const Handle(StepGeom_IntersectionCurve)& ent) const
38{
39
40
41 // --- Number of Parameter Control ---
42
43 if (!data->CheckNbParams(num,4,ach,"intersection_curve")) return;
44
45 // --- inherited field : name ---
46
47 Handle(TCollection_HAsciiString) aName;
48 //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
49 data->ReadString (num,1,"name",ach,aName);
50
51 // --- inherited field : curve3d ---
52
53 Handle(StepGeom_Curve) aCurve3d;
54 //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
55 data->ReadEntity(num, 2,"curve_3d", ach, STANDARD_TYPE(StepGeom_Curve), aCurve3d);
56
57 // --- inherited field : associatedGeometry ---
58
59 Handle(StepGeom_HArray1OfPcurveOrSurface) aAssociatedGeometry;
60 StepGeom_PcurveOrSurface aAssociatedGeometryItem;
61 Standard_Integer nsub3;
62 if (data->ReadSubList (num,3,"associated_geometry",ach,nsub3)) {
63 Standard_Integer nb3 = data->NbParams(nsub3);
64 aAssociatedGeometry = new StepGeom_HArray1OfPcurveOrSurface (1, nb3);
65 for (Standard_Integer i3 = 1; i3 <= nb3; i3 ++) {
66 //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
67 if (data->ReadEntity (nsub3,i3,"associated_geometry",ach,aAssociatedGeometryItem))
68 aAssociatedGeometry->SetValue(i3,aAssociatedGeometryItem);
69 }
70 }
71
72 // --- inherited field : masterRepresentation ---
73
74 StepGeom_PreferredSurfaceCurveRepresentation aMasterRepresentation = StepGeom_pscrCurve3d;
75 if (data->ParamType(num,4) == Interface_ParamEnum) {
76 Standard_CString text = data->ParamCValue(num,4);
77 if (pscrPcurveS2.IsEqual(text)) aMasterRepresentation = StepGeom_pscrPcurveS2;
78 else if (pscrPcurveS1.IsEqual(text)) aMasterRepresentation = StepGeom_pscrPcurveS1;
79 else if (pscrCurve3d.IsEqual(text)) aMasterRepresentation = StepGeom_pscrCurve3d;
80 else ach->AddFail("Enumeration preferred_surface_curve_representation has not an allowed value");
81 }
82 else ach->AddFail("Parameter #4 (master_representation) is not an enumeration");
83
84 //--- Initialisation of the read entity ---
85
86
87 ent->Init(aName, aCurve3d, aAssociatedGeometry, aMasterRepresentation);
88}
89
90
91void RWStepGeom_RWIntersectionCurve::WriteStep
92 (StepData_StepWriter& SW,
93 const Handle(StepGeom_IntersectionCurve)& ent) const
94{
95
96 // --- inherited field name ---
97
98 SW.Send(ent->Name());
99
100 // --- inherited field curve3d ---
101
102 SW.Send(ent->Curve3d());
103
104 // --- inherited field associatedGeometry ---
105
106 SW.OpenSub();
107 for (Standard_Integer i3 = 1; i3 <= ent->NbAssociatedGeometry(); i3 ++) {
108 SW.Send(ent->AssociatedGeometryValue(i3).Value());
109 }
110 SW.CloseSub();
111
112 // --- inherited field masterRepresentation ---
113
114 switch(ent->MasterRepresentation()) {
115 case StepGeom_pscrPcurveS2 : SW.SendEnum (pscrPcurveS2); break;
116 case StepGeom_pscrPcurveS1 : SW.SendEnum (pscrPcurveS1); break;
117 case StepGeom_pscrCurve3d : SW.SendEnum (pscrCurve3d); break;
118 }
119}
120
121
122void RWStepGeom_RWIntersectionCurve::Share(const Handle(StepGeom_IntersectionCurve)& ent, Interface_EntityIterator& iter) const
123{
124
125 iter.GetOneItem(ent->Curve3d());
126
127
128 Standard_Integer nbElem2 = ent->NbAssociatedGeometry();
129 for (Standard_Integer is2=1; is2<=nbElem2; is2 ++) {
130 iter.GetOneItem(ent->AssociatedGeometryValue(is2).Value());
131 }
132
133}
134