5df609e7 |
1 | // Created on: 2015-10-29 |
2 | // Created by: Irina KRYLOVA |
3 | // Copyright (c) 2015 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
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. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
16 | |
17 | #include <Interface_Check.hxx> |
18 | #include <Interface_EntityIterator.hxx> |
19 | #include <RWStepVisual_RWTessellatedCurveSet.hxx> |
20 | #include <StepData_StepReaderData.hxx> |
21 | #include <StepData_StepWriter.hxx> |
22 | #include <StepRepr_RepresentationItem.hxx> |
23 | #include <StepVisual_CoordinatesList.hxx> |
24 | #include <StepVisual_TessellatedCurveSet.hxx> |
25 | |
26 | //======================================================================= |
27 | //function : RWStepVisual_RWTessellatedCurveSet |
28 | //purpose : |
29 | //======================================================================= |
30 | RWStepVisual_RWTessellatedCurveSet::RWStepVisual_RWTessellatedCurveSet () {} |
31 | |
32 | //======================================================================= |
33 | //function : ReadStep |
34 | //purpose : |
35 | //======================================================================= |
36 | void RWStepVisual_RWTessellatedCurveSet::ReadStep |
37 | (const Handle(StepData_StepReaderData)& data, |
38 | const Standard_Integer num, |
39 | Handle(Interface_Check)& ach, |
40 | const Handle(StepVisual_TessellatedCurveSet)& ent) const |
41 | { |
42 | // Number of Parameter Control |
43 | if (!data->CheckNbParams(num, 3, ach, "tessellated_curve_set")) return; |
44 | |
45 | // Inherited field : name |
46 | Handle(TCollection_HAsciiString) aName; |
47 | data->ReadString (num, 1, "name", ach, aName); |
48 | |
49 | Handle(StepVisual_CoordinatesList) aCoordList; |
50 | data->ReadEntity (num, 2,"coord_list",ach,STANDARD_TYPE(StepVisual_CoordinatesList), aCoordList); |
51 | //--- Initialisation of the read entity --- |
52 | Standard_Integer nsub2; |
53 | NCollection_Handle<StepVisual_VectorOfHSequenceOfInteger> aCurves = new StepVisual_VectorOfHSequenceOfInteger; |
54 | if (data->ReadSubList (num,3,"curves",ach,nsub2)) |
55 | { |
56 | Standard_Integer nb2 = data->NbParams(nsub2); |
57 | if( !nb2) |
58 | return; |
59 | |
60 | for (Standard_Integer i = 1; i <= nb2; i++) |
61 | { |
62 | Handle(TColStd_HSequenceOfInteger) aCurve = new TColStd_HSequenceOfInteger; |
63 | Standard_Integer nsub3; |
64 | if (data->ReadSubList (nsub2,i,"number_coordinates",ach,nsub3)) { |
65 | Standard_Integer nb3 = data->NbParams(nsub3); |
66 | for (Standard_Integer j = 1; j <= nb3; j++) { |
67 | Standard_Integer aVal =0; |
68 | if (data->ReadInteger (nsub3,j,"coordinates",ach,aVal)) |
69 | aCurve->Append(aVal); |
70 | |
71 | } |
72 | aCurves->Append(aCurve); |
73 | |
74 | } |
75 | } |
76 | } |
77 | ent->Init(aName, aCoordList, aCurves); |
78 | |
79 | } |
80 | |
81 | //======================================================================= |
82 | //function : WriteStep |
83 | //purpose : |
84 | //======================================================================= |
85 | void RWStepVisual_RWTessellatedCurveSet::WriteStep |
86 | (StepData_StepWriter& SW, |
87 | const Handle(StepVisual_TessellatedCurveSet)& ent) const |
88 | { |
89 | // Inherited field : name |
90 | SW.Send(ent->Name()); |
91 | |
92 | // Own filed : coordinates |
93 | SW.Send(ent->CoordList()); |
94 | |
95 | // Own field : line_strips |
96 | SW.OpenSub(); |
97 | for (Standard_Integer curveIt = 0; curveIt < ent->Curves()->Length(); curveIt++) { |
98 | Handle(TColStd_HSequenceOfInteger) aCurve = ent->Curves()->Value(curveIt); |
99 | SW.OpenSub(); |
100 | for (Standard_Integer i = 1; i <= aCurve->Length(); i++) |
101 | SW.Send(aCurve->Value(i)); |
102 | SW.CloseSub(); |
103 | } |
104 | SW.CloseSub(); |
105 | } |
b0cef606 |
106 | |
107 | //======================================================================= |
108 | //function : Share |
109 | //purpose : |
110 | //======================================================================= |
111 | void RWStepVisual_RWTessellatedCurveSet::Share (const Handle(StepVisual_TessellatedCurveSet) &ent, |
112 | Interface_EntityIterator& iter) const |
113 | { |
114 | // Own filed : coordinates |
115 | iter.AddItem (ent->CoordList()); |
116 | } |
117 | |