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