Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1993-02-02 |
2 | // Created by: Laurent BUCHARD | |
3 | // Copyright (c) 1993-1999 Matra Datavision | |
973c2be1 | 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 5 | // |
973c2be1 | 6 | // This file is part of Open CASCADE Technology software library. |
b311480e | 7 | // |
d5f74e42 | 8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published | |
973c2be1 | 10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT | |
12 | // distribution for complete text of the license and disclaimer of any warranty. | |
b311480e | 13 | // |
973c2be1 | 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. | |
7fd59977 | 16 | |
17 | // modified by Edward AGAPOV (eap) Tue Jan 22 12:29:55 2002 | |
18 | // modified by Oleg FEDYAED (ofv) Fri Nov 29 16:08:02 2002 | |
19 | ||
42cf5bc1 | 20 | #include <Adaptor3d_HSurface.hxx> |
21 | #include <Adaptor3d_TopolTool.hxx> | |
22 | #include <gp_Dir.hxx> | |
23 | #include <gp_Pnt.hxx> | |
7fd59977 | 24 | #include <Intf_PIType.hxx> |
25 | #include <Intf_SectionLine.hxx> | |
7fd59977 | 26 | #include <Intf_SectionPoint.hxx> |
42cf5bc1 | 27 | #include <Intf_TangentZone.hxx> |
28 | #include <IntPatch_InterferencePolyhedron.hxx> | |
29 | #include <IntPatch_Line.hxx> | |
30 | #include <IntPatch_Polyhedron.hxx> | |
31 | #include <IntPatch_PrmPrmIntersection.hxx> | |
32 | #include <IntPatch_PrmPrmIntersection_T3Bits.hxx> | |
33 | #include <IntPatch_RstInt.hxx> | |
34 | #include <IntPatch_WLine.hxx> | |
7fd59977 | 35 | #include <IntPolyh_Intersection.hxx> |
42cf5bc1 | 36 | #include <IntSurf_LineOn2S.hxx> |
7fd59977 | 37 | #include <IntSurf_ListIteratorOfListOfPntOn2S.hxx> |
42cf5bc1 | 38 | #include <IntSurf_PntOn2S.hxx> |
39 | #include <IntWalk_PWalking.hxx> | |
40 | #include <Standard_OutOfRange.hxx> | |
41 | #include <StdFail_NotDone.hxx> | |
42 | #include <TColStd_Array1OfReal.hxx> | |
7fd59977 | 43 | #include <TColStd_HArray1OfReal.hxx> |
42cf5bc1 | 44 | #include <TColStd_SequenceOfInteger.hxx> |
7fd59977 | 45 | |
46 | static void SectionPointToParameters(const Intf_SectionPoint& Sp, | |
00302ba4 | 47 | const IntPatch_Polyhedron& Surf1, |
48 | const IntPatch_Polyhedron& Surf2, | |
49 | Standard_Real& u1, | |
50 | Standard_Real& v1, | |
51 | Standard_Real& u2, | |
52 | Standard_Real& v2); | |
7fd59977 | 53 | |
54 | ||
55 | static | |
00302ba4 | 56 | void AdjustOnPeriodic(const Handle(Adaptor3d_HSurface)& Surf1, |
57 | const Handle(Adaptor3d_HSurface)& Surf2, | |
58 | IntPatch_SequenceOfLine& aSLin); | |
7fd59977 | 59 | |
b1c5c4e6 | 60 | static |
00302ba4 | 61 | IntSurf_PntOn2S MakeNewPoint(const IntSurf_PntOn2S& replacePnt, |
62 | const IntSurf_PntOn2S& oldPnt, | |
63 | const Standard_Real* Periods); | |
b1c5c4e6 | 64 | |
a7dd5d0f | 65 | static Standard_Boolean IsPointOnLine(const IntSurf_PntOn2S &thePOn2S, |
66 | const Handle(IntPatch_WLine) &theWLine, | |
67 | const Standard_Real Deflection); | |
68 | ||
69 | static void AddWLine(IntPatch_SequenceOfLine &theLines, | |
70 | const Handle(IntPatch_WLine) &theWLine, | |
71 | const Standard_Real Deflection); | |
72 | ||
eb75e31c | 73 | static void SeveralWlinesProcessing(const Handle(Adaptor3d_HSurface)& theSurf1, |
74 | const Handle(Adaptor3d_HSurface)& theSurf2, | |
75 | const IntPatch_SequenceOfLine& theSLin, | |
76 | const Standard_Real* const thePeriodsArr, | |
77 | const IntSurf_TypeTrans theTrans1, | |
78 | const IntSurf_TypeTrans theTrans2, | |
79 | const Standard_Real theTol, | |
714c3bfc | 80 | const Standard_Real theMaxStepS1, |
81 | const Standard_Real theMaxStepS2, | |
eb75e31c | 82 | Handle(IntPatch_WLine)& theWLline) |
83 | { | |
84 | if(theSLin.Length() == 0) | |
85 | return; | |
86 | ||
87 | Standard_Real aU1 = 0.0, aV1 = 0.0, aU2 = 0.0, aV2 = 0.0; | |
88 | ||
eb75e31c | 89 | Standard_Integer cnbV = theWLline->NbVertex(); |
90 | Standard_Integer ciV; | |
91 | for( ciV = 1; ciV <= cnbV; ciV++ ) | |
92 | { | |
93 | Standard_Real pntDMin = 1.e+100; | |
94 | Standard_Integer VDMin = 0; | |
95 | Standard_Integer WLDMin = 0; | |
96 | gp_Pnt cPV = theWLline->Vertex(ciV).Value(); | |
97 | theWLline->Vertex(ciV).Parameters(aU1, aV1, aU2, aV2); | |
98 | const gp_Pnt2d aPCS1(aU1, aV1), aPCS2(aU2, aV2); | |
99 | Standard_Integer iL; | |
100 | for( iL = 1; iL <= theSLin.Length(); iL++) | |
101 | { | |
102 | const Handle(IntPatch_Line)& aSLine = theSLin.Value(iL); | |
103 | IntPatch_IType aType = aSLine->ArcType(); | |
104 | if( aType != IntPatch_Walking) | |
105 | continue; | |
106 | const Handle(IntPatch_WLine) aWLine = Handle(IntPatch_WLine)::DownCast(aSLine); | |
107 | Standard_Integer tnbV = aWLine->NbVertex(); | |
108 | Standard_Integer tiV; | |
109 | for( tiV = 1; tiV <= tnbV; tiV++ ) | |
110 | { | |
111 | gp_Pnt tPV = aWLine->Vertex(tiV).Value(); | |
112 | ||
113 | aWLine->Vertex(tiV).Parameters(aU1, aV1, aU2, aV2); | |
114 | const gp_Pnt2d aPTS1(aU1, aV1), aPTS2(aU2, aV2); | |
115 | ||
116 | Standard_Real tDistance = cPV.Distance(tPV); | |
117 | Standard_Real uRs1 = theSurf1->Surface().UResolution(tDistance); | |
118 | Standard_Real vRs1 = theSurf1->Surface().VResolution(tDistance); | |
119 | Standard_Real uRs2 = theSurf2->Surface().UResolution(tDistance); | |
120 | Standard_Real vRs2 = theSurf2->Surface().VResolution(tDistance); | |
121 | Standard_Real RmaxS1 = Max(uRs1,vRs1); | |
122 | Standard_Real RmaxS2 = Max(uRs2,vRs2); | |
714c3bfc | 123 | |
124 | if(RmaxS1 < theMaxStepS1 && RmaxS2 < theMaxStepS2) | |
eb75e31c | 125 | { |
714c3bfc | 126 | if( pntDMin > tDistance && tDistance > Precision::PConfusion()) |
eb75e31c | 127 | { |
714c3bfc | 128 | const Standard_Real aSqDist1 = aPCS1.SquareDistance(aPTS1), |
129 | aSqDist2 = aPCS2.SquareDistance(aPTS2); | |
130 | if((aSqDist1 < RmaxS1*RmaxS1) && (aSqDist2 < RmaxS2*RmaxS2)) | |
eb75e31c | 131 | { |
132 | pntDMin = tDistance; | |
133 | VDMin = tiV; | |
134 | WLDMin = iL; | |
135 | } | |
136 | } | |
137 | } | |
138 | } | |
139 | } | |
140 | ||
141 | if( VDMin != 0 ) | |
142 | { | |
143 | const Handle(IntPatch_Line)& aSLine = theSLin.Value(WLDMin); | |
144 | const Handle(IntPatch_WLine) aWLine = Handle(IntPatch_WLine)::DownCast(aSLine); | |
145 | Standard_Integer tiVpar = (Standard_Integer)aWLine->Vertex(VDMin).ParameterOnLine(); | |
146 | Standard_Integer ciVpar = (Standard_Integer)theWLline->Vertex(ciV).ParameterOnLine(); | |
147 | Standard_Real u11 = 0., u12 = 0., v11 = 0., v12 = 0.; | |
148 | Standard_Real u21 = 0., u22 = 0., v21 = 0., v22 = 0.; | |
149 | theWLline->Point(ciVpar).Parameters(u11,v11,u12,v12); | |
150 | aWLine->Point(tiVpar).Parameters(u21,v21,u22,v22); | |
151 | ||
152 | Handle(IntSurf_LineOn2S) newL2s = new IntSurf_LineOn2S(); | |
153 | IntSurf_PntOn2S replacePnt = aWLine->Point(tiVpar); | |
154 | Standard_Integer cNbP = theWLline->NbPnts(); | |
155 | ||
156 | TColStd_SequenceOfInteger VPold; | |
157 | Standard_Integer iPo; | |
158 | for( iPo = 1; iPo <= cnbV; iPo++ ) | |
159 | { | |
160 | Standard_Real Po = theWLline->Vertex(iPo).ParameterOnLine(); | |
161 | Standard_Integer IPo = (Standard_Integer) Po; | |
162 | VPold.Append(IPo); | |
163 | } | |
164 | ||
165 | Standard_Boolean removeNext = Standard_False; | |
166 | Standard_Boolean removePrev = Standard_False; | |
167 | if( ciV == 1) | |
168 | { | |
169 | Standard_Integer dPar = Abs( VPold.Value(ciV) - VPold.Value(ciV+1)); | |
170 | if(dPar > 10) | |
171 | { | |
172 | removeNext = Standard_True; | |
173 | for( iPo = (ciV+1); iPo <= cnbV; iPo++ ) | |
174 | VPold.SetValue(iPo, VPold.Value(iPo) - 1 ); | |
175 | } | |
176 | } | |
177 | else if( ciV == cnbV) | |
178 | { | |
179 | Standard_Integer dPar = Abs( VPold.Value(ciV) - VPold.Value(ciV-1)); | |
180 | if(dPar > 10) | |
181 | { | |
182 | removePrev = Standard_True; | |
183 | VPold.SetValue(ciV, VPold.Value(ciV) - 1 ); | |
184 | } | |
185 | } | |
186 | else | |
187 | { | |
188 | Standard_Integer dParMi = Abs( VPold.Value(ciV) - VPold.Value(ciV-1)); | |
189 | Standard_Integer dParMa = Abs( VPold.Value(ciV) - VPold.Value(ciV+1)); | |
190 | if(dParMi > 10) | |
191 | { | |
192 | removePrev = Standard_True; | |
193 | VPold.SetValue(ciV, VPold.Value(ciV) - 1 ); | |
194 | } | |
195 | ||
196 | if(dParMa > 10) | |
197 | { | |
198 | removeNext = Standard_True; | |
199 | for( iPo = (ciV+1); iPo <= cnbV; iPo++ ) | |
200 | { | |
201 | if(dParMi > 10) | |
202 | VPold.SetValue(iPo, VPold.Value(iPo) - 2 ); | |
203 | else | |
204 | VPold.SetValue(iPo, VPold.Value(iPo) - 1 ); | |
205 | } | |
206 | } | |
207 | else | |
208 | { | |
209 | if(dParMi > 10) | |
210 | for( iPo = (ciV+1); iPo <= cnbV; iPo++ ) | |
211 | VPold.SetValue(iPo, VPold.Value(iPo) - 1 ); | |
212 | } | |
213 | } | |
214 | ||
215 | Standard_Integer pI = ciVpar; | |
216 | ||
217 | Standard_Integer iP; | |
218 | for( iP = 1; iP <= cNbP; iP++) | |
219 | { | |
220 | if( pI == iP ) | |
221 | { | |
222 | IntSurf_PntOn2S newPnt = MakeNewPoint(replacePnt, theWLline->Point(iP), thePeriodsArr); | |
223 | newL2s->Add(newPnt); | |
224 | } | |
225 | else if(removeNext && iP == (pI + 1)) | |
226 | continue; | |
227 | else if(removePrev && iP == (pI - 1)) | |
228 | continue; | |
229 | else | |
230 | newL2s->Add(theWLline->Point(iP)); | |
231 | } | |
232 | ||
233 | IntPatch_Point newVtx; | |
234 | gp_Pnt Pnt3dV = aWLine->Vertex(VDMin).Value(); | |
235 | newVtx.SetValue(Pnt3dV,theTol,Standard_False); | |
236 | newVtx.SetParameters(u21,v21,u22,v22); | |
237 | newVtx.SetParameter(VPold.Value(ciV)); | |
238 | ||
239 | Handle(IntPatch_WLine) NWLine = new IntPatch_WLine(newL2s,Standard_False,theTrans1,theTrans2); | |
98974dcc | 240 | NWLine->SetCreatingWayInfo(IntPatch_WLine::IntPatch_WLPrmPrm); |
eb75e31c | 241 | |
242 | Standard_Integer iV; | |
243 | for( iV = 1; iV <= cnbV; iV++ ) | |
244 | { | |
245 | if( iV == ciV ) | |
246 | NWLine->AddVertex(newVtx); | |
247 | else | |
248 | { | |
249 | IntPatch_Point theVtx = theWLline->Vertex(iV); | |
250 | theVtx.SetParameter(VPold.Value(iV)); | |
251 | NWLine->AddVertex(theVtx); | |
252 | } | |
253 | } | |
254 | ||
255 | theWLline = NWLine; | |
256 | }//if( VDMin != 0 ) | |
257 | }//for( ciV = 1; ciV <= cnbV; ciV++ ) | |
258 | } | |
259 | ||
c8187bb2 | 260 | //======================================================================= |
261 | //function : DublicateOfLinesProcessing | |
262 | //purpose : Decides, if rejecting current line is necessary | |
263 | //======================================================================= | |
264 | static void DublicateOfLinesProcessing( const IntWalk_PWalking& thePW, | |
265 | const Standard_Integer theWLID, | |
266 | IntPatch_SequenceOfLine& theLines, | |
267 | Standard_Boolean& theIsRejectReq) | |
268 | { | |
269 | const Handle(IntPatch_WLine)& anExistWL = | |
270 | *((Handle(IntPatch_WLine)*)&theLines.Value(theWLID)); | |
271 | const Standard_Integer aNbPrevPoints = anExistWL->NbPnts(); | |
272 | const Standard_Integer aNbCurrPoints = thePW.NbPoints(); | |
273 | ||
274 | if(aNbPrevPoints < aNbCurrPoints) | |
275 | {//Remove preview line | |
276 | theLines.Remove(theWLID); | |
277 | theIsRejectReq = Standard_False; | |
278 | } | |
279 | else if(aNbPrevPoints == aNbCurrPoints) | |
280 | { | |
281 | Standard_Real aLPrev = 0.0, aLCurr = 0.0; | |
282 | for(Standard_Integer aNbPP = 1; aNbPP < aNbPrevPoints; aNbPP++) | |
283 | { | |
284 | const gp_Pnt aP1prev(anExistWL->Point(aNbPP).Value()), | |
285 | aP2prev(anExistWL->Point(aNbPP+1).Value()); | |
286 | const gp_Pnt aP1curr(thePW.Value(aNbPP).Value()), | |
287 | aP2curr(thePW.Value(aNbPP+1).Value()); | |
288 | ||
289 | aLPrev += aP1prev.Distance(aP2prev); | |
290 | aLCurr += aP1curr.Distance(aP2curr); | |
291 | } | |
292 | ||
293 | if(aLPrev < aLCurr) | |
294 | {//Remove preview line | |
295 | theLines.Remove(theWLID); | |
296 | theIsRejectReq = Standard_False; | |
297 | } | |
298 | } | |
299 | } | |
a7dd5d0f | 300 | |
7fd59977 | 301 | //================================================================================== |
302 | // function : | |
303 | // purpose : | |
304 | //================================================================================== | |
305 | IntPatch_PrmPrmIntersection::IntPatch_PrmPrmIntersection(): done(Standard_False) | |
306 | { | |
307 | } | |
308 | ||
309 | //================================================================================== | |
310 | // function : Perform | |
311 | // purpose : | |
312 | //================================================================================== | |
313 | void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Surf1, | |
00302ba4 | 314 | const Handle(Adaptor3d_TopolTool)& D1, |
315 | const Standard_Real TolTangency, | |
316 | const Standard_Real Epsilon, | |
317 | const Standard_Real Deflection, | |
318 | const Standard_Real Increment) | |
7fd59977 | 319 | { |
320 | IntPatch_Polyhedron Poly1( Surf1, D1->NbSamplesU(), D1->NbSamplesV() ); | |
321 | Perform( Surf1, Poly1, D1, TolTangency, Epsilon, Deflection, Increment ); | |
322 | } | |
323 | ||
324 | //================================================================================== | |
325 | // function : Perform | |
326 | // purpose : | |
327 | //================================================================================== | |
328 | void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Surf1, | |
00302ba4 | 329 | const IntPatch_Polyhedron& Poly1, |
330 | const Handle(Adaptor3d_TopolTool)& D1, | |
331 | const Handle(Adaptor3d_HSurface)& Surf2, | |
332 | const Handle(Adaptor3d_TopolTool)& D2, | |
333 | const Standard_Real TolTangency, | |
334 | const Standard_Real Epsilon, | |
335 | const Standard_Real Deflection, | |
336 | const Standard_Real Increment) | |
7fd59977 | 337 | { |
338 | IntPatch_Polyhedron Poly2( Surf2 ); | |
339 | Perform( Surf1, Poly1, D1, Surf2, Poly2, D2, TolTangency, Epsilon, Deflection, Increment); | |
340 | } | |
341 | ||
342 | //================================================================================== | |
343 | // function : Perform | |
344 | // purpose : | |
345 | //================================================================================== | |
346 | void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Surf1, | |
00302ba4 | 347 | const Handle(Adaptor3d_TopolTool)& D1, |
348 | const Handle(Adaptor3d_HSurface)& Surf2, | |
349 | const IntPatch_Polyhedron& Poly2, | |
350 | const Handle(Adaptor3d_TopolTool)& D2, | |
351 | const Standard_Real TolTangency, | |
352 | const Standard_Real Epsilon, | |
353 | const Standard_Real Deflection, | |
354 | const Standard_Real Increment) | |
7fd59977 | 355 | { |
356 | IntPatch_Polyhedron Poly1( Surf1 ); | |
357 | Perform( Surf1, Poly1, D1, Surf2, Poly2, D2, TolTangency, Epsilon, Deflection, Increment ); | |
358 | } | |
359 | ||
360 | //================================================================================== | |
361 | // function : Perform | |
362 | // purpose : | |
363 | //================================================================================== | |
364 | void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Surf1, | |
00302ba4 | 365 | const IntPatch_Polyhedron& Poly1, |
366 | const Handle(Adaptor3d_TopolTool)& D1, | |
367 | const Handle(Adaptor3d_HSurface)& Surf2, | |
368 | const IntPatch_Polyhedron& Poly2, | |
369 | const Handle(Adaptor3d_TopolTool)& D2, | |
370 | const Standard_Real TolTangency, | |
371 | const Standard_Real Epsilon, | |
372 | const Standard_Real Deflection, | |
373 | const Standard_Real Increment) | |
7fd59977 | 374 | { |
47cbf134 | 375 | IntPatch_InterferencePolyhedron Interference(Poly1,Poly2); |
7fd59977 | 376 | empt = Standard_True; |
377 | done = Standard_True; | |
378 | SLin.Clear(); | |
379 | ||
7fd59977 | 380 | Standard_Integer nbLigSec = Interference.NbSectionLines(); |
381 | Standard_Integer nbTanZon = Interference.NbTangentZones(); | |
382 | ||
7fd59977 | 383 | Standard_Integer NbLigCalculee = 0; |
384 | ||
385 | Standard_Real U1,U2,V1,V2; | |
386 | Standard_Real pu1,pu2,pv1,pv2; | |
387 | ||
388 | TColStd_Array1OfReal StartParams(1,4); | |
389 | ||
47cbf134 | 390 | IntWalk_PWalking PW( Surf1, Surf2, TolTangency, Epsilon, Deflection, Increment ); |
00302ba4 | 391 | |
7fd59977 | 392 | Standard_Real SeuildPointLigne = 15.0 * Increment * Increment; //-- 10 est insuffisant |
393 | Standard_Real incidence; | |
394 | Standard_Real dminiPointLigne; | |
395 | ||
396 | Standard_Boolean HasStartPoint,RejetLigne; | |
397 | ||
398 | IntSurf_PntOn2S StartPOn2S; | |
399 | ||
400 | Standard_Integer ver; | |
401 | ||
402 | gp_Pnt Point3dDebut,Point3dFin; | |
403 | ||
404 | if( nbLigSec >= 1 ) { | |
405 | Standard_Integer *TabL = new Standard_Integer [nbLigSec+1]; | |
406 | Standard_Integer ls; | |
407 | for( ls = 1; ls <= nbLigSec; ls++ ) | |
408 | TabL[ls]=ls; | |
409 | ||
410 | Standard_Boolean triok; | |
411 | do { | |
412 | triok=Standard_True; | |
413 | for(Standard_Integer b=2; b<=nbLigSec; b++) { | |
00302ba4 | 414 | Standard_Integer nb_B = Interference.LineValue(TabL[b]).NumberOfPoints(); |
415 | Standard_Integer nb_A = Interference.LineValue(TabL[b-1]).NumberOfPoints(); | |
416 | if( nb_B > nb_A ) { | |
417 | Standard_Integer tyu=TabL[b]; | |
418 | TabL[b]=TabL[b-1]; | |
419 | TabL[b-1]=tyu; | |
420 | triok=Standard_False; | |
421 | } | |
7fd59977 | 422 | } |
423 | } while( triok==Standard_False ); | |
424 | ||
425 | for( ls = 1; ls <= nbLigSec; ls++) { | |
426 | const Intf_SectionLine& LineSec=Interference.LineValue(TabL[ls]); | |
427 | Standard_Integer nbp = LineSec.NumberOfPoints(); | |
428 | ||
429 | Standard_Integer *TabPtDep = new Standard_Integer [nbp+1]; | |
430 | Standard_Integer ilig; | |
431 | for( ilig = 1; ilig <= nbp; ilig++) | |
00302ba4 | 432 | TabPtDep[ilig]=0; |
7fd59977 | 433 | |
434 | Standard_Real UminLig1,VminLig1,UmaxLig1,VmaxLig1; | |
435 | Standard_Real UminLig2,VminLig2,UmaxLig2,VmaxLig2; | |
436 | ||
437 | SectionPointToParameters(LineSec.GetPoint(1),Poly1,Poly2,UminLig1,VminLig1,UminLig2,VminLig2); | |
438 | ||
439 | UmaxLig1=UminLig1; | |
440 | VmaxLig1=VminLig1; | |
441 | UmaxLig2=UminLig2; | |
442 | VmaxLig2=VminLig2; | |
443 | ||
444 | for( ilig = 2; ilig <= nbp; ilig++ ) { | |
00302ba4 | 445 | SectionPointToParameters(LineSec.GetPoint(ilig),Poly1,Poly2,U1,V1,U2,V2); |
7fd59977 | 446 | |
00302ba4 | 447 | if(U1>UmaxLig1) UmaxLig1=U1; |
448 | if(V1>VmaxLig1) VmaxLig1=V1; | |
449 | if(U2>UmaxLig2) UmaxLig2=U2; | |
450 | if(V2>VmaxLig2) VmaxLig2=V2; | |
7fd59977 | 451 | |
00302ba4 | 452 | if(U1<UminLig1) UminLig1=U1; |
453 | if(V1<VminLig1) VminLig1=V1; | |
454 | if(U2<UminLig2) UminLig2=U2; | |
455 | if(V2<VminLig2) VminLig2=V2; | |
7fd59977 | 456 | } |
00302ba4 | 457 | |
7fd59977 | 458 | Standard_Integer nbps2 = (nbp>3)? (nbp/2) : 1; |
459 | Standard_Integer NombreDePointsDeDepartDuCheminement = 0; | |
460 | Standard_Integer IndicePointdeDepart1 = 0,IndicePointdeDepart2 = 0; | |
461 | Standard_Boolean lignetrouvee=Standard_False; | |
462 | ||
463 | do { | |
00302ba4 | 464 | NombreDePointsDeDepartDuCheminement++; |
465 | if(NombreDePointsDeDepartDuCheminement == 1) { | |
466 | incidence=3.0; | |
467 | Standard_Integer nbp1_4=nbp/4; | |
468 | Standard_Integer nbp3_4=nbp-nbp1_4; | |
469 | ||
470 | Standard_Integer nsp; | |
471 | for(nsp=nbp/2; nsp<nbp3_4; nsp++) { | |
472 | Standard_Real CurrentIncidence = LineSec.GetPoint(nsp).Incidence(); | |
473 | if(CurrentIncidence < incidence) { | |
474 | nbps2 = nsp; | |
475 | incidence = 0.9*CurrentIncidence; | |
476 | } | |
477 | } | |
478 | ||
479 | for(nsp=nbp/2; nsp>nbp1_4; nsp--) { | |
480 | Standard_Real CurrentIncidence = LineSec.GetPoint(nsp).Incidence(); | |
481 | if(CurrentIncidence < incidence) { | |
482 | nbps2 = nsp; | |
483 | incidence = 0.9*CurrentIncidence; | |
484 | } | |
485 | } | |
486 | ||
487 | if(nbp<3) | |
488 | NombreDePointsDeDepartDuCheminement=3; | |
489 | ||
490 | IndicePointdeDepart1 = nbps2; | |
491 | } | |
492 | else if(NombreDePointsDeDepartDuCheminement == 2) { | |
493 | if(IndicePointdeDepart1 == 1) { | |
494 | nbps2 = nbp/2; | |
495 | IndicePointdeDepart2 = nbps2; | |
496 | } | |
497 | else { | |
498 | nbps2 = 1; | |
499 | IndicePointdeDepart2 = 1; | |
500 | } | |
501 | } | |
502 | else if(NombreDePointsDeDepartDuCheminement == 3) { | |
503 | if(IndicePointdeDepart1 == nbp) | |
504 | nbps2 = (IndicePointdeDepart1+IndicePointdeDepart2)/2; | |
505 | else | |
506 | nbps2 = nbp; | |
507 | } | |
508 | else { | |
509 | nbps2 = NombreDePointsDeDepartDuCheminement-3; | |
510 | NombreDePointsDeDepartDuCheminement++; | |
511 | } | |
512 | ||
513 | if(TabPtDep[nbps2]==0) { | |
514 | TabPtDep[nbps2]=1; | |
515 | SectionPointToParameters(LineSec.GetPoint(nbps2),Poly1,Poly2,U1,V1,U2,V2); | |
516 | ||
517 | StartParams(1) = U1; | |
518 | StartParams(2) = V1; | |
519 | StartParams(3) = U2; | |
520 | StartParams(4) = V2; | |
521 | ||
522 | HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S); | |
523 | dminiPointLigne = SeuildPointLigne + SeuildPointLigne; | |
524 | ||
525 | if(HasStartPoint) { | |
526 | StartPOn2S.Parameters(pu1,pv1,pu2,pv2); | |
527 | NbLigCalculee = SLin.Length(); | |
528 | Standard_Integer l; | |
529 | for( l=1; (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); l++) { | |
530 | const Handle(IntPatch_WLine)& testwline = *((Handle(IntPatch_WLine)*)&SLin.Value(l)); | |
7fd59977 | 531 | |
a7dd5d0f | 532 | if (IsPointOnLine(StartPOn2S, testwline, Deflection)) { |
533 | dminiPointLigne = 0.0; | |
534 | } | |
00302ba4 | 535 | } // for ( l ... |
536 | ||
537 | if(dminiPointLigne > SeuildPointLigne) { | |
538 | PW.Perform(StartParams,UminLig1,VminLig1,UminLig2,VminLig2,UmaxLig1,VmaxLig1,UmaxLig2,VmaxLig2); | |
539 | if(PW.IsDone()) { | |
540 | if(PW.NbPoints()>2) { | |
541 | RejetLigne = Standard_False; | |
542 | Point3dDebut = PW.Value(1).Value(); | |
a7dd5d0f | 543 | const IntSurf_PntOn2S& PointFin = PW.Value(PW.NbPoints()); |
544 | Point3dFin = PointFin.Value(); | |
1dee0696 | 545 | for( ver = 1 ; ver<= NbLigCalculee ; ver++) { |
00302ba4 | 546 | const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver)); |
a7dd5d0f | 547 | |
548 | // Check end point if it is on existing line. | |
549 | // Start point is checked before. | |
550 | if (IsPointOnLine(PointFin, verwline, Deflection)) { | |
551 | RejetLigne = Standard_True; | |
552 | break; | |
553 | } | |
554 | ||
555 | const IntSurf_PntOn2S& verPointDebut = verwline->Point(1); | |
00302ba4 | 556 | const IntSurf_PntOn2S& verPointFin = verwline->Point(verwline->NbPnts()); |
1dee0696 | 557 | if( (Point3dDebut.Distance(verPointDebut.Value()) <= TolTangency) && |
558 | (Point3dFin.Distance(verPointFin.Value()) <= TolTangency)) | |
559 | { | |
560 | RejetLigne = Standard_True; | |
561 | break; | |
00302ba4 | 562 | } |
563 | } | |
564 | ||
c8187bb2 | 565 | if(RejetLigne) |
566 | { | |
567 | DublicateOfLinesProcessing(PW, ver, SLin, RejetLigne); | |
568 | } | |
569 | ||
00302ba4 | 570 | if(!RejetLigne) { |
571 | // Calculation transition | |
572 | IntSurf_TypeTrans trans1,trans2; | |
573 | Standard_Real locu,locv; | |
574 | gp_Vec norm1,norm2,d1u,d1v; | |
575 | gp_Pnt ptbid; | |
576 | Standard_Integer indextg; | |
577 | gp_Vec tgline(PW.TangentAtLine(indextg)); | |
578 | PW.Line()->Value(indextg).ParametersOnS1(locu,locv); | |
579 | Surf1->D1(locu,locv,ptbid,d1u,d1v); | |
580 | norm1 = d1u.Crossed(d1v); | |
581 | PW.Line()->Value(indextg).ParametersOnS2(locu,locv); | |
582 | Surf2->D1(locu,locv,ptbid,d1u,d1v); | |
583 | norm2 = d1u.Crossed(d1v); | |
584 | if(tgline.DotCross(norm2,norm1)>0.) { | |
585 | trans1 = IntSurf_Out; | |
586 | trans2 = IntSurf_In; | |
587 | } | |
588 | else { | |
589 | trans1 = IntSurf_In; | |
590 | trans2 = IntSurf_Out; | |
591 | } | |
592 | ||
593 | Standard_Real TolTang = TolTangency; | |
594 | Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2); | |
98974dcc | 595 | wline->SetCreatingWayInfo(IntPatch_WLine::IntPatch_WLPrmPrm); |
596 | ||
1406e955 | 597 | //the method PutVertexOnLine can reduce the number of points in <wline> |
00302ba4 | 598 | IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang); |
1406e955 | 599 | if (wline->NbPnts() < 2) |
600 | continue; | |
00302ba4 | 601 | IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang); |
1406e955 | 602 | if (wline->NbPnts() < 2) |
603 | continue; | |
00302ba4 | 604 | |
605 | if(wline->NbVertex() == 0) { | |
606 | IntPatch_Point vtx; | |
607 | IntSurf_PntOn2S POn2S = PW.Line()->Value(1); | |
608 | POn2S.Parameters(pu1,pv1,pu2,pv2); | |
609 | vtx.SetValue(Point3dDebut,TolTang,Standard_False); | |
610 | vtx.SetParameters(pu1,pv1,pu2,pv2); | |
611 | vtx.SetParameter(1); | |
612 | wline->AddVertex(vtx); | |
613 | ||
614 | POn2S = PW.Line()->Value(wline->NbPnts()); | |
615 | POn2S.Parameters(pu1,pv1,pu2,pv2); | |
616 | vtx.SetValue(Point3dFin,TolTang,Standard_False); | |
617 | vtx.SetParameters(pu1,pv1,pu2,pv2); | |
618 | vtx.SetParameter(wline->NbPnts()); | |
619 | wline->AddVertex(vtx); | |
620 | } | |
621 | ||
622 | lignetrouvee = Standard_True; | |
a7dd5d0f | 623 | AddWLine(SLin, wline, Deflection); |
00302ba4 | 624 | empt = Standard_False; |
625 | }// !RejetLigne | |
626 | }// PW.NbPoints()>2 | |
627 | }// done is True | |
628 | }// dminiPointLigne > SeuildPointLigne | |
629 | }// HasStartPoint | |
630 | }// TabPtDep[nbps2]==0 | |
7fd59977 | 631 | } while( nbp>5 && ( !( ( (NombreDePointsDeDepartDuCheminement >= 3) && lignetrouvee ) || |
00302ba4 | 632 | ( (NombreDePointsDeDepartDuCheminement-3>=nbp) && !lignetrouvee ) ) ) ); |
7fd59977 | 633 | |
634 | delete [] TabPtDep; | |
635 | }// for( ls ... | |
636 | ||
637 | delete [] TabL; | |
638 | }// nbLigSec >= 1 | |
639 | ||
640 | Standard_Real UminLig1,VminLig1,UmaxLig1,VmaxLig1; | |
641 | Standard_Real UminLig2,VminLig2,UmaxLig2,VmaxLig2; | |
00302ba4 | 642 | |
7fd59977 | 643 | UminLig1=VminLig1=UminLig2=VminLig2=RealLast(); |
644 | UmaxLig1=VmaxLig1=UmaxLig2=VmaxLig2=-UminLig1; | |
645 | ||
646 | Standard_Integer z; | |
647 | for(z=1; z <= nbTanZon; z++) { | |
648 | const Intf_TangentZone& TangentZone=Interference.ZoneValue(z); | |
649 | for(Standard_Integer pz=1; pz<=TangentZone.NumberOfPoints(); pz++) { | |
650 | SectionPointToParameters(TangentZone.GetPoint(pz),Poly1,Poly2,U1,V1,U2,V2); | |
651 | ||
652 | if(U1>UmaxLig1) UmaxLig1=U1; | |
653 | if(V1>VmaxLig1) VmaxLig1=V1; | |
654 | if(U2>UmaxLig2) UmaxLig2=U2; | |
655 | if(V2>VmaxLig2) VmaxLig2=V2; | |
00302ba4 | 656 | |
7fd59977 | 657 | if(U1<UminLig1) UminLig1=U1; |
658 | if(V1<VminLig1) VminLig1=V1; | |
659 | if(U2<UminLig2) UminLig2=U2; | |
660 | if(V2<VminLig2) VminLig2=V2; | |
661 | } | |
662 | } | |
663 | ||
664 | for(z=1; z <= nbTanZon; z++) { | |
665 | const Intf_TangentZone& TangentZone=Interference.ZoneValue(z); | |
666 | Standard_Integer pz; | |
667 | for( pz=1; pz<=TangentZone.NumberOfPoints(); pz++) { | |
668 | SectionPointToParameters(TangentZone.GetPoint(pz),Poly1,Poly2,U1,V1,U2,V2); | |
669 | ||
670 | StartParams(1) = U1; | |
671 | StartParams(2) = V1; | |
672 | StartParams(3) = U2; | |
673 | StartParams(4) = V2; | |
00302ba4 | 674 | |
7fd59977 | 675 | HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S); |
676 | if(HasStartPoint) { | |
00302ba4 | 677 | StartPOn2S.Parameters(pu1,pv1,pu2,pv2); |
678 | NbLigCalculee = SLin.Length(); | |
679 | dminiPointLigne = SeuildPointLigne + SeuildPointLigne; | |
680 | Standard_Integer l; | |
681 | for( l = 1; (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); l++) { | |
682 | const Handle(IntPatch_WLine)& testwline = *((Handle(IntPatch_WLine)*)&SLin.Value(l)); | |
7fd59977 | 683 | |
a7dd5d0f | 684 | if (IsPointOnLine(StartPOn2S, testwline, Deflection)) { |
685 | dminiPointLigne = 0.0; | |
686 | } | |
00302ba4 | 687 | }// for( l ... |
688 | ||
689 | if(dminiPointLigne > SeuildPointLigne) { | |
690 | PW.Perform(StartParams,UminLig1,VminLig1,UminLig2,VminLig2,UmaxLig1,VmaxLig1,UmaxLig2,VmaxLig2); | |
691 | if(PW.IsDone()) { | |
692 | if(PW.NbPoints()>2) { | |
693 | RejetLigne = Standard_False; | |
694 | Point3dDebut = PW.Value(1).Value(); | |
a7dd5d0f | 695 | const IntSurf_PntOn2S& PointFin = PW.Value(PW.NbPoints()); |
696 | Point3dFin = PointFin.Value(); | |
1dee0696 | 697 | for(ver=1 ; ver<= NbLigCalculee ; ver++) { |
00302ba4 | 698 | const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver)); |
a7dd5d0f | 699 | |
700 | // Check end point if it is on existing line. | |
701 | // Start point is checked before. | |
702 | if (IsPointOnLine(PointFin, verwline, Deflection)) { | |
703 | RejetLigne = Standard_True; | |
704 | break; | |
705 | } | |
706 | ||
00302ba4 | 707 | const IntSurf_PntOn2S& verPointDebut = verwline->Point(1); |
708 | const IntSurf_PntOn2S& verPointFin = verwline->Point(verwline->NbPnts()); | |
1dee0696 | 709 | if( (Point3dDebut.Distance(verPointDebut.Value()) < TolTangency) || |
710 | (Point3dFin.Distance(verPointFin.Value()) < TolTangency)) | |
711 | { | |
00302ba4 | 712 | RejetLigne = Standard_True; |
1dee0696 | 713 | break; |
00302ba4 | 714 | } |
715 | } | |
716 | ||
c8187bb2 | 717 | if(RejetLigne) |
718 | { | |
719 | DublicateOfLinesProcessing(PW, ver, SLin, RejetLigne); | |
720 | } | |
721 | ||
00302ba4 | 722 | if(!RejetLigne) { |
723 | IntSurf_TypeTrans trans1,trans2; | |
724 | Standard_Real locu,locv; | |
725 | gp_Vec norm1,norm2,d1u,d1v; | |
726 | gp_Pnt ptbid; | |
727 | Standard_Integer indextg; | |
728 | gp_Vec tgline(PW.TangentAtLine(indextg)); | |
729 | PW.Line()->Value(indextg).ParametersOnS1(locu,locv); | |
730 | Surf1->D1(locu,locv,ptbid,d1u,d1v); | |
731 | norm1 = d1u.Crossed(d1v); | |
732 | PW.Line()->Value(indextg).ParametersOnS2(locu,locv); | |
733 | Surf2->D1(locu,locv,ptbid,d1u,d1v); | |
734 | norm2 = d1u.Crossed(d1v); | |
735 | if(tgline.DotCross(norm2,norm1)>0.) { | |
736 | trans1 = IntSurf_Out; | |
737 | trans2 = IntSurf_In; | |
738 | } | |
739 | else { | |
740 | trans1 = IntSurf_In; | |
741 | trans2 = IntSurf_Out; | |
742 | } | |
743 | ||
744 | Standard_Real TolTang = TolTangency; | |
745 | Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2); | |
98974dcc | 746 | wline->SetCreatingWayInfo(IntPatch_WLine::IntPatch_WLPrmPrm); |
747 | ||
1406e955 | 748 | //the method PutVertexOnLine can reduce the number of points in <wline> |
00302ba4 | 749 | IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang); |
1406e955 | 750 | if (wline->NbPnts() < 2) |
751 | continue; | |
00302ba4 | 752 | IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang); |
1406e955 | 753 | if (wline->NbPnts() < 2) |
754 | continue; | |
00302ba4 | 755 | |
756 | if(wline->NbVertex() == 0) { | |
757 | IntPatch_Point vtx; | |
758 | IntSurf_PntOn2S POn2S = PW.Line()->Value(1); | |
759 | POn2S.Parameters(pu1,pv1,pu2,pv2); | |
760 | vtx.SetValue(Point3dDebut,TolTang,Standard_False); | |
761 | vtx.SetParameters(pu1,pv1,pu2,pv2); | |
762 | vtx.SetParameter(1); | |
763 | wline->AddVertex(vtx); | |
764 | ||
765 | POn2S = PW.Line()->Value(wline->NbPnts()); | |
766 | POn2S.Parameters(pu1,pv1,pu2,pv2); | |
767 | vtx.SetValue(Point3dFin,TolTang,Standard_False); | |
768 | vtx.SetParameters(pu1,pv1,pu2,pv2); | |
769 | vtx.SetParameter(wline->NbPnts()); | |
770 | wline->AddVertex(vtx); | |
771 | } | |
7fd59977 | 772 | |
a7dd5d0f | 773 | AddWLine(SLin, wline, Deflection); |
00302ba4 | 774 | empt = Standard_False; |
775 | }// if !RejetLigne | |
776 | }// PW.NbPoints()>2 | |
777 | }// done is True | |
778 | }// dminiPointLigne > SeuildPointLigne | |
7fd59977 | 779 | }// HasStartPoint |
780 | }// for( pz ... | |
781 | }// for( z ... | |
782 | } | |
783 | ||
784 | //================================================================================== | |
785 | // function : Perform | |
786 | // purpose : | |
787 | //================================================================================== | |
788 | void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Surf1, | |
00302ba4 | 789 | const IntPatch_Polyhedron& Poly1, |
790 | const Handle(Adaptor3d_TopolTool)& D1, | |
791 | const Standard_Real TolTangency, | |
792 | const Standard_Real Epsilon, | |
793 | const Standard_Real Deflection, | |
794 | const Standard_Real Increment) | |
7fd59977 | 795 | { |
47cbf134 | 796 | IntPatch_InterferencePolyhedron Interference(Poly1); |
7fd59977 | 797 | empt = Standard_True; |
798 | done = Standard_True; | |
799 | SLin.Clear(); | |
800 | ||
801 | Standard_Integer nbLigSec = Interference.NbSectionLines(); | |
802 | Standard_Integer nbTanZon = Interference.NbTangentZones(); | |
803 | ||
804 | Standard_Integer NbPntOn2SOnLine; | |
805 | Standard_Integer NbLigCalculee = 0; | |
806 | ||
807 | Standard_Real U1,U2,V1,V2; | |
808 | Standard_Real pu1,pu2,pv1,pv2; | |
809 | ||
810 | TColStd_Array1OfReal StartParams(1,4); | |
47cbf134 | 811 | IntWalk_PWalking PW(Surf1,Surf1,TolTangency,Epsilon,Deflection,Increment); |
00302ba4 | 812 | |
7fd59977 | 813 | Standard_Real SeuildPointLigne = 15.0 * Increment * Increment; //-- 10 est insuffisant |
814 | Standard_Real incidence; | |
815 | Standard_Real dminiPointLigne; | |
816 | ||
817 | Standard_Boolean HasStartPoint,RejetLigne; | |
818 | ||
819 | IntSurf_PntOn2S StartPOn2S; | |
820 | ||
821 | Standard_Integer ver; | |
822 | ||
823 | gp_Pnt Point3dDebut,Point3dFin; | |
824 | ||
825 | if(nbLigSec>=1) { | |
826 | Standard_Integer ls; | |
827 | for( ls = 1; ls <= nbLigSec; ls++) { | |
828 | const Intf_SectionLine& LineSec=Interference.LineValue(ls); | |
829 | Standard_Integer nbp = LineSec.NumberOfPoints(); | |
830 | Standard_Integer nbps2 = (nbp>3)? (nbp/2) : 1; | |
831 | Standard_Integer NombreDePointsDeDepartDuCheminement = 0; | |
832 | Standard_Integer IndicePointdeDepart1 = 0, IndicePointdeDepart2 = 0; | |
833 | do { | |
00302ba4 | 834 | NombreDePointsDeDepartDuCheminement++; |
835 | if(NombreDePointsDeDepartDuCheminement == 1) { | |
836 | incidence = 0.0; | |
837 | Standard_Integer nsp1; | |
838 | for( nsp1= nbp/2; nsp1 >= 1; nsp1--) { | |
839 | SectionPointToParameters(LineSec.GetPoint(nsp1),Poly1,Poly1,U1,V1,U2,V2); | |
840 | Standard_Real CurrentIncidence = Abs(U1-U2)+Abs(V1-V2); | |
841 | if(CurrentIncidence > incidence) { | |
842 | nbps2 = nsp1; | |
843 | incidence = CurrentIncidence; | |
844 | } | |
845 | } | |
846 | for( nsp1 = nbp/2; nsp1 <= nbp; nsp1++) { | |
847 | SectionPointToParameters(LineSec.GetPoint(nsp1),Poly1,Poly1,U1,V1,U2,V2); | |
848 | Standard_Real CurrentIncidence = Abs(U1-U2)+Abs(V1-V2); | |
849 | if(CurrentIncidence > incidence) { | |
850 | nbps2 = nsp1; | |
851 | incidence = CurrentIncidence; | |
852 | } | |
853 | } | |
854 | ||
855 | if(nbp<3) | |
856 | NombreDePointsDeDepartDuCheminement=3; | |
857 | ||
858 | IndicePointdeDepart1 = nbps2; | |
859 | } | |
860 | else if(NombreDePointsDeDepartDuCheminement == 2) { | |
861 | if(IndicePointdeDepart1 == 1) { | |
862 | nbps2 = nbp/2; | |
863 | IndicePointdeDepart2 = nbps2; | |
864 | } | |
865 | else { | |
866 | nbps2 = 1; | |
867 | IndicePointdeDepart2 = 1; | |
868 | } | |
869 | } | |
870 | else { | |
871 | if(IndicePointdeDepart1 == nbp) | |
872 | nbps2 = (IndicePointdeDepart1+IndicePointdeDepart2)/2; | |
873 | else | |
874 | nbps2 = nbp; | |
875 | } | |
876 | ||
877 | SectionPointToParameters(LineSec.GetPoint(nbps2),Poly1,Poly1,U1,V1,U2,V2); | |
878 | ||
879 | StartParams(1) = U1; | |
880 | StartParams(2) = V1; | |
881 | StartParams(3) = U2; | |
882 | StartParams(4) = V2; | |
883 | ||
884 | HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S); | |
885 | dminiPointLigne = SeuildPointLigne + SeuildPointLigne; | |
886 | if(HasStartPoint) { | |
887 | StartPOn2S.Parameters(pu1,pv1,pu2,pv2); | |
888 | if(Abs(pu1-pu2)>1e-7 || Abs(pv1-pv2)>1e-7) { | |
889 | NbLigCalculee = SLin.Length(); | |
890 | Standard_Integer l; | |
891 | for( l = 1; (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); l++) { | |
892 | const Handle(IntPatch_WLine)& testwline = *((Handle(IntPatch_WLine)*)&SLin.Value(l)); | |
893 | if( (testwline->IsOutSurf1Box(gp_Pnt2d(pu1,pv1))==Standard_False) && | |
894 | (testwline->IsOutSurf2Box(gp_Pnt2d(pu2,pv2))==Standard_False) && | |
895 | (testwline->IsOutBox(StartPOn2S.Value())==Standard_False) ) { | |
896 | NbPntOn2SOnLine = testwline->NbPnts(); | |
897 | Standard_Integer ll; | |
898 | for( ll=1; (ll < NbPntOn2SOnLine) && (dminiPointLigne >= SeuildPointLigne); ll++) { | |
899 | Standard_Real t,Au1,Av1,Au2,Av2,Bu1,Bv1,Bu2,Bv2; | |
900 | testwline->Point(ll).Parameters(Au1,Av1,Au2,Av2); | |
901 | testwline->Point(ll+1).Parameters(Bu1,Bv1,Bu2,Bv2); | |
902 | if(Au1>Bu1) { | |
903 | t=Au1; | |
904 | Au1=Bu1; | |
905 | Bu1=t; | |
906 | } | |
907 | if(Av1>Bv1) { | |
908 | t=Av1; | |
909 | Av1=Bv1; | |
910 | Bv1=t; | |
911 | } | |
912 | Au1-=1.0e-7; | |
913 | Av1-=1.0e-7; | |
914 | Bu1+=1.0e-7; | |
915 | Bv1+=1.0e-7; | |
916 | ||
917 | if((pu1>=Au1) && (pu1<=Bu1) && (pv1>=Av1) && (pv1<=Bv1)) | |
918 | dminiPointLigne = 0.0; | |
919 | else { | |
920 | if((pu2>=Au1) && (pu2<=Bu1) && (pv2>=Av1) && (pv2<=Bv1)) | |
921 | dminiPointLigne = 0.0; | |
922 | } | |
923 | }// for( ll ... | |
924 | }// if ... | |
925 | }// for( l ... | |
926 | ||
927 | if(dminiPointLigne > SeuildPointLigne) { | |
928 | PW.Perform(StartParams); | |
929 | if(PW.IsDone()) { | |
930 | if(PW.NbPoints()>2) { | |
931 | RejetLigne = Standard_False; | |
932 | Point3dDebut = PW.Value(1).Value(); | |
933 | Point3dFin = PW.Value(PW.NbPoints()).Value(); | |
1dee0696 | 934 | for(ver=1 ; ver<= NbLigCalculee ; ver++) { |
00302ba4 | 935 | const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver)); |
936 | const IntSurf_PntOn2S& verPointDebut = verwline->Point(1); | |
937 | const IntSurf_PntOn2S& verPointFin = verwline->Point(verwline->NbPnts()); | |
1dee0696 | 938 | if( (Point3dDebut.Distance(verPointDebut.Value()) < TolTangency) || |
939 | (Point3dFin.Distance(verPointFin.Value()) < TolTangency)) | |
940 | { | |
00302ba4 | 941 | RejetLigne = Standard_True; |
1dee0696 | 942 | break; |
00302ba4 | 943 | } |
944 | } | |
945 | ||
c8187bb2 | 946 | if(RejetLigne) |
947 | { | |
948 | DublicateOfLinesProcessing(PW, ver, SLin, RejetLigne); | |
949 | } | |
950 | ||
00302ba4 | 951 | if(!RejetLigne) { |
952 | IntSurf_TypeTrans trans1,trans2; | |
953 | Standard_Real locu,locv; | |
954 | gp_Vec norm1,norm2,d1u,d1v; | |
955 | gp_Pnt ptbid; | |
956 | Standard_Integer indextg; | |
957 | gp_Vec tgline(PW.TangentAtLine(indextg)); | |
958 | PW.Line()->Value(indextg).ParametersOnS1(locu,locv); | |
959 | Surf1->D1(locu,locv,ptbid,d1u,d1v); | |
960 | norm1 = d1u.Crossed(d1v); | |
961 | PW.Line()->Value(indextg).ParametersOnS2(locu,locv); | |
962 | Surf1->D1(locu,locv,ptbid,d1u,d1v); | |
963 | norm2 = d1u.Crossed(d1v); | |
964 | if (tgline.DotCross(norm2,norm1)>0.) { | |
965 | trans1 = IntSurf_Out; | |
966 | trans2 = IntSurf_In; | |
967 | } | |
968 | else { | |
969 | trans1 = IntSurf_In; | |
970 | trans2 = IntSurf_Out; | |
971 | } | |
972 | ||
973 | IntSurf_LineOn2S LineOn2S; | |
974 | Standard_Integer nbpw,imin,imax,i; | |
975 | nbpw = PW.Line()->NbPoints(); | |
976 | Standard_Real u1,v1,u2,v2; | |
977 | i=0; | |
978 | do { | |
979 | i++; | |
980 | imin=i; | |
981 | const IntSurf_PntOn2S& Pi = PW.Line()->Value(i); | |
982 | Pi.Parameters(u1,v1,u2,v2); | |
983 | } while((i<nbpw)&&(Abs(u1-u2)<=1e-6 && Abs(v1-v2)<=1e-6)); | |
984 | ||
985 | if(imin>2) | |
986 | imin--; | |
987 | ||
988 | i=nbpw+1; | |
989 | do { | |
990 | i--; | |
991 | imax=i; | |
992 | const IntSurf_PntOn2S& Pi = PW.Line()->Value(i); | |
993 | Pi.Parameters(u1,v1,u2,v2); | |
994 | } while((i>2)&&(Abs(u1-u2)<=1e-6 && Abs(v1-v2)<=1e-6)); | |
995 | ||
996 | if(imax<nbpw) | |
997 | imax++; | |
998 | ||
999 | if(imin<imax) { | |
857ffd5e | 1000 | Handle(IntSurf_LineOn2S) PWLine = new IntSurf_LineOn2S(); |
00302ba4 | 1001 | for(i=imin;i<=imax;i++) |
1002 | PWLine->Add(PW.Line()->Value(i)); | |
1003 | ||
1004 | Standard_Real TolTang = TolTangency; | |
1005 | Handle(IntPatch_WLine) wline = new IntPatch_WLine(PWLine,Standard_False,trans1,trans2); | |
98974dcc | 1006 | wline->SetCreatingWayInfo(IntPatch_WLine::IntPatch_WLPrmPrm); |
1007 | ||
00302ba4 | 1008 | const IntSurf_PntOn2S& POn2SDeb = wline->Point(1); |
1009 | const IntSurf_PntOn2S& POn2SFin = wline->Point(wline->NbPnts()); | |
1010 | if((POn2SDeb.Value()).Distance(POn2SFin.Value()) <= TolTangency) { | |
1011 | Standard_Real u1t,v1t,u2t,v2t; | |
1012 | POn2SDeb.Parameters(u1t,v1t,u2t,v2t); | |
1013 | IntPatch_Point vtx; | |
1014 | vtx.SetValue(POn2SDeb.Value(),TolTang,Standard_False); | |
1015 | vtx.SetParameters(u2t,v2t,u1t,v1t); | |
1016 | vtx.SetParameter(wline->NbPnts()); | |
1017 | wline->SetPoint(wline->NbPnts(),vtx); | |
1018 | } | |
1406e955 | 1019 | //the method PutVertexOnLine can reduce the number of points in <wline> |
00302ba4 | 1020 | IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf1,Standard_True,TolTang); |
1406e955 | 1021 | if (wline->NbPnts() < 2) |
1022 | continue; | |
00302ba4 | 1023 | if(wline->NbVertex() == 0) { |
1024 | IntPatch_Point vtx; | |
1025 | IntSurf_PntOn2S POn2S = PW.Line()->Value(1); | |
1026 | POn2S.Parameters(pu1,pv1,pu2,pv2); | |
1027 | vtx.SetValue(Point3dDebut,TolTang,Standard_False); | |
1028 | vtx.SetParameters(pu1,pv1,pu2,pv2); | |
1029 | vtx.SetParameter(1); | |
1030 | wline->AddVertex(vtx); | |
1031 | ||
1032 | POn2S = PW.Line()->Value(wline->NbPnts()); | |
1033 | POn2S.Parameters(pu1,pv1,pu2,pv2); | |
1034 | vtx.SetValue(Point3dFin,TolTang,Standard_False); | |
1035 | vtx.SetParameters(pu1,pv1,pu2,pv2); | |
1036 | vtx.SetParameter(wline->NbPnts()); | |
1037 | wline->AddVertex(vtx); | |
1038 | } | |
1039 | SLin.Append(wline); | |
1040 | empt = Standard_False; | |
1041 | }// imin<imax | |
1042 | }// !RejetLigne | |
1043 | }// PW.NbPoints()>2 | |
1044 | }// done is True | |
1045 | }// dminiPointLigne > SeuildPointLigne | |
1046 | }// Abs || Abs | |
1047 | }// HasStartPoint | |
7fd59977 | 1048 | } while(nbp>5 && NombreDePointsDeDepartDuCheminement<3); |
1049 | }// for( ls ... | |
1050 | }// nbLigSec>=1 | |
1051 | ||
1052 | Standard_Integer z; | |
1053 | for( z = 1; z <= nbTanZon; z++) { | |
1054 | const Intf_TangentZone& TangentZone=Interference.ZoneValue(z); | |
1055 | for(Standard_Integer pz=1; pz<=TangentZone.NumberOfPoints(); pz++) { | |
1056 | SectionPointToParameters(TangentZone.GetPoint(pz),Poly1,Poly1,U1,V1,U2,V2); | |
1057 | ||
1058 | StartParams(1) = U1; | |
1059 | StartParams(2) = V1; | |
1060 | StartParams(3) = U2; | |
1061 | StartParams(4) = V2; | |
1062 | ||
1063 | HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S); | |
1064 | if(HasStartPoint) { | |
00302ba4 | 1065 | StartPOn2S.Parameters(pu1,pv1,pu2,pv2); |
1066 | if(Abs(pu1-pu2)>1e-7 || Abs(pv1-pv2)>1e-7) { | |
1067 | NbLigCalculee = SLin.Length(); | |
1068 | dminiPointLigne = SeuildPointLigne + SeuildPointLigne; | |
1069 | Standard_Integer l; | |
1070 | for( l = 1; (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); l++) { | |
1071 | const Handle(IntPatch_WLine)& testwline = *((Handle(IntPatch_WLine)*)&SLin.Value(l)); | |
1072 | if( (testwline->IsOutSurf1Box(gp_Pnt2d(pu1,pv1))==Standard_False) && | |
1073 | (testwline->IsOutSurf2Box(gp_Pnt2d(pu2,pv2))==Standard_False) && | |
1074 | (testwline->IsOutBox(StartPOn2S.Value())==Standard_False) ) { | |
1075 | NbPntOn2SOnLine = testwline->NbPnts(); | |
1076 | Standard_Integer ll; | |
1077 | for( ll = 1; (ll < NbPntOn2SOnLine) && (dminiPointLigne >= SeuildPointLigne); ll++) { | |
1078 | Standard_Real t,Au1,Av1,Au2,Av2,Bu1,Bv1,Bu2,Bv2; | |
1079 | testwline->Point(ll).Parameters(Au1,Av1,Au2,Av2); | |
1080 | testwline->Point(ll+1).Parameters(Bu1,Bv1,Bu2,Bv2); | |
1081 | if(Au1>Bu1) { | |
1082 | t=Au1; | |
1083 | Au1=Bu1; | |
1084 | Bu1=t; | |
1085 | } | |
1086 | if(Av1>Bv1) { | |
1087 | t=Av1; | |
1088 | Av1=Bv1; | |
1089 | Bv1=t; | |
1090 | } | |
1091 | Au1-=1.0e-7; | |
1092 | Av1-=1.0e-7; | |
1093 | Bu1+=1.0e-7; | |
1094 | Bv1+=1.0e-7; | |
1095 | if((pu1>=Au1) && (pu1<=Bu1) && (pv1>=Av1) && (pv1<=Bv1)) | |
1096 | dminiPointLigne = 0.0; | |
1097 | else { | |
1098 | if((pu2>=Au1) && (pu2<=Bu1) && (pv2>=Av1) && (pv2<=Bv1)) | |
1099 | dminiPointLigne = 0.0; | |
1100 | } | |
1101 | }// for( ll ... | |
1102 | }// if ... | |
1103 | }// for( l ... | |
1104 | ||
1105 | if(dminiPointLigne > SeuildPointLigne) { | |
1106 | PW.Perform(StartParams); | |
1107 | if(PW.IsDone()) { | |
1108 | if(PW.NbPoints()>2) { | |
1109 | RejetLigne = Standard_False; | |
1110 | Point3dDebut = PW.Value(1).Value(); | |
1111 | Point3dFin = PW.Value(PW.NbPoints()).Value(); | |
1dee0696 | 1112 | for( ver = 1 ; ver<= NbLigCalculee ; ver++) { |
00302ba4 | 1113 | const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver)); |
1114 | const IntSurf_PntOn2S& verPointDebut = verwline->Point(1); | |
1115 | const IntSurf_PntOn2S& verPointFin = verwline->Point(verwline->NbPnts()); | |
1dee0696 | 1116 | if( (Point3dDebut.Distance(verPointDebut.Value()) < TolTangency) || |
1117 | (Point3dFin.Distance(verPointFin.Value()) < TolTangency)) | |
1118 | { | |
00302ba4 | 1119 | RejetLigne = Standard_True; |
1dee0696 | 1120 | break; |
00302ba4 | 1121 | } |
1122 | } | |
1123 | ||
c8187bb2 | 1124 | if(RejetLigne) |
1125 | { | |
1126 | DublicateOfLinesProcessing(PW, ver, SLin, RejetLigne); | |
1127 | } | |
1128 | ||
00302ba4 | 1129 | if(!RejetLigne) { |
1130 | IntSurf_TypeTrans trans1,trans2; | |
1131 | Standard_Real locu,locv; | |
1132 | gp_Vec norm1,norm2,d1u,d1v; | |
1133 | gp_Pnt ptbid; | |
1134 | Standard_Integer indextg; | |
1135 | gp_Vec tgline(PW.TangentAtLine(indextg)); | |
1136 | PW.Line()->Value(indextg).ParametersOnS1(locu,locv); | |
1137 | Surf1->D1(locu,locv,ptbid,d1u,d1v); | |
1138 | norm1 = d1u.Crossed(d1v); | |
1139 | PW.Line()->Value(indextg).ParametersOnS2(locu,locv); | |
1140 | Surf1->D1(locu,locv,ptbid,d1u,d1v); | |
1141 | norm2 = d1u.Crossed(d1v); | |
1142 | if(tgline.DotCross(norm2,norm1)>0.) { | |
1143 | trans1 = IntSurf_Out; | |
1144 | trans2 = IntSurf_In; | |
1145 | } | |
1146 | else { | |
1147 | trans1 = IntSurf_In; | |
1148 | trans2 = IntSurf_Out; | |
1149 | } | |
1150 | ||
1151 | IntSurf_LineOn2S LineOn2S; | |
1152 | Standard_Integer nbp,imin,imax,i; | |
1153 | nbp = PW.Line()->NbPoints(); | |
1154 | Standard_Real u1,v1,u2,v2; | |
1155 | i=0; | |
1156 | do { | |
1157 | i++; | |
1158 | imin=i; | |
1159 | const IntSurf_PntOn2S& Pi = PW.Line()->Value(i); | |
1160 | Pi.Parameters(u1,v1,u2,v2); | |
1161 | } while((i<nbp)&&(Abs(u1-u2)<=1e-6 && Abs(v1-v2)<=1e-6)); | |
1162 | ||
1163 | if(imin>2) | |
1164 | imin--; | |
1165 | ||
1166 | i=nbp+1; | |
1167 | do { | |
1168 | i--; | |
1169 | imax=i; | |
1170 | const IntSurf_PntOn2S& Pi = PW.Line()->Value(i); | |
1171 | Pi.Parameters(u1,v1,u2,v2); | |
1172 | } while((i>2)&&(Abs(u1-u2)<=1e-6 && Abs(v1-v2)<=1e-6)); | |
1173 | ||
1174 | if(imax<nbp) | |
1175 | imax++; | |
1176 | ||
1177 | if(imin<imax) { | |
857ffd5e | 1178 | Handle(IntSurf_LineOn2S) PWLine = new IntSurf_LineOn2S(); |
00302ba4 | 1179 | for(i=imin;i<=imax;i++) |
1180 | PWLine->Add(PW.Line()->Value(i)); | |
1181 | ||
1182 | Standard_Real TolTang = TolTangency; | |
1183 | Handle(IntPatch_WLine) wline = new IntPatch_WLine(PWLine,Standard_False,trans1,trans2); | |
98974dcc | 1184 | wline->SetCreatingWayInfo(IntPatch_WLine::IntPatch_WLPrmPrm); |
1185 | ||
00302ba4 | 1186 | const IntSurf_PntOn2S& POn2SDeb = wline->Point(1); |
1187 | const IntSurf_PntOn2S& POn2SFin = wline->Point(wline->NbPnts()); | |
1188 | if((POn2SDeb.Value()).Distance(POn2SFin.Value()) <= TolTangency) { | |
1189 | Standard_Real u1t,v1t,u2t,v2t; | |
1190 | POn2SDeb.Parameters(u1t,v1t,u2t,v2t); | |
1191 | IntPatch_Point vtx; | |
1192 | vtx.SetValue(POn2SDeb.Value(),TolTang,Standard_False); | |
1193 | vtx.SetParameters(u2t,v2t,u1t,v1t); | |
1194 | vtx.SetParameter(wline->NbPnts()); | |
1195 | wline->SetPoint(wline->NbPnts(),vtx); | |
1196 | } | |
1197 | ||
1406e955 | 1198 | //the method PutVertexOnLine can reduce the number of points in <wline> |
00302ba4 | 1199 | IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf1,Standard_True,TolTang); |
1406e955 | 1200 | if (wline->NbPnts() < 2) |
1201 | continue; | |
00302ba4 | 1202 | |
1203 | if(wline->NbVertex() == 0) { | |
1204 | IntPatch_Point vtx; | |
1205 | IntSurf_PntOn2S POn2S = PW.Line()->Value(1); | |
1206 | POn2S.Parameters(pu1,pv1,pu2,pv2); | |
1207 | vtx.SetValue(Point3dDebut,TolTang,Standard_False); | |
1208 | vtx.SetParameters(pu1,pv1,pu2,pv2); | |
1209 | vtx.SetParameter(1); | |
1210 | wline->AddVertex(vtx); | |
1211 | ||
1212 | POn2S = PW.Line()->Value(wline->NbPnts()); | |
1213 | POn2S.Parameters(pu1,pv1,pu2,pv2); | |
1214 | vtx.SetValue(Point3dFin,TolTang,Standard_False); | |
1215 | vtx.SetParameters(pu1,pv1,pu2,pv2); | |
1216 | vtx.SetParameter(wline->NbPnts()); | |
1217 | wline->AddVertex(vtx); | |
1218 | } | |
1219 | ||
1220 | SLin.Append(wline); | |
1221 | empt = Standard_False; | |
1222 | }// imin<imax | |
1223 | }// !RejetLigne | |
1224 | }// PW.NbPoints()>2 | |
1225 | }// done a True | |
1226 | }// dminiPointLigne > SeuildPointLigne | |
1227 | }// Abs || Abs | |
7fd59977 | 1228 | }// HasStartPoint |
1229 | }// for ( pz ... | |
1230 | }// for( z ... | |
1231 | } | |
1232 | ||
1233 | //================================================================================== | |
1234 | // function : NewLine | |
1235 | // purpose : | |
1236 | //================================================================================== | |
857ffd5e | 1237 | Handle(IntPatch_Line) IntPatch_PrmPrmIntersection::NewLine (const Handle(Adaptor3d_HSurface)& Surf1, |
00302ba4 | 1238 | const Handle(Adaptor3d_HSurface)& Surf2, |
1239 | const Standard_Integer NumLine, | |
1240 | const Standard_Integer Low, | |
1241 | const Standard_Integer High, | |
1242 | const Standard_Integer NbPntsToInsert) const | |
7fd59977 | 1243 | { |
1244 | Standard_Integer NbPnts = NbPntsToInsert + High - Low; | |
1245 | if(NumLine>NbLines() || NumLine<1 || Low>=High ) | |
9775fa61 | 1246 | throw Standard_OutOfRange(" IntPatch_PrmPrmIntersection NewLine "); |
7fd59977 | 1247 | //------------------------------------------------------------------ |
1248 | //-- Indice : Low Low+1 I I+1 High -- | |
1249 | //-- -- | |
1250 | //-- Abs.Curv. : S(Low) S(I) S(I+1) S(High) -- | |
1251 | //-- -- | |
1252 | //-- On echantillonne a abcisse curviligne -- | |
1253 | //-- constante. -- | |
1254 | //-- L abcisse est calculee sur les params U1,V1 -- | |
1255 | //------------------------------------------------------------------ | |
1256 | TColStd_Array1OfReal U1(Low,High); | |
1257 | TColStd_Array1OfReal V1(Low,High); | |
1258 | TColStd_Array1OfReal U2(Low,High); | |
1259 | TColStd_Array1OfReal V2(Low,High); | |
1260 | TColStd_Array1OfReal AC(Low,High); | |
1261 | ||
1262 | Standard_Real s,ds; | |
1263 | Handle(IntPatch_WLine) TheLine = Handle(IntPatch_WLine)::DownCast(Line(NumLine)); | |
1264 | const IntSurf_PntOn2S& Point=TheLine->Point(Low); | |
1265 | Standard_Real u1,v1,u2,v2; | |
1266 | Point.Parameters(u1,v1,u2,v2); | |
1267 | U1(Low) = u1; | |
1268 | V1(Low) = v1; | |
1269 | U2(Low) = u2; | |
1270 | V2(Low) = v2; | |
1271 | AC(Low) =0.0; | |
00302ba4 | 1272 | |
47cbf134 | 1273 | IntWalk_PWalking PW(Surf1,Surf2,0.000001,0.000001,0.001,0.001); |
00302ba4 | 1274 | |
7fd59977 | 1275 | Standard_Integer i; |
1276 | for(i=Low+1; i<=High; i++) | |
00302ba4 | 1277 | { |
1278 | const IntSurf_PntOn2S& Pointi=TheLine->Point(i); | |
1279 | Pointi.Parameters(u1,v1,u2,v2); | |
1280 | U1(i) = u1; | |
1281 | V1(i) = v1; | |
1282 | U2(i) = u2; | |
1283 | V2(i) = v2; | |
1284 | ||
1285 | Standard_Real du1=u1-U1(i-1); | |
1286 | Standard_Real dv1=v1-V1(i-1); | |
1287 | ||
1288 | AC(i) = AC(i-1) + Sqrt((du1*du1)+(dv1*dv1)); | |
1289 | } | |
7fd59977 | 1290 | |
1291 | Handle(IntSurf_LineOn2S) ResultPntOn2SLine = new IntSurf_LineOn2S(); | |
00302ba4 | 1292 | |
7fd59977 | 1293 | IntSurf_PntOn2S StartPOn2S; |
1294 | TColStd_Array1OfReal StartParams(1,4); | |
00302ba4 | 1295 | |
7fd59977 | 1296 | ResultPntOn2SLine->Add(TheLine->Point(Low)); |
00302ba4 | 1297 | |
7fd59977 | 1298 | ds = AC(High) / (NbPnts-1); |
1299 | Standard_Integer Indice = Low; | |
00302ba4 | 1300 | |
7fd59977 | 1301 | Standard_Real dsmin = ds*0.3; |
1302 | Standard_Real smax = AC(High); | |
1303 | ||
1304 | for(i=2,s=ds; (i<NbPnts)&&(s<smax); i++,s+=ds) | |
00302ba4 | 1305 | { |
1306 | while(AC(Indice+1) <= s) | |
7fd59977 | 1307 | { |
00302ba4 | 1308 | ResultPntOn2SLine->Add(TheLine->Point(Indice)); |
1309 | Indice++; | |
7fd59977 | 1310 | } |
00302ba4 | 1311 | Standard_Real a = s - AC(Indice); |
1312 | Standard_Real b = AC(Indice+1) - s; | |
1313 | Standard_Real nab = 1.0/(a+b); | |
1314 | //---------------------------------------------------------- | |
1315 | //-- Verification : Si Dist au prochain point < dsmin -- | |
1316 | //-- Si Dist au precedent point < dsmin -- | |
1317 | //-- -- | |
1318 | //---------------------------------------------------------- | |
1319 | if((nab > ds)&&(a>dsmin)&&(b>dsmin)) | |
1320 | { | |
1321 | StartParams(1) = (U1(Indice) * b + U1(Indice+1) * a) * nab; | |
1322 | StartParams(2) = (V1(Indice) * b + V1(Indice+1) * a) * nab; | |
1323 | StartParams(3) = (U2(Indice) * b + U2(Indice+1) * a) * nab; | |
1324 | StartParams(4) = (V2(Indice) * b + V2(Indice+1) * a) * nab; | |
1325 | ||
1326 | Standard_Boolean HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S); | |
1327 | if(HasStartPoint) | |
1328 | ResultPntOn2SLine->Add(StartPOn2S); | |
1329 | } | |
1330 | else | |
1331 | s+=dsmin; | |
1332 | } | |
1333 | ||
7fd59977 | 1334 | ResultPntOn2SLine->Add(TheLine->Point(High)); |
00302ba4 | 1335 | |
98974dcc | 1336 | Handle(IntPatch_WLine) aRWL = new IntPatch_WLine(ResultPntOn2SLine, Standard_False); |
1337 | aRWL->SetCreatingWayInfo(IntPatch_WLine::IntPatch_WLPrmPrm); | |
1338 | ||
1339 | return(aRWL); | |
7fd59977 | 1340 | } |
1341 | ||
1342 | //================================================================================== | |
1343 | // function : SectionPointToParameters | |
1344 | // purpose : | |
1345 | //================================================================================== | |
1346 | void SectionPointToParameters(const Intf_SectionPoint& Sp, | |
00302ba4 | 1347 | const IntPatch_Polyhedron& Poly1, |
1348 | const IntPatch_Polyhedron& Poly2, | |
1349 | Standard_Real& u1, | |
1350 | Standard_Real& v1, | |
1351 | Standard_Real& u2, | |
1352 | Standard_Real& v2) | |
7fd59977 | 1353 | { |
1354 | Intf_PIType typ; | |
1355 | Standard_Integer Adr1,Adr2; | |
1356 | Standard_Real Param,u,v; | |
1357 | gp_Pnt P(Sp.Pnt()); | |
00302ba4 | 1358 | |
7fd59977 | 1359 | Standard_Integer Pt1,Pt2,Pt3; |
00302ba4 | 1360 | |
7fd59977 | 1361 | Sp.InfoFirst(typ,Adr1,Adr2,Param); |
1362 | switch(typ) { | |
1363 | case Intf_VERTEX: //-- Adr1 est le numero du vertex | |
1364 | { | |
1365 | Poly1.Parameters(Adr1,u1,v1); | |
1366 | break; | |
1367 | } | |
1368 | case Intf_EDGE: | |
1369 | { | |
1370 | Poly1.Parameters(Adr1,u1,v1); | |
1371 | Poly1.Parameters(Adr2,u,v); | |
1372 | u1+= Param * (u-u1); | |
1373 | v1+= Param * (v-v1); | |
1374 | break; | |
1375 | } | |
1376 | case Intf_FACE: | |
1377 | { | |
1378 | Standard_Real ua,va,ub,vb,uc,vc,ca,cb,cc,cabc; | |
1379 | Poly1.Triangle(Adr1,Pt1,Pt2,Pt3); | |
1380 | gp_Pnt PA(Poly1.Point(Pt1)); | |
1381 | gp_Pnt PB(Poly1.Point(Pt2)); | |
1382 | gp_Pnt PC(Poly1.Point(Pt3)); | |
1383 | Poly1.Parameters(Pt1,ua,va); | |
1384 | Poly1.Parameters(Pt2,ub,vb); | |
1385 | Poly1.Parameters(Pt3,uc,vc); | |
1386 | gp_Vec Normale(gp_Vec(PA,PB).Crossed(gp_Vec(PA,PC))); | |
1387 | cc = (gp_Vec(PA,PB).Crossed(gp_Vec(PA,P))).Dot(Normale); | |
1388 | ca = (gp_Vec(PB,PC).Crossed(gp_Vec(PB,P))).Dot(Normale); | |
1389 | cb = (gp_Vec(PC,PA).Crossed(gp_Vec(PC,P))).Dot(Normale); | |
1390 | cabc = ca + cb + cc; | |
00302ba4 | 1391 | |
7fd59977 | 1392 | ca/=cabc; cb/=cabc; cc/=cabc; |
00302ba4 | 1393 | |
7fd59977 | 1394 | u1 = ca * ua + cb * ub + cc * uc; |
1395 | v1 = ca * va + cb * vb + cc * vc; | |
1396 | break; | |
1397 | } | |
1398 | default: | |
1399 | { | |
04232180 | 1400 | //-- std::cout<<" Default dans SectionPointToParameters "<<std::endl; |
7fd59977 | 1401 | break; |
1402 | } | |
1403 | } | |
00302ba4 | 1404 | |
1405 | ||
7fd59977 | 1406 | Sp.InfoSecond(typ,Adr1,Adr2,Param); |
1407 | switch(typ) { | |
1408 | case Intf_VERTEX: //-- Adr1 est le numero du vertex | |
1409 | { | |
1410 | Poly2.Parameters(Adr1,u2,v2); | |
1411 | break; | |
1412 | } | |
1413 | case Intf_EDGE: | |
1414 | { | |
1415 | Poly2.Parameters(Adr1,u2,v2); | |
1416 | Poly2.Parameters(Adr2,u,v); | |
1417 | u2+= Param * (u-u2); | |
1418 | v2+= Param * (v-v2); | |
1419 | break; | |
1420 | } | |
1421 | case Intf_FACE: | |
1422 | { | |
1423 | Standard_Real ua,va,ub,vb,uc,vc,ca,cb,cc,cabc; | |
1424 | Poly2.Triangle(Adr1,Pt1,Pt2,Pt3); | |
1425 | gp_Pnt PA(Poly2.Point(Pt1)); | |
1426 | gp_Pnt PB(Poly2.Point(Pt2)); | |
1427 | gp_Pnt PC(Poly2.Point(Pt3)); | |
1428 | Poly2.Parameters(Pt1,ua,va); | |
1429 | Poly2.Parameters(Pt2,ub,vb); | |
1430 | Poly2.Parameters(Pt3,uc,vc); | |
1431 | gp_Vec Normale(gp_Vec(PA,PB).Crossed(gp_Vec(PA,PC))); | |
1432 | cc = (gp_Vec(PA,PB).Crossed(gp_Vec(PA,P))).Dot(Normale); | |
1433 | ca = (gp_Vec(PB,PC).Crossed(gp_Vec(PB,P))).Dot(Normale); | |
1434 | cb = (gp_Vec(PC,PA).Crossed(gp_Vec(PC,P))).Dot(Normale); | |
1435 | cabc = ca + cb + cc; | |
00302ba4 | 1436 | |
7fd59977 | 1437 | ca/=cabc; cb/=cabc; cc/=cabc; |
00302ba4 | 1438 | |
7fd59977 | 1439 | u2 = ca * ua + cb * ub + cc * uc; |
1440 | v2 = ca * va + cb * vb + cc * vc; | |
1441 | break; | |
1442 | } | |
1443 | default: | |
1444 | { | |
04232180 | 1445 | //-- std::cout<<" Default dans SectionPointToParameters "<<std::endl; |
7fd59977 | 1446 | break; |
1447 | } | |
1448 | } | |
1449 | } | |
1450 | ||
7fd59977 | 1451 | //================================================================================== |
1452 | // function : RemplitLin | |
1453 | // purpose : | |
1454 | //================================================================================== | |
1455 | void IntPatch_PrmPrmIntersection::RemplitLin(const Standard_Integer x1, | |
00302ba4 | 1456 | const Standard_Integer y1, |
1457 | const Standard_Integer z1, | |
1458 | const Standard_Integer x2, | |
1459 | const Standard_Integer y2, | |
1460 | const Standard_Integer z2, | |
1461 | IntPatch_PrmPrmIntersection_T3Bits& Map) const | |
7fd59977 | 1462 | { |
1463 | int xg,yg,zg; | |
1464 | xg=x1-x2; if(xg<0) xg=-xg; | |
1465 | yg=y1-y2; if(yg<0) yg=-yg; | |
1466 | zg=z1-z2; if(zg<0) zg=-zg; | |
1467 | if(DansGrille(x1) && DansGrille(y1) && DansGrille(z1)) { | |
1468 | Standard_Integer t = GrilleInteger(x1,y1,z1); | |
1469 | Map.Add(t); | |
1470 | } | |
1471 | if(xg<=1 && yg<=1 && zg<=1) return; | |
1472 | xg = (x1+x2)>>1; | |
1473 | yg = (y1+y2)>>1; | |
1474 | zg = (z1+z2)>>1; | |
1475 | RemplitLin(x1,y1,z1,xg,yg,zg,Map); | |
1476 | RemplitLin(x2,y2,z2,xg,yg,zg,Map); | |
1477 | } | |
1478 | ||
1479 | //================================================================================== | |
1480 | // function : RemplitTri | |
1481 | // purpose : | |
1482 | //================================================================================== | |
1483 | void IntPatch_PrmPrmIntersection::RemplitTri(const Standard_Integer x1, | |
00302ba4 | 1484 | const Standard_Integer y1, |
1485 | const Standard_Integer z1, | |
1486 | const Standard_Integer x2, | |
1487 | const Standard_Integer y2, | |
1488 | const Standard_Integer z2, | |
1489 | const Standard_Integer x3, | |
1490 | const Standard_Integer y3, | |
1491 | const Standard_Integer z3, | |
1492 | IntPatch_PrmPrmIntersection_T3Bits& Map) const | |
7fd59977 | 1493 | { |
1494 | if(x1==x2 && x1==x3 && y1==y2 && y1==y3 && z1==z2 && z1==z3) { | |
1495 | if(DansGrille(x1) && DansGrille(y1) && DansGrille(z1)) { | |
1496 | Standard_Integer t = GrilleInteger(x1,y1,z1); | |
1497 | Map.Add(t); | |
1498 | } | |
1499 | return; | |
1500 | } | |
1501 | else { | |
1502 | Standard_Integer xg=(x1+x2+x3)/3; | |
1503 | Standard_Integer yg=(y1+y2+y3)/3; | |
1504 | Standard_Integer zg=(z1+z2+z3)/3; | |
1505 | if(xg==x1 && yg==y1 && zg==z1) { | |
1506 | RemplitLin(x1,y1,z1,x2,y2,z2,Map); | |
1507 | RemplitLin(x1,y1,z1,x3,y3,z3,Map); | |
1508 | return; | |
1509 | } | |
1510 | if(xg==x2 && yg==y2 && zg==z2) { | |
1511 | RemplitLin(x2,y2,z2,x1,y1,z1,Map); | |
1512 | RemplitLin(x2,y2,z2,x3,y3,z3,Map); | |
1513 | return; | |
1514 | } | |
1515 | if(xg==x3 && yg==y3 && zg==z3) { | |
1516 | RemplitLin(x3,y3,z3,x2,y2,z2,Map); | |
1517 | RemplitLin(x3,y3,z3,x1,y1,z1,Map); | |
1518 | return; | |
1519 | } | |
1520 | if(DansGrille(xg) && DansGrille(yg) && DansGrille(zg)) { | |
1521 | Standard_Integer t = GrilleInteger(xg,yg,zg); | |
1522 | Map.Add(t); | |
1523 | } | |
1524 | if(xg!=x3 || yg!=y3 || zg!=z3) RemplitTri(x1,y1,z1, x2,y2,z2, xg,yg,zg, Map); | |
1525 | if(xg!=x1 || yg!=y1 || zg!=z1) RemplitTri(xg,yg,zg, x2,y2,z2, x3,y3,z3, Map); | |
1526 | if(xg!=x2 || yg!=y2 || zg!=z2) RemplitTri(x1,y1,z1, xg,yg,zg, x3,y3,z3, Map); | |
1527 | } | |
1528 | } | |
1529 | ||
1530 | //================================================================================== | |
1531 | // function : Remplit | |
1532 | // purpose : | |
1533 | //================================================================================== | |
1534 | void IntPatch_PrmPrmIntersection::Remplit(const Standard_Integer a, | |
00302ba4 | 1535 | const Standard_Integer b, |
1536 | const Standard_Integer c, | |
1537 | IntPatch_PrmPrmIntersection_T3Bits& Map) const | |
7fd59977 | 1538 | { |
1539 | int iax,iay,iaz,ibx,iby,ibz,icx,icy,icz; | |
1540 | if(a!=-1) Map.Add(a); | |
1541 | if(b!=-1) Map.Add(b); | |
1542 | if(c!=-1) Map.Add(c); | |
00302ba4 | 1543 | |
7fd59977 | 1544 | if(a!=-1 && b!=-1 && c!=-1 ) { |
1545 | IntegerGrille(a,iax,iay,iaz); | |
1546 | IntegerGrille(b,ibx,iby,ibz); | |
1547 | IntegerGrille(c,icx,icy,icz); | |
1548 | RemplitTri(iax,iay,iaz,ibx,iby,ibz,icx,icy,icz,Map); | |
1549 | } | |
1550 | } | |
1551 | ||
7fd59977 | 1552 | |
7fd59977 | 1553 | |
c66d7156 P |
1554 | //======================================================================= |
1555 | //function : Perform | |
1556 | //purpose : | |
1557 | //======================================================================= | |
1558 | void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Surf1, | |
00302ba4 | 1559 | const Handle(Adaptor3d_TopolTool)& D1, |
1560 | const Handle(Adaptor3d_HSurface)& Surf2, | |
1561 | const Handle(Adaptor3d_TopolTool)& D2, | |
1562 | const Standard_Real TolTangency, | |
1563 | const Standard_Real Epsilon, | |
1564 | const Standard_Real Deflection, | |
1565 | const Standard_Real Increment, | |
7797eb38 | 1566 | IntSurf_ListOfPntOn2S& LOfPnts) |
c66d7156 P |
1567 | { |
1568 | if (LOfPnts.IsEmpty()){ | |
1569 | done = Standard_True; | |
7fd59977 | 1570 | return; |
1571 | } | |
00302ba4 | 1572 | |
c66d7156 P |
1573 | empt = Standard_True; |
1574 | SLin.Clear(); | |
00302ba4 | 1575 | |
c66d7156 P |
1576 | Standard_Real UminLig1,VminLig1,UmaxLig1,VmaxLig1; |
1577 | Standard_Real UminLig2,VminLig2,UmaxLig2,VmaxLig2; | |
1578 | Standard_Real U1,U2,V1,V2; | |
00302ba4 | 1579 | |
c66d7156 P |
1580 | UminLig1 = Surf1->FirstUParameter(); |
1581 | VminLig1 = Surf1->FirstVParameter(); | |
1582 | UmaxLig1 = Surf1->LastUParameter(); | |
1583 | VmaxLig1 = Surf1->LastVParameter(); | |
1584 | UminLig2 = Surf2->FirstUParameter(); | |
1585 | VminLig2 = Surf2->FirstVParameter(); | |
1586 | UmaxLig2 = Surf2->LastUParameter(); | |
1587 | VmaxLig2 = Surf2->LastVParameter(); | |
b1c5c4e6 | 1588 | |
1589 | Standard_Real Periods [4]; | |
1590 | Periods[0] = (Surf1->IsUPeriodic())? Surf1->UPeriod() : 0.; | |
1591 | Periods[1] = (Surf1->IsVPeriodic())? Surf1->VPeriod() : 0.; | |
1592 | Periods[2] = (Surf2->IsUPeriodic())? Surf2->UPeriod() : 0.; | |
1593 | Periods[3] = (Surf2->IsVPeriodic())? Surf2->VPeriod() : 0.; | |
00302ba4 | 1594 | |
c66d7156 | 1595 | IntSurf_ListIteratorOfListOfPntOn2S IterLOP1(LOfPnts); |
4a616573 | 1596 | if (Surf1->IsUClosed() || Surf1->IsVClosed() || |
1597 | Surf2->IsUClosed() || Surf2->IsVClosed()) | |
1598 | { | |
1599 | Standard_Real TolPar = Precision::PConfusion(); | |
1600 | IntSurf_ListOfPntOn2S AdditionalPnts; | |
1601 | Standard_Real NewU1, NewV1, NewU2, NewV2; | |
1602 | for(; IterLOP1.More(); IterLOP1.Next()) | |
1603 | { | |
1604 | IntSurf_PntOn2S Pnt = IterLOP1.Value(); | |
1605 | Pnt.Parameters(U1, V1, U2, V2); | |
1606 | IntSurf_PntOn2S NewPnt; | |
1607 | if (Surf1->IsUClosed()) | |
1608 | { | |
1609 | if (Abs(U1 - Surf1->FirstUParameter()) <= TolPar) | |
1610 | { | |
1611 | NewU1 = Surf1->LastUParameter(); | |
1612 | NewPnt.SetValue( NewU1, V1, U2, V2 ); | |
1613 | AdditionalPnts.Append(NewPnt); | |
1614 | } | |
1615 | else if (Abs(U1 - Surf1->LastUParameter()) <= TolPar) | |
1616 | { | |
1617 | NewU1 = Surf1->FirstUParameter(); | |
1618 | NewPnt.SetValue( NewU1, V1, U2, V2 ); | |
1619 | AdditionalPnts.Append(NewPnt); | |
1620 | } | |
1621 | } | |
1622 | if (Surf1->IsVClosed()) | |
1623 | { | |
1624 | if (Abs(V1 - Surf1->FirstVParameter()) <= TolPar) | |
1625 | { | |
1626 | NewV1 = Surf1->LastVParameter(); | |
1627 | NewPnt.SetValue( U1, NewV1, U2, V2 ); | |
1628 | AdditionalPnts.Append(NewPnt); | |
1629 | } | |
1630 | else if (Abs(V1 - Surf1->LastVParameter()) <= TolPar) | |
1631 | { | |
1632 | NewV1 = Surf1->FirstVParameter(); | |
1633 | NewPnt.SetValue( U1, NewV1, U2, V2 ); | |
1634 | AdditionalPnts.Append(NewPnt); | |
1635 | } | |
1636 | } | |
1637 | if (Surf2->IsUClosed()) | |
1638 | { | |
1639 | if (Abs(U2 - Surf2->FirstUParameter()) <= TolPar) | |
1640 | { | |
1641 | NewU2 = Surf2->LastUParameter(); | |
1642 | NewPnt.SetValue( U1, V1, NewU2, V2); | |
1643 | AdditionalPnts.Append(NewPnt); | |
1644 | } | |
1645 | else if (Abs(U2 - Surf2->LastUParameter()) <= TolPar) | |
1646 | { | |
1647 | NewU2 = Surf2->FirstUParameter(); | |
1648 | NewPnt.SetValue( U1, V1, NewU2, V2); | |
1649 | AdditionalPnts.Append(NewPnt); | |
1650 | } | |
1651 | } | |
1652 | if (Surf2->IsVClosed()) | |
1653 | { | |
1654 | if (Abs(V2 - Surf2->FirstVParameter()) <= TolPar) | |
1655 | { | |
1656 | NewV2 = Surf2->LastVParameter(); | |
1657 | NewPnt.SetValue( U1, V1, U2, NewV2 ); | |
1658 | AdditionalPnts.Append(NewPnt); | |
1659 | } | |
1660 | else if (Abs(V2 - Surf2->LastVParameter()) <= TolPar) | |
1661 | { | |
1662 | NewV2 = Surf2->FirstVParameter(); | |
1663 | NewPnt.SetValue( U1, V1, U2, NewV2 ); | |
1664 | AdditionalPnts.Append(NewPnt); | |
1665 | } | |
1666 | } | |
1667 | } | |
1668 | //Cut repeated points | |
1669 | for (IterLOP1.Initialize(LOfPnts); IterLOP1.More(); IterLOP1.Next()) | |
1670 | { | |
1671 | IntSurf_PntOn2S aPnt = IterLOP1.Value(); | |
1672 | aPnt.Parameters(U1, V1, U2, V2); | |
1673 | IntSurf_ListIteratorOfListOfPntOn2S iter2(AdditionalPnts); | |
1674 | while (iter2.More()) | |
1675 | { | |
1676 | IntSurf_PntOn2S aNewPnt = iter2.Value(); | |
1677 | aNewPnt.Parameters(NewU1, NewV1, NewU2, NewV2); | |
1678 | if (Abs(U1 - NewU1) <= TolPar && | |
1679 | Abs(V1 - NewV1) <= TolPar && | |
1680 | Abs(U2 - NewU2) <= TolPar && | |
1681 | Abs(V2 - NewV2) <= TolPar) | |
1682 | AdditionalPnts.Remove(iter2); | |
1683 | else | |
1684 | iter2.Next(); | |
1685 | } | |
1686 | } | |
1687 | ||
1688 | LOfPnts.Append(AdditionalPnts); | |
1689 | } | |
7fd59977 | 1690 | |
4a616573 | 1691 | for(IterLOP1.Initialize(LOfPnts); IterLOP1.More(); IterLOP1.Next()){ |
c66d7156 P |
1692 | IntSurf_PntOn2S Pnt = IterLOP1.Value(); |
1693 | Pnt.Parameters(U1, V1, U2, V2); | |
1694 | if(U1>UmaxLig1) UmaxLig1=U1; | |
1695 | if(V1>VmaxLig1) VmaxLig1=V1; | |
1696 | if(U2>UmaxLig2) UmaxLig2=U2; | |
1697 | if(V2>VmaxLig2) VmaxLig2=V2; | |
00302ba4 | 1698 | |
c66d7156 P |
1699 | if(U1<UminLig1) UminLig1=U1; |
1700 | if(V1<VminLig1) VminLig1=V1; | |
1701 | if(U2<UminLig2) UminLig2=U2; | |
1702 | if(V2<VminLig2) VminLig2=V2; | |
7fd59977 | 1703 | } |
00302ba4 | 1704 | |
c66d7156 | 1705 | Standard_Real SeuildPointLigne = 15.0 * Increment * Increment; |
00302ba4 | 1706 | |
302f96fb | 1707 | Standard_Integer NbLigCalculee = 0, ver; |
c66d7156 P |
1708 | Standard_Real pu1,pu2,pv1,pv2, dminiPointLigne; |
1709 | Standard_Boolean HasStartPoint,RejetLigne; | |
1710 | IntSurf_PntOn2S StartPOn2S; | |
1711 | gp_Pnt Point3dDebut,Point3dFin; | |
7fd59977 | 1712 | |
c66d7156 | 1713 | TColStd_Array1OfReal StartParams(1,4); |
47cbf134 | 1714 | IntWalk_PWalking PW(Surf1,Surf2,TolTangency,Epsilon,Deflection,Increment); |
00302ba4 | 1715 | |
c66d7156 P |
1716 | IntSurf_ListIteratorOfListOfPntOn2S IterLOP2(LOfPnts); |
1717 | for(; IterLOP2.More(); IterLOP2.Next() ){ | |
00302ba4 | 1718 | |
c66d7156 P |
1719 | IntSurf_PntOn2S cPnt = IterLOP2.Value(); |
1720 | cPnt.Parameters(U1, V1, U2, V2); | |
00302ba4 | 1721 | |
c66d7156 P |
1722 | StartParams(1) = U1; |
1723 | StartParams(2) = V1; | |
1724 | StartParams(3) = U2; | |
1725 | StartParams(4) = V2; | |
00302ba4 | 1726 | |
c66d7156 P |
1727 | HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S); |
1728 | dminiPointLigne = SeuildPointLigne + SeuildPointLigne; | |
1729 | if(HasStartPoint) { | |
1730 | StartPOn2S.Parameters(pu1,pv1,pu2,pv2); | |
1731 | NbLigCalculee = SLin.Length(); | |
1732 | Standard_Integer l; | |
1733 | for( l = 1; (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); l++) { | |
a7dd5d0f | 1734 | const Handle(IntPatch_WLine)& testwline = *((Handle(IntPatch_WLine)*)&SLin.Value(l)); |
1735 | ||
1736 | if (IsPointOnLine(StartPOn2S, testwline, Deflection)) { | |
1737 | dminiPointLigne = 0.0; | |
1738 | } | |
c66d7156 | 1739 | }// for( l ... |
00302ba4 | 1740 | |
c66d7156 P |
1741 | if(dminiPointLigne > SeuildPointLigne) { |
1742 | PW.Perform(StartParams,UminLig1,VminLig1,UminLig2,VminLig2,UmaxLig1,VmaxLig1,UmaxLig2,VmaxLig2); | |
1743 | if(PW.IsDone()) { | |
c2c2f2b6 | 1744 | if(PW.NbPoints()>2) |
1745 | { | |
882e1d11 | 1746 | //Try to extend the intersection line to boundary, if it is possible. |
1747 | PW.PutToBoundary(Surf1, Surf2); | |
c2c2f2b6 | 1748 | |
c66d7156 P |
1749 | RejetLigne = Standard_False; |
1750 | Point3dDebut = PW.Value(1).Value(); | |
a7dd5d0f | 1751 | const IntSurf_PntOn2S& PointFin = PW.Value(PW.NbPoints()); |
1752 | Point3dFin = PointFin.Value(); | |
1dee0696 | 1753 | for( ver = 1 ; ver<= NbLigCalculee ; ver++) { |
c66d7156 | 1754 | const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver)); |
a7dd5d0f | 1755 | |
1756 | // Check end point if it is on existing line. | |
1757 | // Start point is checked before. | |
1758 | if (IsPointOnLine(PointFin, verwline, Deflection)) { | |
1759 | RejetLigne = Standard_True; | |
1760 | break; | |
1761 | } | |
1762 | ||
c66d7156 P |
1763 | const IntSurf_PntOn2S& verPointDebut = verwline->Point(1); |
1764 | const IntSurf_PntOn2S& verPointFin = verwline->Point(verwline->NbPnts()); | |
1dee0696 | 1765 | if( (Point3dDebut.Distance(verPointDebut.Value()) <= TolTangency) && |
1766 | (Point3dFin.Distance(verPointFin.Value()) <= TolTangency)) | |
1767 | { | |
1768 | RejetLigne = Standard_True; | |
1769 | break; | |
c66d7156 P |
1770 | } |
1771 | } | |
00302ba4 | 1772 | |
c8187bb2 | 1773 | if(RejetLigne) |
1774 | { | |
1775 | DublicateOfLinesProcessing(PW, ver, SLin, RejetLigne); | |
1776 | } | |
1777 | ||
c66d7156 P |
1778 | if(!RejetLigne) { |
1779 | IntSurf_TypeTrans trans1,trans2; | |
1780 | Standard_Real locu,locv; | |
1781 | gp_Vec norm1,norm2,d1u,d1v; | |
1782 | gp_Pnt ptbid; | |
1783 | Standard_Integer indextg; | |
1784 | gp_Vec tgline(PW.TangentAtLine(indextg)); | |
1785 | PW.Line()->Value(indextg).ParametersOnS1(locu,locv); | |
1786 | Surf1->D1(locu,locv,ptbid,d1u,d1v); | |
1787 | norm1 = d1u.Crossed(d1v); | |
1788 | PW.Line()->Value(indextg).ParametersOnS2(locu,locv); | |
1789 | Surf2->D1(locu,locv,ptbid,d1u,d1v); | |
1790 | norm2 = d1u.Crossed(d1v); | |
1791 | if( tgline.DotCross(norm2,norm1) >= 0. ) { | |
1792 | trans1 = IntSurf_Out; | |
1793 | trans2 = IntSurf_In; | |
1794 | } | |
1795 | else { | |
1796 | trans1 = IntSurf_In; | |
1797 | trans2 = IntSurf_Out; | |
1798 | } | |
00302ba4 | 1799 | |
c66d7156 P |
1800 | Standard_Real TolTang = TolTangency; |
1801 | Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2); | |
98974dcc | 1802 | wline->SetCreatingWayInfo(IntPatch_WLine::IntPatch_WLPrmPrm); |
1803 | ||
7797eb38 | 1804 | //the method PutVertexOnLine can reduce the number of points in <wline> |
1805 | IntPatch_RstInt::PutVertexOnLine(wline, Surf1, D1, Surf2, Standard_True, TolTang); | |
1806 | if (wline->NbPnts() < 2) | |
1807 | continue; | |
1808 | IntPatch_RstInt::PutVertexOnLine(wline, Surf2, D2, Surf1, Standard_False, TolTang); | |
1809 | if (wline->NbPnts() < 2) | |
1810 | continue; | |
00302ba4 | 1811 | |
c66d7156 P |
1812 | if(wline->NbVertex() == 0) { |
1813 | IntPatch_Point vtx; | |
1814 | IntSurf_PntOn2S POn2S = PW.Line()->Value(1); | |
1815 | POn2S.Parameters(pu1,pv1,pu2,pv2); | |
1816 | vtx.SetValue(Point3dDebut,TolTang,Standard_False); | |
1817 | vtx.SetParameters(pu1,pv1,pu2,pv2); | |
1818 | vtx.SetParameter(1); | |
1819 | wline->AddVertex(vtx); | |
00302ba4 | 1820 | |
c66d7156 P |
1821 | POn2S = PW.Line()->Value(wline->NbPnts()); |
1822 | POn2S.Parameters(pu1,pv1,pu2,pv2); | |
1823 | vtx.SetValue(Point3dFin,TolTang,Standard_False); | |
1824 | vtx.SetParameters(pu1,pv1,pu2,pv2); | |
1825 | vtx.SetParameter(wline->NbPnts()); | |
1826 | wline->AddVertex(vtx); | |
1827 | } | |
7fd59977 | 1828 | |
714c3bfc | 1829 | SeveralWlinesProcessing(Surf1, Surf2, SLin, Periods, trans1, trans2, |
1830 | TolTang, Max(PW.MaxStep(0), PW.MaxStep(1)), | |
1831 | Max(PW.MaxStep(2), PW.MaxStep(3)), wline); | |
00302ba4 | 1832 | |
a7dd5d0f | 1833 | AddWLine(SLin, wline, Deflection); |
c66d7156 P |
1834 | empt = Standard_False; |
1835 | }// !RejetLigne | |
1836 | }// PW points > 2 | |
1837 | }// done is True | |
1838 | }// dminiPointLigne > SeuildPointLigne | |
1839 | }// HasStartPoint | |
1840 | }// for( IterLOP ... | |
1841 | done = Standard_True; | |
1842 | return; | |
1843 | } | |
1844 | //======================================================================= | |
1845 | //function : Perform | |
1846 | //purpose : | |
1847 | //======================================================================= | |
1848 | void IntPatch_PrmPrmIntersection::Perform(const Handle(Adaptor3d_HSurface)& Surf1, | |
00302ba4 | 1849 | const Handle(Adaptor3d_TopolTool)& D1, |
1850 | const Handle(Adaptor3d_HSurface)& Surf2, | |
1851 | const Handle(Adaptor3d_TopolTool)& D2, | |
1852 | const Standard_Real U1Depart, | |
1853 | const Standard_Real V1Depart, | |
1854 | const Standard_Real U2Depart, | |
1855 | const Standard_Real V2Depart, | |
1856 | const Standard_Real TolTangency, | |
1857 | const Standard_Real Epsilon, | |
1858 | const Standard_Real Deflection, | |
1859 | const Standard_Real Increment) | |
1860 | { | |
1861 | // Standard_Integer NbU1 = D1->NbSamplesU(); | |
1862 | // Standard_Integer NbV1 = D1->NbSamplesV(); | |
1863 | // Standard_Integer NbU2 = D2->NbSamplesU(); | |
1864 | // Standard_Integer NbV2 = D2->NbSamplesV(); | |
7fd59977 | 1865 | |
c66d7156 P |
1866 | //-- Traitement des Lignes de sections |
1867 | empt = Standard_True; | |
1868 | done = Standard_True; | |
1869 | SLin.Clear(); | |
00302ba4 | 1870 | |
c66d7156 | 1871 | //------------------------------------------------------------ |
7fd59977 | 1872 | |
c66d7156 | 1873 | Standard_Real pu1,pu2,pv1,pv2; |
00302ba4 | 1874 | |
c66d7156 | 1875 | TColStd_Array1OfReal StartParams(1,4); |
00302ba4 | 1876 | |
1877 | // Standard_Integer MaxOscill = NbU1; | |
1878 | // if(MaxOscill < NbU2) MaxOscill=NbU2; | |
1879 | // if(MaxOscill < NbV1) MaxOscill=NbV1; | |
1880 | // if(MaxOscill < NbV2) MaxOscill=NbV2; | |
1881 | ||
1882 | // Standard_Real nIncrement=Increment; | |
1883 | // if(MaxOscill>10) { | |
0797d9d3 | 1884 | // #ifdef OCCT_DEBUG |
04232180 | 1885 | // std::cout<<"\n IntPatch_PrmPrmIntersection.gxx : Increment:"<<Increment<<" -> "<<Increment/(0.5*MaxOscill)<<std::endl; |
00302ba4 | 1886 | // #endif |
1887 | // nIncrement/=0.5*MaxOscill; | |
1888 | // } | |
1889 | ||
47cbf134 | 1890 | IntWalk_PWalking PW(Surf1,Surf2, |
00302ba4 | 1891 | TolTangency, |
1892 | Epsilon, | |
1893 | Deflection, | |
1894 | Increment); //nIncrement); | |
1895 | ||
1896 | ||
c66d7156 P |
1897 | //Standard_Real SeuildPointLigne = 15.0 * Increment * Increment; //-- 10 est insuffisant |
1898 | //Standard_Real incidence; | |
1899 | //Standard_Real dminiPointLigne; | |
00302ba4 | 1900 | |
c66d7156 | 1901 | Standard_Boolean HasStartPoint;//,RejetLigne; |
00302ba4 | 1902 | |
c66d7156 | 1903 | IntSurf_PntOn2S StartPOn2S; |
00302ba4 | 1904 | |
c66d7156 | 1905 | //Standard_Integer ver; |
00302ba4 | 1906 | |
c66d7156 | 1907 | gp_Pnt Point3dDebut,Point3dFin; |
00302ba4 | 1908 | |
c66d7156 | 1909 | //------------------------------------------------------------ |
00302ba4 | 1910 | |
c66d7156 P |
1911 | StartParams(1) = U1Depart; |
1912 | StartParams(2) = V1Depart; | |
1913 | StartParams(3) = U2Depart; | |
1914 | StartParams(4) = V2Depart; | |
00302ba4 | 1915 | |
c66d7156 P |
1916 | //----------------------------------------------------------------------- |
1917 | //-- Calcul du premier point de cheminement a partir du point approche -- | |
1918 | //----------------------------------------------------------------------- | |
1919 | HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S); | |
1920 | if(HasStartPoint) { | |
1921 | //------------------------------------------------- | |
1922 | //-- Un point a ete trouve -- | |
1923 | //-- On verifie qu il n appartient pas -- | |
1924 | //-- a une ligne de cheminement deja calculee. -- | |
1925 | //------------------------------------------------- | |
00302ba4 | 1926 | |
c66d7156 P |
1927 | PW.Perform(StartParams); |
1928 | if(PW.IsDone()) { | |
bc9a61ec | 1929 | if(PW.NbPoints()>2) { |
1930 | Point3dDebut = PW.Value(1).Value(); | |
1931 | Point3dFin = PW.Value(PW.NbPoints()).Value(); | |
1932 | ||
1933 | IntSurf_TypeTrans trans1,trans2; | |
1934 | Standard_Real locu,locv; | |
1935 | gp_Vec norm1,norm2,d1u,d1v; | |
1936 | gp_Pnt ptbid; | |
1937 | Standard_Integer indextg; | |
1938 | gp_Vec tgline(PW.TangentAtLine(indextg)); | |
1939 | PW.Line()->Value(indextg).ParametersOnS1(locu,locv); | |
1940 | Surf1->D1(locu,locv,ptbid,d1u,d1v); | |
1941 | norm1 = d1u.Crossed(d1v); | |
1942 | PW.Line()->Value(indextg).ParametersOnS2(locu,locv); | |
1943 | Surf2->D1(locu,locv,ptbid,d1u,d1v); | |
1944 | norm2 = d1u.Crossed(d1v); | |
1945 | if (tgline.DotCross(norm2,norm1)>0.) { | |
1946 | trans1 = IntSurf_Out; | |
1947 | trans2 = IntSurf_In; | |
1948 | } | |
1949 | else { | |
1950 | trans1 = IntSurf_In; | |
1951 | trans2 = IntSurf_Out; | |
1952 | } | |
00302ba4 | 1953 | |
bc9a61ec | 1954 | Standard_Real TolTang = TolTangency; |
1955 | Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2); | |
98974dcc | 1956 | wline->SetCreatingWayInfo(IntPatch_WLine::IntPatch_WLPrmPrm); |
1957 | ||
1406e955 | 1958 | //the method PutVertexOnLine can reduce the number of points in <wline> |
bc9a61ec | 1959 | IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang); |
1406e955 | 1960 | if (wline->NbPnts() < 2) |
1961 | return; | |
bc9a61ec | 1962 | IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang); |
1406e955 | 1963 | if (wline->NbPnts() < 2) |
1964 | return; | |
bc9a61ec | 1965 | |
1966 | //--------------- | |
1967 | if(wline->NbVertex() == 0) { | |
1968 | IntPatch_Point vtx; | |
1969 | IntSurf_PntOn2S POn2S = PW.Line()->Value(1); | |
1970 | POn2S.Parameters(pu1,pv1,pu2,pv2); | |
1971 | vtx.SetValue(Point3dDebut,TolTang,Standard_False); | |
1972 | vtx.SetParameters(pu1,pv1,pu2,pv2); | |
1973 | vtx.SetParameter(1); | |
1974 | wline->AddVertex(vtx); | |
1975 | ||
1976 | POn2S = PW.Line()->Value(wline->NbPnts()); | |
1977 | POn2S.Parameters(pu1,pv1,pu2,pv2); | |
1978 | vtx.SetValue(Point3dFin,TolTang,Standard_False); | |
1979 | vtx.SetParameters(pu1,pv1,pu2,pv2); | |
1980 | vtx.SetParameter(wline->NbPnts()); | |
1981 | wline->AddVertex(vtx); | |
1982 | } | |
00302ba4 | 1983 | |
bc9a61ec | 1984 | //--------------- |
1985 | SLin.Append(wline); | |
1986 | empt = Standard_False; | |
1406e955 | 1987 | } //if(PW.NbPoints()>2) |
1988 | } //if(PW.IsDone()) | |
1989 | } //if(HasStartPoint) | |
c66d7156 P |
1990 | } |
1991 | //================================================================================== | |
1992 | // function : AdjustOnPeriodic | |
1993 | // purpose : | |
1994 | //================================================================================== | |
1995 | void AdjustOnPeriodic(const Handle(Adaptor3d_HSurface)& Surf1, | |
00302ba4 | 1996 | const Handle(Adaptor3d_HSurface)& Surf2, |
1997 | IntPatch_SequenceOfLine& aSLin) | |
c66d7156 P |
1998 | { |
1999 | Standard_Boolean bIsPeriodic[4], bModified, bIsNull, bIsPeriod; | |
2000 | Standard_Integer i, j, k, aNbLines, aNbPx, aIndx, aIndq; | |
2001 | Standard_Real aPeriod[4], dPeriod[4], ux[4], uq[4], aEps, du; | |
2002 | // | |
2003 | aEps=Precision::Confusion(); | |
2004 | // | |
2005 | for (k=0; k<4; ++k) { | |
2006 | aPeriod[k]=0.; | |
2007 | } | |
2008 | // | |
2009 | bIsPeriodic[0]=Surf1->IsUPeriodic(); | |
2010 | bIsPeriodic[1]=Surf1->IsVPeriodic(); | |
2011 | bIsPeriodic[2]=Surf2->IsUPeriodic(); | |
2012 | bIsPeriodic[3]=Surf2->IsVPeriodic(); | |
2013 | // | |
2014 | if (bIsPeriodic[0]){ | |
2015 | aPeriod[0]=Surf1->UPeriod(); | |
2016 | } | |
2017 | if (bIsPeriodic[1]){ | |
2018 | aPeriod[1]=Surf1->VPeriod(); | |
2019 | } | |
2020 | if (bIsPeriodic[2]){ | |
2021 | aPeriod[2]=Surf2->UPeriod(); | |
2022 | } | |
2023 | if (bIsPeriodic[3]){ | |
2024 | aPeriod[3]=Surf2->VPeriod(); | |
2025 | } | |
2026 | // | |
2027 | for (k=0; k<4; ++k) { | |
2028 | dPeriod[k]=0.25*aPeriod[k]; | |
2029 | } | |
2030 | // | |
2031 | aNbLines=aSLin.Length(); | |
2032 | for (i=1; i<=aNbLines; ++i) { | |
2033 | Handle(IntPatch_WLine) aIL=Handle(IntPatch_WLine)::DownCast(aSLin.Value(i)); | |
2034 | Handle(IntSurf_LineOn2S) aL=aIL->Curve(); | |
2035 | ||
2036 | aNbPx=aL->NbPoints(); | |
2037 | if (aNbPx<10) { | |
2038 | continue; | |
2039 | } | |
2040 | // | |
2041 | for (j=0; j<2; ++j) { | |
2042 | bModified=Standard_False; | |
2043 | aIndx=1; | |
2044 | aIndq=2; | |
2045 | if (j) { | |
00302ba4 | 2046 | aIndx=aNbPx; |
2047 | aIndq=aNbPx-1; | |
c66d7156 P |
2048 | } |
2049 | // | |
2050 | const IntSurf_PntOn2S& aPSx=aL->Value(aIndx); | |
2051 | const IntSurf_PntOn2S& aPSq=aL->Value(aIndq); | |
2052 | // | |
2053 | aPSx.Parameters(ux[0], ux[1], ux[2], ux[3]); | |
2054 | aPSq.Parameters(uq[0], uq[1], uq[2], uq[3]); | |
2055 | // | |
2056 | for (k=0; k<4; ++k) { | |
00302ba4 | 2057 | bIsNull=Standard_False; |
2058 | bIsPeriod=Standard_False; | |
2059 | // | |
2060 | if (!bIsPeriodic[k]) { | |
2061 | continue; | |
2062 | } | |
2063 | // | |
2064 | if (fabs(ux[k])<aEps) { | |
2065 | bModified=Standard_True; | |
2066 | bIsNull=Standard_True; | |
2067 | } | |
2068 | // | |
2069 | else if (fabs(ux[k]-aPeriod[k])<aEps) { | |
2070 | bModified=Standard_True; | |
2071 | bIsPeriod=Standard_True; | |
2072 | } | |
2073 | // | |
2074 | if (bModified) { | |
2075 | du=fabs(ux[k]-uq[k]); | |
2076 | if (du > dPeriod[k]) { | |
2077 | if(bIsNull){ | |
2078 | ux[k]=aPeriod[k]; | |
2079 | } | |
2080 | if(bIsPeriod) { | |
2081 | ux[k]=0.; | |
2082 | } | |
2083 | } | |
2084 | } | |
c66d7156 P |
2085 | }//for (k=0; k<4; ++k) |
2086 | if (bModified) { | |
00302ba4 | 2087 | IntSurf_PntOn2S aPntOn2S; |
2088 | // | |
2089 | aPntOn2S=aPSx; | |
2090 | aPntOn2S.SetValue(ux[0], ux[1], ux[2], ux[3]); | |
2091 | aL->Value(aIndx, aPntOn2S); | |
c66d7156 P |
2092 | } |
2093 | }//for (j=0; j<1; ++j) { | |
2094 | }//for (i=1; i<=aNbLines; ++i) | |
2095 | } | |
b1c5c4e6 | 2096 | |
2097 | //================================================================================== | |
2098 | // function : MakeNewPoint | |
2099 | // purpose : | |
2100 | //================================================================================== | |
2101 | IntSurf_PntOn2S MakeNewPoint(const IntSurf_PntOn2S& replacePnt, | |
2102 | const IntSurf_PntOn2S& oldPnt, | |
2103 | const Standard_Real* Periods) | |
2104 | { | |
2105 | IntSurf_PntOn2S NewPoint; | |
2106 | NewPoint.SetValue(replacePnt.Value()); | |
00302ba4 | 2107 | |
b1c5c4e6 | 2108 | Standard_Real OldParams[4], NewParams[4]; |
2109 | oldPnt.Parameters(OldParams[0], OldParams[1], OldParams[2], OldParams[3]); | |
2110 | replacePnt.Parameters(NewParams[0], NewParams[1], NewParams[2], NewParams[3]); | |
2111 | ||
2112 | Standard_Integer i; | |
2113 | for (i = 0; i < 4; i++) | |
c48e2889 | 2114 | { |
b1c5c4e6 | 2115 | if (Periods[i] != 0.) |
2116 | { | |
2117 | if (Abs(NewParams[i] - OldParams[i]) >= 0.5*Periods[i]) | |
2118 | { | |
2119 | if (NewParams[i] < OldParams[i]) | |
2120 | NewParams[i] += Periods[i]; | |
2121 | else | |
2122 | NewParams[i] -= Periods[i]; | |
2123 | } | |
2124 | } | |
c48e2889 | 2125 | } |
b1c5c4e6 | 2126 | |
c48e2889 | 2127 | NewPoint.SetValue(NewParams[0], NewParams[1], NewParams[2], NewParams[3]); |
2128 | return NewPoint; | |
b1c5c4e6 | 2129 | } |
2130 | ||
c66d7156 P |
2131 | //================================================================================== |
2132 | // function : Perform | |
2133 | // purpose : base SS Int. function | |
2134 | //================================================================================== | |
2135 | void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Surf1, | |
00302ba4 | 2136 | const Handle(Adaptor3d_TopolTool)& D1, |
2137 | const Handle(Adaptor3d_HSurface)& Surf2, | |
2138 | const Handle(Adaptor3d_TopolTool)& D2, | |
2139 | const Standard_Real TolTangency, | |
2140 | const Standard_Real Epsilon, | |
2141 | const Standard_Real Deflection, | |
2142 | const Standard_Real Increment, | |
c66d7156 P |
2143 | const Standard_Boolean ClearFlag) |
2144 | { | |
00302ba4 | 2145 | Standard_Integer Limit = 2500; |
2146 | Standard_Integer NbU1 = 10, NbV1 = 10, NbU2 = 10, NbV2 = 10; | |
c66d7156 | 2147 | // |
00302ba4 | 2148 | D1->SamplePnts(Deflection, NbU1, NbV1); |
2149 | D2->SamplePnts(Deflection, NbU2, NbV2); | |
c66d7156 P |
2150 | // |
2151 | NbU1 = D1->NbSamplesU(); | |
2152 | NbV1 = D1->NbSamplesV(); | |
2153 | NbU2 = D2->NbSamplesU(); | |
2154 | NbV2 = D2->NbSamplesV(); | |
00302ba4 | 2155 | |
c66d7156 P |
2156 | TColStd_Array1OfReal anUpars1(1, NbU1), aVpars1(1, NbV1); |
2157 | TColStd_Array1OfReal anUpars2(1, NbU2), aVpars2(1, NbV2); | |
2158 | // | |
2159 | D1->UParameters(anUpars1); | |
2160 | D1->VParameters(aVpars1); | |
2161 | D2->UParameters(anUpars2); | |
2162 | D2->VParameters(aVpars2); | |
b1c5c4e6 | 2163 | |
2164 | Standard_Real Periods [4]; | |
2165 | Periods[0] = (Surf1->IsUPeriodic())? Surf1->UPeriod() : 0.; | |
2166 | Periods[1] = (Surf1->IsVPeriodic())? Surf1->VPeriod() : 0.; | |
2167 | Periods[2] = (Surf2->IsUPeriodic())? Surf2->UPeriod() : 0.; | |
2168 | Periods[3] = (Surf2->IsVPeriodic())? Surf2->VPeriod() : 0.; | |
00302ba4 | 2169 | |
c66d7156 | 2170 | //--------------------------------------------- |
00302ba4 | 2171 | if((NbU1*NbV1<=Limit && NbV2*NbU2<=Limit)) |
2172 | { | |
c66d7156 | 2173 | empt = Standard_True; |
00302ba4 | 2174 | if (ClearFlag) |
2175 | { | |
c66d7156 P |
2176 | SLin.Clear(); |
2177 | } | |
2178 | // | |
2179 | IntPolyh_Intersection* pInterference = NULL; | |
2180 | ||
00302ba4 | 2181 | if ( D1->IsUniformSampling() || D2->IsUniformSampling() ) |
2182 | { | |
c66d7156 P |
2183 | pInterference = new IntPolyh_Intersection(Surf1,NbU1,NbV1,Surf2,NbU2,NbV2); |
2184 | } | |
00302ba4 | 2185 | else |
2186 | { | |
c66d7156 | 2187 | pInterference = new IntPolyh_Intersection(Surf1, anUpars1, aVpars1, |
00302ba4 | 2188 | Surf2, anUpars2, aVpars2 ); |
c66d7156 | 2189 | } |
00302ba4 | 2190 | |
2191 | if ( !pInterference ) | |
2192 | { | |
c66d7156 P |
2193 | done = Standard_False; |
2194 | return; | |
2195 | } | |
2196 | // | |
2197 | IntPolyh_Intersection& Interference = *pInterference; | |
2198 | // | |
2199 | done = Interference.IsDone(); | |
00302ba4 | 2200 | if( !done ) |
2201 | { | |
2202 | if (pInterference) | |
2203 | { | |
2204 | delete pInterference; | |
2205 | pInterference = NULL; | |
c66d7156 | 2206 | } |
00302ba4 | 2207 | |
c66d7156 P |
2208 | return; |
2209 | } | |
00302ba4 | 2210 | |
c66d7156 P |
2211 | Standard_Integer nbLigSec = Interference.NbSectionLines(); |
2212 | Standard_Integer nbTanZon = Interference.NbTangentZones(); | |
2213 | Standard_Real SeuildPointLigne = 15.0 * Increment * Increment; | |
2214 | ||
302f96fb | 2215 | Standard_Integer NbLigCalculee = 0, ver; |
00302ba4 | 2216 | Standard_Real pu1,pu2,pv1,pv2, incidence, dminiPointLigne; |
2217 | Standard_Boolean HasStartPoint = Standard_False, RejectLine = Standard_False; | |
c66d7156 P |
2218 | IntSurf_PntOn2S StartPOn2S; |
2219 | gp_Pnt Point3dDebut,Point3dFin; | |
2220 | ||
2221 | TColStd_Array1OfReal StartParams(1,4); | |
47cbf134 | 2222 | IntWalk_PWalking PW(Surf1,Surf2,TolTangency,Epsilon,Deflection,Increment); |
c66d7156 | 2223 | |
00302ba4 | 2224 | if(nbLigSec>=1) |
2225 | { | |
c66d7156 | 2226 | Standard_Integer *TabL = new Standard_Integer [nbLigSec+1]; |
00302ba4 | 2227 | for(Standard_Integer ls=1; ls<=nbLigSec; ++ls) |
2228 | { | |
2229 | TabL[ls]=ls; | |
c66d7156 P |
2230 | } |
2231 | //----------------------------------------1.1 | |
00302ba4 | 2232 | { |
2233 | Standard_Boolean triok; | |
2234 | Standard_Integer nb_A, nb_B, tyu; | |
2235 | do | |
2236 | { | |
2237 | triok=Standard_True; | |
2238 | for(Standard_Integer b = 2; b <= nbLigSec; ++b ) | |
2239 | { | |
2240 | nb_B = Interference.NbPointsInLine(TabL[b]); | |
2241 | nb_A = Interference.NbPointsInLine(TabL[b-1]); | |
2242 | ||
2243 | if( nb_B > nb_A ) | |
2244 | { | |
2245 | tyu=TabL[b]; | |
2246 | TabL[b]=TabL[b-1]; | |
2247 | TabL[b-1]=tyu; | |
2248 | triok=Standard_False; | |
2249 | } | |
2250 | } | |
2251 | } | |
2252 | while(triok==Standard_False); | |
2253 | } | |
2254 | ||
c66d7156 P |
2255 | //---------------------------------------- |
2256 | // 1.2 For the line "ls" get 2D-bounds U,V for surfaces 1,2 | |
2257 | // | |
00302ba4 | 2258 | for(Standard_Integer ls = 1; ls <= nbLigSec; ++ls) |
2259 | { | |
2260 | Standard_Integer nbp = Interference.NbPointsInLine(TabL[ls]); | |
2261 | if (!nbp) | |
2262 | { | |
2263 | continue; | |
2264 | } | |
2265 | // | |
2266 | Standard_Integer *TabPtDep = new Standard_Integer [nbp+1]; | |
2267 | for(Standard_Integer ilig = 1; ilig <= nbp; ++ilig ) | |
2268 | { | |
2269 | TabPtDep[ilig]=0; | |
2270 | } | |
2271 | // | |
2272 | Standard_Real UminLig1,VminLig1,UmaxLig1,VmaxLig1; | |
2273 | Standard_Real UminLig2,VminLig2,UmaxLig2,VmaxLig2; | |
2274 | Standard_Real _x,_y,_z; | |
2275 | // | |
2276 | Interference.GetLinePoint(TabL[ls], 1, _x, _y, _z, | |
2277 | UminLig1, VminLig1, UminLig2, VminLig2, | |
2278 | incidence); | |
2279 | ||
2280 | UmaxLig1=UminLig1; | |
2281 | VmaxLig1=VminLig1; | |
2282 | UmaxLig2=UminLig2; | |
2283 | VmaxLig2=VminLig2; | |
2284 | // | |
2285 | for(Standard_Integer ilig = 2; ilig <= nbp; ilig++ ) | |
2286 | { | |
2287 | Standard_Real U1, U2, V1, V2; | |
2288 | Interference.GetLinePoint(TabL[ls],ilig,_x,_y,_z,U1,V1,U2,V2,incidence); | |
2289 | // | |
2290 | if(U1>UmaxLig1) UmaxLig1=U1; | |
2291 | if(V1>VmaxLig1) VmaxLig1=V1; | |
2292 | if(U2>UmaxLig2) UmaxLig2=U2; | |
2293 | if(V2>VmaxLig2) VmaxLig2=V2; | |
2294 | // | |
2295 | if(U1<UminLig1) UminLig1=U1; | |
2296 | if(V1<VminLig1) VminLig1=V1; | |
2297 | if(U2<UminLig2) UminLig2=U2; | |
2298 | if(V2<VminLig2) VminLig2=V2; | |
2299 | }//for( ilig = 2; ilig <= nbp; ilig++ ) { | |
2300 | // | |
2301 | //---------------------------------------- | |
2302 | // 1.3 | |
2303 | Standard_Integer nbps2 = (nbp>3)? (nbp/2) : 1; | |
2304 | Standard_Integer NombreDePointsDeDepartDuCheminement = 0; | |
2305 | Standard_Boolean lignetrouvee=Standard_False; | |
2306 | const Standard_Integer NbDePointsDeDepartDuChmLimit = 5; | |
2307 | // | |
2308 | do | |
2309 | { | |
2310 | NombreDePointsDeDepartDuCheminement++; | |
2311 | switch (NombreDePointsDeDepartDuCheminement) | |
2312 | { | |
2313 | case 1: | |
2314 | nbps2 = (nbp > 1) ? nbp/2 : 1; | |
2315 | if(nbp<3) | |
2316 | NombreDePointsDeDepartDuCheminement = NbDePointsDeDepartDuChmLimit; | |
2317 | ||
2318 | break; | |
2319 | case 2: | |
2320 | nbps2 = 1; | |
2321 | break; | |
2322 | case 3: | |
2323 | nbps2 = nbp-1; | |
2324 | break; | |
2325 | ||
2326 | case 4: | |
2327 | nbps2 = 3 * nbp / 4; | |
2328 | break; | |
2329 | ||
2330 | case 5: | |
2331 | nbps2 = nbp / 4; | |
2332 | break; | |
2333 | default: | |
2334 | nbps2 = NombreDePointsDeDepartDuCheminement-3; | |
2335 | NombreDePointsDeDepartDuCheminement++; | |
2336 | } | |
2337 | ||
2338 | // | |
2339 | if(TabPtDep[nbps2] == 0) | |
2340 | { | |
2341 | Standard_Real U1, U2, V1, V2; | |
2342 | ||
2343 | TabPtDep[nbps2] = 1; | |
2344 | Interference.GetLinePoint(TabL[ls],nbps2,_x,_y,_z,U1,V1,U2,V2,incidence); | |
2345 | ||
2346 | StartParams(1) = U1; | |
2347 | StartParams(2) = V1; | |
2348 | StartParams(3) = U2; | |
2349 | StartParams(4) = V2; | |
2350 | ||
2351 | HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S); | |
2352 | dminiPointLigne = SeuildPointLigne + SeuildPointLigne; | |
2353 | if(HasStartPoint) | |
2354 | { | |
2355 | StartPOn2S.Parameters(pu1,pv1,pu2,pv2); | |
2356 | NbLigCalculee = SLin.Length(); | |
2357 | Standard_Integer l; | |
2358 | for( l = 1; (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); l++) | |
2359 | { | |
2360 | const Handle(IntPatch_WLine)& testwline = *((Handle(IntPatch_WLine)*)&SLin.Value(l)); | |
2361 | ||
2362 | if (IsPointOnLine(StartPOn2S, testwline, Deflection)) | |
2363 | { | |
a7dd5d0f | 2364 | dminiPointLigne = 0.0; |
2365 | } | |
00302ba4 | 2366 | }// for( l ... |
2367 | ||
2368 | if(dminiPointLigne > SeuildPointLigne) | |
2369 | { | |
2370 | PW.Perform(StartParams, UminLig1, VminLig1, UminLig2, VminLig2, | |
2371 | UmaxLig1, VmaxLig1, UmaxLig2, VmaxLig2); | |
2372 | ||
2373 | // | |
2374 | Standard_Boolean bPWIsDone; | |
00302ba4 | 2375 | Standard_Real aD11, aD12, aD21, aD22, aDx; |
2376 | // | |
2377 | bPWIsDone=PW.IsDone(); | |
2378 | ||
2379 | if(bPWIsDone) | |
2380 | { | |
f73c584c | 2381 | Standard_Boolean hasBeenAdded = Standard_False; |
2382 | if(PW.NbPoints() > 2 ) | |
00302ba4 | 2383 | { |
f73c584c | 2384 | //Try to extend the intersection line to the boundary, |
2385 | //if it is possibly | |
882e1d11 | 2386 | PW.PutToBoundary(Surf1, Surf2); |
c2c2f2b6 | 2387 | |
00302ba4 | 2388 | const Standard_Integer aMinNbPoints = 40; |
f73c584c | 2389 | if(PW.NbPoints() < aMinNbPoints) |
00302ba4 | 2390 | { |
f73c584c | 2391 | hasBeenAdded = PW.SeekAdditionalPoints(Surf1, Surf2, aMinNbPoints); |
00302ba4 | 2392 | } |
2393 | ||
f73c584c | 2394 | Standard_Integer iPWNbPoints = PW.NbPoints(), aNbPointsVer = 0; |
00302ba4 | 2395 | RejectLine = Standard_False; |
2396 | Point3dDebut = PW.Value(1).Value(); | |
f73c584c | 2397 | Point3dFin = PW.Value(iPWNbPoints).Value(); |
00302ba4 | 2398 | for( ver = 1; (!RejectLine) && (ver<= NbLigCalculee); ++ver) |
2399 | { | |
2400 | const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver)); | |
2401 | // | |
2402 | aNbPointsVer=verwline->NbPnts(); | |
2403 | if (aNbPointsVer<3) | |
2404 | { | |
2405 | continue; | |
2406 | } | |
2407 | // | |
2408 | const IntSurf_PntOn2S& verPointDebut = verwline->Point(1); | |
2409 | const IntSurf_PntOn2S& verPointFin = verwline->Point(verwline->NbPnts()); | |
2410 | //xf | |
2411 | const gp_Pnt& aP21=verPointDebut.Value(); | |
2412 | const gp_Pnt& aP22=verPointFin.Value(); | |
2413 | // | |
2414 | aD11=Point3dDebut.Distance(aP21); | |
2415 | aD12=Point3dDebut.Distance(aP22); | |
2416 | aD21=Point3dFin.Distance(aP21); | |
2417 | aD22=Point3dFin.Distance(aP22); | |
2418 | // | |
2419 | if((aD11<=TolTangency && aD22<=TolTangency) || | |
2420 | (aD12<=TolTangency && aD21<=TolTangency)) | |
2421 | { | |
2422 | Standard_Integer m, mx; | |
2423 | // | |
2424 | mx=aNbPointsVer/2; | |
2425 | if (aNbPointsVer%2) | |
2426 | { | |
2427 | ++mx; | |
2428 | } | |
2429 | // | |
2430 | const gp_Pnt& aPx=verwline->Point(mx).Value(); | |
2431 | for(m=1; m<iPWNbPoints; ++m) | |
2432 | { | |
2433 | const gp_Pnt& aP1=PW.Value(m).Value(); | |
2434 | const gp_Pnt& aP2=PW.Value(m+1).Value(); | |
2435 | gp_Vec aVec12(aP1, aP2); | |
2436 | if (aVec12.SquareMagnitude()<1.e-20) | |
2437 | { | |
2438 | continue; | |
2439 | } | |
2440 | ||
2441 | // | |
2442 | gp_Dir aDir12(aVec12); | |
2443 | gp_Lin aLin12(aP1, aDir12); | |
2444 | aDx=aLin12.Distance(aPx); | |
2445 | ||
2446 | //modified by NIZNHY-PKV Tue May 10 11:08:07 2011f | |
2447 | if (aDx<=2.*Epsilon) | |
2448 | { | |
2449 | //if (aDx<=TolTangency) { | |
2450 | //modified by NIZNHY-PKV Tue May 10 11:08:13 2011t | |
2451 | ||
2452 | RejectLine = Standard_True; | |
1dee0696 | 2453 | ver--; |
00302ba4 | 2454 | break; |
2455 | } | |
2456 | }//for(m=1; m<iPWNbPoints; ++m){ | |
2457 | }//if((aD11<=TolTangency && aD22<=TolTangency) ||... | |
2458 | }// for( ver = 1 ; (!RejetLigne) && (ver<= NbLigCalculee) ; ver++) { | |
2459 | // | |
2460 | ||
c8187bb2 | 2461 | if(RejectLine) |
2462 | { | |
2463 | DublicateOfLinesProcessing(PW, ver, SLin, RejectLine); | |
2464 | } | |
2465 | ||
00302ba4 | 2466 | if(!RejectLine) |
2467 | { | |
2468 | IntSurf_TypeTrans trans1,trans2; | |
2469 | Standard_Real locu,locv; | |
2470 | gp_Vec norm1,norm2,d1u,d1v; | |
2471 | gp_Pnt ptbid; | |
2472 | Standard_Integer indextg; | |
2473 | gp_Vec tgline(PW.TangentAtLine(indextg)); | |
2474 | PW.Line()->Value(indextg).ParametersOnS1(locu,locv); | |
2475 | Surf1->D1(locu,locv,ptbid,d1u,d1v); | |
2476 | norm1 = d1u.Crossed(d1v); | |
2477 | PW.Line()->Value(indextg).ParametersOnS2(locu,locv); | |
2478 | Surf2->D1(locu,locv,ptbid,d1u,d1v); | |
2479 | norm2 = d1u.Crossed(d1v); | |
2480 | if( tgline.DotCross(norm2,norm1) >= 0. ) | |
2481 | { | |
2482 | trans1 = IntSurf_Out; | |
2483 | trans2 = IntSurf_In; | |
2484 | } | |
2485 | else | |
2486 | { | |
2487 | trans1 = IntSurf_In; | |
2488 | trans2 = IntSurf_Out; | |
2489 | } | |
2490 | ||
2491 | Standard_Real TolTang = TolTangency; | |
2492 | Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2); | |
98974dcc | 2493 | wline->SetCreatingWayInfo(IntPatch_WLine::IntPatch_WLPrmPrm); |
f73c584c | 2494 | wline->EnablePurging(!hasBeenAdded); |
1406e955 | 2495 | //the method PutVertexOnLine can reduce the number of points in <wline> |
882e1d11 | 2496 | IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang); |
1406e955 | 2497 | if (wline->NbPnts() < 2) |
2498 | continue; | |
882e1d11 | 2499 | IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang); |
1406e955 | 2500 | if (wline->NbPnts() < 2) |
2501 | continue; | |
00302ba4 | 2502 | if(wline->NbVertex() == 0) |
2503 | { | |
2504 | IntPatch_Point vtx; | |
2505 | IntSurf_PntOn2S POn2S = PW.Line()->Value(1); | |
2506 | POn2S.Parameters(pu1,pv1,pu2,pv2); | |
2507 | vtx.SetValue(Point3dDebut,TolTang,Standard_False); | |
2508 | vtx.SetParameters(pu1,pv1,pu2,pv2); | |
2509 | vtx.SetParameter(1); | |
2510 | wline->AddVertex(vtx); | |
2511 | ||
2512 | POn2S = PW.Line()->Value(wline->NbPnts()); | |
2513 | POn2S.Parameters(pu1,pv1,pu2,pv2); | |
2514 | vtx.SetValue(Point3dFin,TolTang,Standard_False); | |
2515 | vtx.SetParameters(pu1,pv1,pu2,pv2); | |
2516 | vtx.SetParameter(wline->NbPnts()); | |
2517 | wline->AddVertex(vtx); | |
2518 | } | |
2519 | ||
2520 | lignetrouvee = Standard_True; | |
2521 | ||
714c3bfc | 2522 | SeveralWlinesProcessing(Surf1, Surf2, SLin, Periods, trans1, trans2, |
2523 | TolTang, Max(PW.MaxStep(0), PW.MaxStep(1)), | |
2524 | Max(PW.MaxStep(2), PW.MaxStep(3)), wline); | |
7fd59977 | 2525 | |
a7dd5d0f | 2526 | AddWLine(SLin, wline, Deflection); |
00302ba4 | 2527 | empt = Standard_False; |
2528 | }// !RejetLigne | |
2529 | }// PW points > 2 | |
2530 | }// done is True | |
2531 | }// dminiPointLigne > SeuildPointLigne | |
2532 | }// HasStartPoint | |
2533 | }// if TabPtDep[nbps2] == 0 | |
2534 | } while(nbp>5 && !( (NombreDePointsDeDepartDuCheminement >= NbDePointsDeDepartDuChmLimit && lignetrouvee) || | |
2535 | (NombreDePointsDeDepartDuCheminement-3 >= nbp && (!lignetrouvee)))); | |
2536 | delete [] TabPtDep; | |
7fd59977 | 2537 | }// for( ls ... |
2538 | ||
2539 | delete [] TabL; | |
2540 | ||
2541 | }// if nbLigSec >= 1 | |
2542 | // | |
2543 | AdjustOnPeriodic(Surf1, Surf2, SLin); | |
2544 | // | |
2545 | ||
2546 | //-------------------------------------------------------------------- | |
2547 | //-- Calcul des parametres approches a partir des Zones De Tangence -- | |
2548 | //-------------------------------------------------------------------- | |
2549 | Standard_Real UminLig1,VminLig1,UmaxLig1,VmaxLig1; | |
2550 | Standard_Real UminLig2,VminLig2,UmaxLig2,VmaxLig2; | |
00302ba4 | 2551 | |
7fd59977 | 2552 | UminLig1=VminLig1=UminLig2=VminLig2=RealLast(); |
2553 | UmaxLig1=VmaxLig1=UmaxLig2=VmaxLig2=-UminLig1; | |
2554 | ||
2555 | // NbPointsInTangentZone always == 1 (eap) | |
00302ba4 | 2556 | |
7fd59977 | 2557 | Standard_Integer z; |
00302ba4 | 2558 | for( z=1; z <= nbTanZon; z++) |
2559 | { | |
7fd59977 | 2560 | //Standard_Integer NbPointsInTangentZone=Interference.NbPointsInTangentZone(z); |
2561 | //for(Standard_Integer pz=1; pz<=NbPointsInTangentZone; pz++) { | |
00302ba4 | 2562 | Standard_Integer pz=1; |
2563 | Standard_Real _x,_y,_z; | |
2564 | Standard_Real U1, U2, V1, V2; | |
2565 | Interference.GetTangentZonePoint(z,pz,_x,_y,_z,U1,V1,U2,V2); | |
2566 | ||
2567 | if(U1>UmaxLig1) UmaxLig1=U1; | |
2568 | if(V1>VmaxLig1) VmaxLig1=V1; | |
2569 | if(U2>UmaxLig2) UmaxLig2=U2; | |
2570 | if(V2>VmaxLig2) VmaxLig2=V2; | |
2571 | ||
2572 | if(U1<UminLig1) UminLig1=U1; | |
2573 | if(V1<VminLig1) VminLig1=V1; | |
2574 | if(U2<UminLig2) UminLig2=U2; | |
2575 | if(V2<VminLig2) VminLig2=V2; | |
7fd59977 | 2576 | //} |
2577 | } | |
7fd59977 | 2578 | |
00302ba4 | 2579 | for(z=1; z <= nbTanZon; z++) |
2580 | { | |
7fd59977 | 2581 | //Standard_Integer NbPointsInTangentZone=Interference.NbPointsInTangentZone(z); |
2582 | //for(Standard_Integer pz=1; pz<=NbPointsInTangentZone; pz++) { | |
00302ba4 | 2583 | Standard_Integer pz=1; |
2584 | Standard_Real _x,_y,_z; | |
2585 | Standard_Real U1, U2, V1, V2; | |
2586 | Interference.GetTangentZonePoint(z,pz,_x,_y,_z,U1,V1,U2,V2); | |
2587 | ||
2588 | StartParams(1) = U1; | |
2589 | StartParams(2) = V1; | |
2590 | StartParams(3) = U2; | |
2591 | StartParams(4) = V2; | |
2592 | ||
2593 | //----------------------------------------------------------------------- | |
2594 | //-- Calcul du premier point de cheminement a partir du point approche -- | |
2595 | //----------------------------------------------------------------------- | |
2596 | HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S); | |
2597 | if(HasStartPoint) | |
2598 | { | |
2599 | //------------------------------------------------- | |
2600 | //-- Un point a ete trouve -- | |
2601 | //-- On verifie qu il n appartient pas -- | |
2602 | //-- a une ligne de cheminement deja calculee. -- | |
2603 | //------------------------------------------------- | |
2604 | StartPOn2S.Parameters(pu1,pv1,pu2,pv2); | |
2605 | ||
2606 | NbLigCalculee = SLin.Length(); | |
2607 | dminiPointLigne = SeuildPointLigne + SeuildPointLigne; | |
2608 | ||
2609 | for(Standard_Integer l=1; | |
2610 | (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); | |
2611 | l++) | |
2612 | { | |
2613 | const Handle(IntPatch_WLine)& testwline = *((Handle(IntPatch_WLine)*)&SLin.Value(l)); | |
2614 | ||
2615 | if (IsPointOnLine(StartPOn2S, testwline, Deflection)) | |
2616 | { | |
2617 | dminiPointLigne = 0.0; | |
2618 | } | |
2619 | } | |
2620 | ||
2621 | //-- Fin d exploration des lignes | |
2622 | if(dminiPointLigne > SeuildPointLigne) | |
2623 | { | |
2624 | //--------------------------------------------------- | |
2625 | //-- Le point de depart du nouveau cheminement -- | |
2626 | //-- n est present dans aucune ligne deja calculee.-- | |
2627 | //--------------------------------------------------- | |
2628 | PW.Perform(StartParams,UminLig1,VminLig1,UminLig2,VminLig2, | |
2629 | UmaxLig1,VmaxLig1,UmaxLig2,VmaxLig2); | |
2630 | ||
2631 | if(PW.IsDone()) | |
2632 | { | |
f73c584c | 2633 | Standard_Boolean hasBeenAdded = Standard_False; |
00302ba4 | 2634 | if(PW.NbPoints()>2) |
2635 | { | |
2636 | const Standard_Integer aMinNbPoints = 40; | |
2637 | if(PW.NbPoints() < aMinNbPoints) | |
2638 | { | |
f73c584c | 2639 | hasBeenAdded = PW.SeekAdditionalPoints(Surf1, Surf2, aMinNbPoints); |
00302ba4 | 2640 | } |
2641 | ||
2642 | //----------------------------------------------- | |
2643 | //-- Verification a posteriori : | |
2644 | //-- On teste si le point de depart et de fin de | |
2645 | //-- la ligne de cheminement est present dans une | |
2646 | //-- autre ligne . | |
2647 | //----------------------------------------------- | |
2648 | RejectLine = Standard_False; | |
2649 | Point3dDebut = PW.Value(1).Value(); | |
2650 | const IntSurf_PntOn2S& PointFin = PW.Value(PW.NbPoints()); | |
2651 | Point3dFin = PointFin.Value(); | |
2652 | ||
2653 | for(ver=1 ; (!RejectLine) && (ver<= NbLigCalculee) ; ver++) | |
2654 | { | |
2655 | const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver)); | |
2656 | //-- Handle(IntPatch_WLine) verwline=Handle(IntPatch_WLine)::DownCast(SLin.Value(ver)); | |
2657 | ||
2658 | // Check end point if it is on existing line. | |
2659 | // Start point is checked before. | |
2660 | if (IsPointOnLine(PointFin, verwline, Deflection)) | |
2661 | { | |
2662 | RejectLine = Standard_True; | |
2663 | break; | |
2664 | } | |
2665 | ||
2666 | const IntSurf_PntOn2S& verPointDebut = verwline->Point(1); | |
2667 | const IntSurf_PntOn2S& verPointFin = verwline->Point(verwline->NbPnts()); | |
2668 | if(Point3dDebut.Distance(verPointDebut.Value()) < TolTangency) | |
2669 | { | |
2670 | RejectLine = Standard_True; | |
2671 | } | |
2672 | else | |
2673 | { | |
2674 | if(Point3dFin.Distance(verPointFin.Value()) < TolTangency) | |
2675 | { | |
2676 | RejectLine = Standard_True; | |
a7dd5d0f | 2677 | } |
00302ba4 | 2678 | } |
2679 | } | |
a7dd5d0f | 2680 | |
00302ba4 | 2681 | if(!RejectLine) |
2682 | { | |
2683 | IntSurf_TypeTrans trans1,trans2; | |
2684 | Standard_Real locu,locv; | |
2685 | gp_Vec norm1,norm2,d1u,d1v; | |
2686 | gp_Pnt ptbid; | |
2687 | Standard_Integer indextg; | |
2688 | gp_Vec tgline(PW.TangentAtLine(indextg)); | |
2689 | PW.Line()->Value(indextg).ParametersOnS1(locu,locv); | |
2690 | Surf1->D1(locu,locv,ptbid,d1u,d1v); | |
2691 | norm1 = d1u.Crossed(d1v); | |
2692 | PW.Line()->Value(indextg).ParametersOnS2(locu,locv); | |
2693 | Surf2->D1(locu,locv,ptbid,d1u,d1v); | |
2694 | norm2 = d1u.Crossed(d1v); | |
2695 | if (tgline.DotCross(norm2,norm1)>0.) | |
2696 | { | |
2697 | trans1 = IntSurf_Out; | |
2698 | trans2 = IntSurf_In; | |
2699 | } | |
2700 | else | |
2701 | { | |
2702 | trans1 = IntSurf_In; | |
2703 | trans2 = IntSurf_Out; | |
2704 | } | |
2705 | ||
2706 | Standard_Real TolTang = TolTangency; | |
2707 | Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2); | |
98974dcc | 2708 | wline->SetCreatingWayInfo(IntPatch_WLine::IntPatch_WLPrmPrm); |
f73c584c | 2709 | wline->EnablePurging(!hasBeenAdded); |
1406e955 | 2710 | //the method PutVertexOnLine can reduce the number of points in <wline> |
00302ba4 | 2711 | IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang); |
1406e955 | 2712 | if (wline->NbPnts() < 2) |
2713 | continue; | |
00302ba4 | 2714 | IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang); |
1406e955 | 2715 | if (wline->NbPnts() < 2) |
2716 | continue; | |
00302ba4 | 2717 | |
2718 | //--------------- | |
2719 | if(wline->NbVertex() == 0) | |
2720 | { | |
2721 | IntPatch_Point vtx; | |
2722 | IntSurf_PntOn2S POn2S = PW.Line()->Value(1); | |
2723 | POn2S.Parameters(pu1,pv1,pu2,pv2); | |
2724 | vtx.SetValue(Point3dDebut,TolTang,Standard_False); | |
2725 | vtx.SetParameters(pu1,pv1,pu2,pv2); | |
2726 | vtx.SetParameter(1); | |
2727 | wline->AddVertex(vtx); | |
2728 | ||
2729 | POn2S = PW.Line()->Value(wline->NbPnts()); | |
2730 | POn2S.Parameters(pu1,pv1,pu2,pv2); | |
2731 | vtx.SetValue(Point3dFin,TolTang,Standard_False); | |
2732 | vtx.SetParameters(pu1,pv1,pu2,pv2); | |
2733 | vtx.SetParameter(wline->NbPnts()); | |
2734 | wline->AddVertex(vtx); | |
2735 | } | |
2736 | ||
2737 | //--------------- | |
2738 | AddWLine(SLin, wline, Deflection); | |
2739 | empt = Standard_False; | |
2740 | } | |
2741 | else | |
2742 | { | |
04232180 | 2743 | //-- std::cout<<" ----- REJET DE LIGNE (POINT DE DEPART) ----- "<<std::endl; |
00302ba4 | 2744 | } |
2745 | //------------------------------------------------------------ | |
2746 | } | |
2747 | } //-- le cheminement a reussi (done a True) | |
2748 | } //-- le point approche ne renvoie pas sur une ligne existante | |
2749 | } //-- Si HasStartPoint | |
c66d7156 P |
2750 | //} //-- Boucle Sur les Points de la Tangent Zone |
2751 | } //-- Boucle sur Les Tangent Zones | |
7fd59977 | 2752 | |
00302ba4 | 2753 | if ( pInterference ) |
2754 | { | |
c66d7156 P |
2755 | delete pInterference; |
2756 | pInterference = NULL; | |
2757 | } | |
00302ba4 | 2758 | |
c66d7156 P |
2759 | return; |
2760 | }// if((NbU1*NbV1<=Limit && NbV2*NbU2<=Limit)) { | |
2761 | ||
2762 | Handle(IntSurf_LineOn2S) LOn2S = new IntSurf_LineOn2S(); | |
2763 | PointDepart( LOn2S, Surf1, NbU1, NbV1, Surf2, NbU2, NbV2 ); | |
7fd59977 | 2764 | empt = Standard_True; |
2765 | done = Standard_True; | |
00302ba4 | 2766 | |
c66d7156 P |
2767 | Standard_Integer NbLigCalculee = 0; |
2768 | Standard_Real U1,U2,V1,V2; | |
7fd59977 | 2769 | Standard_Real pu1,pu2,pv1,pv2; |
00302ba4 | 2770 | |
7fd59977 | 2771 | TColStd_Array1OfReal StartParams(1,4); |
c66d7156 P |
2772 | Standard_Integer MaxOscill = NbU1; |
2773 | if(MaxOscill < NbU2) MaxOscill=NbU2; | |
2774 | if(MaxOscill < NbV1) MaxOscill=NbV1; | |
2775 | if(MaxOscill < NbV2) MaxOscill=NbV2; | |
00302ba4 | 2776 | |
c66d7156 P |
2777 | Standard_Real nIncrement=Increment; |
2778 | //if(MaxOscill>10) | |
00302ba4 | 2779 | //nIncrement/=0.5*MaxOscill; |
c66d7156 | 2780 | |
47cbf134 | 2781 | IntWalk_PWalking PW(Surf1,Surf2,TolTangency,Epsilon,Deflection,nIncrement); |
c66d7156 P |
2782 | Standard_Real SeuildPointLigne = 15.0 * Increment * Increment; //-- 10 est insuffisant |
2783 | Standard_Real dminiPointLigne; | |
2784 | Standard_Boolean HasStartPoint,RejetLigne; | |
7fd59977 | 2785 | IntSurf_PntOn2S StartPOn2S; |
c66d7156 | 2786 | Standard_Integer ver; |
7fd59977 | 2787 | gp_Pnt Point3dDebut,Point3dFin; |
c66d7156 | 2788 | |
7fd59977 | 2789 | //------------------------------------------------------------ |
c66d7156 P |
2790 | //-- Calcul des parametres approches a partir des Zones De Tangence -- |
2791 | //-------------------------------------------------------------------- | |
2792 | Standard_Integer nbTanZon = LOn2S->NbPoints(); | |
2793 | for(Standard_Integer z=1; z <= nbTanZon; z++) { | |
2794 | const IntSurf_PntOn2S& POn2S = LOn2S->Value(z); | |
2795 | POn2S.Parameters(U1,V1,U2,V2); | |
2796 | StartParams(1) = U1; | |
2797 | StartParams(2) = V1; | |
2798 | StartParams(3) = U2; | |
2799 | StartParams(4) = V2; | |
00302ba4 | 2800 | |
c66d7156 P |
2801 | //----------------------------------------------------------------------- |
2802 | //-- Calcul du premier point de cheminement a partir du point approche -- | |
2803 | //----------------------------------------------------------------------- | |
2804 | HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S); | |
00302ba4 | 2805 | if(HasStartPoint) |
2806 | { | |
c66d7156 P |
2807 | //------------------------------------------------- |
2808 | //-- Un point a ete trouve -- | |
2809 | //-- On verifie qu il n appartient pas -- | |
2810 | //-- a une ligne de cheminement deja calculee. -- | |
2811 | //------------------------------------------------- | |
2812 | StartPOn2S.Parameters(pu1,pv1,pu2,pv2); | |
00302ba4 | 2813 | |
c66d7156 P |
2814 | NbLigCalculee = SLin.Length(); |
2815 | dminiPointLigne = SeuildPointLigne + SeuildPointLigne; | |
00302ba4 | 2816 | |
c66d7156 | 2817 | for(Standard_Integer l=1; |
00302ba4 | 2818 | (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); |
2819 | l++) | |
2820 | { | |
a7dd5d0f | 2821 | const Handle(IntPatch_WLine)& testwline = *((Handle(IntPatch_WLine)*)&SLin.Value(l)); |
2822 | ||
00302ba4 | 2823 | if (IsPointOnLine(StartPOn2S, testwline, Deflection)) |
2824 | { | |
a7dd5d0f | 2825 | dminiPointLigne = 0.0; |
2826 | } | |
7fd59977 | 2827 | } |
a7dd5d0f | 2828 | |
c66d7156 | 2829 | //-- Fin d exploration des lignes |
00302ba4 | 2830 | if(dminiPointLigne > SeuildPointLigne) |
2831 | { | |
2832 | //--------------------------------------------------- | |
2833 | //-- Le point de depart du nouveau cheminement -- | |
2834 | //-- n est present dans aucune ligne deja calculee.-- | |
2835 | //--------------------------------------------------- | |
2836 | PW.Perform(StartParams); | |
2837 | if(PW.IsDone()) | |
2838 | { | |
2839 | if(PW.NbPoints()>2) | |
2840 | { | |
2841 | //----------------------------------------------- | |
2842 | //-- Verification a posteriori : | |
2843 | //-- On teste si le point de depart et de fin de | |
2844 | //-- la ligne de cheminement est present dans une | |
2845 | //-- autre ligne . | |
2846 | //----------------------------------------------- | |
2847 | RejetLigne = Standard_False; | |
2848 | Point3dDebut = PW.Value(1).Value(); | |
a7dd5d0f | 2849 | const IntSurf_PntOn2S& PointFin = PW.Value(PW.NbPoints()); |
2850 | Point3dFin = PointFin.Value(); | |
00302ba4 | 2851 | |
1dee0696 | 2852 | for(ver=1 ; ver<= NbLigCalculee ; ver++) |
00302ba4 | 2853 | { |
2854 | const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver)); | |
2855 | //-- Handle(IntPatch_WLine) verwline=Handle(IntPatch_WLine)::DownCast(SLin.Value(ver)); | |
a7dd5d0f | 2856 | |
2857 | // Check end point if it is on existing line. | |
2858 | // Start point is checked before. | |
00302ba4 | 2859 | if (IsPointOnLine(PointFin, verwline, Deflection)) |
2860 | { | |
a7dd5d0f | 2861 | RejetLigne = Standard_True; |
2862 | break; | |
2863 | } | |
2864 | ||
00302ba4 | 2865 | const IntSurf_PntOn2S& verPointDebut = verwline->Point(1); |
2866 | const IntSurf_PntOn2S& verPointFin = verwline->Point(verwline->NbPnts()); | |
1dee0696 | 2867 | if( (Point3dDebut.Distance(verPointDebut.Value()) < TolTangency) || |
2868 | (Point3dFin.Distance(verPointFin.Value()) < TolTangency)) | |
00302ba4 | 2869 | { |
2870 | RejetLigne = Standard_True; | |
1dee0696 | 2871 | break; |
00302ba4 | 2872 | } |
2873 | } | |
2874 | ||
c8187bb2 | 2875 | if(RejetLigne) |
2876 | { | |
2877 | DublicateOfLinesProcessing(PW, ver, SLin, RejetLigne); | |
2878 | } | |
2879 | ||
00302ba4 | 2880 | if(!RejetLigne) |
2881 | { | |
2882 | IntSurf_TypeTrans trans1,trans2; | |
2883 | Standard_Real locu,locv; | |
2884 | gp_Vec norm1,norm2,d1u,d1v; | |
2885 | gp_Pnt ptbid; | |
2886 | Standard_Integer indextg; | |
2887 | gp_Vec tgline(PW.TangentAtLine(indextg)); | |
2888 | PW.Line()->Value(indextg).ParametersOnS1(locu,locv); | |
2889 | Surf1->D1(locu,locv,ptbid,d1u,d1v); | |
2890 | norm1 = d1u.Crossed(d1v); | |
2891 | PW.Line()->Value(indextg).ParametersOnS2(locu,locv); | |
2892 | Surf2->D1(locu,locv,ptbid,d1u,d1v); | |
2893 | norm2 = d1u.Crossed(d1v); | |
2894 | if (tgline.DotCross(norm2,norm1)>0.) | |
2895 | { | |
2896 | trans1 = IntSurf_Out; | |
2897 | trans2 = IntSurf_In; | |
2898 | } | |
2899 | else { | |
2900 | trans1 = IntSurf_In; | |
2901 | trans2 = IntSurf_Out; | |
2902 | } | |
2903 | ||
2904 | Standard_Real TolTang = TolTangency; | |
2905 | Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2); | |
98974dcc | 2906 | wline->SetCreatingWayInfo(IntPatch_WLine::IntPatch_WLPrmPrm); |
2907 | ||
1406e955 | 2908 | //the method PutVertexOnLine can reduce the number of points in <wline> |
00302ba4 | 2909 | IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang); |
1406e955 | 2910 | if (wline->NbPnts() < 2) |
2911 | continue; | |
00302ba4 | 2912 | IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang); |
1406e955 | 2913 | if (wline->NbPnts() < 2) |
2914 | continue; | |
00302ba4 | 2915 | |
2916 | //--------------- | |
2917 | if(wline->NbVertex() == 0) | |
2918 | { | |
2919 | IntPatch_Point vtx; | |
2920 | const IntSurf_PntOn2S& POn2Sf = PW.Line()->Value(1); | |
2921 | POn2Sf.Parameters(pu1,pv1,pu2,pv2); | |
2922 | vtx.SetValue(Point3dDebut,TolTang,Standard_False); | |
2923 | vtx.SetParameters(pu1,pv1,pu2,pv2); | |
2924 | vtx.SetParameter(1); | |
2925 | wline->AddVertex(vtx); | |
2926 | ||
2927 | const IntSurf_PntOn2S& POn2Sl = PW.Line()->Value(wline->NbPnts()); | |
2928 | POn2Sl.Parameters(pu1,pv1,pu2,pv2); | |
2929 | vtx.SetValue(Point3dFin,TolTang,Standard_False); | |
2930 | vtx.SetParameters(pu1,pv1,pu2,pv2); | |
2931 | vtx.SetParameter(wline->NbPnts()); | |
2932 | wline->AddVertex(vtx); | |
2933 | } | |
2934 | ||
2935 | //--------------- | |
a7dd5d0f | 2936 | AddWLine(SLin, wline, Deflection); |
00302ba4 | 2937 | empt = Standard_False; |
2938 | } | |
2939 | else | |
2940 | { | |
04232180 | 2941 | //-- std::cout<<" ----- REJET DE LIGNE (POINT DE DEPART) ----- "<<std::endl; |
00302ba4 | 2942 | } |
2943 | //------------------------------------------------------------ | |
2944 | } | |
2945 | } //-- le cheminement a reussi (done a True) | |
c66d7156 P |
2946 | } //-- le point approche ne renvoie pas sur une ligne existante |
2947 | } //-- Si HasStartPoint | |
2948 | } //-- Boucle sur Les Tangent Zones | |
7fd59977 | 2949 | } |
c66d7156 P |
2950 | //modified by NIZNHY-PKV Wed May 25 09:39:07 2011f |
2951 | //======================================================================= | |
2952 | //class : IntPatch_InfoPD | |
2953 | //purpose : | |
2954 | //======================================================================= | |
2955 | class IntPatch_InfoPD { | |
00302ba4 | 2956 | public: |
c66d7156 P |
2957 | //----------------------------------------C-tor |
2958 | IntPatch_InfoPD(const Standard_Integer aNBI) { | |
2959 | Standard_Integer aNBI2, i, j; | |
2960 | myNBI=aNBI; | |
2961 | // | |
2962 | aNBI2=aNBI*aNBI; | |
2963 | myP1DS2=new char[aNBI2]; | |
2964 | myP2DS1=new char[aNBI2]; | |
2965 | myIP1=new Standard_Integer[aNBI2]; | |
2966 | myIP2=new Standard_Integer[aNBI2]; | |
2967 | myP1=new gp_Pnt[aNBI2]; | |
2968 | myP2=new gp_Pnt[aNBI2]; | |
2969 | // | |
2970 | for (i=0; i<myNBI; ++i) { | |
2971 | for (j=0; j<myNBI; ++j) { | |
00302ba4 | 2972 | xP1DS2(i, j)=0; |
2973 | xP2DS1(i, j)=0; | |
2974 | xIP1(i, j)=0; | |
2975 | xIP2(i, j)=0; | |
2976 | xP1(i, j).SetCoord(0., 0., 0.); | |
2977 | xP2(i, j).SetCoord(0., 0., 0.); | |
c66d7156 P |
2978 | } |
2979 | } | |
2980 | }; | |
2981 | //---------------------------------------- D-tor | |
2982 | ~IntPatch_InfoPD() { | |
2983 | delete [] (char*) myP1DS2; | |
2984 | delete [] (char*) myP2DS1; | |
2985 | delete [] (Standard_Integer*) myIP1; | |
2986 | delete [] (Standard_Integer*) myIP2; | |
2987 | delete [] (gp_Pnt*)myP1; | |
2988 | delete [] (gp_Pnt*)myP2; | |
2989 | }; | |
2990 | //---------------------------------------- Index | |
2991 | Standard_Integer Index(const Standard_Integer i, | |
00302ba4 | 2992 | const Standard_Integer j) const { |
2993 | return i*myNBI+j; | |
c66d7156 P |
2994 | }; |
2995 | //---------------------------------------- NBI | |
2996 | Standard_Integer NBI() const { | |
2997 | return myNBI; | |
2998 | }; | |
2999 | //----------------------------------------xP1DS2 | |
3000 | char& xP1DS2(const Standard_Integer i, | |
00302ba4 | 3001 | const Standard_Integer j) { |
3002 | return myP1DS2[Index(i,j)]; | |
c66d7156 P |
3003 | }; |
3004 | //----------------------------------------xP2DS1 | |
3005 | char& xP2DS1(const Standard_Integer i, | |
00302ba4 | 3006 | const Standard_Integer j) { |
3007 | return myP2DS1[Index(i,j)]; | |
c66d7156 P |
3008 | }; |
3009 | //----------------------------------------xIP1 | |
3010 | Standard_Integer& xIP1(const Standard_Integer i, | |
00302ba4 | 3011 | const Standard_Integer j) { |
3012 | return myIP1[Index(i,j)]; | |
c66d7156 P |
3013 | }; |
3014 | //----------------------------------------xIP2 | |
3015 | Standard_Integer& xIP2(const Standard_Integer i, | |
00302ba4 | 3016 | const Standard_Integer j) { |
3017 | return myIP2[Index(i,j)]; | |
c66d7156 P |
3018 | }; |
3019 | //----------------------------------------xP1 | |
3020 | gp_Pnt& xP1(const Standard_Integer i, | |
00302ba4 | 3021 | const Standard_Integer j) { |
3022 | return myP1[Index(i,j)]; | |
c66d7156 P |
3023 | }; |
3024 | //----------------------------------------xP1 | |
3025 | gp_Pnt& xP2(const Standard_Integer i, | |
00302ba4 | 3026 | const Standard_Integer j) { |
3027 | return myP2[Index(i,j)]; | |
c66d7156 | 3028 | }; |
6a38ff48 | 3029 | |
3030 | private: | |
3031 | ||
3032 | IntPatch_InfoPD (const IntPatch_InfoPD&); | |
3033 | IntPatch_InfoPD& operator=(const IntPatch_InfoPD&); | |
3034 | ||
3035 | private: | |
3036 | ||
c66d7156 P |
3037 | Standard_Integer myNBI; |
3038 | char *myP1DS2; | |
3039 | char *myP2DS1; | |
3040 | Standard_Integer *myIP1; | |
3041 | Standard_Integer *myIP2; | |
3042 | gp_Pnt *myP1; | |
3043 | gp_Pnt *myP2; | |
3044 | }; | |
3045 | //modified by NIZNHY-PKV Tue May 24 11:38:55 2011t | |
7fd59977 | 3046 | //================================================================================== |
c66d7156 | 3047 | // function : PointDepart |
7fd59977 | 3048 | // purpose : |
3049 | //================================================================================== | |
c66d7156 | 3050 | void IntPatch_PrmPrmIntersection::PointDepart(Handle(IntSurf_LineOn2S)& LineOn2S, |
00302ba4 | 3051 | const Handle(Adaptor3d_HSurface)& S1, |
3052 | const Standard_Integer SU_1, | |
3053 | const Standard_Integer SV_1, | |
3054 | const Handle(Adaptor3d_HSurface)& S2, | |
3055 | const Standard_Integer SU_2, | |
3056 | const Standard_Integer SV_2) const | |
c66d7156 P |
3057 | { |
3058 | Standard_Integer i, j, xNBI; | |
3059 | //modified by NIZNHY-PKV Tue May 24 11:37:38 2011f | |
3060 | xNBI=200; | |
3061 | IntPatch_InfoPD aIPD(xNBI); | |
3062 | //modified by NIZNHY-PKV Wed May 25 06:47:12 2011t | |
3063 | Standard_Integer iC15, SU1, SV1, SU2, SV2; | |
3064 | Standard_Real U0, U1, V0, V1, U, V; | |
96a95605 | 3065 | Standard_Real resu0,resv0; |
c66d7156 P |
3066 | Standard_Real du1,du2,dv1,dv2, dmaxOn1, dmaxOn2; |
3067 | Standard_Real x0,y0,z0, x1,y1,z1,d; | |
3068 | Bnd_Box Box1, Box2; | |
7fd59977 | 3069 | // |
c66d7156 P |
3070 | iC15=15; |
3071 | SU1 =iC15*SU_1 ; | |
3072 | SV1 =iC15*SV_1 ; | |
3073 | SU2 =iC15*SU_2 ; | |
3074 | SV2 =iC15*SV_2 ; | |
7fd59977 | 3075 | // |
c66d7156 P |
3076 | if(xNBI<SU1) { |
3077 | SU1 = xNBI; | |
3078 | } | |
3079 | if(xNBI<SV1){ | |
3080 | SV1 = xNBI; | |
3081 | } | |
3082 | if(xNBI<SU2){ | |
3083 | SU2 = xNBI; | |
3084 | } | |
3085 | if(xNBI<SV2){ | |
3086 | SV2 = xNBI; | |
3087 | } | |
3088 | // | |
3089 | U0 = S1->FirstUParameter(); | |
3090 | U1 = S1->LastUParameter(); | |
3091 | V0 = S1->FirstVParameter(); | |
3092 | V1 = S1->LastVParameter(); | |
3093 | // | |
3094 | resu0=U0; | |
c66d7156 P |
3095 | resv0=V0; |
3096 | // | |
3097 | dmaxOn1 = 0.0; | |
3098 | dmaxOn2 = 0.0; | |
3099 | //----- | |
3100 | du1 = (U1-U0)/(SU1-1); | |
3101 | dv1 = (V1-V0)/(SV1-1); | |
3102 | for(U=U0,i=0; i<SU1; i++,U+=du1) { | |
3103 | for(V=V0,j=0; j<SV1; V+=dv1,j++) { | |
3104 | aIPD.xP1(i, j)= S1->Value(U,V); | |
3105 | Box1.Add(aIPD.xP1(i, j)); | |
3106 | if(i>0 && j>0) { | |
00302ba4 | 3107 | aIPD.xP1(i, j) .Coord(x0,y0,z0); |
3108 | aIPD.xP1(i-1, j-1).Coord(x1,y1,z1); | |
3109 | // | |
3110 | d=Abs(x1-x0)+Abs(y1-y0)+Abs(z1-z0); | |
3111 | if(d>dmaxOn1) { | |
3112 | dmaxOn1 = d; | |
3113 | } | |
c66d7156 P |
3114 | } |
3115 | } | |
3116 | } | |
3117 | Box1.Enlarge(1.e-8); | |
3118 | // | |
3119 | U0 = S2->FirstUParameter(); | |
3120 | U1 = S2->LastUParameter(); | |
3121 | V0 = S2->FirstVParameter(); | |
3122 | V1 = S2->LastVParameter(); | |
3123 | // | |
3124 | du2 = (U1-U0)/(SU2-1); | |
3125 | dv2 = (V1-V0)/(SV2-1); | |
3126 | for(U=U0,i=0; i<SU2; i++,U+=du2) { | |
3127 | for(V=V0,j=0; j<SV2; V+=dv2,j++) { | |
3128 | aIPD.xP2(i, j) = S2->Value(U,V); | |
3129 | Box2.Add(aIPD.xP2(i, j)); | |
3130 | if(i>0 && j>0) { | |
00302ba4 | 3131 | aIPD.xP2(i, j) .Coord(x0,y0,z0); |
3132 | aIPD.xP2(i-1, j-1).Coord(x1,y1,z1); | |
3133 | d = Abs(x1-x0)+Abs(y1-y0)+Abs(z1-z0); | |
3134 | if(d>dmaxOn2) { | |
3135 | dmaxOn2 = d; | |
3136 | } | |
c66d7156 P |
3137 | } |
3138 | } | |
3139 | } | |
3140 | Box2.Enlarge(1.e-8); | |
3141 | //-------- | |
3142 | // | |
3143 | if(Box1.IsOut(Box2)) { | |
00302ba4 | 3144 | |
c66d7156 P |
3145 | return; |
3146 | } | |
3147 | // | |
3148 | Standard_Integer aNbPG; | |
3149 | Standard_Real x10,y10,z10,x11,y11,z11; | |
3150 | Standard_Real x20,y20,z20,x21,y21,z21; | |
3151 | Standard_Real dx, dy, dz, dmax; | |
3152 | Standard_Real dx2, dy2, dz2; | |
3153 | // | |
3154 | Box1.Get(x10,y10,z10,x11,y11,z11); | |
3155 | Box2.Get(x20,y20,z20,x21,y21,z21); | |
3156 | // | |
3157 | x0 = (x10>x20)? x10 : x20; | |
3158 | y0 = (y10>y20)? y10 : y20; | |
3159 | z0 = (z10>z20)? z10 : z20; | |
3160 | // | |
3161 | x1 = (x11<x21)? x11 : x21; | |
3162 | y1 = (y11<y21)? y11 : y21; | |
3163 | z1 = (z11<z21)? z11 : z21; | |
3164 | // | |
3165 | if(dmaxOn2 > dmaxOn1) { | |
3166 | dmaxOn1 = dmaxOn2; | |
7fd59977 | 3167 | } |
3168 | // | |
c66d7156 P |
3169 | dmaxOn1+=dmaxOn1; |
3170 | x0-=dmaxOn1; | |
3171 | y0-=dmaxOn1; | |
3172 | z0-=dmaxOn1; | |
3173 | x1+=dmaxOn1; | |
3174 | y1+=dmaxOn1; | |
3175 | z1+=dmaxOn1; | |
3176 | // | |
3177 | x10-=dmaxOn1; y10-=dmaxOn1; z10-=dmaxOn1; | |
3178 | x11+=dmaxOn1; y11+=dmaxOn1; z11+=dmaxOn1; | |
3179 | ||
3180 | x20-=dmaxOn1; y20-=dmaxOn1; z20-=dmaxOn1; | |
3181 | x21+=dmaxOn1; y21+=dmaxOn1; z21+=dmaxOn1; | |
3182 | ||
3183 | aNbPG=NbPointsGrille(); | |
3184 | dx = (x1-x0)/aNbPG; | |
3185 | dy = (y1-y0)/aNbPG; | |
3186 | dz = (z1-z0)/aNbPG; | |
7fd59977 | 3187 | // |
c66d7156 P |
3188 | dmax = dx; |
3189 | if(dy>dmax) { | |
3190 | dmax = dy; | |
7fd59977 | 3191 | } |
c66d7156 P |
3192 | if(dz>dmax){ |
3193 | dmax = dz; | |
7fd59977 | 3194 | } |
c66d7156 P |
3195 | // |
3196 | if(dx<dmax*0.01) { | |
3197 | dx = dmax*0.01; | |
7fd59977 | 3198 | } |
c66d7156 P |
3199 | if(dy<dmax*0.01) { |
3200 | dy = dmax*0.01; | |
3201 | } | |
3202 | if(dz<dmax*0.01) { | |
3203 | dz = dmax*0.01; | |
7fd59977 | 3204 | } |
3205 | // | |
c66d7156 P |
3206 | dx2 = dx*0.5; |
3207 | dy2 = dy*0.5; | |
3208 | dz2 = dz*0.5 ; | |
3209 | // | |
3210 | IntPatch_PrmPrmIntersection_T3Bits M1(_BASE); | |
3211 | IntPatch_PrmPrmIntersection_T3Bits M2(_BASE); | |
3212 | // | |
3213 | for(i=0;i<SU1;i++) { | |
3214 | for(j=0;j<SV1;j++) { | |
3215 | aIPD.xIP1(i, j)=-1; | |
3216 | const gp_Pnt& P=aIPD.xP1(i, j); | |
8263fcd3 | 3217 | aIPD.xP1DS2(i, j) = (char)CodeReject(x20,y20,z20,x21,y21,z21,P.X(),P.Y(),P.Z()); |
c66d7156 P |
3218 | int ix = (int)((P.X()-x0 + dx2 )/dx); |
3219 | if(DansGrille(ix)) { | |
00302ba4 | 3220 | int iy = (int)((P.Y()-y0 + dy2)/dy); |
3221 | if(DansGrille(iy)) { | |
3222 | int iz = (int)((P.Z()-z0 + dz2)/dz); | |
3223 | if(DansGrille(iz)) { | |
3224 | aIPD.xIP1(i, j) = GrilleInteger(ix,iy,iz); | |
3225 | } | |
3226 | } | |
c66d7156 P |
3227 | } |
3228 | } | |
3229 | } | |
04232180 | 3230 | //-- std::cout<<" Grille du 1 fini "<<std::endl; |
c66d7156 P |
3231 | for(i=0;i<SU2;i++) { |
3232 | for(j=0;j<SV2;j++) { | |
3233 | aIPD.xIP2(i, j)=-1; | |
3234 | const gp_Pnt& P=aIPD.xP2(i, j); | |
8263fcd3 | 3235 | aIPD.xP2DS1(i, j) = (char)CodeReject(x10,y10,z10,x11,y11,z11,P.X(),P.Y(),P.Z()); |
c66d7156 P |
3236 | int ix = (int)((P.X()-x0 + dx2)/dx); |
3237 | if(DansGrille(ix)) { | |
00302ba4 | 3238 | int iy = (int)((P.Y()-y0 + dy2)/dy); |
3239 | if(DansGrille(iy)) { | |
3240 | int iz = (int)((P.Z()-z0 + dz2)/dz); | |
3241 | if(DansGrille(iz)) { | |
3242 | aIPD.xIP2(i, j) = GrilleInteger(ix,iy,iz); | |
3243 | } | |
3244 | } | |
c66d7156 P |
3245 | } |
3246 | } | |
7fd59977 | 3247 | } |
3248 | // | |
c66d7156 P |
3249 | for(i=0;i<SU1-1;i+=1) { |
3250 | for(j=0;j<SV1-1;j+=1) { | |
3251 | if(!((aIPD.xP1DS2(i, j) & aIPD.xP1DS2(i+1, j)) || | |
00302ba4 | 3252 | (aIPD.xP1DS2(i, j) & aIPD.xP1DS2(i+1, j+1)))){ |
3253 | Remplit(aIPD.xIP1(i, j), | |
3254 | aIPD.xIP1(i+1, j), | |
3255 | aIPD.xIP1(i+1, j+1), | |
3256 | M1); | |
c66d7156 P |
3257 | } |
3258 | if(!((aIPD.xP1DS2(i, j) & aIPD.xP1DS2(i, j+1)) || | |
00302ba4 | 3259 | (aIPD.xP1DS2(i, j) & aIPD.xP1DS2(i+1, j+1)))) { |
3260 | Remplit(aIPD.xIP1(i, j), | |
3261 | aIPD.xIP1(i, j+1), | |
3262 | aIPD.xIP1(i+1, j+1), | |
3263 | M1); | |
c66d7156 | 3264 | } |
7fd59977 | 3265 | } |
c66d7156 P |
3266 | } |
3267 | // | |
3268 | for(i=0;i<SU2-1;i+=1) { | |
3269 | for(j=0;j<SV2-1;j+=1) { | |
3270 | if(!((aIPD.xP2DS1(i, j) & aIPD.xP2DS1(i+1, j)) || | |
00302ba4 | 3271 | (aIPD.xP2DS1(i, j) & aIPD.xP2DS1(i+1, j+1)))){ |
3272 | Remplit(aIPD.xIP2(i, j), | |
3273 | aIPD.xIP2(i+1, j), | |
3274 | aIPD.xIP2(i+1, j+1), | |
3275 | M2); | |
c66d7156 P |
3276 | } |
3277 | if(!((aIPD.xP2DS1(i, j) & aIPD.xP2DS1(i, j+1)) || | |
00302ba4 | 3278 | (aIPD.xP2DS1(i, j) & aIPD.xP2DS1(i+1, j+1)))){ |
3279 | Remplit(aIPD.xIP2(i, j), | |
3280 | aIPD.xIP2(i, j+1), | |
3281 | aIPD.xIP2(i+1, j+1), | |
3282 | M2); | |
c66d7156 P |
3283 | } |
3284 | } | |
3285 | } | |
3286 | // | |
3287 | M1.ResetAnd(); | |
3288 | M2.ResetAnd(); | |
3289 | // | |
3290 | int newind=0; | |
3291 | long unsigned Compt=0; | |
3292 | int ok=0; | |
3293 | int indicepointtraite = 0; | |
3294 | Standard_Integer k,nu,nv; | |
3295 | // | |
3296 | do { | |
3297 | indicepointtraite--; | |
3298 | ok = M1.And(M2,newind); | |
3299 | if(ok) { | |
3300 | IntegerGrille(newind,i,j,k); | |
3301 | int nb=0; | |
3302 | int LIM=3; | |
3303 | if( DansGrille(i-1) && DansGrille(j-1) && DansGrille(k-1) | |
00302ba4 | 3304 | && DansGrille(i+1) && DansGrille(j+1) && DansGrille(k+1)) { |
3305 | int si,sj,sk; | |
3306 | for(si=-1; si<= 1 && nb<LIM; si++) { | |
3307 | for(sj=-1; sj<= 1 && nb<LIM; sj++) { | |
3308 | for(sk=-1; sk<= 1 && nb<LIM; sk++) { | |
3309 | long unsigned lu=GrilleInteger(i+si,j+sj,k+sk); | |
3310 | if(M1.Val(lu) && M2.Val(lu)) { | |
3311 | nb++; | |
3312 | } | |
3313 | } | |
3314 | } | |
3315 | } | |
3316 | if(nb>=LIM) { | |
3317 | for(si=-1; si<= 1; si++) { | |
3318 | for(sj=-1; sj<= 1; sj++) { | |
3319 | for(sk=-1; sk<= 1; sk++) { | |
3320 | if(si || sj || sk) { | |
3321 | long unsigned lu=GrilleInteger(i+si,j+sj,k+sk); | |
3322 | M1.Raz(lu); | |
3323 | } | |
3324 | } | |
3325 | } | |
3326 | } | |
3327 | } | |
7fd59977 | 3328 | } |
3329 | // | |
c66d7156 | 3330 | gp_Pnt P(dx*i + x0, dy*j + y0, dz*k+z0); |
7fd59977 | 3331 | // |
c66d7156 P |
3332 | Standard_Integer nu1=-1,nu2=-1; |
3333 | Standard_Integer nv1=0, nv2=0; | |
3334 | int nbsur1 = 0; | |
3335 | for(nu=0;nu1<0 && nu<SU1;nu++) { | |
00302ba4 | 3336 | for(nv=0;nu1<0 && nv<SV1;nv++) { |
3337 | if( aIPD.xIP1(nu, nv) ==(Standard_Integer) newind ) { | |
3338 | nbsur1++; | |
3339 | aIPD.xIP1(nu, nv)=indicepointtraite; | |
3340 | nu1=nu; nv1=nv; | |
3341 | } | |
3342 | } | |
c66d7156 P |
3343 | } |
3344 | if(nu1>=0) { | |
00302ba4 | 3345 | int nbsur2 = 0; |
3346 | for(nu=0;nu2<0 && nu<SU2;nu++) { | |
3347 | for(nv=0;nu2<0 && nv<SV2;nv++) { | |
3348 | if( aIPD.xIP2(nu, nv)==(Standard_Integer) newind ) { | |
3349 | nbsur2++; | |
3350 | aIPD.xIP2(nu, nv)=indicepointtraite; | |
3351 | nu2=nu; nv2=nv; | |
3352 | } | |
3353 | } | |
3354 | } | |
c66d7156 P |
3355 | } |
3356 | if(nu1>=0 && nu2>=0) { | |
00302ba4 | 3357 | IntSurf_PntOn2S POn2S; |
3358 | POn2S.SetValue(P, | |
3359 | S1->FirstUParameter()+nu1*du1, | |
3360 | S1->FirstVParameter()+nv1*dv1, | |
3361 | S2->FirstUParameter()+nu2*du2, | |
3362 | S2->FirstVParameter()+nv2*dv2); | |
3363 | LineOn2S->Add(POn2S); | |
3364 | Compt++; | |
c66d7156 P |
3365 | } |
3366 | else { | |
00302ba4 | 3367 | //-- aucun point du triangle n a ete trouve assez proche |
3368 | //-- on recherche les 3 points les plus proches de P | |
3369 | //-- dans chacun des tableaux | |
3370 | Standard_Real Dist3[3],u3[3] = { 0.0, 0.0, 0.0 },v3[3] = { 0.0, 0.0, 0.0 }; | |
3371 | Dist3[0]=Dist3[1]=Dist3[2]=RealLast(); | |
3372 | for(U=resu0,i=0; i<SU1; i++,U+=du1) { | |
3373 | for(V=resv0,j=0; j<SV1; V+=dv1,j++) { | |
3374 | //-- On place les 3 meilleures valeurs dans Dist1,Dist2,Dist3 | |
3375 | Standard_Real t = aIPD.xP1(i, j).SquareDistance(P); | |
3376 | //-- On remplace la plus grande valeur ds Dist[.] par la val courante | |
3377 | if(Dist3[0]<Dist3[1]) { | |
3378 | Standard_Real z; | |
3379 | z=Dist3[0]; Dist3[0]=Dist3[1]; Dist3[1]=z; | |
3380 | z=u3[0]; u3[0]=u3[1]; u3[1]=z; | |
3381 | z=v3[0]; v3[0]=v3[1]; v3[1]=z; | |
3382 | } | |
3383 | if(Dist3[1]<Dist3[2]) { | |
3384 | Standard_Real z; | |
3385 | z=Dist3[1]; Dist3[1]=Dist3[2]; Dist3[2]=z; | |
3386 | z=u3[1]; u3[1]=u3[2]; u3[2]=z; | |
3387 | z=v3[1]; v3[1]=v3[2]; v3[2]=z; | |
3388 | } | |
3389 | if(Dist3[0]<Dist3[1]) { | |
3390 | Standard_Real z; | |
3391 | z=Dist3[0]; Dist3[0]=Dist3[1]; Dist3[1]=z; | |
3392 | z=u3[0]; u3[0]=u3[1]; u3[1]=z; | |
3393 | z=v3[0]; v3[0]=v3[1]; v3[1]=z; | |
3394 | } | |
3395 | //-- la plus grande valeur est dans Dist3[0] | |
3396 | if(t<Dist3[0]) { | |
3397 | Dist3[0]=t; u3[0]=U; v3[0]=V; | |
3398 | } | |
3399 | } | |
3400 | } | |
3401 | // | |
3402 | Standard_Real U1_3 = (u3[0]+u3[1]+u3[2])/3.0; | |
3403 | Standard_Real V1_3 = (v3[0]+v3[1]+v3[2])/3.0; | |
3404 | ||
3405 | Dist3[0]=Dist3[1]=Dist3[2]=RealLast(); | |
3406 | for(U=U0,i=0; i<SU2; i++,U+=du2) { | |
3407 | for(V=V0,j=0; j<SV2; V+=dv2,j++) { | |
3408 | //-- On place les 3 meilleures valeurs dans Dist1,Dist2,Dist3 | |
3409 | Standard_Real t = aIPD.xP2(i, j).SquareDistance(P); | |
3410 | //-- On remplace la plus grande valeur ds Dist3[.] par la val courante | |
3411 | if(Dist3[0]<Dist3[1]) { | |
3412 | Standard_Real z; | |
3413 | z=Dist3[0]; Dist3[0]=Dist3[1]; Dist3[1]=z; | |
3414 | z=u3[0]; u3[0]=u3[1]; u3[1]=z; | |
3415 | z=v3[0]; v3[0]=v3[1]; v3[1]=z; | |
3416 | } | |
3417 | if(Dist3[1]<Dist3[2]) { | |
3418 | Standard_Real z; | |
3419 | z=Dist3[1]; Dist3[1]=Dist3[2]; Dist3[2]=z; | |
3420 | z=u3[1]; u3[1]=u3[2]; u3[2]=z; | |
3421 | z=v3[1]; v3[1]=v3[2]; v3[2]=z; | |
3422 | } | |
3423 | if(Dist3[0]<Dist3[1]) { | |
3424 | Standard_Real z; | |
3425 | z=Dist3[0]; Dist3[0]=Dist3[1]; Dist3[1]=z; | |
3426 | z=u3[0]; u3[0]=u3[1]; u3[1]=z; | |
3427 | z=v3[0]; v3[0]=v3[1]; v3[1]=z; | |
3428 | } | |
3429 | //-- la plus grande valeur est dans Dist3[0] | |
3430 | if(t<Dist3[0]) { | |
3431 | Dist3[0]=t; u3[0]=U; v3[0]=V; | |
3432 | } | |
3433 | } | |
3434 | } | |
3435 | // | |
3436 | Standard_Real U2_3 = (u3[0]+u3[1]+u3[2])/3.0; | |
3437 | Standard_Real V2_3 = (v3[0]+v3[1]+v3[2])/3.0; | |
3438 | // | |
3439 | IntSurf_PntOn2S POn2S; | |
3440 | POn2S.SetValue(P,U1_3,V1_3,U2_3,V2_3); | |
3441 | LineOn2S->Add(POn2S); | |
3442 | Compt++; | |
7fd59977 | 3443 | } |
c66d7156 P |
3444 | } |
3445 | } | |
3446 | while(ok); | |
7fd59977 | 3447 | } |
a7dd5d0f | 3448 | |
3449 | //================================================================================== | |
3450 | // function : IsPointOnLine | |
3451 | // purpose : | |
3452 | //================================================================================== | |
3453 | ||
3454 | Standard_Boolean IsPointOnLine(const IntSurf_PntOn2S &thePOn2S, | |
3455 | const Handle(IntPatch_WLine) &theWLine, | |
3456 | const Standard_Real Deflection) | |
3457 | { | |
3458 | Standard_Boolean isOnLine = Standard_False; | |
3459 | Standard_Real Deflection2 = Deflection*Deflection; | |
3460 | Standard_Real pu1, pu2, pv1, pv2; | |
3461 | ||
3462 | thePOn2S.Parameters(pu1, pv1, pu2, pv2); | |
3463 | ||
3464 | if ((theWLine->IsOutSurf1Box(gp_Pnt2d(pu1, pv1)) == Standard_False) && | |
00302ba4 | 3465 | (theWLine->IsOutSurf2Box(gp_Pnt2d(pu2, pv2)) == Standard_False) && |
3466 | (theWLine->IsOutBox(thePOn2S.Value()) == Standard_False)) { | |
3467 | const Standard_Integer NbPntOn2SOnLine = theWLine->NbPnts(); | |
3468 | Standard_Integer ll; | |
3469 | ||
3470 | for (ll=1; ll < NbPntOn2SOnLine && !isOnLine; ll++) { | |
3471 | const gp_Pnt &Pa = theWLine->Point(ll).Value(); | |
3472 | const gp_Pnt &Pb = theWLine->Point(ll+1).Value(); | |
3473 | const gp_Pnt &PStart = thePOn2S.Value(); | |
3474 | const gp_Vec AM(Pa, PStart); | |
3475 | const gp_Vec MB(PStart,Pb); | |
3476 | const Standard_Real AMMB = AM.Dot(MB); | |
3477 | ||
3478 | if(AMMB > 0.0) { | |
3479 | gp_Dir ABN(Pb.X() - Pa.X(), Pb.Y() - Pa.Y(), Pb.Z() - Pa.Z()); | |
3480 | Standard_Real lan = ABN.X()*AM.X() + ABN.Y()*AM.Y() + ABN.Z()*AM.Z(); | |
3481 | gp_Vec AH(lan*ABN.X(), lan*ABN.Y(), lan*ABN.Z()); | |
3482 | gp_Vec HM(AM.X() - AH.X(), AM.Y() - AH.Y(), AM.Z() - AH.Z()); | |
3483 | Standard_Real d = 0.0; | |
3484 | ||
3485 | if(HM.X() < Deflection) { | |
3486 | d += HM.X()*HM.X(); | |
3487 | ||
3488 | if(HM.Y() < Deflection) { | |
3489 | d += HM.Y()*HM.Y(); | |
3490 | ||
3491 | if(HM.Z() < Deflection) { | |
3492 | d += HM.Z()*HM.Z(); | |
3493 | } else { | |
3494 | d = Deflection2; | |
3495 | } | |
a7dd5d0f | 3496 | } else { |
3497 | d = Deflection2; | |
3498 | } | |
3499 | } else { | |
3500 | d = Deflection2; | |
3501 | } | |
a7dd5d0f | 3502 | |
00302ba4 | 3503 | if(d < Deflection2) { |
3504 | isOnLine = Standard_True; | |
3505 | } | |
a7dd5d0f | 3506 | } else { |
00302ba4 | 3507 | Standard_Real dab = Pa.SquareDistance(Pb); |
3508 | Standard_Real dap = Pa.SquareDistance(PStart); | |
a7dd5d0f | 3509 | |
00302ba4 | 3510 | if(dap < dab) { |
a7dd5d0f | 3511 | isOnLine = Standard_True; |
00302ba4 | 3512 | } else { |
3513 | Standard_Real dbp = Pb.SquareDistance(PStart); | |
3514 | ||
3515 | if(dbp < dab) { | |
3516 | isOnLine = Standard_True; | |
3517 | } | |
a7dd5d0f | 3518 | } |
3519 | } | |
3520 | } | |
a7dd5d0f | 3521 | } |
3522 | ||
3523 | return isOnLine; | |
3524 | } | |
3525 | ||
3526 | //================================================================================== | |
3527 | // function : AddWLine | |
3528 | // purpose : | |
3529 | //================================================================================== | |
3530 | ||
3531 | void AddWLine(IntPatch_SequenceOfLine &theLines, | |
3532 | const Handle(IntPatch_WLine) &theWLine, | |
3533 | const Standard_Real Deflection) | |
3534 | { | |
3535 | Standard_Integer i = 1; | |
3536 | Standard_Integer aNbLines = theLines.Length(); | |
3537 | Standard_Boolean isToRemove; | |
3538 | ||
3539 | // Check each line of theLines if it is on theWLine. | |
3540 | while (i <= aNbLines) { | |
3541 | Handle(IntPatch_WLine) aWLine = | |
3542 | Handle(IntPatch_WLine)::DownCast(theLines.Value(i)); | |
00302ba4 | 3543 | |
a7dd5d0f | 3544 | isToRemove = Standard_False; |
3545 | ||
3546 | if (aWLine.IsNull() == Standard_False) { | |
3547 | // Check the middle point. | |
3548 | Standard_Integer aMidIndex = (aWLine->NbPnts() + 1)/2; | |
3549 | ||
3550 | if (aMidIndex > 0) { | |
3551 | const IntSurf_PntOn2S &aPnt = aWLine->Point(aMidIndex); | |
3552 | ||
3553 | if (IsPointOnLine(aPnt, theWLine, Deflection)) { | |
3554 | // Middle point is on theWLine. Check vertices. | |
3555 | isToRemove = Standard_True; | |
3556 | ||
3557 | Standard_Integer j; | |
3558 | const Standard_Integer aNbVtx = aWLine->NbVertex(); | |
3559 | ||
3560 | for (j = 1; j <= aNbVtx; j++) { | |
3561 | const IntPatch_Point &aPoint = aWLine->Vertex(j); | |
3562 | ||
3563 | if (!IsPointOnLine(aPoint.PntOn2S(), theWLine, Deflection)) { | |
3564 | isToRemove = Standard_False; | |
3565 | break; | |
3566 | } | |
3567 | } | |
3568 | } | |
3569 | } | |
3570 | } | |
3571 | ||
3572 | if (isToRemove) { | |
3573 | theLines.Remove(i); | |
3574 | aNbLines--; | |
3575 | } else { | |
3576 | i++; | |
3577 | } | |
3578 | } | |
3579 | ||
3580 | // Add theWLine to the sequence of lines. | |
3581 | theLines.Append(theWLine); | |
3582 | } |