0030277: Coding Rules - avoid extremely long class names in STEP packages
[occt.git] / src / RWStepVisual / RWStepVisual_RWCharacterizedObjAndRepresentationAndDraughtingModel.cxx
1 // Created on: 2016-08-25
2 // Created by: Irina KRYLOVA
3 // Copyright (c) 2016 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_RWCharacterizedObjAndRepresentationAndDraughtingModel.hxx>
20 #include <StepData_StepReaderData.hxx>
21 #include <StepData_StepWriter.hxx>
22 #include <StepRepr_RepresentationContext.hxx>
23 #include <StepVisual_CharacterizedObjAndRepresentationAndDraughtingModel.hxx>
24
25 //=======================================================================
26 //function : RWStepVisual_RWCharacterizedObjAndRepresentationAndDraughtingModel
27 //purpose  : 
28 //=======================================================================
29 RWStepVisual_RWCharacterizedObjAndRepresentationAndDraughtingModel::
30 RWStepVisual_RWCharacterizedObjAndRepresentationAndDraughtingModel()
31 {
32 }
33
34
35 //=======================================================================
36 //function : ReadStep
37 //purpose  : 
38 //=======================================================================
39
40 void RWStepVisual_RWCharacterizedObjAndRepresentationAndDraughtingModel::ReadStep
41   (const Handle(StepData_StepReaderData)& data,
42    const Standard_Integer num0, Handle(Interface_Check)& ach,
43    const Handle(StepVisual_CharacterizedObjAndRepresentationAndDraughtingModel)& ent) const
44 {
45   Standard_Integer num = 0;
46   data->NamedForComplex("REPRESENTATION","RPRSNT", num0, num, ach);
47   if (!data->CheckNbParams(num, 3, ach, "shape_aspect")) return;
48
49   // name
50   Handle(TCollection_HAsciiString) aName;
51   data->ReadString(num, 1, "name", ach, aName);
52
53   // items
54   Handle(StepRepr_HArray1OfRepresentationItem) anItems;
55   Handle(StepRepr_RepresentationItem) anItem;
56   Standard_Integer nsub;
57   if (data->ReadSubList(num, 2, "items", ach, nsub)) {
58     Standard_Integer nb = data->NbParams(nsub);
59     anItems = new StepRepr_HArray1OfRepresentationItem(1, nb);
60     for (Standard_Integer i = 1; i <= nb; i++) {
61       if (data->ReadEntity(nsub, i, "representation_item", ach,
62         STANDARD_TYPE(StepRepr_RepresentationItem), anItem))
63         anItems->SetValue(i, anItem);
64     }
65   }
66
67   // context_of_items
68   Handle(StepRepr_RepresentationContext) aContextOfItems;
69   data->ReadEntity(num, 3, "context_of_items", ach, STANDARD_TYPE(StepRepr_RepresentationContext), aContextOfItems);
70
71   // Initialize the entity
72   ent->Init(aName, anItems, aContextOfItems);
73 }
74
75
76 //=======================================================================
77 //function : WriteStep
78 //purpose  : 
79 //=======================================================================
80
81 void RWStepVisual_RWCharacterizedObjAndRepresentationAndDraughtingModel::WriteStep
82   (StepData_StepWriter& SW,
83   const Handle(StepVisual_CharacterizedObjAndRepresentationAndDraughtingModel)& ent) const
84 {
85   SW.StartEntity("CHARACTERIZED_OBJECT");
86   SW.SendDerived();
87   SW.SendDerived();
88   SW.StartEntity("CHARACTERIZED_REPRESENTATION");
89   SW.StartEntity("DRAUGHTING_MODEL");
90   SW.StartEntity("REPRESENTATION");
91   SW.Send(ent->Name());
92   SW.OpenSub();
93   for (Standard_Integer i = 1; i <= ent->NbItems(); i++) {
94     SW.Send(ent->ItemsValue(i));
95   }
96   SW.CloseSub();
97   SW.Send(ent->ContextOfItems());
98 }
99
100
101 //=======================================================================
102 //function : Share
103 //purpose  : 
104 //=======================================================================
105
106 void RWStepVisual_RWCharacterizedObjAndRepresentationAndDraughtingModel::Share
107 (const Handle(StepVisual_CharacterizedObjAndRepresentationAndDraughtingModel)& ent,
108    Interface_EntityIterator& iter) const
109 {
110   Standard_Integer nbElem = ent->NbItems();
111   for (Standard_Integer i = 1; i <= nbElem; i++) {
112     iter.GetOneItem(ent->ItemsValue(i));
113   }
114   iter.GetOneItem(ent->ContextOfItems());
115 }