0026377: Passing Handle objects as arguments to functions as non-const reference...
[occt.git] / src / IGESAppli / IGESAppli_ToolRegionRestriction.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 <IGESAppli_RegionRestriction.hxx>
20 #include <IGESAppli_ToolRegionRestriction.hxx>
21 #include <IGESData_DirChecker.hxx>
22 #include <IGESData_IGESDumper.hxx>
23 #include <IGESData_IGESReaderData.hxx>
24 #include <IGESData_IGESWriter.hxx>
25 #include <IGESData_LevelListEntity.hxx>
26 #include <IGESData_ParamCursor.hxx>
27 #include <IGESData_ParamReader.hxx>
28 #include <Interface_Check.hxx>
29 #include <Interface_CopyTool.hxx>
30 #include <Interface_EntityIterator.hxx>
31 #include <Interface_ShareTool.hxx>
32 #include <Message_Messenger.hxx>
33 #include <Standard_DomainError.hxx>
34
35 IGESAppli_ToolRegionRestriction::IGESAppli_ToolRegionRestriction ()    {  }
36
37
38 void  IGESAppli_ToolRegionRestriction::ReadOwnParams
39   (const Handle(IGESAppli_RegionRestriction)& ent,
40    const Handle(IGESData_IGESReaderData)& /*IR*/, IGESData_ParamReader& PR) const
41 {
42   Standard_Integer tempNbPropertyValues;
43   Standard_Integer tempElectViasRestrict;
44   Standard_Integer tempElectCompRestrict;
45   Standard_Integer tempElectCktRestrict;
46
47   PR.ReadInteger(PR.Current(),"No. of Property values",tempNbPropertyValues);
48   PR.ReadInteger(PR.Current(),"Electrical vias restriction",tempElectViasRestrict);
49   PR.ReadInteger(PR.Current(),"Electrical components restriction", tempElectCompRestrict);
50   PR.ReadInteger(PR.Current(), " Electrical circuitary restriction",tempElectCktRestrict);
51
52   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
53   ent->Init(tempNbPropertyValues,tempElectViasRestrict,tempElectCompRestrict, tempElectCktRestrict);
54 }
55
56 void  IGESAppli_ToolRegionRestriction::WriteOwnParams
57   (const Handle(IGESAppli_RegionRestriction)& ent, IGESData_IGESWriter& IW) const
58 {
59   IW.Send(ent->NbPropertyValues());
60   IW.Send(ent->ElectricalViasRestriction());
61   IW.Send(ent->ElectricalComponentRestriction());
62   IW.Send(ent->ElectricalCktRestriction());
63 }
64
65 void  IGESAppli_ToolRegionRestriction::OwnShared
66   (const Handle(IGESAppli_RegionRestriction)& /*ent*/, Interface_EntityIterator& /*iter*/) const
67 {
68 }
69
70 void  IGESAppli_ToolRegionRestriction::OwnCopy
71   (const Handle(IGESAppli_RegionRestriction)& another,
72    const Handle(IGESAppli_RegionRestriction)& ent, Interface_CopyTool& /*TC*/) const
73 {
74   ent->Init
75     (3,another->ElectricalViasRestriction(),
76      another->ElectricalComponentRestriction(),
77      another->ElectricalCktRestriction());    // nbprops = 3
78 }
79
80 Standard_Boolean  IGESAppli_ToolRegionRestriction::OwnCorrect
81   (const Handle(IGESAppli_RegionRestriction)& ent) const
82 {
83   Standard_Boolean res = (ent->NbPropertyValues() != 3);
84   if (res) ent->Init
85     (3,ent->ElectricalViasRestriction(),ent->ElectricalComponentRestriction(),
86      ent->ElectricalCktRestriction());    // nbprops = 3
87   if (ent->SubordinateStatus() != 0) {
88     Handle(IGESData_LevelListEntity) nulevel;
89     ent->InitLevel(nulevel,0);
90     res = Standard_True;
91   }
92   return res;    // + RAZ level selon subordibate
93 }
94
95 IGESData_DirChecker  IGESAppli_ToolRegionRestriction::DirChecker
96   (const Handle(IGESAppli_RegionRestriction)& /*ent*/ ) const
97 {
98   IGESData_DirChecker DC(406,2);  //Form no = 2 & Type = 406
99   DC.Structure(IGESData_DefVoid);
100   DC.GraphicsIgnored();
101   DC.BlankStatusIgnored();
102   DC.UseFlagIgnored();
103   DC.HierarchyStatusIgnored();
104   return DC;
105 }
106
107 void  IGESAppli_ToolRegionRestriction::OwnCheck
108   (const Handle(IGESAppli_RegionRestriction)& ent,
109    const Interface_ShareTool& , Handle(Interface_Check)& ach) const
110 {
111   if (ent->SubordinateStatus() != 0)
112     if (ent->DefLevel() != IGESData_DefOne &&
113         ent->DefLevel() != IGESData_DefSeveral)
114       ach->AddFail("Level type: Not value/reference");
115   if (ent->NbPropertyValues() != 3)
116     ach->AddFail("Number of Property Values != 3");
117   if (ent->ElectricalViasRestriction() < 0 || ent->ElectricalViasRestriction() > 2)
118     ach->AddFail("Incorrect value for Electrical Vias Restriction");
119   if (ent->ElectricalComponentRestriction() < 0 || ent->ElectricalComponentRestriction() > 2)
120     ach->AddFail("Incorrect value for Electrical Component Restriction");
121   if (ent->ElectricalCktRestriction() < 0 || ent->ElectricalCktRestriction() > 2)
122     ach->AddFail("Incorrect value for Electrical Circuit Restriction");
123   //UNFINISHED
124   //level ignored if this property is subordinate -- queried
125 }
126
127 void  IGESAppli_ToolRegionRestriction::OwnDump
128   (const Handle(IGESAppli_RegionRestriction)& ent, const IGESData_IGESDumper& /*dumper*/,
129    const Handle(Message_Messenger)& S, const Standard_Integer /*level*/) const
130 {
131   S << "IGESAppli_RegionRestriction" << endl;
132   S << "Number of property values : " << ent->NbPropertyValues() << endl;
133   S << "Electrical vias restriction       : "
134     << ent->ElectricalViasRestriction() << endl;
135   S << "Electrical components restriction : "
136     << ent->ElectricalComponentRestriction() << endl;
137   S << "Electrical circuitary restriction : "
138     << ent->ElectricalCktRestriction()  << endl;
139 }