summaryrefslogtreecommitdiff
path: root/inc/HatchGen_ElementsGen.gxx
blob: 676e1463f096d780265b5720425b84e0defbe3a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
// File:	HatchGen_ElementsGen.gxx
// Created:	Fri Dec 16 16:26:12 1994
// Author:	Laurent BUCHARD
//		<lbr@mastox>

//  Modified by skv - Fri Jul 14 17:03:47 2006 OCC12627

#include <TopAbs_Orientation.hxx>
#include <gp.hxx>
#include <gp_Vec2d.hxx>

//HatchGen_ElementsGen::HatchGen_ElementsGen(const HatchGen_ElementsGen& Other) {
HatchGen_ElementsGen::HatchGen_ElementsGen(const HatchGen_ElementsGen& ) {
  cout<<" Magic Constructor in HatchGen_ElementsGen:: "<<endl;
} 

HatchGen_ElementsGen::HatchGen_ElementsGen() { 
  NumWire = 0;
  NumEdge = 0;
  myCurEdge = 1;
}

void HatchGen_ElementsGen::Clear() { 
  myMap.Clear();
}

Standard_Boolean HatchGen_ElementsGen::IsBound(const TheKey& K) const  { 
  return(myMap.IsBound(K));
}

Standard_Boolean HatchGen_ElementsGen::UnBind(const TheKey& K) { 
  return(myMap.UnBind(K));
}

Standard_Boolean HatchGen_ElementsGen::Bind(const TheKey& K,const TheItem& I) { 
  return(myMap.Bind(K,I));
}

const TheItem& HatchGen_ElementsGen::Find(const TheKey& K) const { 
  return(myMap.Find(K));
}

TheItem& HatchGen_ElementsGen::ChangeFind(const TheKey& K)  { 
  return(myMap.ChangeFind(K));
}

//=======================================================================
//function : Reject
//purpose  : 
//=======================================================================

Standard_Boolean  HatchGen_ElementsGen::Reject(const gp_Pnt2d&) const  {
  return Standard_False;
}

//=======================================================================
//function : Segment
//purpose  : 
//=======================================================================

Standard_Boolean HatchGen_ElementsGen::Segment(const gp_Pnt2d& P, 
					             gp_Lin2d& L, 
					             Standard_Real& Par)
{
  myCurEdge = 1;

  return OtherSegment(P, L, Par);
}

//=======================================================================
//function : Segment
//purpose  : 
//=======================================================================

Standard_Boolean HatchGen_ElementsGen::OtherSegment(const gp_Pnt2d& P, 
						          gp_Lin2d& L, 
						          Standard_Real& Par)
{
  HatchGen_DataMapIteratorOfMapOfElements Itertemp;
  Standard_Integer                        i;
  
  for(  Itertemp.Initialize(myMap), i = 1; Itertemp.More(); Itertemp.Next(), i++) { 
    if (i < myCurEdge)
      continue;

    void *ptrmyMap = (void *)(&myMap);
    TheItem& Item=((HatchGen_MapOfElements*)ptrmyMap)->ChangeFind(Itertemp.Key());
    TheCurve& E = Item.ChangeCurve();
    TopAbs_Orientation Or= Item.Orientation();
    gp_Pnt2d P2 = E.Value
      ((E.FirstParameter() + E.LastParameter()) *0.5);
    if ((Or == TopAbs_FORWARD) ||
	(Or == TopAbs_REVERSED)) {
      gp_Vec2d V(P,P2);
      Par = V.Magnitude();
      if (Par >= gp::Resolution()) {
	L = gp_Lin2d(P,V);
	myCurEdge++;
	return Standard_True;
      }
    }
  }

  if (i == myCurEdge + 1) {
    Par = RealLast();
    L = gp_Lin2d(P,gp_Dir2d(1,0));
    myCurEdge++;

    return Standard_True;
  }

  return Standard_False;
}

//=======================================================================
//function : InitWires
//purpose  : 
//=======================================================================

void  HatchGen_ElementsGen::InitWires()  {
  NumWire = 0;
}

//=======================================================================
//function : RejectWire NYI
//purpose  : 
//=======================================================================

Standard_Boolean HatchGen_ElementsGen::RejectWire(const gp_Lin2d& , 
						   const Standard_Real) const 
{
  return Standard_False;
}

//=======================================================================
//function : InitEdges
//purpose  : 
//=======================================================================

void  HatchGen_ElementsGen::InitEdges()  {
  NumEdge = 0;
  Iter.Initialize(myMap);
}

//=======================================================================
//function : RejectEdge NYI
//purpose  : 
//=======================================================================

Standard_Boolean HatchGen_ElementsGen::RejectEdge(const gp_Lin2d& , 
						  const Standard_Real ) const 
{
  return Standard_False;
}


//=======================================================================
//function : CurrentEdge
//purpose  : 
//=======================================================================

void  HatchGen_ElementsGen::CurrentEdge(TheCurve& E, 
					TopAbs_Orientation& Or) const 
{
  void *ptrmyMap = (void *)(&myMap);
  TheItem& Item=((HatchGen_MapOfElements*)ptrmyMap)->ChangeFind(Iter.Key());

  E = Item.ChangeCurve();
  Or= Item.Orientation();
#if 0 
  E.Edge() = TopoDS::Edge(myEExplorer.Current());
  E.Face() = myFace;
  Or = E.Edge().Orientation();
#endif
}


//=======================================================================
//function : MoreWires
//purpose  : 
//=======================================================================

Standard_Boolean  HatchGen_ElementsGen::MoreWires() const 
{
  return (NumWire == 0);
}

//=======================================================================
//function : NextWire
//purpose  : 
//=======================================================================

void HatchGen_ElementsGen::NextWire()  {
  NumWire++;
}

//=======================================================================
//function : MoreEdges
//purpose  : 
//=======================================================================

Standard_Boolean  HatchGen_ElementsGen::MoreEdges() const  {
  return(Iter.More());
}

//=======================================================================
//function : NextEdge
//purpose  : 
//=======================================================================

void HatchGen_ElementsGen::NextEdge()  {
  Iter.Next();
}