b311480e |
1 | // Created on: 2009-04-06 |
2 | // Created by: Sergey ZARITCHNY |
973c2be1 |
3 | // Copyright (c) 2009-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 | |
42cf5bc1 |
16 | |
17 | #include <BRep_Tool.hxx> |
18 | #include <BRepBuilderAPI_MakeVertex.hxx> |
19 | #include <Geom_CartesianPoint.hxx> |
20 | #include <gp_Pnt.hxx> |
21 | #include <Standard_GUID.hxx> |
22 | #include <Standard_Type.hxx> |
7fd59977 |
23 | #include <TDataStd.hxx> |
24 | #include <TDataXtd.hxx> |
42cf5bc1 |
25 | #include <TDataXtd_Point.hxx> |
26 | #include <TDF_Attribute.hxx> |
27 | #include <TDF_Label.hxx> |
28 | #include <TDF_RelocationTable.hxx> |
29 | #include <TNaming_Builder.hxx> |
7fd59977 |
30 | #include <TNaming_NamedShape.hxx> |
31 | #include <TNaming_Tool.hxx> |
42cf5bc1 |
32 | #include <TopAbs.hxx> |
7fd59977 |
33 | #include <TopoDS.hxx> |
34 | #include <TopoDS_Vertex.hxx> |
7fd59977 |
35 | |
92efcf78 |
36 | IMPLEMENT_STANDARD_RTTIEXT(TDataXtd_Point,TDF_Attribute) |
37 | |
7fd59977 |
38 | //======================================================================= |
39 | //function : GetID |
40 | //purpose : |
41 | //======================================================================= |
7fd59977 |
42 | const Standard_GUID& TDataXtd_Point::GetID() |
43 | { |
44 | static Standard_GUID TDataXtd_PointID("2a96b60d-ec8b-11d0-bee7-080009dc3333"); |
45 | return TDataXtd_PointID; |
46 | } |
47 | |
48 | |
49 | //======================================================================= |
50 | //function : Set |
51 | //purpose : |
52 | //======================================================================= |
53 | |
54 | Handle(TDataXtd_Point) TDataXtd_Point::Set (const TDF_Label& L) |
55 | { |
56 | Handle(TDataXtd_Point) A; |
57 | if (!L.FindAttribute(TDataXtd_Point::GetID(),A)) { |
58 | A = new TDataXtd_Point (); |
59 | L.AddAttribute(A); |
60 | } |
61 | return A; |
62 | } |
63 | |
64 | //======================================================================= |
65 | //function : Set |
66 | //purpose : |
67 | //======================================================================= |
68 | |
69 | Handle(TDataXtd_Point) TDataXtd_Point::Set (const TDF_Label& L, const gp_Pnt& P) |
70 | { |
71 | Handle(TDataXtd_Point) A = Set (L); |
72 | |
7fd59977 |
73 | Handle(TNaming_NamedShape) aNS; |
74 | if(L.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { |
75 | if(!aNS->Get().IsNull()) |
76 | if(aNS->Get().ShapeType() == TopAbs_VERTEX) { |
77 | gp_Pnt anOldPnt = BRep_Tool::Pnt(TopoDS::Vertex(aNS->Get())); |
78 | if(anOldPnt.X() == P.X() && |
79 | anOldPnt.Y() == P.Y() && |
80 | anOldPnt.Z() == P.Z() |
81 | ) |
82 | return A; |
83 | } |
84 | } |
7fd59977 |
85 | |
86 | TNaming_Builder B(L); |
87 | B.Generated(BRepBuilderAPI_MakeVertex(P)); |
88 | return A; |
89 | } |
90 | |
91 | |
92 | //======================================================================= |
93 | //function : TDataXtd_Point |
94 | //purpose : |
95 | //======================================================================= |
96 | |
97 | TDataXtd_Point::TDataXtd_Point () {} |
98 | |
99 | |
100 | |
101 | //======================================================================= |
102 | //function : ID |
103 | //purpose : |
104 | //======================================================================= |
105 | |
106 | const Standard_GUID& TDataXtd_Point::ID() const { return GetID ();} |
107 | |
108 | |
109 | //======================================================================= |
110 | //function : NewEmpty |
111 | //purpose : |
112 | //======================================================================= |
113 | |
114 | Handle(TDF_Attribute) TDataXtd_Point::NewEmpty () const |
115 | { |
116 | return new TDataXtd_Point(); |
117 | } |
118 | |
7fd59977 |
119 | //======================================================================= |
120 | //function : Restore |
121 | //purpose : |
122 | //======================================================================= |
123 | |
35e08fe8 |
124 | void TDataXtd_Point::Restore(const Handle(TDF_Attribute)&) |
125 | { |
126 | } |
7fd59977 |
127 | |
128 | //======================================================================= |
129 | //function : Paste |
130 | //purpose : |
131 | //======================================================================= |
132 | |
35e08fe8 |
133 | void TDataXtd_Point::Paste (const Handle(TDF_Attribute)&, const Handle(TDF_RelocationTable)&) const |
134 | { |
135 | } |
7fd59977 |
136 | |
137 | //======================================================================= |
138 | //function : Dump |
139 | //purpose : |
140 | //======================================================================= |
141 | |
142 | Standard_OStream& TDataXtd_Point::Dump (Standard_OStream& anOS) const |
143 | { |
144 | anOS << "Point"; |
145 | return anOS; |
146 | } |