0024154: Wrong result of CUT operation
[occt.git] / src / IntPatch / IntPatch_Intersection.cxx
CommitLineData
b311480e 1// Created by: Modelization
2// Copyright (c) 1999-2012 OPEN CASCADE SAS
3//
4// The content of this file is subject to the Open CASCADE Technology Public
5// License Version 6.5 (the "License"). You may not use the content of this file
6// except in compliance with the License. Please obtain a copy of the License
7// at http://www.opencascade.org and read it completely before using this file.
8//
9// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11//
12// The Original Code and all software distributed under the License is
13// distributed on an "AS IS" basis, without warranty of any kind, and the
14// Initial Developer hereby disclaims all such warranties, including without
15// limitation, any warranties of merchantability, fitness for a particular
16// purpose or non-infringement. Please see the License for the specific terms
17// and conditions governing the rights and limitations under the License.
18
7fd59977 19
20#include <IntPatch_Intersection.ixx>
21
22#include <IntPatch_ALineToWLine.hxx>
23#include <IntPatch_GLine.hxx>
24#include <IntPatch_ALine.hxx>
25#include <IntPatch_WLine.hxx>
26#include <IntPatch_RLine.hxx>
27#include <IntPatch_PrmPrmIntersection.hxx>
28#include <IntPatch_ImpPrmIntersection.hxx>
29#include <IntPatch_ImpImpIntersection.hxx>
30#include <IntSurf_Quadric.hxx>
31
32#include <stdio.h>
33
34#define DEBUG 0
35static Standard_Integer NBPOINTSSURALINE = 200;
36
37//======================================================================
38// function: SequenceOfLine
39//======================================================================
40const IntPatch_SequenceOfLine& IntPatch_Intersection::SequenceOfLine() const { return(slin); }
41
42//======================================================================
43// function: IntPatch_Intersection
44//======================================================================
45IntPatch_Intersection::IntPatch_Intersection ()
46 : done(Standard_False),
47 //empt, tgte, oppo,
48 myTolArc(0.0), myTolTang(0.0),
49 myUVMaxStep(0.0), myFleche(0.0),
50 myIsStartPnt(Standard_False)
51 //myU1Start, myV1Start, myU2Start, myV2Start
52{
53}
54
55//======================================================================
56// function: IntPatch_Intersection
57//======================================================================
58IntPatch_Intersection::IntPatch_Intersection(const Handle(Adaptor3d_HSurface)& S1,
59 const Handle(Adaptor3d_TopolTool)& D1,
60 const Handle(Adaptor3d_HSurface)& S2,
61 const Handle(Adaptor3d_TopolTool)& D2,
62 const Standard_Real TolArc,
63 const Standard_Real TolTang)
64 : done(Standard_False),
65 //empt, tgte, oppo,
66 myTolArc(TolArc), myTolTang(TolTang),
67 myUVMaxStep(0.0), myFleche(0.0),
68 myIsStartPnt(Standard_False)
69 //myU1Start, myV1Start, myU2Start, myV2Start
70{
71 if(myTolArc<1e-8) myTolArc=1e-8;
72 if(myTolTang<1e-8) myTolTang=1e-8;
73 if(myTolArc>0.5) myTolArc=0.5;
74 if(myTolTang>0.5) myTolTang=0.5;
75 Perform(S1,D1,S2,D2,TolArc,TolTang);
76}
77
78//======================================================================
79// function: IntPatch_Intersection
80//======================================================================
81IntPatch_Intersection::IntPatch_Intersection(const Handle(Adaptor3d_HSurface)& S1,
82 const Handle(Adaptor3d_TopolTool)& D1,
83 const Standard_Real TolArc,
84 const Standard_Real TolTang)
85 : done(Standard_False),
86 //empt, tgte, oppo,
87 myTolArc(TolArc), myTolTang(TolTang),
88 myUVMaxStep(0.0), myFleche(0.0),
89 myIsStartPnt(Standard_False)
90 //myU1Start, myV1Start, myU2Start, myV2Start
91{
92 Perform(S1,D1,TolArc,TolTang);
93}
94
95//======================================================================
96// function: SetTolerances
97//======================================================================
98void IntPatch_Intersection::SetTolerances(const Standard_Real TolArc,
99 const Standard_Real TolTang,
100 const Standard_Real UVMaxStep,
101 const Standard_Real Fleche)
102{
103 myTolArc = TolArc;
104 myTolTang = TolTang;
105 myUVMaxStep = UVMaxStep;
106 myFleche = Fleche;
107 if(myTolArc<1e-8) myTolArc=1e-8;
108 if(myTolTang<1e-8) myTolTang=1e-8;
109 if(myTolArc>0.5) myTolArc=0.5;
110 if(myTolTang>0.5) myTolTang=0.5;
111 if(myFleche<1.0e-3) myFleche=1e-3;
112 if(myUVMaxStep<1.0e-3) myUVMaxStep=1e-3;
113 if(myFleche>10) myFleche=10;
114 if(myUVMaxStep>0.5) myUVMaxStep=0.5;
115}
116
117//======================================================================
118// function: Perform
119//======================================================================
120void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& S1,
121 const Handle(Adaptor3d_TopolTool)& D1,
122 const Standard_Real TolArc,
123 const Standard_Real TolTang)
124{
125 myTolArc = TolArc;
126 myTolTang = TolTang;
127 if(myFleche == 0.0) myFleche = 0.01;
128 if(myUVMaxStep==0.0) myUVMaxStep = 0.01;
129
130 done = Standard_True;
131 spnt.Clear();
132 slin.Clear();
133
134 empt = Standard_True;
135 tgte = Standard_False;
136 oppo = Standard_False;
137
138 switch (S1->GetType())
139 {
140 case GeomAbs_Plane:
141 case GeomAbs_Cylinder:
142 case GeomAbs_Sphere:
143 case GeomAbs_Cone:
144 case GeomAbs_Torus: break;
145 default:
146 {
147 IntPatch_PrmPrmIntersection interpp;
148 interpp.Perform(S1,D1,TolArc,TolTang,myFleche,myUVMaxStep);
149 if (interpp.IsDone())
150 {
151 done = Standard_True;
152 tgte = Standard_False;
153 empt = interpp.IsEmpty();
154 const Standard_Integer nblm = interpp.NbLines();
155 for (Standard_Integer i=1; i<=nblm; i++) slin.Append(interpp.Line(i));
156 }
157 }
158 break;
159 }
160}
161
162/////////////////////////////////////////////////////////////////////////////
163// These several support functions provide methods which can help basic //
164// algorithm to intersect infinite surfaces of the following types: //
165// //
166// a.) SurfaceOfExtrusion; //
167// b.) SurfaceOfRevolution; //
168// c.) OffsetSurface. //
169// //
170/////////////////////////////////////////////////////////////////////////////
171#include <TColgp_Array1OfXYZ.hxx>
172#include <TColgp_Array1OfPnt.hxx>
173#include <TColgp_SequenceOfPnt.hxx>
174#include <Extrema_ExtPS.hxx>
175#include <Extrema_POnSurf.hxx>
176#include <Geom2d_Curve.hxx>
177#include <Geom2dAPI_InterCurveCurve.hxx>
178#include <GeomAdaptor.hxx>
179#include <GeomAdaptor_HCurve.hxx>
180#include <GeomAdaptor_Curve.hxx>
181#include <GeomAdaptor_Surface.hxx>
182#include <Handle_GeomAdaptor_HSurface.hxx>
183#include <Geom_Plane.hxx>
184#include <ProjLib_ProjectOnPlane.hxx>
185#include <GeomProjLib.hxx>
186#include <ElCLib.hxx>
187#include <Geom_TrimmedCurve.hxx>
188#include <Geom_Surface.hxx>
189#include <Geom_SurfaceOfLinearExtrusion.hxx>
190#include <Geom_OffsetSurface.hxx>
191#include <Geom_SurfaceOfRevolution.hxx>
192#include <Geom_RectangularTrimmedSurface.hxx>
193
194//===============================================================
195//function: FUN_GetMinMaxXYZPnt
196//===============================================================
197static void FUN_GetMinMaxXYZPnt( const Handle(Adaptor3d_HSurface)& S,
198 gp_Pnt& pMin, gp_Pnt& pMax )
199{
200 const Standard_Real DU = 0.25 * Abs(S->LastUParameter() - S->FirstUParameter());
201 const Standard_Real DV = 0.25 * Abs(S->LastVParameter() - S->FirstVParameter());
202 Standard_Real tMinXYZ = RealLast();
203 Standard_Real tMaxXYZ = -tMinXYZ;
204 gp_Pnt PUV, ptMax, ptMin;
205 for(Standard_Real U = S->FirstUParameter(); U <= S->LastUParameter(); U += DU)
206 {
207 for(Standard_Real V = S->FirstVParameter(); V <= S->LastVParameter(); V += DV)
208 {
209 S->D0(U,V,PUV);
210 const Standard_Real cXYZ = PUV.XYZ().Modulus();
211 if(cXYZ > tMaxXYZ) { tMaxXYZ = cXYZ; ptMax = PUV; }
212 if(cXYZ < tMinXYZ) { tMinXYZ = cXYZ; ptMin = PUV; }
213 }
214 }
215 pMin = ptMin;
216 pMax = ptMax;
217}
218//==========================================================================
219//function: FUN_TrimInfSurf
220//==========================================================================
221static void FUN_TrimInfSurf(const gp_Pnt& Pmin,
222 const gp_Pnt& Pmax,
223 const Handle(Adaptor3d_HSurface)& InfSurf,
224 const Standard_Real& AlternativeTrimPrm,
225 Handle(Adaptor3d_HSurface)& TrimS)
226{
227 Standard_Real TP = AlternativeTrimPrm;
228 Extrema_ExtPS ext1(Pmin, InfSurf->Surface(), 1.e-7, 1.e-7);
229 Extrema_ExtPS ext2(Pmax, InfSurf->Surface(), 1.e-7, 1.e-7);
230 if(ext1.IsDone() || ext2.IsDone())
231 {
232 Standard_Real Umax = -1.e+100, Umin = 1.e+100, Vmax = -1.e+100, Vmin = 1.e+100, cU, cV;
233 if(ext1.IsDone())
234 {
235 for(Standard_Integer i = 1; i <= ext1.NbExt(); i++)
236 {
237 const Extrema_POnSurf & pons = ext1.Point(i);
238 pons.Parameter(cU,cV);
239 if(cU > Umax) Umax = cU;
240 if(cU < Umin) Umin = cU;
241 if(cV > Vmax) Vmax = cV;
242 if(cV < Vmin) Vmin = cV;
243 }
244 }
245 if(ext2.IsDone())
246 {
247 for(Standard_Integer i = 1; i <= ext2.NbExt(); i++)
248 {
249 const Extrema_POnSurf & pons = ext2.Point(i);
250 pons.Parameter(cU,cV);
251 if(cU > Umax) Umax = cU;
252 if(cU < Umin) Umin = cU;
253 if(cV > Vmax) Vmax = cV;
254 if(cV < Vmin) Vmin = cV;
255 }
256 }
257 TP = Max(Abs(Umin),Max(Abs(Umax),Max(Abs(Vmin),Abs(Vmax))));
258 }
259 if(TP == 0.) { TrimS = InfSurf; return; }
260 else
261 {
262 const Standard_Boolean Uinf = Precision::IsNegativeInfinite(InfSurf->FirstUParameter());
263 const Standard_Boolean Usup = Precision::IsPositiveInfinite(InfSurf->LastUParameter());
264 const Standard_Boolean Vinf = Precision::IsNegativeInfinite(InfSurf->FirstVParameter());
265 const Standard_Boolean Vsup = Precision::IsPositiveInfinite(InfSurf->LastVParameter());
266 Handle(Adaptor3d_HSurface) TmpSS;
267 Standard_Integer IsTrimed = 0;
268 const Standard_Real tp = 1000.0 * TP;
269 if(Vinf && Vsup) { TrimS = InfSurf->VTrim(-tp, tp, 1.0e-7); IsTrimed = 1; }
270 if(Vinf && !Vsup){ TrimS = InfSurf->VTrim(-tp, InfSurf->LastVParameter(), 1.0e-7); IsTrimed = 1; }
271 if(!Vinf && Vsup){ TrimS = InfSurf->VTrim(InfSurf->FirstVParameter(), tp, 1.0e-7); IsTrimed = 1; }
272 if(IsTrimed)
273 {
274 TmpSS = TrimS;
275 if(Uinf && Usup) TrimS = TmpSS->UTrim(-tp, tp, 1.0e-7);
276 if(Uinf && !Usup) TrimS = TmpSS->UTrim(-tp, InfSurf->LastUParameter(), 1.0e-7);
277 if(!Uinf && Usup) TrimS = TmpSS->UTrim(InfSurf->FirstUParameter(), tp, 1.0e-7);
278 }
279 else
280 {
281 if(Uinf && Usup) TrimS = InfSurf->UTrim(-tp, tp, 1.0e-7);
282 if(Uinf && !Usup) TrimS = InfSurf->UTrim(-tp, InfSurf->LastUParameter(), 1.0e-7);
283 if(!Uinf && Usup) TrimS = InfSurf->UTrim(InfSurf->FirstUParameter(), tp, 1.0e-7);
284 }
285 }
286}
287//================================================================================
288//function: FUN_GetUiso
289//================================================================================
290static void FUN_GetUiso(const Handle(Geom_Surface)& GS,
291 const GeomAbs_SurfaceType& T,
292 const Standard_Real& FirstV,
293 const Standard_Real& LastV,
294 const Standard_Boolean& IsVC,
295 const Standard_Boolean& IsVP,
296 const Standard_Real& U,
297 Handle(Geom_Curve)& I)
298{
299 if(T != GeomAbs_OffsetSurface)
300 {
301 Handle(Geom_Curve) gc = GS->UIso(U);
c6541a0c 302 if(IsVP && (FirstV == 0.0 && LastV == (2.*M_PI))) I = gc;
7fd59977 303 else
304 {
305 Handle(Geom_TrimmedCurve) gtc = new Geom_TrimmedCurve(gc,FirstV,LastV);
306 //szv:I = Handle(Geom_Curve)::DownCast(gtc);
307 I = gtc;
308 }
309 }
310 else//OffsetSurface
311 {
312 const Handle(Geom_OffsetSurface) gos = *(Handle_Geom_OffsetSurface*)&GS;
313 const Handle(Geom_Surface) bs = gos->BasisSurface();
314 Handle(Geom_Curve) gcbs = bs->UIso(U);
315 GeomAdaptor_Curve gac(gcbs);
316 const GeomAbs_CurveType GACT = gac.GetType();
317 if(IsVP || IsVC || GACT == GeomAbs_BSplineCurve || GACT == GeomAbs_BezierCurve || Abs(LastV - FirstV) < 1.e+5)
318 {
319 Handle(Geom_Curve) gc = gos->UIso(U);
c6541a0c 320 if(IsVP && (FirstV == 0.0 && LastV == (2*M_PI))) I = gc;
7fd59977 321 else
322 {
323 Handle(Geom_TrimmedCurve) gtc = new Geom_TrimmedCurve(gc,FirstV,LastV);
324 //szv:I = Handle(Geom_Curve)::DownCast(gtc);
325 I = gtc;
326 }
327 }
328 else//Offset Line, Parab, Hyperb
329 {
330 Standard_Real VmTr, VMTr;
331 if(GACT != GeomAbs_Hyperbola)
332 {
333 if(FirstV >= 0. && LastV >= 0.){ VmTr = FirstV; VMTr = ((LastV - FirstV) > 1.e+4) ? (FirstV + 1.e+4) : LastV; }
334 else if(FirstV < 0. && LastV < 0.){ VMTr = LastV; VmTr = ((FirstV - LastV) < -1.e+4) ? (LastV - 1.e+4) : FirstV; }
335 else { VmTr = (FirstV < -1.e+4) ? -1.e+4 : FirstV; VMTr = (LastV > 1.e+4) ? 1.e+4 : LastV; }
336 }
337 else//Hyperbola
338 {
339 if(FirstV >= 0. && LastV >= 0.)
340 {
341 if(FirstV > 4.) return;
342 VmTr = FirstV; VMTr = (LastV > 4.) ? 4. : LastV;
343 }
344 else if(FirstV < 0. && LastV < 0.)
345 {
346 if(LastV < -4.) return;
347 VMTr = LastV; VmTr = (FirstV < -4.) ? -4. : FirstV;
348 }
349 else { VmTr = (FirstV < -4.) ? -4. : FirstV; VMTr = (LastV > 4.) ? 4. : LastV; }
350 }
351 //Make trimmed surface
352 Handle(Geom_RectangularTrimmedSurface) rts = new Geom_RectangularTrimmedSurface(gos,VmTr,VMTr,Standard_True);
353 I = rts->UIso(U);
354 }
355 }
356}
357//================================================================================
358//function: FUN_GetViso
359//================================================================================
360static void FUN_GetViso(const Handle(Geom_Surface)& GS,
361 const GeomAbs_SurfaceType& T,
362 const Standard_Real& FirstU,
363 const Standard_Real& LastU,
364 const Standard_Boolean& IsUC,
365 const Standard_Boolean& IsUP,
366 const Standard_Real& V,
367 Handle(Geom_Curve)& I)
368{
369 if(T != GeomAbs_OffsetSurface)
370 {
371 Handle(Geom_Curve) gc = GS->VIso(V);
c6541a0c 372 if(IsUP && (FirstU == 0.0 && LastU == (2*M_PI))) I = gc;
7fd59977 373 else
374 {
375 Handle(Geom_TrimmedCurve) gtc = new Geom_TrimmedCurve(gc,FirstU,LastU);
376 //szv:I = Handle(Geom_Curve)::DownCast(gtc);
377 I = gtc;
378 }
379 }
380 else//OffsetSurface
381 {
382 const Handle(Geom_OffsetSurface) gos = *(Handle_Geom_OffsetSurface*)&GS;
383 const Handle(Geom_Surface) bs = gos->BasisSurface();
384 Handle(Geom_Curve) gcbs = bs->VIso(V);
385 GeomAdaptor_Curve gac(gcbs);
386 const GeomAbs_CurveType GACT = gac.GetType();
387 if(IsUP || IsUC || GACT == GeomAbs_BSplineCurve || GACT == GeomAbs_BezierCurve || Abs(LastU - FirstU) < 1.e+5)
388 {
389 Handle(Geom_Curve) gc = gos->VIso(V);
c6541a0c 390 if(IsUP && (FirstU == 0.0 && LastU == (2*M_PI))) I = gc;
7fd59977 391 else
392 {
393 Handle(Geom_TrimmedCurve) gtc = new Geom_TrimmedCurve(gc,FirstU,LastU);
394 //szv:I = Handle(Geom_Curve)::DownCast(gtc);
395 I = gtc;
396 }
397 }
398 else//Offset Line, Parab, Hyperb
399 {
400 Standard_Real UmTr, UMTr;
401 if(GACT != GeomAbs_Hyperbola)
402 {
403 if(FirstU >= 0. && LastU >= 0.){ UmTr = FirstU; UMTr = ((LastU - FirstU) > 1.e+4) ? (FirstU + 1.e+4) : LastU; }
404 else if(FirstU < 0. && LastU < 0.){ UMTr = LastU; UmTr = ((FirstU - LastU) < -1.e+4) ? (LastU - 1.e+4) : FirstU; }
405 else { UmTr = (FirstU < -1.e+4) ? -1.e+4 : FirstU; UMTr = (LastU > 1.e+4) ? 1.e+4 : LastU; }
406 }
407 else//Hyperbola
408 {
409 if(FirstU >= 0. && LastU >= 0.)
410 {
411 if(FirstU > 4.) return;
412 UmTr = FirstU; UMTr = (LastU > 4.) ? 4. : LastU;
413 }
414 else if(FirstU < 0. && LastU < 0.)
415 {
416 if(LastU < -4.) return;
417 UMTr = LastU; UmTr = (FirstU < -4.) ? -4. : FirstU;
418 }
419 else { UmTr = (FirstU < -4.) ? -4. : FirstU; UMTr = (LastU > 4.) ? 4. : LastU; }
420 }
421 //Make trimmed surface
422 Handle(Geom_RectangularTrimmedSurface) rts = new Geom_RectangularTrimmedSurface(gos,UmTr,UMTr,Standard_True);
423 I = rts->VIso(V);
424 }
425 }
426}
427//================================================================================
428//function: FUN_PL_Intersection
429//================================================================================
430static void FUN_PL_Intersection(const Handle(Adaptor3d_HSurface)& S1,
431 const GeomAbs_SurfaceType& T1,
432 const Handle(Adaptor3d_HSurface)& S2,
433 const GeomAbs_SurfaceType& T2,
434 Standard_Boolean& IsOk,
435 TColgp_SequenceOfPnt& SP,
436 gp_Vec& DV)
437{
438 IsOk = Standard_False;
439 // 1. Check: both surfaces have U(V)isos - lines.
440 DV = gp_Vec(0.,0.,1.);
441 Standard_Boolean isoS1isLine[2] = {0, 0};
442 Standard_Boolean isoS2isLine[2] = {0, 0};
443 Handle(Geom_Curve) C1, C2;
444 const GeomAdaptor_Surface & gas1 = *(GeomAdaptor_Surface*)(&(S1->Surface()));
445 const GeomAdaptor_Surface & gas2 = *(GeomAdaptor_Surface*)(&(S2->Surface()));
446 const Handle(Geom_Surface) gs1 = gas1.Surface();
447 const Handle(Geom_Surface) gs2 = gas2.Surface();
448 Standard_Real MS1[2], MS2[2];
449 MS1[0] = 0.5 * (S1->LastUParameter() + S1->FirstUParameter());
450 MS1[1] = 0.5 * (S1->LastVParameter() + S1->FirstVParameter());
451 MS2[0] = 0.5 * (S2->LastUParameter() + S2->FirstUParameter());
452 MS2[1] = 0.5 * (S2->LastVParameter() + S2->FirstVParameter());
453 if(T1 == GeomAbs_SurfaceOfExtrusion) isoS1isLine[0] = Standard_True;
454 else if(!S1->IsVPeriodic() && !S1->IsVClosed()) {
455 if(T1 != GeomAbs_OffsetSurface) C1 = gs1->UIso(MS1[0]);
456 else {
457 const Handle(Geom_OffsetSurface) gos = *(Handle_Geom_OffsetSurface*)&gs1;
458 const Handle(Geom_Surface) bs = gos->BasisSurface();
459 C1 = bs->UIso(MS1[0]);
460 }
461 GeomAdaptor_Curve gac(C1);
462 if(gac.GetType() == GeomAbs_Line) isoS1isLine[0] = Standard_True;
463 }
464 if(!S1->IsUPeriodic() && !S1->IsUClosed()) {
465 if(T1 != GeomAbs_OffsetSurface) C1 = gs1->VIso(MS1[1]);
466 else {
467 const Handle(Geom_OffsetSurface) gos = *(Handle_Geom_OffsetSurface*)&gs1;
468 const Handle(Geom_Surface) bs = gos->BasisSurface();
469 C1 = bs->VIso(MS1[1]);
470 }
471 GeomAdaptor_Curve gac(C1);
472 if(gac.GetType() == GeomAbs_Line) isoS1isLine[1] = Standard_True;
473 }
474 if(T2 == GeomAbs_SurfaceOfExtrusion) isoS2isLine[0] = Standard_True;
475 else if(!S2->IsVPeriodic() && !S2->IsVClosed()) {
476 if(T2 != GeomAbs_OffsetSurface) C2 = gs2->UIso(MS2[0]);
477 else {
478 const Handle(Geom_OffsetSurface) gos = *(Handle_Geom_OffsetSurface*)&gs2;
479 const Handle(Geom_Surface) bs = gos->BasisSurface();
480 C2 = bs->UIso(MS2[0]);
481 }
482 GeomAdaptor_Curve gac(C2);
483 if(gac.GetType() == GeomAbs_Line) isoS2isLine[0] = Standard_True;
484 }
485 if(!S2->IsUPeriodic() && !S2->IsUClosed()) {
486 if(T2 != GeomAbs_OffsetSurface) C2 = gs2->VIso(MS2[1]);
487 else {
488 const Handle(Geom_OffsetSurface) gos = *(Handle_Geom_OffsetSurface*)&gs2;
489 const Handle(Geom_Surface) bs = gos->BasisSurface();
490 C2 = bs->VIso(MS2[1]);
491 }
492 GeomAdaptor_Curve gac(C2);
493 if(gac.GetType() == GeomAbs_Line) isoS2isLine[1] = Standard_True;
494 }
495 Standard_Boolean IsBothLines = ((isoS1isLine[0] || isoS1isLine[1]) &&
496 (isoS2isLine[0] || isoS2isLine[1]));
497 if(!IsBothLines){
498 return;
499 }
500 // 2. Check: Uiso lines of both surfaces are collinear.
501 gp_Pnt puvS1, puvS2;
502 gp_Vec derS1[2], derS2[2];
503 S1->D1(MS1[0], MS1[1], puvS1, derS1[0], derS1[1]);
504 S2->D1(MS2[0], MS2[1], puvS2, derS2[0], derS2[1]);
505 C1.Nullify(); C2.Nullify();
506 Standard_Integer iso = 0;
507 if(isoS1isLine[0] && isoS2isLine[0] &&
508 derS1[1].IsParallel(derS2[1],Precision::Angular())) {
509 iso = 1;
510 FUN_GetViso(gs1,T1,S1->FirstUParameter(),S1->LastUParameter(),
511 S1->IsUClosed(),S1->IsUPeriodic(),MS1[1],C1);
512 FUN_GetViso(gs2,T2,S2->FirstUParameter(),S2->LastUParameter(),
513 S2->IsUClosed(),S2->IsUPeriodic(),MS2[1],C2);
514 }
515 else if(isoS1isLine[0] && isoS2isLine[1] &&
516 derS1[1].IsParallel(derS2[0],Precision::Angular())) {
517 iso = 1;
518 FUN_GetViso(gs1,T1,S1->FirstUParameter(),S1->LastUParameter(),
519 S1->IsUClosed(),S1->IsUPeriodic(),MS1[1],C1);
520 FUN_GetUiso(gs2,T2,S2->FirstVParameter(),S2->LastVParameter(),
521 S2->IsVClosed(),S2->IsVPeriodic(),MS2[0],C2);
522 }
523 else if(isoS1isLine[1] && isoS2isLine[0] &&
524 derS1[0].IsParallel(derS2[1],Precision::Angular())) {
525 iso = 0;
526 FUN_GetUiso(gs1,T1,S1->FirstVParameter(),S1->LastVParameter(),
527 S1->IsVClosed(),S1->IsVPeriodic(),MS1[0],C1);
528 FUN_GetViso(gs2,T2,S2->FirstUParameter(),S2->LastUParameter(),
529 S2->IsUClosed(),S2->IsUPeriodic(),MS2[1],C2);
530 }
531 else if(isoS1isLine[1] && isoS2isLine[1] &&
532 derS1[0].IsParallel(derS2[0],Precision::Angular())) {
533 iso = 0;
534 FUN_GetUiso(gs1,T1,S1->FirstVParameter(),S1->LastVParameter(),
535 S1->IsVClosed(),S1->IsVPeriodic(),MS1[0],C1);
536 FUN_GetUiso(gs2,T2,S2->FirstVParameter(),S2->LastVParameter(),
537 S2->IsVClosed(),S2->IsVPeriodic(),MS2[0],C2);
538 }
539 else {
540 IsOk = Standard_False;
541 return;
542 }
543 IsOk = Standard_True;
544 // 3. Make intersections of V(U)isos
545 if(C1.IsNull() || C2.IsNull()) return;
546 DV = derS1[iso];
547 Handle(Geom_Plane) GPln = new Geom_Plane(gp_Pln(puvS1,gp_Dir(DV)));
548 Handle(Geom_Curve) C1Prj =
549 GeomProjLib::ProjectOnPlane(C1,GPln,gp_Dir(DV),Standard_True);
550 Handle(Geom_Curve) C2Prj =
551 GeomProjLib::ProjectOnPlane(C2,GPln,gp_Dir(DV),Standard_True);
552 if(C1Prj.IsNull() || C2Prj.IsNull()) return;
553 Handle(Geom2d_Curve) C1Prj2d =
554 GeomProjLib::Curve2d(C1Prj,*(Handle_Geom_Surface *)&GPln);
555 Handle(Geom2d_Curve) C2Prj2d =
556 GeomProjLib::Curve2d(C2Prj,*(Handle_Geom_Surface *)&GPln);
557 Geom2dAPI_InterCurveCurve ICC(C1Prj2d,C2Prj2d,1.0e-7);
558 if(ICC.NbPoints() > 0 )
559 {
560 for(Standard_Integer ip = 1; ip <= ICC.NbPoints(); ip++)
561 {
562 gp_Pnt2d P = ICC.Point(ip);
563 gp_Pnt P3d = ElCLib::To3d(gp_Ax2(puvS1,gp_Dir(DV)),P);
564 SP.Append(P3d);
565 }
566 }
567}
568//================================================================================
569//function: FUN_NewFirstLast
570//================================================================================
571static void FUN_NewFirstLast(const GeomAbs_CurveType& ga_ct,
572 const Standard_Real& Fst,
573 const Standard_Real& Lst,
574 const Standard_Real& TrVal,
575 Standard_Real& NewFst,
576 Standard_Real& NewLst,
577 Standard_Boolean& NeedTr)
578{
579 NewFst = Fst; NewLst = Lst; NeedTr = Standard_False;
580 switch (ga_ct)
581 {
582 case GeomAbs_Line:
583 case GeomAbs_Parabola:
584 {
585 if(Abs(Lst - Fst) > TrVal)
586 {
587 if(Fst >= 0. && Lst >= 0.)
588 {
589 NewFst = Fst;
590 NewLst = ((Fst + TrVal) < Lst) ? (Fst + TrVal) : Lst;
591 }
592 if(Fst < 0. && Lst < 0.)
593 {
594 NewLst = Lst;
595 NewFst = ((Lst - TrVal) > Fst) ? (Lst - TrVal) : Fst;
596 }
597 else
598 {
599 NewFst = (Fst < -TrVal) ? -TrVal : Fst;
600 NewLst = (Lst > TrVal) ? TrVal : Lst;
601 }
602 NeedTr = Standard_True;
603 }
604 break;
605 }
606 case GeomAbs_Hyperbola:
607 {
608 if(Abs(Lst - Fst) > 10.)
609 {
610 if(Fst >= 0. && Lst >= 0.)
611 {
612 if(Fst > 4.) return;
613 NewFst = Fst;
614 NewLst = (Lst > 4.) ? 4. : Lst;
615 }
616 if(Fst < 0. && Lst < 0.)
617 {
618 if(Lst < -4.) return;
619 NewLst = Lst;
620 NewFst = (Fst < -4.) ? -4. : Fst;
621 }
622 else
623 {
624 NewFst = (Fst < -4.) ? -4. : Fst;
625 NewLst = (Lst > 4.) ? 4. : Lst;
626 }
627 NeedTr = Standard_True;
628 }
629 break;
630 }
631 }
632}
633//================================================================================
634//function: FUN_TrimBothSurf
635//================================================================================
636static void FUN_TrimBothSurf(const Handle(Adaptor3d_HSurface)& S1,
637 const GeomAbs_SurfaceType& T1,
638 const Handle(Adaptor3d_HSurface)& S2,
639 const GeomAbs_SurfaceType& T2,
640 const Standard_Real& TV,
641 Handle(Adaptor3d_HSurface)& NS1,
642 Handle(Adaptor3d_HSurface)& NS2)
643{
644 const GeomAdaptor_Surface & gas1 = *(GeomAdaptor_Surface*)(&(S1->Surface()));
645 const GeomAdaptor_Surface & gas2 = *(GeomAdaptor_Surface*)(&(S2->Surface()));
646 const Handle(Geom_Surface) gs1 = gas1.Surface();
647 const Handle(Geom_Surface) gs2 = gas2.Surface();
648 const Standard_Real UM1 = 0.5 * (S1->LastUParameter() + S1->FirstUParameter());
649 const Standard_Real UM2 = 0.5 * (S2->LastUParameter() + S2->FirstUParameter());
650 const Standard_Real VM1 = 0.5 * (S1->LastVParameter() + S1->FirstVParameter());
651 const Standard_Real VM2 = 0.5 * (S2->LastVParameter() + S2->FirstVParameter());
652 Handle(Geom_Curve) visoS1, visoS2, uisoS1, uisoS2;
653 if(T1 != GeomAbs_OffsetSurface){ visoS1 = gs1->VIso(VM1); uisoS1 = gs1->UIso(UM1); }
654 else
655 {
656 const Handle(Geom_OffsetSurface) gos = *(Handle_Geom_OffsetSurface*)&gs1;
657 const Handle(Geom_Surface) bs = gos->BasisSurface();
658 visoS1 = bs->VIso(VM1); uisoS1 = bs->UIso(UM1);
659 }
660 if(T2 != GeomAbs_OffsetSurface){ visoS2 = gs2->VIso(VM2); uisoS2 = gs2->UIso(UM2); }
661 else
662 {
663 const Handle(Geom_OffsetSurface) gos = *(Handle_Geom_OffsetSurface*)&gs2;
664 const Handle(Geom_Surface) bs = gos->BasisSurface();
665 visoS2 = bs->VIso(VM2); uisoS2 = bs->UIso(UM2);
666 }
667 if(uisoS1.IsNull() || uisoS2.IsNull() || visoS1.IsNull() || visoS2.IsNull()){ NS1 = S1; NS2 = S2; return; }
668 GeomAdaptor_Curve gau1(uisoS1);
669 GeomAdaptor_Curve gav1(visoS1);
670 GeomAdaptor_Curve gau2(uisoS2);
671 GeomAdaptor_Curve gav2(visoS2);
672 GeomAbs_CurveType GA_U1 = gau1.GetType();
673 GeomAbs_CurveType GA_V1 = gav1.GetType();
674 GeomAbs_CurveType GA_U2 = gau2.GetType();
675 GeomAbs_CurveType GA_V2 = gav2.GetType();
676 Standard_Boolean TrmU1 = Standard_False;
677 Standard_Boolean TrmV1 = Standard_False;
678 Standard_Boolean TrmU2 = Standard_False;
679 Standard_Boolean TrmV2 = Standard_False;
680 Standard_Real V1S1,V2S1,U1S1,U2S1, V1S2,V2S2,U1S2,U2S2;
681 FUN_NewFirstLast(GA_U1,S1->FirstVParameter(),S1->LastVParameter(),TV,V1S1,V2S1,TrmV1);
682 FUN_NewFirstLast(GA_V1,S1->FirstUParameter(),S1->LastUParameter(),TV,U1S1,U2S1,TrmU1);
683 FUN_NewFirstLast(GA_U2,S2->FirstVParameter(),S2->LastVParameter(),TV,V1S2,V2S2,TrmV2);
684 FUN_NewFirstLast(GA_V2,S2->FirstUParameter(),S2->LastUParameter(),TV,U1S2,U2S2,TrmU2);
685 if(TrmV1) NS1 = S1->VTrim(V1S1, V2S1, 1.0e-7);
686 if(TrmV2) NS2 = S2->VTrim(V1S2, V2S2, 1.0e-7);
687 if(TrmU1)
688 {
689 if(TrmV1)
690 {
691 Handle(Adaptor3d_HSurface) TS = NS1;
692 NS1 = TS->UTrim(U1S1, U2S1, 1.0e-7);
693 }
694 else NS1 = S1->UTrim(U1S1, U2S1, 1.0e-7);
695 }
696 if(TrmU2)
697 {
698 if(TrmV2)
699 {
700 Handle(Adaptor3d_HSurface) TS = NS2;
701 NS2 = TS->UTrim(U1S2, U2S2, 1.0e-7);
702 }
703 else NS2 = S2->UTrim(U1S2, U2S2, 1.0e-7);
704 }
705}
706
707//=======================================================================
708//function : Perform
709//purpose :
710//=======================================================================
711void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& S1,
712 const Handle(Adaptor3d_TopolTool)& D1,
713 const Handle(Adaptor3d_HSurface)& S2,
714 const Handle(Adaptor3d_TopolTool)& D2,
715 const Standard_Real TolArc,
716 const Standard_Real TolTang)
717{
718 myTolArc = TolArc;
719 myTolTang = TolTang;
720 if(myFleche == 0.0) myFleche = 0.01;
721 if(myUVMaxStep == 0.0) myUVMaxStep = 0.01;
722
723 done = Standard_False;
724 spnt.Clear();
725 slin.Clear();
726 empt = Standard_True;
727 tgte = Standard_False;
728 oppo = Standard_False;
729
730 Standard_Integer i;
731
732 GeomAbs_SurfaceType typs1 = S1->GetType();
733 GeomAbs_SurfaceType typs2 = S2->GetType();
734
735 Standard_Boolean TreatAsBiParametric = Standard_False;
736 if(typs1 == GeomAbs_Cone) {
737 Standard_Real a1 = S1->Cone().SemiAngle();
738 if(a1<0.0) a1=-a1;
739 if(a1<2.e-2 || a1>1.55) {
740 if(typs2==GeomAbs_Plane) {
741 if(a1<2e-2) {
742 const gp_Dir axec = S1->Cone().Axis().Direction();
743 const gp_Dir axep = S2->Plane().Axis().Direction();
744 Standard_Real ps=axec.Dot(axep);
745 if(ps<0.0) {
746 ps=-ps;
747 }
7fd59977 748 if(ps<0.015) {
7fd59977 749 TreatAsBiParametric = Standard_True;
750 }
751 }
752 }
753 else TreatAsBiParametric = Standard_True;
754 }
755 }
756 if(typs2 == GeomAbs_Cone) {
757 gp_Cone Con2 = S2->Cone();
758 Standard_Real a2 = Con2.SemiAngle();
759 if(a2<0.0) a2=-a2;
760 if(a2<2.e-2 || a2>1.55) {
761 if(typs1==GeomAbs_Plane) {
762 if(a2<2e-2) {
763 const gp_Dir axec = S2->Cone().Axis().Direction();
764 const gp_Dir axep = S1->Plane().Axis().Direction();
765 Standard_Real ps=axec.Dot(axep);
766 if(ps<0.0) {
767 ps=-ps;
768 }
7fd59977 769 if(ps<0.015){
7fd59977 770 TreatAsBiParametric = Standard_True;
771 }
772 }
773 }
774 else TreatAsBiParametric = Standard_True;
775 }
776 //// modified by jgv, 15.12.02 for OCC565 ////
777 if (typs1 == GeomAbs_Cone) {
778 gp_Cone Con1 = S1->Cone();
779 Standard_Real a1 = Con1.SemiAngle();
780 if (a1 < 0.0) a1 = -a1;
781 if (a1 < 2.e-2 && a2 < 2.e-2) {//quasi-cylinders: if same domain, treat as canonic
782 gp_Ax1 A1 = Con1.Axis(), A2 = Con2.Axis();
783 if (A1.IsParallel(A2,Precision::Angular())) {
784 gp_Lin L1(A1);
785 if (L1.Distance( A2.Location() ) <= Precision::Confusion()){
786 TreatAsBiParametric = Standard_False;
787 }
788 }
789 }
bf0ba813 790 else if (a1 > 1.55 && a2 > 1.55) { //quasi-planes: if same domain, treat as canonic
7fd59977 791 gp_Ax1 A1 = Con1.Axis(), A2 = Con2.Axis();
792 if (A1.IsParallel(A2,Precision::Angular())) {
793 gp_Pnt Apex1 = Con1.Apex(), Apex2 = Con2.Apex();
794 gp_Pln Plan1( Apex1, A1.Direction() );
795 if (Plan1.Distance( Apex2 ) <= Precision::Confusion()){
796 TreatAsBiParametric = Standard_False;
797 }
798 }
799 }
bf0ba813 800 else if ((a1 > 1.55 && a2 < 1.55) || (a2 > 1.55 && a1 < 1.55) ) {
801 gp_Ax1 A1 = Con1.Axis(), A2 = Con2.Axis();
802 if (A1.IsCoaxial(A2,Precision::Angular(),Precision::Confusion())) {
803 TreatAsBiParametric = Standard_False;
804 }
805 }
806 }// if (typs1 == GeomAbs_Cone) {
807 }// if(typs2 == GeomAbs_Cone) {
7fd59977 808 //
bf0ba813 809 if(D1->DomainIsInfinite() || D2->DomainIsInfinite()) {
810 TreatAsBiParametric= Standard_False;
811 }
7fd59977 812
813// Modified by skv - Mon Sep 26 14:58:30 2005 Begin
814// if(TreatAsBiParametric) { typs1 = typs2 = GeomAbs_BezierSurface; }
815 if(TreatAsBiParametric) {
816 if (typs1 == GeomAbs_Cone && typs2 == GeomAbs_Plane)
817 typs1 = GeomAbs_BezierSurface; // Using Imp-Prm Intersector
818 else if (typs1 == GeomAbs_Plane && typs2 == GeomAbs_Cone)
819 typs2 = GeomAbs_BezierSurface; // Using Imp-Prm Intersector
820 else {
821 // Using Prm-Prm Intersector
822 typs1 = GeomAbs_BezierSurface;
823 typs2 = GeomAbs_BezierSurface;
824 }
825 }
826// Modified by skv - Mon Sep 26 14:58:30 2005 End
827
828 // Surface type definition
829 Standard_Integer ts1 = 0;
830 switch (typs1)
831 {
832 case GeomAbs_Plane:
833 case GeomAbs_Cylinder:
834 case GeomAbs_Sphere:
835 case GeomAbs_Cone: ts1 = 1; break;
836 default: break;
837 }
838 Standard_Integer ts2 = 0;
839 switch (typs2)
840 {
841 case GeomAbs_Plane:
842 case GeomAbs_Cylinder:
843 case GeomAbs_Sphere:
844 case GeomAbs_Cone: ts2 = 1; break;
845 default: break;
846 }
847 // Possible intersection types: 1. ts1 == ts2 == 1 <Geom-Geom>
848 // 2. ts1 != ts2 <Geom-Param>
849 // 3. ts1 == ts2 == 0 <Param-Param>
850
851 // Geom - Geom
852 if(ts1 == ts2 && ts1 == 1)
853 {
854 IntPatch_ImpImpIntersection interii(S1,D1,S2,D2,myTolArc,myTolTang);
855 if (interii.IsDone())
856 {
857 done = Standard_True;
858 empt = interii.IsEmpty();
859 if (!empt)
860 {
861 tgte = interii.TangentFaces();
862 if (tgte) oppo = interii.OppositeFaces();
863 for (i = 1; i <= interii.NbLines(); i++)
864 {
865 const Handle_IntPatch_Line& line = interii.Line(i);
866 if (line->ArcType() == IntPatch_Analytic)
867 {
868 const GeomAbs_SurfaceType typs1 = S1->GetType();
869 const GeomAbs_SurfaceType typs2 = S2->GetType();
870 IntSurf_Quadric Quad1,Quad2;
871 switch(typs1)
872 {
873 case GeomAbs_Plane: Quad1.SetValue(S1->Plane()); break;
874 case GeomAbs_Cylinder: Quad1.SetValue(S1->Cylinder()); break;
875 case GeomAbs_Sphere: Quad1.SetValue(S1->Sphere()); break;
876 case GeomAbs_Cone: Quad1.SetValue(S1->Cone()); break;
877 default: break;
878 }
879 switch(typs2)
880 {
881 case GeomAbs_Plane: Quad2.SetValue(S2->Plane()); break;
882 case GeomAbs_Cylinder: Quad2.SetValue(S2->Cylinder()); break;
883 case GeomAbs_Sphere: Quad2.SetValue(S2->Sphere()); break;
884 case GeomAbs_Cone: Quad2.SetValue(S2->Cone()); break;
885 default: break;
886 }
887 IntPatch_ALineToWLine AToW(Quad1,Quad2,0.01,0.05,NBPOINTSSURALINE);
888 Handle(IntPatch_Line) wlin=AToW.MakeWLine((*((Handle_IntPatch_ALine *)(&line))));
889 slin.Append(wlin);
890 }
891 else slin.Append(interii.Line(i));
892 }
893 for (i = 1; i <= interii.NbPnts(); i++) spnt.Append(interii.Point(i));
894 }
895 }
896 else goto prm;
897 }
898 // Geom - Param
899 if(ts1 != ts2)
900 {
901 //cout << "IP" << endl;
902 IntPatch_ImpPrmIntersection interip;
903 if (myIsStartPnt) {
904 if (ts1 == 0) interip.SetStartPoint(myU1Start,myV1Start);
905 else interip.SetStartPoint(myU2Start,myV2Start);
906 }
907 if(D1->DomainIsInfinite() && D2->DomainIsInfinite())
908 {
909 Standard_Boolean IsPLInt = Standard_False;
910 TColgp_SequenceOfPnt sop;
911 gp_Vec v;
912 FUN_PL_Intersection(S1,typs1,S2,typs2,IsPLInt,sop,v);
913 if(IsPLInt)
914 {
915 if(sop.Length() > 0)
916 {
917 for(Standard_Integer ip = 1; ip <= sop.Length(); ip++)
918 {
919 gp_Lin lin(sop.Value(ip),gp_Dir(v));
920 Handle(IntPatch_GLine) gl = new IntPatch_GLine(lin,Standard_False);
921 slin.Append(*(Handle_IntPatch_Line *)&gl);
922 }
923 done = Standard_True;
924 }
925 else done = Standard_False;
926 return;
927 }
928 else
929 {
930 Handle(Adaptor3d_HSurface) nS1 = S1;
931 Handle(Adaptor3d_HSurface) nS2 = S2;
932 FUN_TrimBothSurf(S1,typs1,S2,typs2,1.e+5,nS1,nS2);
933 interip.Perform(nS1,D1,nS2,D2,myTolArc,myTolTang,myFleche,myUVMaxStep);
934 }
935 }
936 else interip.Perform(S1,D1,S2,D2,myTolArc,myTolTang,myFleche,myUVMaxStep);
937// IntPatch_ImpPrmIntersection interip(S1,D1,S2,D2,myTolArc,myTolTang,myFleche,myUVMaxStep);
938 if (interip.IsDone())
939 {
940 done = Standard_True;
941 empt = interip.IsEmpty();
942 if (!empt)
943 {
944 for(i = 1; i <= interip.NbLines(); i++)
945 {
946 if(interip.Line(i)->ArcType() != IntPatch_Walking) slin.Append(interip.Line(i));
947 }
948 for(i = 1; i <= interip.NbLines(); i++)
949 {
950 if(interip.Line(i)->ArcType() == IntPatch_Walking) slin.Append(interip.Line(i));
951 }
952 for (i = 1; i <= interip.NbPnts(); i++) spnt.Append(interip.Point(i));
953 }
954 }
955 }
956 // Param - Param
957 if(ts1 == ts2 && ts1 == 0)
958 {
959 //cout << "PP" << endl;
960prm:; // this algorithm was modified last by OFV [29-Oct-2001] -> [2-Nov-2001]
961 IntPatch_PrmPrmIntersection interpp;
962 if(!D1->DomainIsInfinite() && !D2->DomainIsInfinite())
963 {
964 interpp.Perform(S1,D1,S2,D2,TolArc,TolTang,myFleche,myUVMaxStep);
965 goto met;
966 }
967 else if( (!D1->DomainIsInfinite() && D2->DomainIsInfinite()) || (D1->DomainIsInfinite() && !D2->DomainIsInfinite()) )
968 {
969 gp_Pnt pMaxXYZ, pMinXYZ;
970 if(D1->DomainIsInfinite())
971 {
972 FUN_GetMinMaxXYZPnt( S2, pMinXYZ, pMaxXYZ );
973 const Standard_Real MU = Max(Abs(S2->FirstUParameter()),Abs(S2->LastUParameter()));
974 const Standard_Real MV = Max(Abs(S2->FirstVParameter()),Abs(S2->LastVParameter()));
975 const Standard_Real AP = Max(MU, MV);
976 Handle(Adaptor3d_HSurface) SS;
977 FUN_TrimInfSurf(pMinXYZ, pMaxXYZ, S1, AP, SS);
978 interpp.Perform(SS,D1,S2,D2,TolArc,TolTang,myFleche,myUVMaxStep);
979 }
980 else
981 {
982 FUN_GetMinMaxXYZPnt( S1, pMinXYZ, pMaxXYZ );
983 const Standard_Real MU = Max(Abs(S1->FirstUParameter()),Abs(S1->LastUParameter()));
984 const Standard_Real MV = Max(Abs(S1->FirstVParameter()),Abs(S1->LastVParameter()));
985 const Standard_Real AP = Max(MU, MV);
986 Handle(Adaptor3d_HSurface) SS;
987 FUN_TrimInfSurf(pMinXYZ, pMaxXYZ, S2, AP, SS);
988 interpp.Perform(S1,D1,SS,D2,TolArc,TolTang,myFleche,myUVMaxStep);
989 }
990 goto met;
991 }//(!D1->DomainIsInfinite() && D2->DomainIsInfinite()) || (D1->DomainIsInfinite() && !D2->DomainIsInfinite())
992 else
993 {
994 if(typs1 == GeomAbs_OtherSurface || typs2 == GeomAbs_OtherSurface){ done = Standard_False; return; }
995 Standard_Boolean IsPLInt = Standard_False;
996 TColgp_SequenceOfPnt sop;
997 gp_Vec v;
998 FUN_PL_Intersection(S1,typs1,S2,typs2,IsPLInt,sop,v);
999 if(IsPLInt)
1000 {
1001 if(sop.Length() > 0)
1002 {
1003 for(Standard_Integer ip = 1; ip <= sop.Length(); ip++)
1004 {
1005 gp_Lin lin(sop.Value(ip),gp_Dir(v));
1006 Handle(IntPatch_GLine) gl = new IntPatch_GLine(lin,Standard_False);
1007 slin.Append(*(Handle_IntPatch_Line *)&gl);
1008 }
1009 done = Standard_True;
1010 }
1011 else done = Standard_False;
1012 return;
1013 } // 'COLLINEAR LINES'
1014 else
1015 {
1016 Handle(Adaptor3d_HSurface) nS1 = S1;
1017 Handle(Adaptor3d_HSurface) nS2 = S2;
1018 FUN_TrimBothSurf(S1,typs1,S2,typs2,1.e+8,nS1,nS2);
1019 interpp.Perform(nS1,D1,nS2,D2,TolArc,TolTang,myFleche,myUVMaxStep);
1020 goto met;
1021 }// 'NON - COLLINEAR LINES'
1022 }// both domains are infinite
1023met:if (interpp.IsDone())
1024 {
1025 done = Standard_True;
1026 tgte = Standard_False;
1027 empt = interpp.IsEmpty();
1028 for(i=1; i <= interpp.NbLines(); i++)
1029 {
1030 if(interpp.Line(i)->ArcType() != IntPatch_Walking) slin.Append(interpp.Line(i));
1031 }
1032 for(i=1; i <= interpp.NbLines(); i++)
1033 {
1034 if(interpp.Line(i)->ArcType() == IntPatch_Walking) slin.Append(interpp.Line(i));
1035 }
1036 }
1037 }
1038}
1039
1040//=======================================================================
1041//function : Perform
1042//purpose :
1043//=======================================================================
1044void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& S1,
1045 const Handle(Adaptor3d_TopolTool)& D1,
1046 const Handle(Adaptor3d_HSurface)& S2,
1047 const Handle(Adaptor3d_TopolTool)& D2,
1048 const Standard_Real TolArc,
1049 const Standard_Real TolTang,
1050 IntSurf_ListOfPntOn2S& ListOfPnts,
1051 const Standard_Boolean RestrictLine)
1052{
1053 myTolArc = TolArc;
1054 myTolTang = TolTang;
1055 if(myFleche == 0.0) myFleche = 0.01;
1056 if(myUVMaxStep == 0.0) myUVMaxStep = 0.01;
1057
1058 done = Standard_False;
1059 spnt.Clear();
1060 slin.Clear();
1061 empt = Standard_True;
1062 tgte = Standard_False;
1063 oppo = Standard_False;
1064
1065 Standard_Integer i;
1066
1067 GeomAbs_SurfaceType typs1 = S1->GetType();
1068 GeomAbs_SurfaceType typs2 = S2->GetType();
1069
1070 Standard_Boolean TreatAsBiParametric = Standard_False;
1071 if(typs1 == GeomAbs_Cone) {
1072 Standard_Real a1 = S1->Cone().SemiAngle();
1073 if(a1<0.0) a1=-a1;
1074 if(a1<2e-2 || a1>1.55) {
1075 if(typs2==GeomAbs_Plane) {
1076 if(a1<2e-2) {
1077 gp_Dir axec = S1->Cone().Axis().Direction();
1078 gp_Dir axep = S2->Plane().Axis().Direction();
1079 Standard_Real ps=axec.Dot(axep);
1080 if(ps<0.0) {
1081 ps=-ps;
1082 }
7fd59977 1083 if(ps<0.015) {
7fd59977 1084 TreatAsBiParametric = Standard_True;
1085 }
1086 }
1087 }
1088 else {
1089 TreatAsBiParametric = Standard_True;
1090 }
1091 }
1092 }
1093 if(typs2 == GeomAbs_Cone) {
1094 Standard_Real a2 = S2->Cone().SemiAngle();
1095 if(a2<0.0) a2=-a2;
1096 if(a2<2.e-2 || a2>1.55) {
1097 if(typs1==GeomAbs_Plane) {
1098 if(a2<2e-2) {
1099 const gp_Dir axec = S2->Cone().Axis().Direction();
1100 const gp_Dir axep = S1->Plane().Axis().Direction();
1101 Standard_Real ps=axec.Dot(axep);
1102 if(ps<0.0){
1103 ps=-ps;
1104 }
7fd59977 1105 if(ps<0.015){
7fd59977 1106 TreatAsBiParametric = Standard_True;
1107 }
1108 }
1109 }
1110 else {
1111 TreatAsBiParametric = Standard_True;
1112 }
1113 }
1114 }
1115 //// modified by jgv, 15.12.02 for OCC565 ////
1116 if (typs1 == GeomAbs_Cone && typs2 == GeomAbs_Cone)
1117 {
1118 gp_Cone Con1 = S1->Cone();
1119 gp_Cone Con2 = S2->Cone();
1120 Standard_Real a1 = Con1.SemiAngle();
1121 if (a1 < 0.0) a1 = -a1;
1122 Standard_Real a2 = Con2.SemiAngle();
1123 if (a2 < 0.0) a2 = -a2;
1124 if (a1 < 2e-2 && a2 < 2e-2) //quasi-cylinders: if same domain, treat as canonic
1125 {
1126 gp_Ax1 A1 = Con1.Axis(), A2 = Con2.Axis();
1127 if (A1.IsParallel(A2,Precision::Angular()))
1128 {
1129 gp_Lin L1(A1);
1130 if (L1.Distance( A2.Location() ) <= Precision::Confusion())
1131 TreatAsBiParametric = Standard_False;
1132 }
1133 }
1134 else if (a1 > 1.55 && a2 > 1.55) //quasi-planes: if same domain, treat as canonic
1135 {
1136 gp_Ax1 A1 = Con1.Axis(), A2 = Con2.Axis();
1137 if (A1.IsParallel(A2,Precision::Angular()))
1138 {
1139 gp_Pnt Apex1 = Con1.Apex(), Apex2 = Con2.Apex();
1140 gp_Pln Plan1( Apex1, A1.Direction() );
1141 if (Plan1.Distance( Apex2 ) <= Precision::Confusion())
1142 TreatAsBiParametric = Standard_False;
1143 }
1144 }
bf0ba813 1145 else if ((a1 > 1.55 && a2 < 1.55) || (a2 > 1.55 && a1 < 1.55) ) {
1146 gp_Ax1 A1 = Con1.Axis(), A2 = Con2.Axis();
1147 if (A1.IsCoaxial(A2,Precision::Angular(),Precision::Confusion())) {
1148 TreatAsBiParametric = Standard_False;
1149 }
1150 }
7fd59977 1151 }
1152 //////////////////////////////////////////////
1153
bf0ba813 1154 if(D1->DomainIsInfinite() || D2->DomainIsInfinite()) {
1155 TreatAsBiParametric= Standard_False;
1156 }
1157 if(TreatAsBiParametric) {
1158 typs1 = GeomAbs_BezierSurface;
1159 typs2 = GeomAbs_BezierSurface;
1160 }
7fd59977 1161
1162 // Surface type definition
1163 Standard_Integer ts1 = 0;
1164 switch (typs1)
1165 {
1166 case GeomAbs_Plane:
1167 case GeomAbs_Cylinder:
1168 case GeomAbs_Sphere:
1169 case GeomAbs_Cone: ts1 = 1; break;
1170 default: break;
1171 }
1172 Standard_Integer ts2 = 0;
1173 switch (typs2)
1174 {
1175 case GeomAbs_Plane:
1176 case GeomAbs_Cylinder:
1177 case GeomAbs_Sphere:
1178 case GeomAbs_Cone: ts2 = 1; break;
1179 default: break;
1180 }
1181 // Possible intersection types: 1. ts1 == ts2 == 1 <Geom-Geom>
1182 // 2. ts1 != ts2 <Geom-Param>
1183 // 3. ts1 == ts2 == 0 <Param-Param>
1184
1185 // Geom - Geom
1186 if(ts1 == ts2 && ts1 == 1)
1187 {
1188 IntPatch_ImpImpIntersection interii(S1,D1,S2,D2,myTolArc,myTolTang);
1189 if (interii.IsDone())
1190 {
1191 done = Standard_True;
1192 empt = interii.IsEmpty();
1193 if (!empt)
1194 {
1195 tgte = interii.TangentFaces();
1196 if (tgte) oppo = interii.OppositeFaces();
1197 for (i = 1; i <= interii.NbLines(); i++)
1198 {
1199 const Handle_IntPatch_Line& line = interii.Line(i);
1200 if (line->ArcType() == IntPatch_Analytic)
1201 {
1202 const GeomAbs_SurfaceType typs1 = S1->GetType();
1203 const GeomAbs_SurfaceType typs2 = S2->GetType();
1204 IntSurf_Quadric Quad1,Quad2;
1205 switch(typs1)
1206 {
1207 case GeomAbs_Plane: Quad1.SetValue(S1->Plane()); break;
1208 case GeomAbs_Cylinder: Quad1.SetValue(S1->Cylinder()); break;
1209 case GeomAbs_Sphere: Quad1.SetValue(S1->Sphere()); break;
1210 case GeomAbs_Cone: Quad1.SetValue(S1->Cone()); break;
1211 default: break;
1212 }
1213 switch(typs2)
1214 {
1215 case GeomAbs_Plane: Quad2.SetValue(S2->Plane()); break;
1216 case GeomAbs_Cylinder: Quad2.SetValue(S2->Cylinder()); break;
1217 case GeomAbs_Sphere: Quad2.SetValue(S2->Sphere()); break;
1218 case GeomAbs_Cone: Quad2.SetValue(S2->Cone()); break;
1219 default: break;
1220 }
1221 IntPatch_ALineToWLine AToW(Quad1,Quad2,0.01,0.05,NBPOINTSSURALINE);
1222 Handle(IntPatch_Line) wlin=AToW.MakeWLine((*((Handle_IntPatch_ALine *)(&line))));
1223 slin.Append(wlin);
1224 }
1225 else slin.Append(interii.Line(i));
1226 }
1227 for (i = 1; i <= interii.NbPnts(); i++) spnt.Append(interii.Point(i));
1228 }
1229 }
1230 else goto prm;
1231 }
1232 // Geom - Param
1233 if(ts1 != ts2)
1234 {
1235 //cout << "IP" << endl;
1236 IntPatch_ImpPrmIntersection interip;
1237 if (myIsStartPnt) {
1238 if (ts1 == 0) interip.SetStartPoint(myU1Start,myV1Start);
1239 else interip.SetStartPoint(myU2Start,myV2Start);
1240 }
1241 if(D1->DomainIsInfinite() && D2->DomainIsInfinite())
1242 {
1243 Standard_Boolean IsPLInt = Standard_False;
1244 TColgp_SequenceOfPnt sop;
1245 gp_Vec v;
1246 FUN_PL_Intersection(S1,typs1,S2,typs2,IsPLInt,sop,v);
1247 if(IsPLInt)
1248 {
1249 if(sop.Length() > 0)
1250 {
1251 for(Standard_Integer ip = 1; ip <= sop.Length(); ip++)
1252 {
1253 gp_Lin lin(sop.Value(ip),gp_Dir(v));
1254 Handle(IntPatch_GLine) gl = new IntPatch_GLine(lin,Standard_False);
1255 slin.Append(*(Handle_IntPatch_Line *)&gl);
1256 }
1257 done = Standard_True;
1258 }
1259 else done = Standard_False;
1260 return;
1261 }
1262 else
1263 {
1264 Handle(Adaptor3d_HSurface) nS1 = S1;
1265 Handle(Adaptor3d_HSurface) nS2 = S2;
1266 FUN_TrimBothSurf(S1,typs1,S2,typs2,1.e+5,nS1,nS2);
1267 interip.Perform(nS1,D1,nS2,D2,myTolArc,myTolTang,myFleche,myUVMaxStep);
1268 }
1269 }
1270 else interip.Perform(S1,D1,S2,D2,myTolArc,myTolTang,myFleche,myUVMaxStep);
1271// IntPatch_ImpPrmIntersection interip(S1,D1,S2,D2,myTolArc,myTolTang,myFleche,myUVMaxStep);
1272 if (interip.IsDone())
1273 {
1274 done = Standard_True;
1275 empt = interip.IsEmpty();
1276 if (!empt)
1277 {
1278 for(i = 1; i <= interip.NbLines(); i++)
1279 {
1280 if(interip.Line(i)->ArcType() != IntPatch_Walking) slin.Append(interip.Line(i));
1281 }
1282 for(i = 1; i <= interip.NbLines(); i++)
1283 {
1284 if(interip.Line(i)->ArcType() == IntPatch_Walking) slin.Append(interip.Line(i));
1285 }
1286 for (i = 1; i <= interip.NbPnts(); i++) spnt.Append(interip.Point(i));
1287 }
1288 }
1289 }
1290 // Param - Param
1291 if(ts1 == ts2 && ts1 == 0)
1292 {
1293 //cout << "PP" << endl;
1294prm:; // this algorithm was modified last by OFV [29-Oct-2001] -> [2-Nov-2001]
1295 IntPatch_PrmPrmIntersection interpp;
1296 if(!D1->DomainIsInfinite() && !D2->DomainIsInfinite())
1297 {
1298 // modified by NIZHNY-AMV Tue Oct 18 12:37:02 2005.BEGIN
1299 Standard_Boolean ClearFlag = Standard_True;
1300 if(!ListOfPnts.IsEmpty()){
1301 interpp.Perform(S1,D1,S2,D2,TolArc,TolTang,myFleche,myUVMaxStep, ListOfPnts, RestrictLine);
1302 ClearFlag = Standard_False;
1303 }
1304 // modified by NIZHNY-AMV Tue Oct 18 12:37:02 2005.END
1305 interpp.Perform(S1,D1,S2,D2,TolArc,TolTang,myFleche,myUVMaxStep,ClearFlag);
1306 goto met;
1307 }
1308 else if( (!D1->DomainIsInfinite() && D2->DomainIsInfinite()) || (D1->DomainIsInfinite() && !D2->DomainIsInfinite()) )
1309 {
1310 gp_Pnt pMaxXYZ, pMinXYZ;
1311 if(D1->DomainIsInfinite())
1312 {
1313 FUN_GetMinMaxXYZPnt( S2, pMinXYZ, pMaxXYZ );
1314 const Standard_Real MU = Max(Abs(S2->FirstUParameter()),Abs(S2->LastUParameter()));
1315 const Standard_Real MV = Max(Abs(S2->FirstVParameter()),Abs(S2->LastVParameter()));
1316 const Standard_Real AP = Max(MU, MV);
1317 Handle(Adaptor3d_HSurface) SS;
1318 FUN_TrimInfSurf(pMinXYZ, pMaxXYZ, S1, AP, SS);
1319 interpp.Perform(SS,D1,S2,D2,TolArc,TolTang,myFleche,myUVMaxStep);
1320 }
1321 else
1322 {
1323 FUN_GetMinMaxXYZPnt( S1, pMinXYZ, pMaxXYZ );
1324 const Standard_Real MU = Max(Abs(S1->FirstUParameter()),Abs(S1->LastUParameter()));
1325 const Standard_Real MV = Max(Abs(S1->FirstVParameter()),Abs(S1->LastVParameter()));
1326 const Standard_Real AP = Max(MU, MV);
1327 Handle(Adaptor3d_HSurface) SS;
1328 FUN_TrimInfSurf(pMinXYZ, pMaxXYZ, S2, AP, SS);
1329 interpp.Perform(S1,D1,SS,D2,TolArc,TolTang,myFleche,myUVMaxStep);
1330 }
1331 goto met;
1332 }//(!D1->DomainIsInfinite() && D2->DomainIsInfinite()) || (D1->DomainIsInfinite() && !D2->DomainIsInfinite())
1333 else
1334 {
1335 if(typs1 == GeomAbs_OtherSurface || typs2 == GeomAbs_OtherSurface){ done = Standard_False; return; }
1336 Standard_Boolean IsPLInt = Standard_False;
1337 TColgp_SequenceOfPnt sop;
1338 gp_Vec v;
1339 FUN_PL_Intersection(S1,typs1,S2,typs2,IsPLInt,sop,v);
1340 if(IsPLInt)
1341 {
1342 if(sop.Length() > 0)
1343 {
1344 for(Standard_Integer ip = 1; ip <= sop.Length(); ip++)
1345 {
1346 gp_Lin lin(sop.Value(ip),gp_Dir(v));
1347 Handle(IntPatch_GLine) gl = new IntPatch_GLine(lin,Standard_False);
1348 slin.Append(*(Handle_IntPatch_Line *)&gl);
1349 }
1350 done = Standard_True;
1351 }
1352 else done = Standard_False;
1353 return;
1354 } // 'COLLINEAR LINES'
1355 else
1356 {
1357 Handle(Adaptor3d_HSurface) nS1 = S1;
1358 Handle(Adaptor3d_HSurface) nS2 = S2;
1359 FUN_TrimBothSurf(S1,typs1,S2,typs2,1.e+8,nS1,nS2);
1360 interpp.Perform(nS1,D1,nS2,D2,TolArc,TolTang,myFleche,myUVMaxStep);
1361 goto met;
1362 }// 'NON - COLLINEAR LINES'
1363 }// both domains are infinite
1364met: if (interpp.IsDone())
1365 {
1366 done = Standard_True;
1367 tgte = Standard_False;
1368 empt = interpp.IsEmpty();
1369 for(i=1; i <= interpp.NbLines(); i++)
1370 {
1371 if(interpp.Line(i)->ArcType() != IntPatch_Walking) slin.Append(interpp.Line(i));
1372 }
1373 for (i=1; i <= interpp.NbLines(); i++)
1374 {
1375 if(interpp.Line(i)->ArcType() == IntPatch_Walking) slin.Append(interpp.Line(i));
1376 }
1377 }
1378 }
1379}
1380
1381void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& S1,
1382 const Handle(Adaptor3d_TopolTool)& D1,
1383 const Handle(Adaptor3d_HSurface)& S2,
1384 const Handle(Adaptor3d_TopolTool)& D2,
1385 const Standard_Real U1,
1386 const Standard_Real V1,
1387 const Standard_Real U2,
1388 const Standard_Real V2,
1389 const Standard_Real TolArc,
1390 const Standard_Real TolTang)
1391{
1392 myTolArc = TolArc;
1393 myTolTang = TolTang;
1394 if(myFleche == 0.0) {
1395#if DEBUG
1396 //cout<<" -- IntPatch_Intersection::myFleche fixe par defaut a 0.01 --"<<endl;
1397 //cout<<" -- Utiliser la Methode SetTolerances( ... ) "<<endl;
1398#endif
1399 myFleche = 0.01;
1400 }
1401 if(myUVMaxStep==0.0) {
1402#if DEBUG
1403 //cout<<" -- IntPatch_Intersection::myUVMaxStep fixe par defaut a 0.01 --"<<endl;
1404 //cout<<" -- Utiliser la Methode SetTolerances( ... ) "<<endl;
1405#endif
1406 myUVMaxStep = 0.01;
1407 }
1408
1409 done = Standard_False;
1410 spnt.Clear();
1411 slin.Clear();
1412
1413 empt = Standard_True;
1414 tgte = Standard_False;
1415 oppo = Standard_False;
1416
1417 const GeomAbs_SurfaceType typs1 = S1->GetType();
1418 const GeomAbs_SurfaceType typs2 = S2->GetType();
1419
1420 if( typs1==GeomAbs_Plane
1421 || typs1==GeomAbs_Cylinder
1422 || typs1==GeomAbs_Sphere
1423 || typs1==GeomAbs_Cone
1424 || typs2==GeomAbs_Plane
1425 || typs2==GeomAbs_Cylinder
1426 || typs2==GeomAbs_Sphere
1427 || typs2==GeomAbs_Cone)
1428 {
1429 myIsStartPnt = Standard_True;
1430 myU1Start = U1; myV1Start = V1; myU2Start = U2; myV2Start = V2;
1431 Perform(S1,D1,S2,D2,TolArc,TolTang);
1432 myIsStartPnt = Standard_False;
1433 }
1434 else
1435 {
1436 IntPatch_PrmPrmIntersection interpp;
1437 interpp.Perform(S1,D1,S2,D2,U1,V1,U2,V2,TolArc,TolTang,myFleche,myUVMaxStep);
1438 if (interpp.IsDone())
1439 {
1440 done = Standard_True;
1441 tgte = Standard_False;
1442 empt = interpp.IsEmpty();
1443 const Standard_Integer nblm = interpp.NbLines();
1444 Standard_Integer i = 1;
1445 for (; i<=nblm; i++) slin.Append(interpp.Line(i));
1446 }
1447 }
1448}
1449//======================================================================
1450#include <IntPatch_IType.hxx>
1451#include <IntPatch_LineConstructor.hxx>
1452#include <Handle_Adaptor2d_HCurve2d.hxx>
1453#define MAXR 200
1454
1455
1456//void IntPatch_Intersection__MAJ_R(Handle_Adaptor2d_HCurve2d *R1,
1457// Handle_Adaptor2d_HCurve2d *R2,
1458// int *NR1,
1459// int *NR2,
1460// Standard_Integer nbR1,
1461// Standard_Integer nbR2,
1462// const IntPatch_Point& VTX)
1463void IntPatch_Intersection__MAJ_R(Handle_Adaptor2d_HCurve2d *,
1464 Handle_Adaptor2d_HCurve2d *,
1465 int *,
1466 int *,
1467 Standard_Integer ,
1468 Standard_Integer ,
1469 const IntPatch_Point& )
1470{
1471 /*
1472 if(VTX.IsOnDomS1()) {
1473
1474 //-- long unsigned ptr= *((long unsigned *)(((Handle_Standard_Transient *)(&(VTX.ArcOnS1())))));
1475 for(Standard_Integer i=0; i<nbR1;i++) {
1476 if(VTX.ArcOnS1()==R1[i]) {
1477 NR1[i]++;
1478 printf("\n ******************************");
1479 return;
1480 }
1481 }
1482 printf("\n R Pas trouvee (IntPatch)\n");
1483
1484 }
1485 */
1486}
1487
1488
1489//void IntPatch_Intersection::Dump(const Standard_Integer Mode,
1490void IntPatch_Intersection::Dump(const Standard_Integer ,
1491 const Handle(Adaptor3d_HSurface)& S1,
1492 const Handle(Adaptor3d_TopolTool)& D1,
1493 const Handle(Adaptor3d_HSurface)& S2,
1494 const Handle(Adaptor3d_TopolTool)& D2) const
1495{
1496
1497 //-- ----------------------------------------------------------------------
1498 //-- construction de la liste des restrictions & vertex
1499 //--
1500 int NR1[MAXR],NR2[MAXR];
1501 Handle_Adaptor2d_HCurve2d R1[MAXR],R2[MAXR];
1502 Standard_Integer nbR1=0,nbR2=0;
1503 for(D1->Init();D1->More() && nbR1<MAXR; D1->Next()) {
1504 R1[nbR1]=D1->Value();
1505 NR1[nbR1]=0;
1506 nbR1++;
1507 }
1508 for(D2->Init();D2->More() && nbR2<MAXR; D2->Next()) {
1509 R2[nbR2]=D2->Value();
1510 NR2[nbR2]=0;
1511 nbR2++;
1512 }
1513
1514 printf("\nDUMP_INT: ----empt:%2d tgte:%2d oppo:%2d ---------------------------------",empt,tgte,empt);
1515 Standard_Integer i,j,nbr1,nbr2,nbgl,nbgc,nbge,nbgp,nbgh,nbl,nbr,nbg,nbw,nba;
1516 nbl=nbr=nbg=nbw=nba=nbgl=nbge=nbr1=nbr2=nbgc=nbgp=nbgh=0;
1517 nbl=NbLines();
1518 for(i=1;i<=nbl;i++) {
1519 const Handle(IntPatch_Line)& line=Line(i);
1520 const IntPatch_IType IType=line->ArcType();
1521 if(IType == IntPatch_Walking) nbw++;
1522 else if(IType == IntPatch_Restriction) {
1523 nbr++;
1524 Handle(IntPatch_RLine)& rlin =
1525 *((Handle(IntPatch_RLine) *)&line);
1526 if(rlin->IsArcOnS1()) nbr1++;
1527 if(rlin->IsArcOnS2()) nbr2++;
1528 }
1529 else if(IType == IntPatch_Analytic) nba++;
1530 else { nbg++;
1531 if(IType == IntPatch_Lin) nbgl++;
1532 else if(IType == IntPatch_Circle) nbgc++;
1533 else if(IType == IntPatch_Parabola) nbgp++;
1534 else if(IType == IntPatch_Hyperbola) nbgh++;
1535 else if(IType == IntPatch_Ellipse) nbge++;
1536 }
1537 }
1538
1539
1540 printf("\nDUMP_INT:Lines:%2d Wlin:%2d Restr:%2d(On1:%2d On2:%2d) Ana:%2d Geom:%2d(L:%2d C:%2d E:%2d H:%2d P:%2d)",
1541 nbl,nbw,nbr,nbr1,nbr2,nba,nbg,nbgl,nbgc,nbge,nbgh,nbgp);
1542
1543 IntPatch_LineConstructor LineConstructor(2);
1544
1545 Standard_Integer nbllc=0;
1546 nbw=nbr=nbg=nba=0;
1547 Standard_Integer nbva,nbvw,nbvr,nbvg;
1548 nbva=nbvr=nbvw=nbvg=0;
1549 for (j=1; j<=nbl; j++) {
1550 Standard_Integer v,nbvtx;
1551 const Handle(IntPatch_Line)& intersLinej = Line(j);
1552 Standard_Integer NbLines;
1553 LineConstructor.Perform(SequenceOfLine(),intersLinej,S1,D1,S2,D2,1e-7);
1554 NbLines = LineConstructor.NbLines();
1555
1556 for(Standard_Integer k=1;k<=NbLines;k++) {
1557 nbllc++;
1558 const Handle(IntPatch_Line)& LineK = LineConstructor.Line(k);
1559 if (LineK->ArcType() == IntPatch_Analytic) {
1560 Handle(IntPatch_ALine)& alin =
1561 *((Handle(IntPatch_ALine) *)&LineK);
1562 nbvtx=alin->NbVertex();
1563 nbva+=nbvtx; nba++;
1564 for(v=1;v<=nbvtx;v++) {
1565 IntPatch_Intersection__MAJ_R(R1,R2,NR1,NR2,nbR1,nbR2,alin->Vertex(v));
1566 }
1567 }
1568 else if (LineK->ArcType() == IntPatch_Restriction) {
1569 Handle(IntPatch_RLine)& rlin =
1570 *((Handle(IntPatch_RLine) *)&LineK);
1571 nbvtx=rlin->NbVertex();
1572 nbvr+=nbvtx; nbr++;
1573 for(v=1;v<=nbvtx;v++) {
1574 IntPatch_Intersection__MAJ_R(R1,R2,NR1,NR2,nbR1,nbR2,rlin->Vertex(v));
1575 }
1576 }
1577 else if (LineK->ArcType() == IntPatch_Walking) {
1578 Handle(IntPatch_WLine)& wlin =
1579 *((Handle(IntPatch_WLine) *)&LineK);
1580 nbvtx=wlin->NbVertex();
1581 nbvw+=nbvtx; nbw++;
1582 for(v=1;v<=nbvtx;v++) {
1583 IntPatch_Intersection__MAJ_R(R1,R2,NR1,NR2,nbR1,nbR2,wlin->Vertex(v));
1584 }
1585 }
1586 else {
1587 Handle(IntPatch_GLine)& glin =
1588 *((Handle(IntPatch_GLine) *)&LineK);
1589 nbvtx=glin->NbVertex();
1590 nbvg+=nbvtx; nbg++;
1591 for(v=1;v<=nbvtx;v++) {
1592 IntPatch_Intersection__MAJ_R(R1,R2,NR1,NR2,nbR1,nbR2,glin->Vertex(v));
1593 }
1594 }
1595 }
1596 }
1597 printf("\nDUMP_LC :Lines:%2d WLin:%2d Restr:%2d Ana:%2d Geom:%2d",
1598 nbllc,nbw,nbr,nba,nbg);
1599 printf("\nDUMP_LC :vtx :%2d r:%2d :%2d :%2d",
1600 nbvw,nbvr,nbva,nbvg);
1601
1602
1603
1604 printf("\n");
1605}