Integration of OCCT 6.5.0 from SVN
[occt.git] / src / IntWalk / IntWalk_IWalking_1.gxx
CommitLineData
7fd59977 1#ifdef CHRONO
2#include <OSD_Chronometer.hxx>
3OSD_Chronometer Chronrsnld;
4
5#endif
6
7#include <Precision.hxx>
8
9IntWalk_IWalking::IntWalk_IWalking (const Standard_Real Epsilon,
10 const Standard_Real Deflection,
11 const Standard_Real Increment ) :
12 done(Standard_False),
13 fleche(Deflection),
14 pas(Increment),
15 tolerance(1,2),
16 epsilon(Epsilon*Epsilon)
17{
18}
19
20
21// ***************************************************************************
22 // etat1=12 pas tangent,pas passant
23 // etat1=11 tangent,pas passant
24 // etat1=2 pas tangent,passant
25 // etat1=1 tangent,passant
26 // lorsque un point a ete traite son etat devient negatif.
27// ***************************************************************************
28 // etat2=13 point de demarage interieur sur ligne ferme
29 // etat2=12 point de demarage interieur sur ligne ouverte
30 // (ligne initialement fermee -> la ligne s est ouverte)
31 // lorsque un point a ete traite (ou si on passe dessus lors du
32 // cheminement) son etat devient negatif.
33// ****************************************************************************
34
35//
36// Perform avec points interieurs
37//
38void IntWalk_IWalking::Perform(const ThePOPIterator& Pnts1,
39 const ThePOLIterator& Pnts2,
40 TheIWFunction& Func,
41 const ThePSurface& Caro,
42 const Standard_Boolean Reversed)
43
44{
45
46 Standard_Integer I;
47 ThePointOfPath PathPnt;
48 Standard_Boolean Rajout = Standard_False;
49 Standard_Integer nbPnts1 = Pnts1.Length();
50 Standard_Integer nbPnts2 = Pnts2.Length();
51 Standard_Real U,V;
52
53 done = Standard_False;
54
55 ustart1.Clear();
56 vstart1.Clear();
57 etat1.Clear();
58 nbMultiplicities.Clear();
59 ustart2.Clear();
60 vstart2.Clear();
61 etat2.Clear();
62 seqAjout.Clear();
63 lines.Clear();
64 reversed = Reversed;
65
66
67 // Chargement de etat1 et etat2 et des ustart et vstart.
68
69 TColStd_SequenceOfReal Umult;
70 TColStd_SequenceOfReal Vmult;
71
72 Standard_Integer decal=0;
73 for (I=1;I <= nbPnts1+decal; I++) {
74 PathPnt = Pnts1.Value(I-decal);
75 etat1.Append(1);
76 if (!ThePointOfPathTool::IsPassingPnt(PathPnt))
77 etat1(I) = 11;
78 if (!ThePointOfPathTool::IsTangent(PathPnt))
79 etat1(I) = etat1(I) + 1;
80
81 Standard_Integer etat1I=etat1(I);
82#ifdef DEB
83 Standard_Integer multi=0;
84#endif
85 //-- cout<<" \n Etat1("<<I<<") = "<<etat1I<<endl;
86 if(etat1I==2) { //-- lbr le 15 fev 99
87 etat1(I)=11;
88
89 ThePointOfPathTool::Value2d(PathPnt, U,V);
90 ustart1.Append(U);
91 vstart1.Append(V);
92 nbMultiplicities.Append(ThePointOfPathTool::Multiplicity(PathPnt));
93
94 for (Standard_Integer J = 1; J <= nbMultiplicities(I); J++) {
95 ThePointOfPathTool::Parameters(PathPnt, J, U , V);
96 Umult.Append(U);
97 Vmult.Append(V);
98 }
99 }
100
101 else {
102 ThePointOfPathTool::Value2d(PathPnt, U,V);
103 ustart1.Append(U);
104 vstart1.Append(V);
105 nbMultiplicities.Append(ThePointOfPathTool::Multiplicity(PathPnt));
106
107 for (Standard_Integer J = 1; J <= nbMultiplicities(I); J++) {
108 ThePointOfPathTool::Parameters(PathPnt, J, U , V);
109 Umult.Append(U);
110 Vmult.Append(V);
111 }
112 }
113 }
114
115
116 for (I = 1; I <= nbPnts2; I++) {
117 etat2.Append(13);
118 ThePointOfLoopTool::Value2d(Pnts2.Value(I), U,V);
119 ustart2.Append(U);
120 vstart2.Append(V);
121 }
122
123 tolerance(1) = ThePSurfaceTool::UResolution(Caro,Precision::Confusion());
124 tolerance(2) = ThePSurfaceTool::VResolution(Caro,Precision::Confusion());
125
126 Um = ThePSurfaceTool::FirstUParameter(Caro);
127 Vm = ThePSurfaceTool::FirstVParameter(Caro);
128 UM = ThePSurfaceTool::LastUParameter(Caro);
129 VM = ThePSurfaceTool::LastVParameter(Caro);
130
131 if (UM < Um) {
132 Standard_Real utemp = UM;
133 UM = Um;
134 Um = utemp;
135 }
136 if (VM < Vm) {
137 Standard_Real vtemp = VM;
138 VM = Vm;
139 Vm = vtemp;
140 }
141
142 Func.Set(Caro);
143
144 // calcul de toutes les lignes ouvertes
145 if (nbPnts1 != 0) ComputeOpenLine(Umult,Vmult,Pnts1,Func,Rajout);
146 // calcul de toutes les lignes fermees
147 if (nbPnts2 != 0) ComputeCloseLine(Umult,Vmult,Pnts1,Pnts2,Func,Rajout);
148 for (I = 1; I <= nbPnts1; I++) {
149 if (etat1(I) >0) seqSingle.Append(Pnts1(I));
150 }
151 done = Standard_True;
152}
153
154
155
156//
157// Perform sans point interieur
158//
159
160void IntWalk_IWalking::Perform(const ThePOPIterator& Pnts1,
161 TheIWFunction& Func,
162 const ThePSurface& Caro,
163 const Standard_Boolean Reversed)
164
165{
166 Standard_Integer I;
167 ThePointOfPath PathPnt;
168 Standard_Boolean Rajout = Standard_False;
169 Standard_Integer nbPnts1 = Pnts1.Length();
170 Standard_Real U,V;
171
172 done = Standard_False;
173
174 ustart1.Clear();
175 vstart1.Clear();
176 etat1.Clear();
177 nbMultiplicities.Clear();
178 ustart2.Clear();
179 vstart2.Clear();
180 etat2.Clear();
181 seqAjout.Clear();
182 lines.Clear();
183 reversed = Reversed;
184
185
186 // Chargement de etat1 et de ustart1 et vstart1.
187
188 TColStd_SequenceOfReal Umult;
189 TColStd_SequenceOfReal Vmult;
190
191 for (I=1;I <= nbPnts1; I++) {
192 PathPnt = Pnts1.Value(I);
193 etat1.Append(1);
194 if (!ThePointOfPathTool::IsPassingPnt(PathPnt)) etat1(I) = 11;
195 if (!ThePointOfPathTool::IsTangent(PathPnt)) etat1(I) = etat1(I) + 1;
196 ThePointOfPathTool::Value2d(PathPnt, U,V);
197 ustart1.Append(U);
198 vstart1.Append(V);
199 nbMultiplicities.Append(ThePointOfPathTool::Multiplicity(PathPnt));
200
201 for (Standard_Integer J = 1; J <= nbMultiplicities(I); J++) {
202 ThePointOfPathTool::Parameters(PathPnt, J, U , V);
203 Umult.Append(U);
204 Vmult.Append(V);
205 }
206 }
207
208 tolerance(1) = ThePSurfaceTool::UResolution(Caro,Precision::Confusion());
209 tolerance(2) = ThePSurfaceTool::VResolution(Caro,Precision::Confusion());
210
211 Um = ThePSurfaceTool::FirstUParameter(Caro);
212 Vm = ThePSurfaceTool::FirstVParameter(Caro);
213 UM = ThePSurfaceTool::LastUParameter(Caro);
214 VM = ThePSurfaceTool::LastVParameter(Caro);
215
216 if (UM < Um) {
217 Standard_Real utemp = UM;
218 UM = Um;
219 Um = utemp;
220 }
221 if (VM < Vm) {
222 Standard_Real vtemp = VM;
223 VM = Vm;
224 Vm = vtemp;
225 }
226
227 Func.Set(Caro);
228
229 // calcul de toutes les lignes ouvertes
230 if (nbPnts1 != 0) ComputeOpenLine(Umult,Vmult,Pnts1,Func,Rajout);
231
232 for (I = 1; I <= nbPnts1; I++) {
233 if (etat1(I) >0) seqSingle.Append(Pnts1(I));
234 }
235 done = Standard_True;
236}
237
238
239