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> |
7fd59977 |
16 | #include <Interface_EntityIterator.hxx> |
42cf5bc1 |
17 | #include <RWStepShape_RWLoopAndPath.hxx> |
18 | #include <StepData_StepReaderData.hxx> |
19 | #include <StepData_StepWriter.hxx> |
20 | #include <StepShape_HArray1OfOrientedEdge.hxx> |
21 | #include <StepShape_Loop.hxx> |
7fd59977 |
22 | #include <StepShape_LoopAndPath.hxx> |
42cf5bc1 |
23 | #include <StepShape_OrientedEdge.hxx> |
24 | #include <StepShape_Path.hxx> |
7fd59977 |
25 | |
26 | RWStepShape_RWLoopAndPath::RWStepShape_RWLoopAndPath () {} |
27 | |
28 | void RWStepShape_RWLoopAndPath::ReadStep |
29 | (const Handle(StepData_StepReaderData)& data, |
30 | const Standard_Integer num0, |
31 | Handle(Interface_Check)& ach, |
32 | const Handle(StepShape_LoopAndPath)& ent) const |
33 | { |
34 | |
35 | Standard_Integer num = num0; |
36 | |
37 | |
38 | // --- Instance of plex componant Loop --- |
39 | |
40 | if (!data->CheckNbParams(num,0,ach,"loop")) return; |
41 | |
42 | num = data->NextForComplex(num); |
43 | |
44 | // --- Instance of plex componant Path --- |
45 | |
46 | if (!data->CheckNbParams(num,1,ach,"path")) return; |
47 | |
48 | // --- field : edgeList --- |
49 | |
50 | Handle(StepShape_HArray1OfOrientedEdge) aEdgeList; |
51 | Handle(StepShape_OrientedEdge) anent1; |
52 | Standard_Integer nsub1; |
53 | if (data->ReadSubList (num,1,"edge_list",ach,nsub1)) { |
54 | Standard_Integer nb1 = data->NbParams(nsub1); |
55 | aEdgeList = new StepShape_HArray1OfOrientedEdge (1, nb1); |
56 | for (Standard_Integer i1 = 1; i1 <= nb1; i1 ++) { |
57 | //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed |
58 | if (data->ReadEntity (nsub1, i1,"oriented_edge", ach, STANDARD_TYPE(StepShape_OrientedEdge), anent1)) |
59 | aEdgeList->SetValue(i1, anent1); |
60 | } |
61 | } |
62 | |
63 | num = data->NextForComplex(num); |
64 | |
65 | // --- Instance of plex componant RepresentationItem --- |
66 | |
67 | if (!data->CheckNbParams(num,1,ach,"representation_item")) return; |
68 | |
69 | // --- field : name --- |
70 | |
71 | Handle(TCollection_HAsciiString) aName; |
72 | //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed |
73 | data->ReadString (num,1,"name",ach,aName); |
74 | |
75 | num = data->NextForComplex(num); |
76 | |
77 | // --- Instance of common supertype TopologicalRepresentationItem --- |
78 | |
79 | if (!data->CheckNbParams(num,0,ach,"topological_representation_item")) return; |
80 | |
81 | //--- Initialisation of the red entity --- |
82 | |
83 | ent->Init(aName,aEdgeList); |
84 | } |
85 | |
86 | |
87 | void RWStepShape_RWLoopAndPath::WriteStep |
88 | (StepData_StepWriter& SW, |
89 | const Handle(StepShape_LoopAndPath)& ent) const |
90 | { |
91 | |
92 | // --- Instance of plex componant Loop --- |
93 | |
94 | SW.StartEntity("LOOP"); |
95 | |
96 | // --- Instance of plex componant Path --- |
97 | |
98 | SW.StartEntity("PATH"); |
99 | // --- field : edgeList --- |
100 | |
101 | SW.OpenSub(); |
102 | for (Standard_Integer i1 = 1; i1 <= ent->NbEdgeList(); i1 ++) { |
103 | SW.Send(ent->EdgeListValue(i1)); |
104 | } |
105 | SW.CloseSub(); |
106 | |
107 | // --- Instance of plex componant RepresentationItem --- |
108 | |
109 | SW.StartEntity("REPRESENTATION_ITEM"); |
110 | // --- field : name --- |
111 | |
112 | SW.Send(ent->Name()); |
113 | |
114 | // --- Instance of common supertype TopologicalRepresentationItem --- |
115 | |
116 | SW.StartEntity("TOPOLOGICAL_REPRESENTATION_ITEM"); |
117 | } |
118 | |
119 | |
120 | void RWStepShape_RWLoopAndPath::Share(const Handle(StepShape_LoopAndPath)& ent, Interface_EntityIterator& iter) const |
121 | { |
122 | |
123 | Standard_Integer nbElem1 = ent->NbEdgeList(); |
124 | for (Standard_Integer is1=1; is1<=nbElem1; is1 ++) { |
125 | iter.GetOneItem(ent->EdgeListValue(is1)); |
126 | } |
127 | |
128 | } |
129 | |