b311480e |
1 | // Created on: 1994-12-16 |
2 | // Created by: Laurent BUCHARD |
3 | // Copyright (c) 1994-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | // Modified by skv - Fri Jul 14 17:03:47 2006 OCC12627 |
23 | |
24 | #include <TopAbs_Orientation.hxx> |
25 | #include <gp.hxx> |
26 | #include <gp_Vec2d.hxx> |
27 | |
28 | //HatchGen_ElementsGen::HatchGen_ElementsGen(const HatchGen_ElementsGen& Other) { |
29 | HatchGen_ElementsGen::HatchGen_ElementsGen(const HatchGen_ElementsGen& ) { |
30 | cout<<" Magic Constructor in HatchGen_ElementsGen:: "<<endl; |
31 | } |
32 | |
33 | HatchGen_ElementsGen::HatchGen_ElementsGen() { |
34 | NumWire = 0; |
35 | NumEdge = 0; |
36 | myCurEdge = 1; |
37 | } |
38 | |
39 | void HatchGen_ElementsGen::Clear() { |
40 | myMap.Clear(); |
41 | } |
42 | |
43 | Standard_Boolean HatchGen_ElementsGen::IsBound(const TheKey& K) const { |
44 | return(myMap.IsBound(K)); |
45 | } |
46 | |
47 | Standard_Boolean HatchGen_ElementsGen::UnBind(const TheKey& K) { |
48 | return(myMap.UnBind(K)); |
49 | } |
50 | |
51 | Standard_Boolean HatchGen_ElementsGen::Bind(const TheKey& K,const TheItem& I) { |
52 | return(myMap.Bind(K,I)); |
53 | } |
54 | |
55 | const TheItem& HatchGen_ElementsGen::Find(const TheKey& K) const { |
56 | return(myMap.Find(K)); |
57 | } |
58 | |
59 | TheItem& HatchGen_ElementsGen::ChangeFind(const TheKey& K) { |
60 | return(myMap.ChangeFind(K)); |
61 | } |
62 | |
63 | //======================================================================= |
64 | //function : Reject |
65 | //purpose : |
66 | //======================================================================= |
67 | |
68 | Standard_Boolean HatchGen_ElementsGen::Reject(const gp_Pnt2d&) const { |
69 | return Standard_False; |
70 | } |
71 | |
72 | //======================================================================= |
73 | //function : Segment |
74 | //purpose : |
75 | //======================================================================= |
76 | |
77 | Standard_Boolean HatchGen_ElementsGen::Segment(const gp_Pnt2d& P, |
78 | gp_Lin2d& L, |
79 | Standard_Real& Par) |
80 | { |
81 | myCurEdge = 1; |
82 | |
83 | return OtherSegment(P, L, Par); |
84 | } |
85 | |
86 | //======================================================================= |
87 | //function : Segment |
88 | //purpose : |
89 | //======================================================================= |
90 | |
91 | Standard_Boolean HatchGen_ElementsGen::OtherSegment(const gp_Pnt2d& P, |
92 | gp_Lin2d& L, |
93 | Standard_Real& Par) |
94 | { |
95 | HatchGen_DataMapIteratorOfMapOfElements Itertemp; |
96 | Standard_Integer i; |
97 | |
98 | for( Itertemp.Initialize(myMap), i = 1; Itertemp.More(); Itertemp.Next(), i++) { |
99 | if (i < myCurEdge) |
100 | continue; |
101 | |
102 | void *ptrmyMap = (void *)(&myMap); |
103 | TheItem& Item=((HatchGen_MapOfElements*)ptrmyMap)->ChangeFind(Itertemp.Key()); |
104 | TheCurve& E = Item.ChangeCurve(); |
105 | TopAbs_Orientation Or= Item.Orientation(); |
106 | gp_Pnt2d P2 = E.Value |
107 | ((E.FirstParameter() + E.LastParameter()) *0.5); |
108 | if ((Or == TopAbs_FORWARD) || |
109 | (Or == TopAbs_REVERSED)) { |
110 | gp_Vec2d V(P,P2); |
111 | Par = V.Magnitude(); |
112 | if (Par >= gp::Resolution()) { |
113 | L = gp_Lin2d(P,V); |
114 | myCurEdge++; |
115 | return Standard_True; |
116 | } |
117 | } |
118 | } |
119 | |
120 | if (i == myCurEdge + 1) { |
121 | Par = RealLast(); |
122 | L = gp_Lin2d(P,gp_Dir2d(1,0)); |
123 | myCurEdge++; |
124 | |
125 | return Standard_True; |
126 | } |
127 | |
128 | return Standard_False; |
129 | } |
130 | |
131 | //======================================================================= |
132 | //function : InitWires |
133 | //purpose : |
134 | //======================================================================= |
135 | |
136 | void HatchGen_ElementsGen::InitWires() { |
137 | NumWire = 0; |
138 | } |
139 | |
140 | //======================================================================= |
141 | //function : RejectWire NYI |
142 | //purpose : |
143 | //======================================================================= |
144 | |
145 | Standard_Boolean HatchGen_ElementsGen::RejectWire(const gp_Lin2d& , |
146 | const Standard_Real) const |
147 | { |
148 | return Standard_False; |
149 | } |
150 | |
151 | //======================================================================= |
152 | //function : InitEdges |
153 | //purpose : |
154 | //======================================================================= |
155 | |
156 | void HatchGen_ElementsGen::InitEdges() { |
157 | NumEdge = 0; |
158 | Iter.Initialize(myMap); |
159 | } |
160 | |
161 | //======================================================================= |
162 | //function : RejectEdge NYI |
163 | //purpose : |
164 | //======================================================================= |
165 | |
166 | Standard_Boolean HatchGen_ElementsGen::RejectEdge(const gp_Lin2d& , |
167 | const Standard_Real ) const |
168 | { |
169 | return Standard_False; |
170 | } |
171 | |
172 | |
173 | //======================================================================= |
174 | //function : CurrentEdge |
175 | //purpose : |
176 | //======================================================================= |
177 | |
178 | void HatchGen_ElementsGen::CurrentEdge(TheCurve& E, |
179 | TopAbs_Orientation& Or) const |
180 | { |
181 | void *ptrmyMap = (void *)(&myMap); |
182 | TheItem& Item=((HatchGen_MapOfElements*)ptrmyMap)->ChangeFind(Iter.Key()); |
183 | |
184 | E = Item.ChangeCurve(); |
185 | Or= Item.Orientation(); |
186 | #if 0 |
187 | E.Edge() = TopoDS::Edge(myEExplorer.Current()); |
188 | E.Face() = myFace; |
189 | Or = E.Edge().Orientation(); |
190 | #endif |
191 | } |
192 | |
193 | |
194 | //======================================================================= |
195 | //function : MoreWires |
196 | //purpose : |
197 | //======================================================================= |
198 | |
199 | Standard_Boolean HatchGen_ElementsGen::MoreWires() const |
200 | { |
201 | return (NumWire == 0); |
202 | } |
203 | |
204 | //======================================================================= |
205 | //function : NextWire |
206 | //purpose : |
207 | //======================================================================= |
208 | |
209 | void HatchGen_ElementsGen::NextWire() { |
210 | NumWire++; |
211 | } |
212 | |
213 | //======================================================================= |
214 | //function : MoreEdges |
215 | //purpose : |
216 | //======================================================================= |
217 | |
218 | Standard_Boolean HatchGen_ElementsGen::MoreEdges() const { |
219 | return(Iter.More()); |
220 | } |
221 | |
222 | //======================================================================= |
223 | //function : NextEdge |
224 | //purpose : |
225 | //======================================================================= |
226 | |
227 | void HatchGen_ElementsGen::NextEdge() { |
228 | Iter.Next(); |
229 | } |
230 | |
231 | |
232 | |