b311480e |
1 | // Created on: 1994-12-16 |
2 | // Created by: Laurent BUCHARD |
3 | // Copyright (c) 1994-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
17 | // Modified by skv - Fri Jul 14 17:03:47 2006 OCC12627 |
18 | |
0b85f9a6 |
19 | #include <Geom2dHatch_Elements.ixx> |
20 | |
21 | #include <Standard_Integer.hxx> |
22 | #include <Geom2dHatch_Element.hxx> |
23 | #include <TColStd_MapIntegerHasher.hxx> |
24 | #include <Geom2dAdaptor_Curve.hxx> |
25 | |
7fd59977 |
26 | #include <TopAbs_Orientation.hxx> |
27 | #include <gp.hxx> |
28 | #include <gp_Vec2d.hxx> |
29 | |
0b85f9a6 |
30 | Geom2dHatch_Elements::Geom2dHatch_Elements(const Geom2dHatch_Elements& ) |
31 | { |
32 | cout<<" Magic Constructor in Geom2dHatch_Elements:: "<<endl; |
33 | } |
7fd59977 |
34 | |
0b85f9a6 |
35 | Geom2dHatch_Elements::Geom2dHatch_Elements() |
36 | { |
7fd59977 |
37 | NumWire = 0; |
38 | NumEdge = 0; |
39 | myCurEdge = 1; |
40 | } |
41 | |
0b85f9a6 |
42 | void Geom2dHatch_Elements::Clear() |
43 | { |
7fd59977 |
44 | myMap.Clear(); |
45 | } |
46 | |
0b85f9a6 |
47 | Standard_Boolean Geom2dHatch_Elements::IsBound(const Standard_Integer K) const |
48 | { |
7fd59977 |
49 | return(myMap.IsBound(K)); |
50 | } |
51 | |
0b85f9a6 |
52 | Standard_Boolean Geom2dHatch_Elements::UnBind(const Standard_Integer K) |
53 | { |
7fd59977 |
54 | return(myMap.UnBind(K)); |
55 | } |
56 | |
0b85f9a6 |
57 | Standard_Boolean Geom2dHatch_Elements::Bind(const Standard_Integer K,const Geom2dHatch_Element& I) |
58 | { |
7fd59977 |
59 | return(myMap.Bind(K,I)); |
60 | } |
61 | |
0b85f9a6 |
62 | const Geom2dHatch_Element& Geom2dHatch_Elements::Find(const Standard_Integer K) const |
63 | { |
7fd59977 |
64 | return(myMap.Find(K)); |
65 | } |
66 | |
0b85f9a6 |
67 | Geom2dHatch_Element& Geom2dHatch_Elements::ChangeFind(const Standard_Integer K) |
68 | { |
7fd59977 |
69 | return(myMap.ChangeFind(K)); |
70 | } |
71 | |
72 | //======================================================================= |
73 | //function : Reject |
74 | //purpose : |
75 | //======================================================================= |
76 | |
0b85f9a6 |
77 | Standard_Boolean Geom2dHatch_Elements::Reject(const gp_Pnt2d&) const { |
7fd59977 |
78 | return Standard_False; |
79 | } |
80 | |
81 | //======================================================================= |
82 | //function : Segment |
83 | //purpose : |
84 | //======================================================================= |
85 | |
0b85f9a6 |
86 | Standard_Boolean Geom2dHatch_Elements::Segment(const gp_Pnt2d& P, |
7fd59977 |
87 | gp_Lin2d& L, |
88 | Standard_Real& Par) |
89 | { |
90 | myCurEdge = 1; |
91 | |
92 | return OtherSegment(P, L, Par); |
93 | } |
94 | |
95 | //======================================================================= |
96 | //function : Segment |
97 | //purpose : |
98 | //======================================================================= |
99 | |
0b85f9a6 |
100 | Standard_Boolean Geom2dHatch_Elements::OtherSegment(const gp_Pnt2d& P, |
7fd59977 |
101 | gp_Lin2d& L, |
102 | Standard_Real& Par) |
103 | { |
0b85f9a6 |
104 | Geom2dHatch_DataMapIteratorOfMapOfElements Itertemp; |
7fd59977 |
105 | Standard_Integer i; |
106 | |
107 | for( Itertemp.Initialize(myMap), i = 1; Itertemp.More(); Itertemp.Next(), i++) { |
108 | if (i < myCurEdge) |
109 | continue; |
110 | |
111 | void *ptrmyMap = (void *)(&myMap); |
0b85f9a6 |
112 | Geom2dHatch_Element& Item=((Geom2dHatch_MapOfElements*)ptrmyMap)->ChangeFind(Itertemp.Key()); |
113 | Geom2dAdaptor_Curve& E = Item.ChangeCurve(); |
7fd59977 |
114 | TopAbs_Orientation Or= Item.Orientation(); |
115 | gp_Pnt2d P2 = E.Value |
116 | ((E.FirstParameter() + E.LastParameter()) *0.5); |
117 | if ((Or == TopAbs_FORWARD) || |
118 | (Or == TopAbs_REVERSED)) { |
119 | gp_Vec2d V(P,P2); |
120 | Par = V.Magnitude(); |
121 | if (Par >= gp::Resolution()) { |
122 | L = gp_Lin2d(P,V); |
123 | myCurEdge++; |
124 | return Standard_True; |
125 | } |
126 | } |
127 | } |
128 | |
129 | if (i == myCurEdge + 1) { |
130 | Par = RealLast(); |
131 | L = gp_Lin2d(P,gp_Dir2d(1,0)); |
132 | myCurEdge++; |
133 | |
134 | return Standard_True; |
135 | } |
136 | |
137 | return Standard_False; |
138 | } |
139 | |
140 | //======================================================================= |
141 | //function : InitWires |
142 | //purpose : |
143 | //======================================================================= |
144 | |
0b85f9a6 |
145 | void Geom2dHatch_Elements::InitWires() { |
7fd59977 |
146 | NumWire = 0; |
147 | } |
148 | |
149 | //======================================================================= |
150 | //function : RejectWire NYI |
151 | //purpose : |
152 | //======================================================================= |
153 | |
0b85f9a6 |
154 | Standard_Boolean Geom2dHatch_Elements::RejectWire(const gp_Lin2d& , |
7fd59977 |
155 | const Standard_Real) const |
156 | { |
157 | return Standard_False; |
158 | } |
159 | |
160 | //======================================================================= |
161 | //function : InitEdges |
162 | //purpose : |
163 | //======================================================================= |
164 | |
0b85f9a6 |
165 | void Geom2dHatch_Elements::InitEdges() { |
7fd59977 |
166 | NumEdge = 0; |
167 | Iter.Initialize(myMap); |
168 | } |
169 | |
170 | //======================================================================= |
171 | //function : RejectEdge NYI |
172 | //purpose : |
173 | //======================================================================= |
174 | |
0b85f9a6 |
175 | Standard_Boolean Geom2dHatch_Elements::RejectEdge(const gp_Lin2d& , |
7fd59977 |
176 | const Standard_Real ) const |
177 | { |
178 | return Standard_False; |
179 | } |
180 | |
181 | |
182 | //======================================================================= |
183 | //function : CurrentEdge |
184 | //purpose : |
185 | //======================================================================= |
186 | |
0b85f9a6 |
187 | void Geom2dHatch_Elements::CurrentEdge(Geom2dAdaptor_Curve& E, |
7fd59977 |
188 | TopAbs_Orientation& Or) const |
189 | { |
190 | void *ptrmyMap = (void *)(&myMap); |
0b85f9a6 |
191 | Geom2dHatch_Element& Item=((Geom2dHatch_MapOfElements*)ptrmyMap)->ChangeFind(Iter.Key()); |
7fd59977 |
192 | |
193 | E = Item.ChangeCurve(); |
194 | Or= Item.Orientation(); |
195 | #if 0 |
196 | E.Edge() = TopoDS::Edge(myEExplorer.Current()); |
197 | E.Face() = myFace; |
198 | Or = E.Edge().Orientation(); |
199 | #endif |
200 | } |
201 | |
202 | |
203 | //======================================================================= |
204 | //function : MoreWires |
205 | //purpose : |
206 | //======================================================================= |
207 | |
0b85f9a6 |
208 | Standard_Boolean Geom2dHatch_Elements::MoreWires() const |
7fd59977 |
209 | { |
210 | return (NumWire == 0); |
211 | } |
212 | |
213 | //======================================================================= |
214 | //function : NextWire |
215 | //purpose : |
216 | //======================================================================= |
217 | |
0b85f9a6 |
218 | void Geom2dHatch_Elements::NextWire() { |
7fd59977 |
219 | NumWire++; |
220 | } |
221 | |
222 | //======================================================================= |
223 | //function : MoreEdges |
224 | //purpose : |
225 | //======================================================================= |
226 | |
0b85f9a6 |
227 | Standard_Boolean Geom2dHatch_Elements::MoreEdges() const { |
7fd59977 |
228 | return(Iter.More()); |
229 | } |
230 | |
231 | //======================================================================= |
232 | //function : NextEdge |
233 | //purpose : |
234 | //======================================================================= |
235 | |
0b85f9a6 |
236 | void Geom2dHatch_Elements::NextEdge() { |
7fd59977 |
237 | Iter.Next(); |
238 | } |
239 | |
240 | |
241 | |