0026377: Passing Handle objects as arguments to functions as non-const reference...
[occt.git] / src / XSControl / XSControl_Vars.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
15 #include <Dico_DictionaryOfTransient.hxx>
16 #include <Geom2d_CartesianPoint.hxx>
17 #include <Geom2d_Curve.hxx>
18 #include <Geom_CartesianPoint.hxx>
19 #include <Geom_Curve.hxx>
20 #include <Geom_Geometry.hxx>
21 #include <Geom_Surface.hxx>
22 #include <gp_Pnt.hxx>
23 #include <gp_Pnt2d.hxx>
24 #include <Interface_Macros.hxx>
25 #include <Standard_Transient.hxx>
26 #include <Standard_Type.hxx>
27 #include <TopoDS_HShape.hxx>
28 #include <TopoDS_Shape.hxx>
29 #include <XSControl_Vars.hxx>
30
31 IMPLEMENT_STANDARD_RTTIEXT(XSControl_Vars,MMgt_TShared)
32
33 XSControl_Vars::XSControl_Vars  ()
34     {  thevars = new Dico_DictionaryOfTransient;  }
35
36 void  XSControl_Vars::Set
37   (const Standard_CString name,
38    const Handle(Standard_Transient)& val)
39 {
40   thevars->SetItem (name,val);
41 }
42
43 Handle(Standard_Transient)  XSControl_Vars::Get ( Standard_CString& name) const
44 {
45   Handle(Standard_Transient) val;
46   if (!thevars->GetItem (name,val)) val.Nullify();
47   return val;
48 }
49
50 Handle(Geom_Geometry)  XSControl_Vars::GetGeom ( Standard_CString& name) const
51 {  return GetCasted(Geom_Geometry,Get(name));  }
52
53 Handle(Geom2d_Curve)  XSControl_Vars::GetCurve2d ( Standard_CString& name) const
54 {  return GetCasted(Geom2d_Curve,Get(name));  }
55
56 Handle(Geom_Curve)  XSControl_Vars::GetCurve ( Standard_CString& name) const
57 {  return GetCasted(Geom_Curve,Get(name));  }
58
59 Handle(Geom_Surface)  XSControl_Vars::GetSurface ( Standard_CString& name) const
60 {  return GetCasted(Geom_Surface,Get(name));  }
61
62
63 void  XSControl_Vars::SetPoint (const Standard_CString name, const gp_Pnt& val)
64 {  Set (name, new Geom_CartesianPoint(val));  }
65
66 Standard_Boolean  XSControl_Vars::GetPoint (Standard_CString& name, gp_Pnt& pnt) const
67 {
68   DeclareAndCast(Geom_CartesianPoint,val,Get(name));
69   if (val.IsNull()) return Standard_False;
70   pnt = val->Pnt();
71   return Standard_True;
72 }
73
74
75 void  XSControl_Vars::SetPoint2d (const Standard_CString name, const gp_Pnt2d& val)
76 {  Set (name, new Geom2d_CartesianPoint(val));  }
77
78 Standard_Boolean  XSControl_Vars::GetPoint2d (Standard_CString& name, gp_Pnt2d& pnt) const
79 {
80   DeclareAndCast(Geom2d_CartesianPoint,val,Get(name));
81   if (val.IsNull()) return Standard_False;
82   pnt = val->Pnt2d();
83   return Standard_True;
84 }
85
86
87 void  XSControl_Vars::SetShape (const Standard_CString name, const TopoDS_Shape& val)
88 {  Set (name, new TopoDS_HShape(val));  }
89
90 TopoDS_Shape  XSControl_Vars::GetShape (Standard_CString& name) const
91 {
92   TopoDS_Shape sh;
93   DeclareAndCast(TopoDS_HShape,val,Get(name));
94   if (!val.IsNull()) sh = val->Shape();
95   return sh;
96 }