0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / Draft / Draft_VertexInfo.cxx
1 // Created on: 1994-09-01
2 // Created by: Jacques GOUSSARD
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <Draft_VertexInfo.hxx>
19 #include <gp_Pnt.hxx>
20 #include <Standard_DomainError.hxx>
21 #include <Standard_NoMoreObject.hxx>
22 #include <TColStd_ListIteratorOfListOfReal.hxx>
23 #include <TopoDS.hxx>
24 #include <TopoDS_Edge.hxx>
25
26 //=======================================================================
27 //function : Draft_VertexInfo
28 //purpose  : 
29 //=======================================================================
30 Draft_VertexInfo::Draft_VertexInfo () {}
31
32
33 //=======================================================================
34 //function : Add
35 //purpose  : 
36 //=======================================================================
37
38 void Draft_VertexInfo::Add(const TopoDS_Edge& E)
39 {
40   for (myItEd.Initialize(myEdges); myItEd.More(); myItEd.Next()) {
41     if (E.IsSame(myItEd.Value())) {
42       break;
43     }
44   }
45   if (!myItEd.More()) {
46     myEdges.Append(E);
47     myParams.Append(RealLast());
48   }
49 }
50
51
52 //=======================================================================
53 //function : Geometry
54 //purpose  : 
55 //=======================================================================
56
57 const gp_Pnt& Draft_VertexInfo::Geometry () const
58 {
59   return myGeom;
60 }
61
62
63 //=======================================================================
64 //function : ChangeGeometry
65 //purpose  : 
66 //=======================================================================
67
68 gp_Pnt& Draft_VertexInfo::ChangeGeometry ()
69 {
70   return myGeom;
71 }
72
73
74 //=======================================================================
75 //function : Parameter
76 //purpose  : 
77 //=======================================================================
78
79 Standard_Real Draft_VertexInfo::Parameter (const TopoDS_Edge& E)
80 {
81   TColStd_ListIteratorOfListOfReal itp(myParams);
82   myItEd.Initialize(myEdges);
83   for (; myItEd.More(); myItEd.Next(),itp.Next()) {
84     if (myItEd.Value().IsSame(E)) {
85       return itp.Value();
86     }
87   }
88   throw Standard_DomainError();
89 }
90
91
92 //=======================================================================
93 //function : ChangeParameter
94 //purpose  : 
95 //=======================================================================
96
97 Standard_Real& Draft_VertexInfo::ChangeParameter (const TopoDS_Edge& E)
98 {
99   TColStd_ListIteratorOfListOfReal itp(myParams);
100   myItEd.Initialize(myEdges);
101   for (; myItEd.More(); myItEd.Next(),itp.Next()) {
102     if (myItEd.Value().IsSame(E)) {
103       return itp.Value();
104     }
105   }
106   throw Standard_DomainError();
107 }
108
109
110 //=======================================================================
111 //function : InitEdgeIterator
112 //purpose  : 
113 //=======================================================================
114
115 void Draft_VertexInfo::InitEdgeIterator () 
116 {
117   myItEd.Initialize(myEdges);
118 }
119
120
121 //=======================================================================
122 //function : Edge
123 //purpose  : 
124 //=======================================================================
125
126 const TopoDS_Edge& Draft_VertexInfo::Edge () const
127 {
128   return TopoDS::Edge(myItEd.Value());
129 }
130
131
132 //=======================================================================
133 //function : MoreEdge
134 //purpose  : 
135 //=======================================================================
136
137 Standard_Boolean Draft_VertexInfo::MoreEdge() const
138 {
139   return myItEd.More();
140 }
141
142
143 //=======================================================================
144 //function : NextEdge
145 //purpose  : 
146 //=======================================================================
147
148 void Draft_VertexInfo::NextEdge()
149 {
150   myItEd.Next();
151 }
152
153