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 | { |
aefdc31b |
32 | #ifdef GEOM2DHATCH_DEB |
0b85f9a6 |
33 | cout<<" Magic Constructor in Geom2dHatch_Elements:: "<<endl; |
aefdc31b |
34 | #endif |
0b85f9a6 |
35 | } |
7fd59977 |
36 | |
0b85f9a6 |
37 | Geom2dHatch_Elements::Geom2dHatch_Elements() |
38 | { |
7fd59977 |
39 | NumWire = 0; |
40 | NumEdge = 0; |
41 | myCurEdge = 1; |
42 | } |
43 | |
0b85f9a6 |
44 | void Geom2dHatch_Elements::Clear() |
45 | { |
7fd59977 |
46 | myMap.Clear(); |
47 | } |
48 | |
0b85f9a6 |
49 | Standard_Boolean Geom2dHatch_Elements::IsBound(const Standard_Integer K) const |
50 | { |
7fd59977 |
51 | return(myMap.IsBound(K)); |
52 | } |
53 | |
0b85f9a6 |
54 | Standard_Boolean Geom2dHatch_Elements::UnBind(const Standard_Integer K) |
55 | { |
7fd59977 |
56 | return(myMap.UnBind(K)); |
57 | } |
58 | |
0b85f9a6 |
59 | Standard_Boolean Geom2dHatch_Elements::Bind(const Standard_Integer K,const Geom2dHatch_Element& I) |
60 | { |
7fd59977 |
61 | return(myMap.Bind(K,I)); |
62 | } |
63 | |
0b85f9a6 |
64 | const Geom2dHatch_Element& Geom2dHatch_Elements::Find(const Standard_Integer K) const |
65 | { |
7fd59977 |
66 | return(myMap.Find(K)); |
67 | } |
68 | |
0b85f9a6 |
69 | Geom2dHatch_Element& Geom2dHatch_Elements::ChangeFind(const Standard_Integer K) |
70 | { |
7fd59977 |
71 | return(myMap.ChangeFind(K)); |
72 | } |
73 | |
74 | //======================================================================= |
75 | //function : Reject |
76 | //purpose : |
77 | //======================================================================= |
78 | |
0b85f9a6 |
79 | Standard_Boolean Geom2dHatch_Elements::Reject(const gp_Pnt2d&) const { |
7fd59977 |
80 | return Standard_False; |
81 | } |
82 | |
83 | //======================================================================= |
84 | //function : Segment |
85 | //purpose : |
86 | //======================================================================= |
87 | |
0b85f9a6 |
88 | Standard_Boolean Geom2dHatch_Elements::Segment(const gp_Pnt2d& P, |
7fd59977 |
89 | gp_Lin2d& L, |
90 | Standard_Real& Par) |
91 | { |
92 | myCurEdge = 1; |
93 | |
94 | return OtherSegment(P, L, Par); |
95 | } |
96 | |
97 | //======================================================================= |
98 | //function : Segment |
99 | //purpose : |
100 | //======================================================================= |
101 | |
0b85f9a6 |
102 | Standard_Boolean Geom2dHatch_Elements::OtherSegment(const gp_Pnt2d& P, |
7fd59977 |
103 | gp_Lin2d& L, |
104 | Standard_Real& Par) |
105 | { |
0b85f9a6 |
106 | Geom2dHatch_DataMapIteratorOfMapOfElements Itertemp; |
7fd59977 |
107 | Standard_Integer i; |
108 | |
109 | for( Itertemp.Initialize(myMap), i = 1; Itertemp.More(); Itertemp.Next(), i++) { |
110 | if (i < myCurEdge) |
111 | continue; |
112 | |
113 | void *ptrmyMap = (void *)(&myMap); |
0b85f9a6 |
114 | Geom2dHatch_Element& Item=((Geom2dHatch_MapOfElements*)ptrmyMap)->ChangeFind(Itertemp.Key()); |
115 | Geom2dAdaptor_Curve& E = Item.ChangeCurve(); |
7fd59977 |
116 | TopAbs_Orientation Or= Item.Orientation(); |
117 | gp_Pnt2d P2 = E.Value |
118 | ((E.FirstParameter() + E.LastParameter()) *0.5); |
119 | if ((Or == TopAbs_FORWARD) || |
120 | (Or == TopAbs_REVERSED)) { |
121 | gp_Vec2d V(P,P2); |
122 | Par = V.Magnitude(); |
123 | if (Par >= gp::Resolution()) { |
124 | L = gp_Lin2d(P,V); |
125 | myCurEdge++; |
126 | return Standard_True; |
127 | } |
128 | } |
129 | } |
130 | |
131 | if (i == myCurEdge + 1) { |
132 | Par = RealLast(); |
133 | L = gp_Lin2d(P,gp_Dir2d(1,0)); |
134 | myCurEdge++; |
135 | |
136 | return Standard_True; |
137 | } |
138 | |
139 | return Standard_False; |
140 | } |
141 | |
142 | //======================================================================= |
143 | //function : InitWires |
144 | //purpose : |
145 | //======================================================================= |
146 | |
0b85f9a6 |
147 | void Geom2dHatch_Elements::InitWires() { |
7fd59977 |
148 | NumWire = 0; |
149 | } |
150 | |
151 | //======================================================================= |
152 | //function : RejectWire NYI |
153 | //purpose : |
154 | //======================================================================= |
155 | |
0b85f9a6 |
156 | Standard_Boolean Geom2dHatch_Elements::RejectWire(const gp_Lin2d& , |
7fd59977 |
157 | const Standard_Real) const |
158 | { |
159 | return Standard_False; |
160 | } |
161 | |
162 | //======================================================================= |
163 | //function : InitEdges |
164 | //purpose : |
165 | //======================================================================= |
166 | |
0b85f9a6 |
167 | void Geom2dHatch_Elements::InitEdges() { |
7fd59977 |
168 | NumEdge = 0; |
169 | Iter.Initialize(myMap); |
170 | } |
171 | |
172 | //======================================================================= |
173 | //function : RejectEdge NYI |
174 | //purpose : |
175 | //======================================================================= |
176 | |
0b85f9a6 |
177 | Standard_Boolean Geom2dHatch_Elements::RejectEdge(const gp_Lin2d& , |
7fd59977 |
178 | const Standard_Real ) const |
179 | { |
180 | return Standard_False; |
181 | } |
182 | |
183 | |
184 | //======================================================================= |
185 | //function : CurrentEdge |
186 | //purpose : |
187 | //======================================================================= |
188 | |
0b85f9a6 |
189 | void Geom2dHatch_Elements::CurrentEdge(Geom2dAdaptor_Curve& E, |
7fd59977 |
190 | TopAbs_Orientation& Or) const |
191 | { |
192 | void *ptrmyMap = (void *)(&myMap); |
0b85f9a6 |
193 | Geom2dHatch_Element& Item=((Geom2dHatch_MapOfElements*)ptrmyMap)->ChangeFind(Iter.Key()); |
7fd59977 |
194 | |
195 | E = Item.ChangeCurve(); |
196 | Or= Item.Orientation(); |
197 | #if 0 |
198 | E.Edge() = TopoDS::Edge(myEExplorer.Current()); |
199 | E.Face() = myFace; |
200 | Or = E.Edge().Orientation(); |
201 | #endif |
202 | } |
203 | |
204 | |
205 | //======================================================================= |
206 | //function : MoreWires |
207 | //purpose : |
208 | //======================================================================= |
209 | |
0b85f9a6 |
210 | Standard_Boolean Geom2dHatch_Elements::MoreWires() const |
7fd59977 |
211 | { |
212 | return (NumWire == 0); |
213 | } |
214 | |
215 | //======================================================================= |
216 | //function : NextWire |
217 | //purpose : |
218 | //======================================================================= |
219 | |
0b85f9a6 |
220 | void Geom2dHatch_Elements::NextWire() { |
7fd59977 |
221 | NumWire++; |
222 | } |
223 | |
224 | //======================================================================= |
225 | //function : MoreEdges |
226 | //purpose : |
227 | //======================================================================= |
228 | |
0b85f9a6 |
229 | Standard_Boolean Geom2dHatch_Elements::MoreEdges() const { |
7fd59977 |
230 | return(Iter.More()); |
231 | } |
232 | |
233 | //======================================================================= |
234 | //function : NextEdge |
235 | //purpose : |
236 | //======================================================================= |
237 | |
0b85f9a6 |
238 | void Geom2dHatch_Elements::NextEdge() { |
7fd59977 |
239 | Iter.Next(); |
240 | } |
241 | |
242 | |
243 | |