summaryrefslogtreecommitdiff
path: root/inc/IntWalk_IWalking_1.gxx
blob: e3cbc241ac2feb011fdd1aba3a1dea11a39e6c66 (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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
#ifdef CHRONO
#include <OSD_Chronometer.hxx>
OSD_Chronometer Chronrsnld;

#endif

#include <Precision.hxx>

IntWalk_IWalking::IntWalk_IWalking (const Standard_Real Epsilon,
                                    const Standard_Real Deflection,
                                    const Standard_Real Increment ) :
      done(Standard_False),
      fleche(Deflection),
      pas(Increment),
      tolerance(1,2),
      epsilon(Epsilon*Epsilon)
{
}


// ***************************************************************************
     //  etat1=12 pas tangent,pas passant
     //  etat1=11 tangent,pas passant
     //  etat1=2  pas tangent,passant
     //  etat1=1  tangent,passant
     //  lorsque un point a ete traite son etat devient negatif.
// ***************************************************************************
     //  etat2=13  point de demarage interieur sur ligne ferme
     //  etat2=12  point de demarage interieur sur ligne ouverte
     //            (ligne initialement fermee -> la ligne s est ouverte)       
     //  lorsque un point a ete traite (ou si on passe dessus lors du 
     //  cheminement) son etat devient negatif.
// ****************************************************************************

//
// Perform avec points interieurs
//
void IntWalk_IWalking::Perform(const ThePOPIterator& Pnts1,
			       const ThePOLIterator& Pnts2,
			       TheIWFunction& Func,
			       const ThePSurface& Caro,
			       const Standard_Boolean Reversed)

{

  Standard_Integer I;
  ThePointOfPath PathPnt;
  Standard_Boolean Rajout = Standard_False;
  Standard_Integer nbPnts1 = Pnts1.Length();
  Standard_Integer nbPnts2 = Pnts2.Length();
  Standard_Real U,V;

  done = Standard_False;

  ustart1.Clear();
  vstart1.Clear();
  etat1.Clear();
  nbMultiplicities.Clear();
  ustart2.Clear();
  vstart2.Clear();
  etat2.Clear();
  seqAjout.Clear();
  lines.Clear();
  reversed = Reversed;


  // Chargement de etat1 et etat2  et des ustart et vstart.

  TColStd_SequenceOfReal Umult;
  TColStd_SequenceOfReal Vmult;

  Standard_Integer decal=0;
  for (I=1;I <= nbPnts1+decal; I++) {
    PathPnt = Pnts1.Value(I-decal);
    etat1.Append(1);
    if (!ThePointOfPathTool::IsPassingPnt(PathPnt)) 
      etat1(I) = 11; 
    if (!ThePointOfPathTool::IsTangent(PathPnt))   
      etat1(I) = etat1(I) + 1;

    Standard_Integer etat1I=etat1(I);
    //-- cout<<" \n Etat1("<<I<<") = "<<etat1I<<endl;
    if(etat1I==2) {  //-- lbr le 15 fev 99 
      etat1(I)=11;      
      
      ThePointOfPathTool::Value2d(PathPnt, U,V);
      ustart1.Append(U);
      vstart1.Append(V);
      nbMultiplicities.Append(ThePointOfPathTool::Multiplicity(PathPnt));
      
      for (Standard_Integer J = 1; J <= nbMultiplicities(I); J++) {
	ThePointOfPathTool::Parameters(PathPnt, J, U , V);
	Umult.Append(U);
	Vmult.Append(V);
      }
    }
     
    else { 
      ThePointOfPathTool::Value2d(PathPnt, U,V);
      ustart1.Append(U);
      vstart1.Append(V);
      nbMultiplicities.Append(ThePointOfPathTool::Multiplicity(PathPnt));
      
      for (Standard_Integer J = 1; J <= nbMultiplicities(I); J++) {
	ThePointOfPathTool::Parameters(PathPnt, J, U , V);
	Umult.Append(U);
	Vmult.Append(V);
      }
    }
  }


  for (I = 1; I <= nbPnts2; I++) {
    etat2.Append(13);
    ThePointOfLoopTool::Value2d(Pnts2.Value(I), U,V);
    ustart2.Append(U);
    vstart2.Append(V);
  }

  tolerance(1) = ThePSurfaceTool::UResolution(Caro,Precision::Confusion());
  tolerance(2) = ThePSurfaceTool::VResolution(Caro,Precision::Confusion());

  Um = ThePSurfaceTool::FirstUParameter(Caro);
  Vm = ThePSurfaceTool::FirstVParameter(Caro);
  UM = ThePSurfaceTool::LastUParameter(Caro);
  VM = ThePSurfaceTool::LastVParameter(Caro);

  if (UM < Um) {
    Standard_Real utemp = UM;
    UM = Um;
    Um = utemp;
  }
  if (VM < Vm) {
    Standard_Real vtemp = VM;
    VM = Vm;
    Vm = vtemp;
  }

  Func.Set(Caro);

  // calcul de toutes les lignes ouvertes   
  if (nbPnts1 != 0) ComputeOpenLine(Umult,Vmult,Pnts1,Func,Rajout); 
  // calcul de toutes les lignes fermees 
  if (nbPnts2 != 0) ComputeCloseLine(Umult,Vmult,Pnts1,Pnts2,Func,Rajout); 
  for (I = 1; I <= nbPnts1; I++) { 
    if (etat1(I) >0) seqSingle.Append(Pnts1(I));
  }
  done = Standard_True;
}



//
// Perform sans point interieur
//

void IntWalk_IWalking::Perform(const ThePOPIterator& Pnts1,
			       TheIWFunction& Func,
			       const ThePSurface& Caro,
			       const Standard_Boolean Reversed)

{
  Standard_Integer I;
  ThePointOfPath PathPnt;
  Standard_Boolean Rajout = Standard_False;
  Standard_Integer nbPnts1 = Pnts1.Length();
  Standard_Real U,V;

  done = Standard_False;

  ustart1.Clear();
  vstart1.Clear();
  etat1.Clear();
  nbMultiplicities.Clear();
  ustart2.Clear();
  vstart2.Clear();
  etat2.Clear();
  seqAjout.Clear();
  lines.Clear();
  reversed = Reversed;


  // Chargement de etat1 et de ustart1 et vstart1.

  TColStd_SequenceOfReal Umult;
  TColStd_SequenceOfReal Vmult;

  for (I=1;I <= nbPnts1; I++) {
    PathPnt = Pnts1.Value(I);
    etat1.Append(1);
    if (!ThePointOfPathTool::IsPassingPnt(PathPnt)) etat1(I) = 11; 
    if (!ThePointOfPathTool::IsTangent(PathPnt))   etat1(I) = etat1(I) + 1;
    ThePointOfPathTool::Value2d(PathPnt, U,V);
    ustart1.Append(U);
    vstart1.Append(V);
    nbMultiplicities.Append(ThePointOfPathTool::Multiplicity(PathPnt));

    for (Standard_Integer J = 1; J <= nbMultiplicities(I); J++) {
      ThePointOfPathTool::Parameters(PathPnt, J, U , V);
      Umult.Append(U);
      Vmult.Append(V);
    }
  }

  tolerance(1) = ThePSurfaceTool::UResolution(Caro,Precision::Confusion());
  tolerance(2) = ThePSurfaceTool::VResolution(Caro,Precision::Confusion());

  Um = ThePSurfaceTool::FirstUParameter(Caro);
  Vm = ThePSurfaceTool::FirstVParameter(Caro);
  UM = ThePSurfaceTool::LastUParameter(Caro);
  VM = ThePSurfaceTool::LastVParameter(Caro);

  if (UM < Um) {
    Standard_Real utemp = UM;
    UM = Um;
    Um = utemp;
  }
  if (VM < Vm) {
    Standard_Real vtemp = VM;
    VM = Vm;
    Vm = vtemp;
  }

  Func.Set(Caro);

  // calcul de toutes les lignes ouvertes   
  if (nbPnts1 != 0) ComputeOpenLine(Umult,Vmult,Pnts1,Func,Rajout); 

  for (I = 1; I <= nbPnts1; I++) { 
    if (etat1(I) >0) seqSingle.Append(Pnts1(I));
  }
  done = Standard_True;
}