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 | #include <RWStepAP242_RWDraughtingModelItemAssociation.hxx> |
17 | #include <Interface_EntityIterator.hxx> |
18 | #include <StepData_StepReaderData.hxx> |
19 | #include <StepData_StepWriter.hxx> |
20 | #include <StepAP242_DraughtingModelItemAssociation.hxx> |
21 | #include <StepRepr_HArray1OfRepresentationItem.hxx> |
22 | #include <StepRepr_Representation.hxx> |
23 | |
24 | //======================================================================= |
25 | //function : RWStepAP242_RWDraughtingModelItemAssociation |
26 | //purpose : |
27 | //======================================================================= |
28 | RWStepAP242_RWDraughtingModelItemAssociation::RWStepAP242_RWDraughtingModelItemAssociation () {} |
29 | |
30 | //======================================================================= |
31 | //function : ReadStep |
32 | //purpose : |
33 | //======================================================================= |
34 | void RWStepAP242_RWDraughtingModelItemAssociation::ReadStep |
35 | (const Handle(StepData_StepReaderData)& data, |
36 | const Standard_Integer num, |
37 | Handle(Interface_Check)& ach, |
38 | const Handle(StepAP242_DraughtingModelItemAssociation)& ent) const |
39 | { |
40 | // Number of Parameter Control |
41 | if (!data->CheckNbParams(num,5,ach,"geometric_item_specific_usage")) return; |
42 | |
43 | // Inherited fields of ItemIdentifiedRepresentationUsage |
44 | Handle(TCollection_HAsciiString) aName; |
45 | data->ReadString (num,1,"item_identified_representation_usage.name",ach,aName); |
46 | |
47 | Handle(TCollection_HAsciiString) aDescription; |
48 | if (data->IsParamDefined (num,2)) { |
49 | data->ReadString (num,2,"item_identified_representation_usage.description",ach,aDescription); |
50 | } |
51 | |
52 | StepAP242_ItemIdentifiedRepresentationUsageDefinition aDefinition; |
53 | data->ReadEntity(num,3,"item_identified_representation_usage.definition",ach,aDefinition); |
54 | |
55 | Handle(StepRepr_Representation) aRepresentation; |
56 | data->ReadEntity (num,4,"item_identified_representation_usage.used_representation",ach,STANDARD_TYPE(StepRepr_Representation), aRepresentation); |
57 | |
58 | Handle(StepRepr_HArray1OfRepresentationItem) anItems; |
59 | Handle(StepRepr_RepresentationItem) anEnt; |
60 | Standard_Integer nbSub; |
61 | Interface_ParamType aType = data->ParamType(num, 5); |
62 | if (aType == Interface_ParamIdent) { |
63 | data->ReadEntity(num, 5,"item_identified_representation_usage.identified_item", ach, STANDARD_TYPE(StepRepr_RepresentationItem), anEnt); |
64 | anItems = new StepRepr_HArray1OfRepresentationItem (1, 1); |
65 | anItems->SetValue(1, anEnt); |
66 | } |
67 | else if (data->ReadSubList (num,5,"item_identified_representation_usage.identified_item",ach,nbSub)) { |
68 | Standard_Integer nbElements = data->NbParams(nbSub); |
69 | anItems = new StepRepr_HArray1OfRepresentationItem (1, nbElements); |
70 | for (Standard_Integer i = 1; i <= nbElements; i++) { |
71 | if (data->ReadEntity(nbSub, i,"representation_item", ach, |
72 | STANDARD_TYPE(StepRepr_RepresentationItem), anEnt)) |
73 | anItems->SetValue(i, anEnt); |
74 | } |
75 | } |
76 | |
77 | // Initialisation of the read entity |
78 | ent->Init(aName, aDescription, aDefinition, aRepresentation, anItems); |
79 | } |
80 | |
81 | //======================================================================= |
82 | //function : WriteStep |
83 | //purpose : |
84 | //======================================================================= |
85 | void RWStepAP242_RWDraughtingModelItemAssociation::WriteStep |
86 | (StepData_StepWriter& SW, |
87 | const Handle(StepAP242_DraughtingModelItemAssociation)& ent) const |
88 | { |
89 | // Inherited fields of ItemIdentifiedRepresentationUsage |
90 | SW.Send(ent->Name()); |
91 | |
92 | SW.Send(ent->Description()); |
93 | |
94 | SW.Send(ent->Definition().Value()); |
95 | |
96 | SW.Send(ent->UsedRepresentation()); |
97 | |
98 | if (ent->NbIdentifiedItem() == 1) |
99 | SW.Send(ent->IdentifiedItemValue(1)); |
100 | else { |
101 | SW.OpenSub(); |
102 | for (Standard_Integer i = 1; i <= ent->NbIdentifiedItem(); i++) { |
103 | SW.Send(ent->IdentifiedItemValue(i)); |
104 | } |
105 | SW.CloseSub(); |
106 | } |
107 | } |
108 | |
109 | //======================================================================= |
110 | //function : Share |
111 | //purpose : |
112 | //======================================================================= |
113 | void RWStepAP242_RWDraughtingModelItemAssociation::Share( |
114 | const Handle(StepAP242_DraughtingModelItemAssociation)& ent, |
115 | Interface_EntityIterator& iter) const |
116 | { |
117 | // Inherited fields of ItemIdentifiedRepresentationUsage |
118 | |
119 | iter.AddItem(ent->Definition().Value()); |
120 | Standard_Integer i, nb = ent->NbIdentifiedItem(); |
121 | for (i = 1; i <= nb; i++) |
122 | iter.AddItem (ent->IdentifiedItemValue(i)); |
123 | } |
124 | |