022942667dbe7de6e78b064b0bf29cc53fb8f812
[occt.git] / src / IGESAppli / IGESAppli_ToolFiniteElement.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_FiniteElement.hxx>
20 #include <IGESAppli_HArray1OfNode.hxx>
21 #include <IGESAppli_Node.hxx>
22 #include <IGESAppli_ToolFiniteElement.hxx>
23 #include <IGESData_DirChecker.hxx>
24 #include <IGESData_Dump.hxx>
25 #include <IGESData_IGESDumper.hxx>
26 #include <IGESData_IGESReaderData.hxx>
27 #include <IGESData_IGESWriter.hxx>
28 #include <IGESData_ParamCursor.hxx>
29 #include <IGESData_ParamReader.hxx>
30 #include <Interface_Check.hxx>
31 #include <Interface_CopyTool.hxx>
32 #include <Interface_EntityIterator.hxx>
33 #include <Interface_Macros.hxx>
34 #include <Interface_ShareTool.hxx>
35 #include <Standard_DomainError.hxx>
36 #include <TCollection_HAsciiString.hxx>
37
38 IGESAppli_ToolFiniteElement::IGESAppli_ToolFiniteElement ()    {  }
39
40
41 void  IGESAppli_ToolFiniteElement::ReadOwnParams
42   (const Handle(IGESAppli_FiniteElement)& ent,
43    const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
44 {
45   Standard_Integer tempTopology;
46   Handle(TCollection_HAsciiString) tempName;
47   Standard_Integer nbval = 0;
48   //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
49   Handle(IGESAppli_HArray1OfNode) tempData;
50
51   //szv#4:S4163:12Mar99 `st=` not needed
52   PR.ReadInteger(PR.Current(),"Topology type",tempTopology);
53   PR.ReadInteger(PR.Current(),"No. of nodes defining element",nbval);
54   tempData = new IGESAppli_HArray1OfNode(1,nbval);
55   for (Standard_Integer i = 1; i <= nbval; i ++)
56     {
57       Handle(IGESAppli_Node) tempNode;
58       //szv#4:S4163:12Mar99 moved in if
59       if (PR.ReadEntity (IR,PR.Current(),"Node defining element", STANDARD_TYPE(IGESAppli_Node),tempNode))
60         tempData->SetValue(i,tempNode);
61     }
62   PR.ReadText(PR.Current(),"Element type name",tempName); //szv#4:S4163:12Mar99 `st=` not needed
63
64   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
65   ent->Init(tempTopology,tempData,tempName);
66 }
67
68 void  IGESAppli_ToolFiniteElement::WriteOwnParams
69   (const Handle(IGESAppli_FiniteElement)& ent, IGESData_IGESWriter& IW) const
70 {
71   Standard_Integer upper = ent->NbNodes();
72   IW.Send(ent->Topology());
73   IW.Send(upper);
74   for (Standard_Integer i= 1; i <= upper ; i ++)
75     IW.Send(ent->Node(i));
76   IW.Send(ent->Name());
77 }
78
79 void  IGESAppli_ToolFiniteElement::OwnShared
80   (const Handle(IGESAppli_FiniteElement)& ent, Interface_EntityIterator& iter) const
81 {
82   Standard_Integer upper = ent->NbNodes();
83   for (Standard_Integer i= 1; i <= upper ; i ++)
84     iter.GetOneItem(ent->Node(i));
85 }
86
87 void  IGESAppli_ToolFiniteElement::OwnCopy
88   (const Handle(IGESAppli_FiniteElement)& another,
89    const Handle(IGESAppli_FiniteElement)& ent, Interface_CopyTool& TC) const
90 {
91   Standard_Integer aTopology = another->Topology();
92   Handle(TCollection_HAsciiString) aName =
93     new TCollection_HAsciiString(another->Name());
94   Standard_Integer nbval = another->NbNodes();
95   Handle(IGESAppli_HArray1OfNode) aList = new
96     IGESAppli_HArray1OfNode(1,nbval);
97   for (Standard_Integer i=1;i <=nbval;i++)
98     {
99       DeclareAndCast(IGESAppli_Node,aEntity,TC.Transferred(another->Node(i)));
100       aList->SetValue(i,aEntity);
101     }
102   ent->Init(aTopology,aList,aName);
103 }
104
105 IGESData_DirChecker  IGESAppli_ToolFiniteElement::DirChecker
106   (const Handle(IGESAppli_FiniteElement)& /* ent */ ) const
107 {
108   IGESData_DirChecker DC(136,0);  //Form no = 0 & Type = 136
109   DC.Structure(IGESData_DefVoid);
110   DC.LineFont(IGESData_DefAny);
111   DC.LineWeight(IGESData_DefVoid);
112   DC.Color(IGESData_DefAny);
113   DC.BlankStatusIgnored();
114   DC.SubordinateStatusIgnored();
115   DC.UseFlagIgnored();
116   DC.HierarchyStatusIgnored();
117   return DC;
118 }
119
120 void  IGESAppli_ToolFiniteElement::OwnCheck
121   (const Handle(IGESAppli_FiniteElement)& /* ent */,
122    const Interface_ShareTool& , Handle(Interface_Check)& /* ach */) const
123 {
124 }
125
126 void  IGESAppli_ToolFiniteElement::OwnDump
127   (const Handle(IGESAppli_FiniteElement)& ent, const IGESData_IGESDumper& dumper,
128    Standard_OStream& S, const Standard_Integer level) const
129 {
130   S << "IGESAppli_FiniteElement\n";
131
132   S << "Topology type : " << ent->Topology() << "\n";
133   S << "Nodes : ";
134   IGESData_DumpEntities(S,dumper ,level,1, ent->NbNodes(),ent->Node);
135   S << "\nElement Name : " << ent->Name()->String();
136   S << std::endl;
137 }