0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / XCAFDoc / XCAFDoc_Area.cxx
CommitLineData
b311480e 1// Created on: 2000-09-08
2// Created by: data exchange team
973c2be1 3// Copyright (c) 2000-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 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.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
bc73b006 16#include <XCAFDoc_Area.hxx>
42cf5bc1 17
bc73b006 18#include <Standard_Dump.hxx>
42cf5bc1 19#include <Standard_GUID.hxx>
20#include <Standard_Type.hxx>
21#include <TDF_Attribute.hxx>
22#include <TDF_Label.hxx>
23#include <TDF_RelocationTable.hxx>
7fd59977 24
92efcf78 25IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_Area,TDF_Attribute)
26
7fd59977 27//=======================================================================
28//function : Constructor
29//purpose :
30//=======================================================================
7fd59977 31XCAFDoc_Area::XCAFDoc_Area()
32{
33}
34
35//=======================================================================
36//function : GetID
37//purpose :
38//=======================================================================
39
40const Standard_GUID& XCAFDoc_Area::GetID()
41{
42 static Standard_GUID AreaID ("efd212f2-6dfd-11d4-b9c8-0060b0ee281b");
43 return AreaID;
44}
45
46//=======================================================================
47//function : ID
48//purpose :
49//=======================================================================
50
51const Standard_GUID& XCAFDoc_Area::ID() const
52{
53 return GetID();
54}
55
56//=======================================================================
57//function : Set
58//purpose :
59//=======================================================================
60
61Handle(XCAFDoc_Area) XCAFDoc_Area::Set (const TDF_Label& L,const Standard_Real V)
62{
63 Handle(XCAFDoc_Area) A;
64 if (!L.FindAttribute(XCAFDoc_Area::GetID(), A)) {
65 A = new XCAFDoc_Area;
66 L.AddAttribute(A);
67 }
68 A->Set(V);
69 return A;
70}
71
72//=======================================================================
73//function : Set
74//purpose :
75//=======================================================================
76
77void XCAFDoc_Area::Set (const Standard_Real V)
78{
79 Backup();
80 myValue = V;
81}
82
83//=======================================================================
84//function : Get
85//purpose :
86//=======================================================================
87
88Standard_Real XCAFDoc_Area::Get() const { return myValue; }
89
90//=======================================================================
91//function : Get
92//purpose :
93//=======================================================================
94
95Standard_Boolean XCAFDoc_Area::Get(const TDF_Label& label,Standard_Real& area)
96{
97 Handle(XCAFDoc_Area) anArea;
98 if (!label.FindAttribute(XCAFDoc_Area::GetID(), anArea))
99 return Standard_False;
100
101 area = anArea->Get();
102 return Standard_True;
103}
104
105//=======================================================================
106//function : NewEmpty
107//purpose :
108//=======================================================================
109
110Handle(TDF_Attribute) XCAFDoc_Area::NewEmpty () const
111{
112 return new XCAFDoc_Area();
113}
114
115//=======================================================================
116//function : Restore
117//purpose :
118//=======================================================================
119
120void XCAFDoc_Area::Restore(const Handle(TDF_Attribute)& With)
121{
122 Handle(XCAFDoc_Area) R = Handle(XCAFDoc_Area)::DownCast (With);
123 myValue = R->Get();
124}
125
126
127//=======================================================================
128//function : Paste
129//purpose :
130//=======================================================================
131
132void XCAFDoc_Area::Paste (const Handle(TDF_Attribute)& Into,
133 const Handle(TDF_RelocationTable)& /* RT */) const
134{
135 Handle(XCAFDoc_Area) R = Handle(XCAFDoc_Area)::DownCast (Into);
136 R->Set(myValue);
137}
138
139//=======================================================================
140//function : Dump
141//purpose :
142//=======================================================================
143
144Standard_OStream& XCAFDoc_Area::Dump (Standard_OStream& anOS) const
145{
146 anOS << "Area ";
147 anOS << Get();
148 return anOS;
149}
bc73b006 150
151//=======================================================================
152//function : DumpJson
153//purpose :
154//=======================================================================
155void XCAFDoc_Area::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
156{
157 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
158
159 OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TDF_Attribute)
160
161 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myValue)
162}