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