0023952: Improving thread-safety of intersections, approximations and other modeling...
[occt.git] / src / IntWalk / IntWalk_IWalking_1.gxx
CommitLineData
b311480e 1// Copyright (c) 1995-1999 Matra Datavision
2// Copyright (c) 1999-2012 OPEN CASCADE SAS
3//
4// The content of this file is subject to the Open CASCADE Technology Public
5// License Version 6.5 (the "License"). You may not use the content of this file
6// except in compliance with the License. Please obtain a copy of the License
7// at http://www.opencascade.org and read it completely before using this file.
8//
9// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11//
12// The Original Code and all software distributed under the License is
13// distributed on an "AS IS" basis, without warranty of any kind, and the
14// Initial Developer hereby disclaims all such warranties, including without
15// limitation, any warranties of merchantability, fitness for a particular
16// purpose or non-infringement. Please see the License for the specific terms
17// and conditions governing the rights and limitations under the License.
18
7fd59977 19#ifdef CHRONO
20#include <OSD_Chronometer.hxx>
21OSD_Chronometer Chronrsnld;
22
23#endif
24
25#include <Precision.hxx>
26
27IntWalk_IWalking::IntWalk_IWalking (const Standard_Real Epsilon,
28 const Standard_Real Deflection,
29 const Standard_Real Increment ) :
30 done(Standard_False),
31 fleche(Deflection),
32 pas(Increment),
33 tolerance(1,2),
1ef32e96
RL
34 epsilon(Epsilon*Epsilon),
35 NbPointsConfondusConsecutifs(0),
36 EpsilonSembleTropGrand(0)
7fd59977 37{
38}
39
40
41// ***************************************************************************
42 // etat1=12 pas tangent,pas passant
43 // etat1=11 tangent,pas passant
44 // etat1=2 pas tangent,passant
45 // etat1=1 tangent,passant
46 // lorsque un point a ete traite son etat devient negatif.
47// ***************************************************************************
48 // etat2=13 point de demarage interieur sur ligne ferme
49 // etat2=12 point de demarage interieur sur ligne ouverte
50 // (ligne initialement fermee -> la ligne s est ouverte)
51 // lorsque un point a ete traite (ou si on passe dessus lors du
52 // cheminement) son etat devient negatif.
53// ****************************************************************************
54
55//
56// Perform avec points interieurs
57//
58void IntWalk_IWalking::Perform(const ThePOPIterator& Pnts1,
59 const ThePOLIterator& Pnts2,
60 TheIWFunction& Func,
61 const ThePSurface& Caro,
62 const Standard_Boolean Reversed)
63
64{
65
66 Standard_Integer I;
67 ThePointOfPath PathPnt;
68 Standard_Boolean Rajout = Standard_False;
69 Standard_Integer nbPnts1 = Pnts1.Length();
70 Standard_Integer nbPnts2 = Pnts2.Length();
71 Standard_Real U,V;
72
73 done = Standard_False;
74
75 ustart1.Clear();
76 vstart1.Clear();
77 etat1.Clear();
78 nbMultiplicities.Clear();
79 ustart2.Clear();
80 vstart2.Clear();
81 etat2.Clear();
82 seqAjout.Clear();
83 lines.Clear();
84 reversed = Reversed;
85
86
87 // Chargement de etat1 et etat2 et des ustart et vstart.
88
89 TColStd_SequenceOfReal Umult;
90 TColStd_SequenceOfReal Vmult;
91
92 Standard_Integer decal=0;
93 for (I=1;I <= nbPnts1+decal; I++) {
94 PathPnt = Pnts1.Value(I-decal);
95 etat1.Append(1);
96 if (!ThePointOfPathTool::IsPassingPnt(PathPnt))
97 etat1(I) = 11;
98 if (!ThePointOfPathTool::IsTangent(PathPnt))
99 etat1(I) = etat1(I) + 1;
100
101 Standard_Integer etat1I=etat1(I);
7fd59977 102 //-- cout<<" \n Etat1("<<I<<") = "<<etat1I<<endl;
103 if(etat1I==2) { //-- lbr le 15 fev 99
104 etat1(I)=11;
105
106 ThePointOfPathTool::Value2d(PathPnt, U,V);
107 ustart1.Append(U);
108 vstart1.Append(V);
109 nbMultiplicities.Append(ThePointOfPathTool::Multiplicity(PathPnt));
110
111 for (Standard_Integer J = 1; J <= nbMultiplicities(I); J++) {
112 ThePointOfPathTool::Parameters(PathPnt, J, U , V);
113 Umult.Append(U);
114 Vmult.Append(V);
115 }
116 }
117
118 else {
119 ThePointOfPathTool::Value2d(PathPnt, U,V);
120 ustart1.Append(U);
121 vstart1.Append(V);
122 nbMultiplicities.Append(ThePointOfPathTool::Multiplicity(PathPnt));
123
124 for (Standard_Integer J = 1; J <= nbMultiplicities(I); J++) {
125 ThePointOfPathTool::Parameters(PathPnt, J, U , V);
126 Umult.Append(U);
127 Vmult.Append(V);
128 }
129 }
130 }
131
132
133 for (I = 1; I <= nbPnts2; I++) {
134 etat2.Append(13);
135 ThePointOfLoopTool::Value2d(Pnts2.Value(I), U,V);
136 ustart2.Append(U);
137 vstart2.Append(V);
138 }
139
140 tolerance(1) = ThePSurfaceTool::UResolution(Caro,Precision::Confusion());
141 tolerance(2) = ThePSurfaceTool::VResolution(Caro,Precision::Confusion());
142
143 Um = ThePSurfaceTool::FirstUParameter(Caro);
144 Vm = ThePSurfaceTool::FirstVParameter(Caro);
145 UM = ThePSurfaceTool::LastUParameter(Caro);
146 VM = ThePSurfaceTool::LastVParameter(Caro);
147
148 if (UM < Um) {
149 Standard_Real utemp = UM;
150 UM = Um;
151 Um = utemp;
152 }
153 if (VM < Vm) {
154 Standard_Real vtemp = VM;
155 VM = Vm;
156 Vm = vtemp;
157 }
158
159 Func.Set(Caro);
160
161 // calcul de toutes les lignes ouvertes
162 if (nbPnts1 != 0) ComputeOpenLine(Umult,Vmult,Pnts1,Func,Rajout);
163 // calcul de toutes les lignes fermees
164 if (nbPnts2 != 0) ComputeCloseLine(Umult,Vmult,Pnts1,Pnts2,Func,Rajout);
165 for (I = 1; I <= nbPnts1; I++) {
166 if (etat1(I) >0) seqSingle.Append(Pnts1(I));
167 }
168 done = Standard_True;
169}
170
171
172
173//
174// Perform sans point interieur
175//
176
177void IntWalk_IWalking::Perform(const ThePOPIterator& Pnts1,
178 TheIWFunction& Func,
179 const ThePSurface& Caro,
180 const Standard_Boolean Reversed)
181
182{
183 Standard_Integer I;
184 ThePointOfPath PathPnt;
185 Standard_Boolean Rajout = Standard_False;
186 Standard_Integer nbPnts1 = Pnts1.Length();
187 Standard_Real U,V;
188
189 done = Standard_False;
190
191 ustart1.Clear();
192 vstart1.Clear();
193 etat1.Clear();
194 nbMultiplicities.Clear();
195 ustart2.Clear();
196 vstart2.Clear();
197 etat2.Clear();
198 seqAjout.Clear();
199 lines.Clear();
200 reversed = Reversed;
201
202
203 // Chargement de etat1 et de ustart1 et vstart1.
204
205 TColStd_SequenceOfReal Umult;
206 TColStd_SequenceOfReal Vmult;
207
208 for (I=1;I <= nbPnts1; I++) {
209 PathPnt = Pnts1.Value(I);
210 etat1.Append(1);
211 if (!ThePointOfPathTool::IsPassingPnt(PathPnt)) etat1(I) = 11;
212 if (!ThePointOfPathTool::IsTangent(PathPnt)) etat1(I) = etat1(I) + 1;
213 ThePointOfPathTool::Value2d(PathPnt, U,V);
214 ustart1.Append(U);
215 vstart1.Append(V);
216 nbMultiplicities.Append(ThePointOfPathTool::Multiplicity(PathPnt));
217
218 for (Standard_Integer J = 1; J <= nbMultiplicities(I); J++) {
219 ThePointOfPathTool::Parameters(PathPnt, J, U , V);
220 Umult.Append(U);
221 Vmult.Append(V);
222 }
223 }
224
225 tolerance(1) = ThePSurfaceTool::UResolution(Caro,Precision::Confusion());
226 tolerance(2) = ThePSurfaceTool::VResolution(Caro,Precision::Confusion());
227
228 Um = ThePSurfaceTool::FirstUParameter(Caro);
229 Vm = ThePSurfaceTool::FirstVParameter(Caro);
230 UM = ThePSurfaceTool::LastUParameter(Caro);
231 VM = ThePSurfaceTool::LastVParameter(Caro);
232
233 if (UM < Um) {
234 Standard_Real utemp = UM;
235 UM = Um;
236 Um = utemp;
237 }
238 if (VM < Vm) {
239 Standard_Real vtemp = VM;
240 VM = Vm;
241 Vm = vtemp;
242 }
243
244 Func.Set(Caro);
245
246 // calcul de toutes les lignes ouvertes
247 if (nbPnts1 != 0) ComputeOpenLine(Umult,Vmult,Pnts1,Func,Rajout);
248
249 for (I = 1; I <= nbPnts1; I++) {
250 if (etat1(I) >0) seqSingle.Append(Pnts1(I));
251 }
252 done = Standard_True;
253}
254
255
256