0024624: Lost word in license statement in source files
[occt.git] / src / IGESDefs / IGESDefs_ToolAssociativityDef.cxx
1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 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 //--------------------------------------------------------------------
18
19 #include <IGESDefs_ToolAssociativityDef.ixx>
20 #include <IGESData_ParamCursor.hxx>
21 #include <IGESBasic_HArray1OfHArray1OfInteger.hxx>
22 #include <TColStd_HArray1OfInteger.hxx>
23 #include <IGESData_Dump.hxx>
24 #include <Interface_Macros.hxx>
25
26
27 IGESDefs_ToolAssociativityDef::IGESDefs_ToolAssociativityDef ()    {  }
28
29
30 void  IGESDefs_ToolAssociativityDef::ReadOwnParams
31   (const Handle(IGESDefs_AssociativityDef)& ent,
32    const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const
33
34   //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
35   Handle(TColStd_HArray1OfInteger) requirements;
36   Handle(TColStd_HArray1OfInteger) orders;
37   Handle(TColStd_HArray1OfInteger) numItems;
38   Handle(IGESBasic_HArray1OfHArray1OfInteger) items;
39   Standard_Integer nbval;
40
41   Standard_Boolean st = PR.ReadInteger(PR.Current(), "No. of Class definitions", nbval);
42   if (st && nbval > 0)
43     {
44       requirements = new TColStd_HArray1OfInteger(1, nbval);
45       orders = new TColStd_HArray1OfInteger(1, nbval);
46       numItems = new TColStd_HArray1OfInteger(1, nbval);
47       items = new IGESBasic_HArray1OfHArray1OfInteger(1, nbval);
48     }
49   else  PR.AddFail("No. of Class definitions: Not Positive");
50
51   if ( ! requirements.IsNull())
52     for (Standard_Integer i = 1; i <= nbval; i++)
53       {
54         Standard_Integer requirement;
55         Standard_Integer order;
56         Standard_Integer numItem;
57         Handle(TColStd_HArray1OfInteger) item;
58
59         //st = PR.ReadInteger(PR.Current(), "Back Pointer Requirement", requirement); //szv#4:S4163:12Mar99 moved in if
60         if (PR.ReadInteger(PR.Current(), "Back Pointer Requirement", requirement))
61           requirements->SetValue(i, requirement);
62         
63         //st = PR.ReadInteger(PR.Current(), "Ordered/Unordered Class", order); //szv#4:S4163:12Mar99 moved in if
64         if (PR.ReadInteger(PR.Current(), "Ordered/Unordered Class", order))
65           orders->SetValue(i, order);
66         
67         //st = PR.ReadInteger(PR.Current(),"No. of items per entry", numItem); //szv#4:S4163:12Mar99 moved in if
68         if (PR.ReadInteger(PR.Current(),"No. of items per entry", numItem)) {
69           Standard_Integer temp;
70           numItems->SetValue(i, numItem);
71           item = new TColStd_HArray1OfInteger(1, numItem);
72           for (Standard_Integer j = 1; j <= numItem; j++)
73             {
74               //Standard_Integer temp; //szv#4:S4163:12Mar99 moved out of for
75               //st = PR.ReadInteger(PR.Current(), "Item", temp); //szv#4:S4163:12Mar99 moved in if
76               if (PR.ReadInteger(PR.Current(), "Item", temp))
77                 item->SetValue(j, temp);
78             }
79           items->SetValue(i, item);
80         }
81       }
82
83   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
84   ent->Init(requirements, orders, numItems, items);
85 }
86
87 void  IGESDefs_ToolAssociativityDef::WriteOwnParams
88   (const Handle(IGESDefs_AssociativityDef)& ent, IGESData_IGESWriter& IW) const 
89
90   Standard_Integer upper = ent->NbClassDefs();
91   IW.Send(upper); 
92   for (Standard_Integer i = 1; i <= upper; i++) {
93     IW.Send(ent->BackPointerReq(i));
94     IW.Send(ent->ClassOrder(i));
95     IW.Send(ent->NbItemsPerClass(i));
96     Standard_Integer items = ent->NbItemsPerClass(i);
97     for (Standard_Integer j = 1; j <= items; j++)
98       IW.Send(ent->Item(i,j));
99   }
100 }
101
102 void  IGESDefs_ToolAssociativityDef::OwnShared
103   (const Handle(IGESDefs_AssociativityDef)& /* ent */, Interface_EntityIterator& /* iter */) const
104 {
105 }
106
107 void  IGESDefs_ToolAssociativityDef::OwnCopy
108   (const Handle(IGESDefs_AssociativityDef)& another,
109    const Handle(IGESDefs_AssociativityDef)& ent, Interface_CopyTool& /* TC */) const
110
111
112   Handle(TColStd_HArray1OfInteger) requirements;
113   Handle(TColStd_HArray1OfInteger) orders;
114   Handle(TColStd_HArray1OfInteger) numItems;
115   Handle(IGESBasic_HArray1OfHArray1OfInteger) items;
116
117   Standard_Integer nbval = another->NbClassDefs();
118
119   requirements = new TColStd_HArray1OfInteger(1, nbval);
120   orders = new TColStd_HArray1OfInteger(1, nbval);
121   numItems = new TColStd_HArray1OfInteger(1, nbval);
122   items = new IGESBasic_HArray1OfHArray1OfInteger(1, nbval);
123
124   for (Standard_Integer i = 1; i <= nbval; i++)
125     {
126       Standard_Integer requirement = another->BackPointerReq(i);
127       requirements->SetValue(i, requirement);
128       Standard_Integer order = another->ClassOrder(i);
129       orders->SetValue(i, order);
130       Standard_Integer numItem = another->NbItemsPerClass(i);
131       numItems->SetValue(i, numItem);
132       Handle(TColStd_HArray1OfInteger) item;
133       item = new TColStd_HArray1OfInteger(1, numItem);
134
135       for (Standard_Integer j = 1; j <= numItem; j++)
136         {
137           Standard_Integer temp = another->Item(i, j);
138           item->SetValue(j, temp);
139         }
140       items->SetValue(i, item);
141     }
142   ent->Init(requirements, orders, numItems, items);
143   ent->SetFormNumber (another->FormNumber());
144 }
145
146 IGESData_DirChecker  IGESDefs_ToolAssociativityDef::DirChecker
147   (const Handle(IGESDefs_AssociativityDef)& /* ent */ ) const 
148
149   IGESData_DirChecker DC (302, 5001, 9999);
150   DC.Structure(IGESData_DefVoid);
151   DC.LineFont(IGESData_DefVoid);
152   DC.LineWeight(IGESData_DefVoid);
153   DC.Color(IGESData_DefVoid);
154   DC.BlankStatusIgnored();
155   DC.SubordinateStatusRequired(0);
156   DC.UseFlagRequired(2);
157   DC.HierarchyStatusIgnored();
158   return DC;
159 }
160
161 void  IGESDefs_ToolAssociativityDef::OwnCheck
162   (const Handle(IGESDefs_AssociativityDef)& /* ent */,
163    const Interface_ShareTool& , Handle(Interface_Check)& /* ach */) const 
164 {
165 }
166
167 void  IGESDefs_ToolAssociativityDef::OwnDump
168   (const Handle(IGESDefs_AssociativityDef)& ent, const IGESData_IGESDumper& /* dumper */,
169    const Handle(Message_Messenger)& S, const Standard_Integer level) const 
170
171   S << "IGESDefs_AssociativityDef" << endl;
172   S << "Number of Class Definitions : " << ent->NbClassDefs() << endl;
173   S << "Back Pointer Requirement  : " << endl; 
174   S << "Ordered / Unordered Class : " << endl;
175   S << "Number Of Items per Entry : " << endl;
176   S << "Items : " << endl; 
177   IGESData_DumpVals(S,-level,1, ent->NbClassDefs(),ent->BackPointerReq);
178   S << endl;
179   if (level > 4)
180     {
181 // Warning : Item is a JAGGED Array
182       Standard_Integer upper = ent->NbClassDefs();
183       for (Standard_Integer i = 1; i <= upper; i ++) {
184         S << "[" << i << "]: " << endl;
185         S << "Back Pointer Requirement : "  << ent->BackPointerReq(i) << "  ";
186         if (ent->IsBackPointerReq(i)) S << "(Yes)  ";
187         else                          S << "(No)   ";
188         S << " Ordered/Unordered Class : "  << ent->ClassOrder(i) << " ";
189         if (ent->IsOrdered(i)) S << "(Yes)" <<endl;
190         else                   S << "(No)"  <<endl;
191         S << "Number Of Items per Entry : " << ent->NbItemsPerClass(i);
192         if (level < 6) {
193           S << " [ask level > 5 for more]" << endl;
194           continue;
195         }
196         S << endl << " [";
197         for (Standard_Integer j = 1; j <= ent->NbItemsPerClass(i); j ++)
198           S << "  " << ent->Item(i,j);
199         S << "]" << endl;
200       }
201     }
202   S << endl;
203 }
204