0022627: Change OCCT memory management defaults
[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);
7fd59977 82 //-- cout<<" \n Etat1("<<I<<") = "<<etat1I<<endl;
83 if(etat1I==2) { //-- lbr le 15 fev 99
84 etat1(I)=11;
85
86 ThePointOfPathTool::Value2d(PathPnt, U,V);
87 ustart1.Append(U);
88 vstart1.Append(V);
89 nbMultiplicities.Append(ThePointOfPathTool::Multiplicity(PathPnt));
90
91 for (Standard_Integer J = 1; J <= nbMultiplicities(I); J++) {
92 ThePointOfPathTool::Parameters(PathPnt, J, U , V);
93 Umult.Append(U);
94 Vmult.Append(V);
95 }
96 }
97
98 else {
99 ThePointOfPathTool::Value2d(PathPnt, U,V);
100 ustart1.Append(U);
101 vstart1.Append(V);
102 nbMultiplicities.Append(ThePointOfPathTool::Multiplicity(PathPnt));
103
104 for (Standard_Integer J = 1; J <= nbMultiplicities(I); J++) {
105 ThePointOfPathTool::Parameters(PathPnt, J, U , V);
106 Umult.Append(U);
107 Vmult.Append(V);
108 }
109 }
110 }
111
112
113 for (I = 1; I <= nbPnts2; I++) {
114 etat2.Append(13);
115 ThePointOfLoopTool::Value2d(Pnts2.Value(I), U,V);
116 ustart2.Append(U);
117 vstart2.Append(V);
118 }
119
120 tolerance(1) = ThePSurfaceTool::UResolution(Caro,Precision::Confusion());
121 tolerance(2) = ThePSurfaceTool::VResolution(Caro,Precision::Confusion());
122
123 Um = ThePSurfaceTool::FirstUParameter(Caro);
124 Vm = ThePSurfaceTool::FirstVParameter(Caro);
125 UM = ThePSurfaceTool::LastUParameter(Caro);
126 VM = ThePSurfaceTool::LastVParameter(Caro);
127
128 if (UM < Um) {
129 Standard_Real utemp = UM;
130 UM = Um;
131 Um = utemp;
132 }
133 if (VM < Vm) {
134 Standard_Real vtemp = VM;
135 VM = Vm;
136 Vm = vtemp;
137 }
138
139 Func.Set(Caro);
140
141 // calcul de toutes les lignes ouvertes
142 if (nbPnts1 != 0) ComputeOpenLine(Umult,Vmult,Pnts1,Func,Rajout);
143 // calcul de toutes les lignes fermees
144 if (nbPnts2 != 0) ComputeCloseLine(Umult,Vmult,Pnts1,Pnts2,Func,Rajout);
145 for (I = 1; I <= nbPnts1; I++) {
146 if (etat1(I) >0) seqSingle.Append(Pnts1(I));
147 }
148 done = Standard_True;
149}
150
151
152
153//
154// Perform sans point interieur
155//
156
157void IntWalk_IWalking::Perform(const ThePOPIterator& Pnts1,
158 TheIWFunction& Func,
159 const ThePSurface& Caro,
160 const Standard_Boolean Reversed)
161
162{
163 Standard_Integer I;
164 ThePointOfPath PathPnt;
165 Standard_Boolean Rajout = Standard_False;
166 Standard_Integer nbPnts1 = Pnts1.Length();
167 Standard_Real U,V;
168
169 done = Standard_False;
170
171 ustart1.Clear();
172 vstart1.Clear();
173 etat1.Clear();
174 nbMultiplicities.Clear();
175 ustart2.Clear();
176 vstart2.Clear();
177 etat2.Clear();
178 seqAjout.Clear();
179 lines.Clear();
180 reversed = Reversed;
181
182
183 // Chargement de etat1 et de ustart1 et vstart1.
184
185 TColStd_SequenceOfReal Umult;
186 TColStd_SequenceOfReal Vmult;
187
188 for (I=1;I <= nbPnts1; I++) {
189 PathPnt = Pnts1.Value(I);
190 etat1.Append(1);
191 if (!ThePointOfPathTool::IsPassingPnt(PathPnt)) etat1(I) = 11;
192 if (!ThePointOfPathTool::IsTangent(PathPnt)) etat1(I) = etat1(I) + 1;
193 ThePointOfPathTool::Value2d(PathPnt, U,V);
194 ustart1.Append(U);
195 vstart1.Append(V);
196 nbMultiplicities.Append(ThePointOfPathTool::Multiplicity(PathPnt));
197
198 for (Standard_Integer J = 1; J <= nbMultiplicities(I); J++) {
199 ThePointOfPathTool::Parameters(PathPnt, J, U , V);
200 Umult.Append(U);
201 Vmult.Append(V);
202 }
203 }
204
205 tolerance(1) = ThePSurfaceTool::UResolution(Caro,Precision::Confusion());
206 tolerance(2) = ThePSurfaceTool::VResolution(Caro,Precision::Confusion());
207
208 Um = ThePSurfaceTool::FirstUParameter(Caro);
209 Vm = ThePSurfaceTool::FirstVParameter(Caro);
210 UM = ThePSurfaceTool::LastUParameter(Caro);
211 VM = ThePSurfaceTool::LastVParameter(Caro);
212
213 if (UM < Um) {
214 Standard_Real utemp = UM;
215 UM = Um;
216 Um = utemp;
217 }
218 if (VM < Vm) {
219 Standard_Real vtemp = VM;
220 VM = Vm;
221 Vm = vtemp;
222 }
223
224 Func.Set(Caro);
225
226 // calcul de toutes les lignes ouvertes
227 if (nbPnts1 != 0) ComputeOpenLine(Umult,Vmult,Pnts1,Func,Rajout);
228
229 for (I = 1; I <= nbPnts1; I++) {
230 if (etat1(I) >0) seqSingle.Append(Pnts1(I));
231 }
232 done = Standard_True;
233}
234
235
236