1 // Created on: 2000-09-08
2 // Created by: data exchange team
3 // Copyright (c) 2000-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <XCAFDoc_Centroid.hxx>
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>
25 IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_Centroid,TDF_Attribute)
27 //=======================================================================
28 //function : Constructor
30 //=======================================================================
31 XCAFDoc_Centroid::XCAFDoc_Centroid()
35 //=======================================================================
38 //=======================================================================
40 const Standard_GUID& XCAFDoc_Centroid::GetID()
42 static Standard_GUID CentroidID ("efd212f3-6dfd-11d4-b9c8-0060b0ee281b");
46 //=======================================================================
49 //=======================================================================
51 Handle(XCAFDoc_Centroid) XCAFDoc_Centroid::Set(const TDF_Label& L,const gp_Pnt& pnt)
53 Handle(XCAFDoc_Centroid) A;
54 if (!L.FindAttribute (XCAFDoc_Centroid::GetID(), A)) {
55 A = new XCAFDoc_Centroid ();
62 //=======================================================================
65 //=======================================================================
67 void XCAFDoc_Centroid::Set(const gp_Pnt& pnt)
73 //=======================================================================
76 //=======================================================================
78 gp_Pnt XCAFDoc_Centroid::Get() const
83 //=======================================================================
86 //=======================================================================
88 Standard_Boolean XCAFDoc_Centroid::Get(const TDF_Label& label,gp_Pnt& pnt)
90 Handle(XCAFDoc_Centroid) aCentroid;
91 if (!label.FindAttribute(XCAFDoc_Centroid::GetID(), aCentroid))
92 return Standard_False;
94 pnt = aCentroid->Get();
98 //=======================================================================
101 //=======================================================================
103 const Standard_GUID& XCAFDoc_Centroid::ID() const
108 //=======================================================================
111 //=======================================================================
113 void XCAFDoc_Centroid::Restore(const Handle(TDF_Attribute)& With)
115 myCentroid = Handle(XCAFDoc_Centroid)::DownCast(With)->Get();
118 //=======================================================================
119 //function : NewEmpty
121 //=======================================================================
123 Handle(TDF_Attribute) XCAFDoc_Centroid::NewEmpty() const
125 return new XCAFDoc_Centroid();
128 //=======================================================================
131 //=======================================================================
133 void XCAFDoc_Centroid::Paste(const Handle(TDF_Attribute)& Into,const Handle(TDF_RelocationTable)& /* RT */) const
135 Handle(XCAFDoc_Centroid)::DownCast(Into)->Set(myCentroid);
139 //=======================================================================
142 //=======================================================================
144 Standard_OStream& XCAFDoc_Centroid::Dump (Standard_OStream& anOS) const
146 anOS << "Centroid ( ";
147 anOS << myCentroid.X() << ",";
148 anOS << myCentroid.Y() << ",";
149 anOS << myCentroid.Z() << ")";
153 //=======================================================================
154 //function : DumpJson
156 //=======================================================================
157 void XCAFDoc_Centroid::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
159 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
161 OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TDF_Attribute)
163 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myCentroid)