0027104: DownCast() cannot return null for mismatched handle
[occt.git] / src / IGESAppli / IGESAppli_ToolNode.cxx
CommitLineData
b311480e 1// Created by: CKY / Contract Toubro-Larsen
2// Copyright (c) 1993-1999 Matra Datavision
973c2be1 3// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
7fd59977 6//
d5f74e42 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
973c2be1 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.
7fd59977 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
16//--------------------------------------------------------------------
7fd59977 17//--------------------------------------------------------------------
18
42cf5bc1 19#include <gp_Pnt.hxx>
20#include <gp_XYZ.hxx>
21#include <IGESAppli_Node.hxx>
22#include <IGESAppli_ToolNode.hxx>
23#include <IGESData_DirChecker.hxx>
24#include <IGESData_IGESDumper.hxx>
25#include <IGESData_IGESReaderData.hxx>
26#include <IGESData_IGESWriter.hxx>
7fd59977 27#include <IGESData_ParamCursor.hxx>
42cf5bc1 28#include <IGESData_ParamReader.hxx>
7fd59977 29#include <IGESGeom_TransformationMatrix.hxx>
42cf5bc1 30#include <Interface_Check.hxx>
31#include <Interface_CopyTool.hxx>
32#include <Interface_EntityIterator.hxx>
7fd59977 33#include <Interface_Macros.hxx>
42cf5bc1 34#include <Interface_ShareTool.hxx>
7fd59977 35#include <Message_Messenger.hxx>
42cf5bc1 36#include <Standard_DomainError.hxx>
7fd59977 37
38IGESAppli_ToolNode::IGESAppli_ToolNode () { }
39
40
41void IGESAppli_ToolNode::ReadOwnParams
42 (const Handle(IGESAppli_Node)& ent,
43 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
44{
45 gp_XYZ tempCoordinates;
46 Handle(IGESGeom_TransformationMatrix) tempSystem;
47 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
48
49 //szv#4:S4163:12Mar99 `st=` not needed
50 PR.ReadXYZ(PR.CurrentList(1, 3),"Coordinates of Node (XYZ)",tempCoordinates);
51
52 if (PR.DefinedElseSkip())
53 PR.ReadEntity(IR,PR.Current(),"Transformation Matrix",
54 STANDARD_TYPE(IGESGeom_TransformationMatrix), tempSystem,Standard_True);
55
56 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
57 ent->Init(tempCoordinates,tempSystem);
58}
59
60void IGESAppli_ToolNode::WriteOwnParams
61 (const Handle(IGESAppli_Node)& ent, IGESData_IGESWriter& IW) const
62{
63 IW.Send(ent->Coord().X());
64 IW.Send(ent->Coord().Y());
65 IW.Send(ent->Coord().Z());
66 IW.Send(ent->System());
67}
68
69void IGESAppli_ToolNode::OwnShared
70 (const Handle(IGESAppli_Node)& ent, Interface_EntityIterator& iter) const
71{
72 iter.GetOneItem(ent->System());
73}
74
75void IGESAppli_ToolNode::OwnCopy
76 (const Handle(IGESAppli_Node)& another,
77 const Handle(IGESAppli_Node)& ent, Interface_CopyTool& TC) const
78{
79 gp_XYZ aCoord = (another->Coord()).XYZ();
80 DeclareAndCast(IGESGeom_TransformationMatrix,aSystem,
81 TC.Transferred(another->System()));
82
83 ent->Init(aCoord,aSystem);
84}
85
86IGESData_DirChecker IGESAppli_ToolNode::DirChecker
87 (const Handle(IGESAppli_Node)& /*ent*/ ) const
88{
89 IGESData_DirChecker DC(134,0); //Form no = 0 & Type = 134
90 DC.Structure(IGESData_DefVoid);
91 DC.LineFont(IGESData_DefVoid);
92 DC.LineWeight(IGESData_DefVoid);
93 DC.Color(IGESData_DefAny);
94 DC.UseFlagRequired(04);
95 return DC;
96}
97
98void IGESAppli_ToolNode::OwnCheck
99 (const Handle(IGESAppli_Node)& ent,
100 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
101{
102 if (!ent->HasSubScriptNumber())
103 ach->AddFail("SubScript Number expected (for Node Number) not present");
104 if (!ent->HasTransf())
105 ach->AddFail("Transformation Matrix expected, not present");
106 if (!ent->System().IsNull())
107 if (ent->System()->FormNumber() < 10)
108 ach->AddFail("System : Incorrect FormNumber (not 10-11-12)");
109}
110
111void IGESAppli_ToolNode::OwnDump
112 (const Handle(IGESAppli_Node)& ent, const IGESData_IGESDumper& dumper,
113 const Handle(Message_Messenger)& S, const Standard_Integer level) const
114{
115 S << "IGESAppli_Node" << endl;
116 S << " Nodal Coords : 1st " << ent->Coord().X()
117 << " 2nd : " << ent->Coord().Y() << " 3rd : " << ent->Coord().Z() <<endl;
118 S << "Nodal Displacement Coordinate System : ";
119 if (!ent->System().IsNull())
120 dumper.Dump(ent->System(),S, level);
121 else
122 S << "Global Cartesian Coordinate System (default)";
123 S << endl;
124}