0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / IGESAppli / IGESAppli_ToolNodalConstraint.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_NodalConstraint.hxx>
20 #include <IGESAppli_Node.hxx>
21 #include <IGESAppli_ToolNodalConstraint.hxx>
22 #include <IGESData_DirChecker.hxx>
23 #include <IGESData_Dump.hxx>
24 #include <IGESData_IGESDumper.hxx>
25 #include <IGESData_IGESReaderData.hxx>
26 #include <IGESData_IGESWriter.hxx>
27 #include <IGESData_ParamCursor.hxx>
28 #include <IGESData_ParamReader.hxx>
29 #include <IGESDefs_HArray1OfTabularData.hxx>
30 #include <IGESDefs_TabularData.hxx>
31 #include <Interface_Check.hxx>
32 #include <Interface_CopyTool.hxx>
33 #include <Interface_EntityIterator.hxx>
34 #include <Interface_Macros.hxx>
35 #include <Interface_ShareTool.hxx>
36 #include <Message_Messenger.hxx>
37 #include <Standard_DomainError.hxx>
38
39 IGESAppli_ToolNodalConstraint::IGESAppli_ToolNodalConstraint ()    {  }
40
41
42 void  IGESAppli_ToolNodalConstraint::ReadOwnParams
43   (const Handle(IGESAppli_NodalConstraint)& ent,
44    const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR)  const
45 {
46   //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
47   Standard_Integer num, i;
48   Standard_Integer tempType;
49   Handle(IGESAppli_Node) tempNode;
50   Handle(IGESDefs_HArray1OfTabularData) tempTabularDataProps;
51   if (!PR.ReadInteger(PR.Current(), "Number of cases", num)) num = 0;
52   if (num > 0)  tempTabularDataProps = new IGESDefs_HArray1OfTabularData(1, num);
53   else  PR.AddFail("Number of cases: Not Positive");
54   //szv#4:S4163:12Mar99 `st=` not needed
55   PR.ReadInteger(PR.Current(), "Type of Constraint", tempType);
56   PR.ReadEntity(IR, PR.Current(), "Node", STANDARD_TYPE(IGESAppli_Node), tempNode);
57
58   if (!tempTabularDataProps.IsNull())
59     for ( i = 1; i <= num; i++ )
60       {
61         Handle(IGESDefs_TabularData) tempEntity;
62         //szv#4:S4163:12Mar99 moved in if
63         if (PR.ReadEntity(IR, PR.Current(), "Tabular Data Property",
64                           STANDARD_TYPE(IGESDefs_TabularData), tempEntity))
65           tempTabularDataProps->SetValue(i, tempEntity);
66       }
67   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
68   ent->Init (tempType, tempNode, tempTabularDataProps);
69 }
70
71 void  IGESAppli_ToolNodalConstraint::WriteOwnParams
72   (const Handle(IGESAppli_NodalConstraint)& ent, IGESData_IGESWriter& IW) const
73 {
74   Standard_Integer i, num;
75   IW.Send(ent->NbCases());
76   IW.Send(ent->Type());
77   IW.Send(ent->NodeEntity());
78   for ( num = ent->NbCases(), i = 1; i <= num; i++ )
79     IW.Send(ent->TabularData(i));
80 }
81
82 void  IGESAppli_ToolNodalConstraint::OwnShared
83   (const Handle(IGESAppli_NodalConstraint)& ent, Interface_EntityIterator& iter) const
84 {
85   Standard_Integer i, num;
86   iter.GetOneItem(ent->NodeEntity());
87   for ( num = ent->NbCases(), i = 1; i <= num; i++ )
88     iter.GetOneItem(ent->TabularData(i));
89 }
90
91 void  IGESAppli_ToolNodalConstraint::OwnCopy
92   (const Handle(IGESAppli_NodalConstraint)& another,
93    const Handle(IGESAppli_NodalConstraint)& ent, Interface_CopyTool& TC) const
94 {
95   Standard_Integer num = another->NbCases();
96   Standard_Integer tempType = another->Type();
97   DeclareAndCast(IGESAppli_Node, tempNode,
98                  TC.Transferred(another->NodeEntity()));
99   Handle(IGESDefs_HArray1OfTabularData) tempTabularDataProps =
100     new IGESDefs_HArray1OfTabularData(1, num);
101   for ( Standard_Integer i = 1; i <= num; i++ )
102     {
103       DeclareAndCast(IGESDefs_TabularData, new_item,
104                      TC.Transferred(another->TabularData(i)));
105       tempTabularDataProps->SetValue(i, new_item);
106     }
107   ent->Init(tempType, tempNode, tempTabularDataProps);
108 }
109
110 IGESData_DirChecker  IGESAppli_ToolNodalConstraint::DirChecker
111   (const Handle(IGESAppli_NodalConstraint)& /* ent */ ) const
112 {
113   IGESData_DirChecker DC(418, 0);
114   DC.Structure(IGESData_DefVoid);
115   DC.GraphicsIgnored();
116   DC.LineFont(IGESData_DefVoid);
117   DC.LineWeight(IGESData_DefVoid);
118   DC.Color(IGESData_DefVoid);
119   DC.HierarchyStatusIgnored();
120   return DC;
121 }
122
123 void  IGESAppli_ToolNodalConstraint::OwnCheck
124   (const Handle(IGESAppli_NodalConstraint)& ent,
125    const Interface_ShareTool& , Handle(Interface_Check)& ach) const
126 {
127   if ((ent->Type() != 1) && (ent->Type() != 2))
128     ach->AddFail("Type of Constraint != 1,2");
129 }
130
131 void  IGESAppli_ToolNodalConstraint::OwnDump
132   (const Handle(IGESAppli_NodalConstraint)& ent, const IGESData_IGESDumper& dumper,
133    Standard_OStream& S, const Standard_Integer level) const
134 {
135   Standard_Integer sublevel = (level > 4) ? 1 : 0;
136   S << "IGESAppli_NodalConstraint\n";
137   S << "Type of Constraint : " << ent->Type() << "\n";
138   S << "Node : ";
139   dumper.Dump(ent->NodeEntity(),S, sublevel);
140   S << "\n";
141   S << "Tabular Data Properties : ";
142   IGESData_DumpEntities(S,dumper ,level,1, ent->NbCases(),ent->TabularData);
143   S << std::endl;
144 }