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 |
788cbaf4 |
35 | static const Standard_Integer aNbPointsInALine = 200; |
7fd59977 |
36 | |
37 | //====================================================================== |
38 | // function: SequenceOfLine |
39 | //====================================================================== |
40 | const IntPatch_SequenceOfLine& IntPatch_Intersection::SequenceOfLine() const { return(slin); } |
41 | |
42 | //====================================================================== |
43 | // function: IntPatch_Intersection |
44 | //====================================================================== |
45 | IntPatch_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 | //====================================================================== |
58 | IntPatch_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 | //====================================================================== |
81 | IntPatch_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 | //====================================================================== |
98 | void 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 | //====================================================================== |
120 | void 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 | //=============================================================== |
197 | static 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 | //========================================================================== |
221 | static 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 | //================================================================================ |
290 | static 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 | //================================================================================ |
360 | static 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 | //================================================================================ |
430 | static 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 | //================================================================================ |
571 | static 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 | //================================================================================ |
636 | static 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 | //======================================================================= |
788cbaf4 |
711 | void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& theS1, |
712 | const Handle(Adaptor3d_TopolTool)& theD1, |
713 | const Handle(Adaptor3d_HSurface)& theS2, |
714 | const Handle(Adaptor3d_TopolTool)& theD2, |
7fd59977 |
715 | const Standard_Real TolArc, |
788cbaf4 |
716 | const Standard_Real TolTang, |
717 | const Standard_Boolean isGeomInt) |
718 | { |
7fd59977 |
719 | myTolArc = TolArc; |
720 | myTolTang = TolTang; |
788cbaf4 |
721 | if(myFleche <= Precision::PConfusion()) |
722 | myFleche = 0.01; |
723 | if(myUVMaxStep <= Precision::PConfusion()) |
724 | myUVMaxStep = 0.01; |
725 | |
7fd59977 |
726 | done = Standard_False; |
727 | spnt.Clear(); |
728 | slin.Clear(); |
729 | empt = Standard_True; |
730 | tgte = Standard_False; |
731 | oppo = Standard_False; |
732 | |
788cbaf4 |
733 | GeomAbs_SurfaceType typs1 = theS1->GetType(); |
734 | GeomAbs_SurfaceType typs2 = theS2->GetType(); |
7fd59977 |
735 | |
736 | Standard_Boolean TreatAsBiParametric = Standard_False; |
788cbaf4 |
737 | if(typs1 == GeomAbs_Cone) |
738 | { |
739 | const gp_Cone Con1 = theS1->Cone(); |
740 | const Standard_Real a1 = Abs(Con1.SemiAngle()); |
741 | if((a1 < 0.02) || (a1 > 1.55)) |
742 | { |
743 | if(typs2==GeomAbs_Plane) |
744 | { |
745 | if(a1 < 0.02) |
746 | { |
747 | const gp_Pln Plan2 = theS2->Plane(); |
748 | const gp_Dir axec = Con1.Axis().Direction(); |
749 | const gp_Dir axep = Plan2.Axis().Direction(); |
750 | const Standard_Real ps = Abs(axec.Dot(axep)); |
751 | if(ps < 0.015) |
752 | { |
753 | TreatAsBiParametric = Standard_True; |
754 | } |
755 | } |
7fd59977 |
756 | } |
788cbaf4 |
757 | else |
758 | TreatAsBiParametric = Standard_True; |
7fd59977 |
759 | } |
760 | } |
788cbaf4 |
761 | |
762 | if(typs2 == GeomAbs_Cone) |
763 | { |
764 | const gp_Cone Con2 = theS2->Cone(); |
765 | const Standard_Real a2 = Abs(Con2.SemiAngle()); |
766 | if((a2 < 0.02) || (a2 > 1.55)) |
767 | { |
768 | if(typs1 == GeomAbs_Plane) |
769 | { |
770 | if(a2 < 0.02) |
771 | { |
772 | const gp_Pln Plan1 = theS1->Plane(); |
773 | const gp_Dir axec = Con2.Axis().Direction(); |
774 | const gp_Dir axep = Plan1.Axis().Direction(); |
775 | const Standard_Real ps = Abs(axec.Dot(axep)); |
776 | if(ps<0.015) |
777 | { |
778 | TreatAsBiParametric = Standard_True; |
779 | } |
780 | } |
7fd59977 |
781 | } |
788cbaf4 |
782 | else |
783 | TreatAsBiParametric = Standard_True; |
7fd59977 |
784 | } |
788cbaf4 |
785 | |
7fd59977 |
786 | //// modified by jgv, 15.12.02 for OCC565 //// |
b92a64cc |
787 | if (typs1 == GeomAbs_Cone && TreatAsBiParametric) |
788cbaf4 |
788 | { |
789 | const gp_Cone Con1 = theS1->Cone(); |
790 | const Standard_Real a1 = Abs(Con1.SemiAngle()); |
b92a64cc |
791 | //if collinear, treat as canonical |
792 | const gp_Ax1 A1 = Con1.Axis(), A2 = Con2.Axis(); |
793 | const gp_Lin L1(A1); |
794 | if (A1.IsParallel(A2,Precision::Angular()) && |
795 | (L1.Distance(A2.Location()) <= Precision::Confusion())) |
788cbaf4 |
796 | { |
b92a64cc |
797 | TreatAsBiParametric = Standard_False; |
7fd59977 |
798 | } |
788cbaf4 |
799 | else if (a1 > 1.55 && a2 > 1.55) //quasi-planes: if same domain, treat as canonic |
800 | { |
801 | const gp_Ax1 A1 = Con1.Axis(), A2 = Con2.Axis(); |
802 | if (A1.IsParallel(A2,Precision::Angular())) |
803 | { |
804 | const gp_Pnt Apex1 = Con1.Apex(), Apex2 = Con2.Apex(); |
805 | const gp_Pln Plan1( Apex1, A1.Direction() ); |
806 | if (Plan1.Distance( Apex2 ) <= Precision::Confusion()) |
807 | { |
808 | TreatAsBiParametric = Standard_False; |
809 | } |
810 | } |
7fd59977 |
811 | } |
bf0ba813 |
812 | }// if (typs1 == GeomAbs_Cone) { |
813 | }// if(typs2 == GeomAbs_Cone) { |
788cbaf4 |
814 | |
815 | if(theD1->DomainIsInfinite() || theD2->DomainIsInfinite()) { |
bf0ba813 |
816 | TreatAsBiParametric= Standard_False; |
817 | } |
7fd59977 |
818 | |
819 | // Modified by skv - Mon Sep 26 14:58:30 2005 Begin |
820 | // if(TreatAsBiParametric) { typs1 = typs2 = GeomAbs_BezierSurface; } |
788cbaf4 |
821 | if(TreatAsBiParametric) |
822 | { |
7fd59977 |
823 | if (typs1 == GeomAbs_Cone && typs2 == GeomAbs_Plane) |
824 | typs1 = GeomAbs_BezierSurface; // Using Imp-Prm Intersector |
825 | else if (typs1 == GeomAbs_Plane && typs2 == GeomAbs_Cone) |
826 | typs2 = GeomAbs_BezierSurface; // Using Imp-Prm Intersector |
827 | else { |
828 | // Using Prm-Prm Intersector |
829 | typs1 = GeomAbs_BezierSurface; |
830 | typs2 = GeomAbs_BezierSurface; |
831 | } |
832 | } |
833 | // Modified by skv - Mon Sep 26 14:58:30 2005 End |
834 | |
835 | // Surface type definition |
836 | Standard_Integer ts1 = 0; |
837 | switch (typs1) |
838 | { |
839 | case GeomAbs_Plane: |
840 | case GeomAbs_Cylinder: |
841 | case GeomAbs_Sphere: |
842 | case GeomAbs_Cone: ts1 = 1; break; |
843 | default: break; |
844 | } |
788cbaf4 |
845 | |
7fd59977 |
846 | Standard_Integer ts2 = 0; |
847 | switch (typs2) |
848 | { |
849 | case GeomAbs_Plane: |
850 | case GeomAbs_Cylinder: |
851 | case GeomAbs_Sphere: |
852 | case GeomAbs_Cone: ts2 = 1; break; |
853 | default: break; |
854 | } |
788cbaf4 |
855 | |
7fd59977 |
856 | // Possible intersection types: 1. ts1 == ts2 == 1 <Geom-Geom> |
857 | // 2. ts1 != ts2 <Geom-Param> |
858 | // 3. ts1 == ts2 == 0 <Param-Param> |
859 | |
860 | // Geom - Geom |
861 | if(ts1 == ts2 && ts1 == 1) |
862 | { |
788cbaf4 |
863 | const Standard_Boolean RestrictLine = Standard_True; |
864 | IntSurf_ListOfPntOn2S ListOfPnts; |
865 | ListOfPnts.Clear(); |
866 | if(isGeomInt) |
867 | { |
868 | GeomGeomPerfom(theS1, theD1, theS2, theD2, TolArc, TolTang, ListOfPnts, RestrictLine, typs1, typs2); |
869 | } |
870 | else |
871 | { |
872 | ParamParamPerfom(theS1, theD1, theS2, theD2, TolArc, TolTang, ListOfPnts, RestrictLine, typs1, typs2); |
873 | } |
7fd59977 |
874 | } |
788cbaf4 |
875 | |
7fd59977 |
876 | // Geom - Param |
877 | if(ts1 != ts2) |
878 | { |
788cbaf4 |
879 | GeomParamPerfom(theS1, theD1, theS2, theD2, ts1 == 0, typs1, typs2); |
7fd59977 |
880 | } |
788cbaf4 |
881 | |
7fd59977 |
882 | // Param - Param |
883 | if(ts1 == ts2 && ts1 == 0) |
884 | { |
788cbaf4 |
885 | const Standard_Boolean RestrictLine = Standard_True; |
886 | IntSurf_ListOfPntOn2S ListOfPnts; |
887 | ListOfPnts.Clear(); |
888 | |
889 | ParamParamPerfom(theS1, theD1, theS2, theD2, TolArc, TolTang, ListOfPnts, RestrictLine, typs1, typs2); |
7fd59977 |
890 | } |
891 | } |
892 | |
893 | //======================================================================= |
894 | //function : Perform |
895 | //purpose : |
896 | //======================================================================= |
788cbaf4 |
897 | void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& theS1, |
898 | const Handle(Adaptor3d_TopolTool)& theD1, |
899 | const Handle(Adaptor3d_HSurface)& theS2, |
900 | const Handle(Adaptor3d_TopolTool)& theD2, |
7fd59977 |
901 | const Standard_Real TolArc, |
902 | const Standard_Real TolTang, |
903 | IntSurf_ListOfPntOn2S& ListOfPnts, |
788cbaf4 |
904 | const Standard_Boolean RestrictLine, |
905 | const Standard_Boolean isGeomInt) |
7fd59977 |
906 | { |
907 | myTolArc = TolArc; |
908 | myTolTang = TolTang; |
788cbaf4 |
909 | if(myFleche <= Precision::PConfusion()) |
910 | myFleche = 0.01; |
911 | if(myUVMaxStep <= Precision::PConfusion()) |
912 | myUVMaxStep = 0.01; |
7fd59977 |
913 | |
914 | done = Standard_False; |
915 | spnt.Clear(); |
916 | slin.Clear(); |
917 | empt = Standard_True; |
918 | tgte = Standard_False; |
919 | oppo = Standard_False; |
920 | |
788cbaf4 |
921 | GeomAbs_SurfaceType typs1 = theS1->GetType(); |
922 | GeomAbs_SurfaceType typs2 = theS2->GetType(); |
7fd59977 |
923 | |
924 | Standard_Boolean TreatAsBiParametric = Standard_False; |
788cbaf4 |
925 | if(typs1 == GeomAbs_Cone) |
926 | { |
927 | const gp_Cone Con1 = theS1->Cone(); |
928 | const Standard_Real a1 = Abs(Con1.SemiAngle()); |
929 | if((a1 < 0.02) || (a1 > 1.55)) |
930 | { |
931 | if(typs2==GeomAbs_Plane) |
932 | { |
933 | if(a1 < 0.02) |
934 | { |
935 | const gp_Pln Plan2 = theS2->Plane(); |
936 | const gp_Dir axec = Con1.Axis().Direction(); |
937 | const gp_Dir axep = Plan2.Axis().Direction(); |
938 | const Standard_Real ps = Abs(axec.Dot(axep)); |
939 | if(ps < 0.015) |
940 | { |
941 | TreatAsBiParametric = Standard_True; |
942 | } |
943 | } |
7fd59977 |
944 | } |
788cbaf4 |
945 | else |
946 | TreatAsBiParametric = Standard_True; |
947 | } |
948 | } |
949 | |
950 | if(typs2 == GeomAbs_Cone) |
951 | { |
952 | const gp_Cone Con2 = theS2->Cone(); |
953 | const Standard_Real a2 = Abs(Con2.SemiAngle()); |
954 | if((a2 < 0.02) || (a2 > 1.55)) |
955 | { |
956 | if(typs1 == GeomAbs_Plane) |
957 | { |
958 | if(a2 < 0.02) |
959 | { |
960 | const gp_Pln Plan1 = theS1->Plane(); |
961 | const gp_Dir axec = Con2.Axis().Direction(); |
962 | const gp_Dir axep = Plan1.Axis().Direction(); |
963 | const Standard_Real ps = Abs(axec.Dot(axep)); |
964 | if(ps<0.015) |
965 | { |
966 | TreatAsBiParametric = Standard_True; |
967 | } |
968 | } |
7fd59977 |
969 | } |
788cbaf4 |
970 | else |
971 | TreatAsBiParametric = Standard_True; |
7fd59977 |
972 | } |
788cbaf4 |
973 | |
974 | //// modified by jgv, 15.12.02 for OCC565 //// |
b92a64cc |
975 | if (typs1 == GeomAbs_Cone && TreatAsBiParametric) |
788cbaf4 |
976 | { |
977 | const gp_Cone Con1 = theS1->Cone(); |
978 | const Standard_Real a1 = Abs(Con1.SemiAngle()); |
b92a64cc |
979 | //if collinear, treat as canonical |
980 | const gp_Ax1 A1 = Con1.Axis(), A2 = Con2.Axis(); |
981 | const gp_Lin L1(A1); |
982 | if (A1.IsParallel(A2,Precision::Angular()) && |
983 | (L1.Distance(A2.Location()) <= Precision::Confusion())) |
788cbaf4 |
984 | { |
b92a64cc |
985 | TreatAsBiParametric = Standard_False; |
7fd59977 |
986 | } |
788cbaf4 |
987 | else if (a1 > 1.55 && a2 > 1.55) //quasi-planes: if same domain, treat as canonic |
988 | { |
989 | const gp_Ax1 A1 = Con1.Axis(), A2 = Con2.Axis(); |
990 | if (A1.IsParallel(A2,Precision::Angular())) |
991 | { |
992 | const gp_Pnt Apex1 = Con1.Apex(), Apex2 = Con2.Apex(); |
993 | const gp_Pln Plan1( Apex1, A1.Direction() ); |
994 | if (Plan1.Distance( Apex2 ) <= Precision::Confusion()) |
995 | { |
996 | TreatAsBiParametric = Standard_False; |
997 | } |
998 | } |
7fd59977 |
999 | } |
788cbaf4 |
1000 | }// if (typs1 == GeomAbs_Cone) { |
1001 | }// if(typs2 == GeomAbs_Cone) { |
7fd59977 |
1002 | |
788cbaf4 |
1003 | if(theD1->DomainIsInfinite() || theD2->DomainIsInfinite()) { |
bf0ba813 |
1004 | TreatAsBiParametric= Standard_False; |
1005 | } |
788cbaf4 |
1006 | |
1007 | if(TreatAsBiParametric) |
1008 | { |
1009 | // Using Prm-Prm Intersector |
1010 | typs1 = GeomAbs_BezierSurface; |
1011 | typs2 = GeomAbs_BezierSurface; |
bf0ba813 |
1012 | } |
7fd59977 |
1013 | |
1014 | // Surface type definition |
1015 | Standard_Integer ts1 = 0; |
1016 | switch (typs1) |
1017 | { |
1018 | case GeomAbs_Plane: |
1019 | case GeomAbs_Cylinder: |
1020 | case GeomAbs_Sphere: |
1021 | case GeomAbs_Cone: ts1 = 1; break; |
1022 | default: break; |
1023 | } |
788cbaf4 |
1024 | |
7fd59977 |
1025 | Standard_Integer ts2 = 0; |
1026 | switch (typs2) |
1027 | { |
1028 | case GeomAbs_Plane: |
1029 | case GeomAbs_Cylinder: |
1030 | case GeomAbs_Sphere: |
1031 | case GeomAbs_Cone: ts2 = 1; break; |
1032 | default: break; |
1033 | } |
788cbaf4 |
1034 | |
7fd59977 |
1035 | // Possible intersection types: 1. ts1 == ts2 == 1 <Geom-Geom> |
1036 | // 2. ts1 != ts2 <Geom-Param> |
1037 | // 3. ts1 == ts2 == 0 <Param-Param> |
1038 | |
788cbaf4 |
1039 | if(!isGeomInt) |
7fd59977 |
1040 | { |
788cbaf4 |
1041 | ParamParamPerfom(theS1, theD1, theS2, theD2, TolArc, TolTang, ListOfPnts, RestrictLine, typs1, typs2); |
7fd59977 |
1042 | } |
788cbaf4 |
1043 | else if(ts1 != ts2) |
1044 | { |
1045 | GeomParamPerfom(theS1, theD1, theS2, theD2, ts1 == 0, typs1, typs2); |
1046 | } |
1047 | else if (ts1 == 0) |
1048 | { |
1049 | ParamParamPerfom(theS1, theD1, theS2, theD2, TolArc, TolTang, ListOfPnts, RestrictLine, typs1, typs2); |
1050 | } |
1051 | else if(ts1 == 1) |
1052 | { |
1053 | GeomGeomPerfom(theS1, theD1, theS2, theD2, TolArc, TolTang, ListOfPnts, RestrictLine, typs1, typs2); |
1054 | } |
1055 | } |
1056 | |
1057 | //======================================================================= |
1058 | //function : ParamParamPerfom |
1059 | //purpose : |
1060 | //======================================================================= |
1061 | void IntPatch_Intersection::ParamParamPerfom(const Handle(Adaptor3d_HSurface)& theS1, |
1062 | const Handle(Adaptor3d_TopolTool)& theD1, |
1063 | const Handle(Adaptor3d_HSurface)& theS2, |
1064 | const Handle(Adaptor3d_TopolTool)& theD2, |
1065 | const Standard_Real TolArc, |
1066 | const Standard_Real TolTang, |
1067 | IntSurf_ListOfPntOn2S& ListOfPnts, |
1068 | const Standard_Boolean RestrictLine, |
1069 | const GeomAbs_SurfaceType typs1, |
1070 | const GeomAbs_SurfaceType typs2) |
1071 | { |
1072 | IntPatch_PrmPrmIntersection interpp; |
1073 | if(!theD1->DomainIsInfinite() && !theD2->DomainIsInfinite()) |
7fd59977 |
1074 | { |
788cbaf4 |
1075 | Standard_Boolean ClearFlag = Standard_True; |
1076 | if(!ListOfPnts.IsEmpty()) |
1077 | { |
1078 | interpp.Perform(theS1,theD1,theS2,theD2,TolArc,TolTang,myFleche,myUVMaxStep, ListOfPnts, RestrictLine); |
1079 | ClearFlag = Standard_False; |
7fd59977 |
1080 | } |
788cbaf4 |
1081 | interpp.Perform(theS1,theD1,theS2,theD2,TolArc,TolTang,myFleche,myUVMaxStep,ClearFlag); //double call!!!!!!! |
7fd59977 |
1082 | } |
788cbaf4 |
1083 | else if((theD1->DomainIsInfinite()) ^ (theD2->DomainIsInfinite())) |
7fd59977 |
1084 | { |
788cbaf4 |
1085 | gp_Pnt pMaxXYZ, pMinXYZ; |
1086 | if(theD1->DomainIsInfinite()) |
1087 | { |
1088 | FUN_GetMinMaxXYZPnt( theS2, pMinXYZ, pMaxXYZ ); |
1089 | const Standard_Real MU = Max(Abs(theS2->FirstUParameter()),Abs(theS2->LastUParameter())); |
1090 | const Standard_Real MV = Max(Abs(theS2->FirstVParameter()),Abs(theS2->LastVParameter())); |
1091 | const Standard_Real AP = Max(MU, MV); |
1092 | Handle(Adaptor3d_HSurface) SS; |
1093 | FUN_TrimInfSurf(pMinXYZ, pMaxXYZ, theS1, AP, SS); |
1094 | interpp.Perform(SS,theD1,theS2,theD2,TolArc,TolTang,myFleche,myUVMaxStep); |
1095 | } |
1096 | else |
1097 | { |
1098 | FUN_GetMinMaxXYZPnt( theS1, pMinXYZ, pMaxXYZ ); |
1099 | const Standard_Real MU = Max(Abs(theS1->FirstUParameter()),Abs(theS1->LastUParameter())); |
1100 | const Standard_Real MV = Max(Abs(theS1->FirstVParameter()),Abs(theS1->LastVParameter())); |
1101 | const Standard_Real AP = Max(MU, MV); |
1102 | Handle(Adaptor3d_HSurface) SS; |
1103 | FUN_TrimInfSurf(pMinXYZ, pMaxXYZ, theS2, AP, SS); |
1104 | interpp.Perform(theS1, theD1, SS, theD2,TolArc,TolTang,myFleche,myUVMaxStep); |
1105 | } |
1106 | }//(theD1->DomainIsInfinite()) ^ (theD2->DomainIsInfinite()) |
1107 | else |
1108 | { |
1109 | if(typs1 == GeomAbs_OtherSurface || typs2 == GeomAbs_OtherSurface) |
1110 | { |
1111 | done = Standard_False; |
1112 | return; |
1113 | } |
1114 | |
1115 | Standard_Boolean IsPLInt = Standard_False; |
1116 | TColgp_SequenceOfPnt sop; |
1117 | gp_Vec v; |
1118 | FUN_PL_Intersection(theS1,typs1,theS2,typs2,IsPLInt,sop,v); |
1119 | |
1120 | if(IsPLInt) |
1121 | { |
1122 | if(sop.Length() > 0) |
1123 | { |
1124 | for(Standard_Integer ip = 1; ip <= sop.Length(); ip++) |
1125 | { |
1126 | gp_Lin lin(sop.Value(ip),gp_Dir(v)); |
1127 | Handle(IntPatch_GLine) gl = new IntPatch_GLine(lin,Standard_False); |
1128 | slin.Append(*(Handle_IntPatch_Line *)&gl); |
1129 | } |
1130 | |
1131 | done = Standard_True; |
7fd59977 |
1132 | } |
788cbaf4 |
1133 | else |
1134 | done = Standard_False; |
1135 | |
1136 | return; |
1137 | }// 'COLLINEAR LINES' |
1138 | else |
1139 | { |
1140 | Handle(Adaptor3d_HSurface) nS1 = theS1; |
1141 | Handle(Adaptor3d_HSurface) nS2 = theS2; |
1142 | FUN_TrimBothSurf(theS1,typs1,theS2,typs2,1.e+8,nS1,nS2); |
1143 | interpp.Perform(nS1,theD1,nS2,theD2,TolArc,TolTang,myFleche,myUVMaxStep); |
1144 | }// 'NON - COLLINEAR LINES' |
1145 | }// both domains are infinite |
1146 | |
1147 | if (interpp.IsDone()) |
1148 | { |
1149 | done = Standard_True; |
1150 | tgte = Standard_False; |
1151 | empt = interpp.IsEmpty(); |
1152 | |
1153 | for(Standard_Integer i = 1; i <= interpp.NbLines(); i++) |
1154 | { |
1155 | if(interpp.Line(i)->ArcType() != IntPatch_Walking) |
1156 | slin.Append(interpp.Line(i)); |
1157 | } |
1158 | |
1159 | for (Standard_Integer i = 1; i <= interpp.NbLines(); i++) |
1160 | { |
1161 | if(interpp.Line(i)->ArcType() == IntPatch_Walking) |
1162 | slin.Append(interpp.Line(i)); |
1163 | } |
1164 | } |
1165 | } |
1166 | |
1167 | //======================================================================= |
1168 | ////function : GeomGeomPerfom |
1169 | //purpose : |
1170 | //======================================================================= |
1171 | void IntPatch_Intersection::GeomGeomPerfom(const Handle(Adaptor3d_HSurface)& theS1, |
1172 | const Handle(Adaptor3d_TopolTool)& theD1, |
1173 | const Handle(Adaptor3d_HSurface)& theS2, |
1174 | const Handle(Adaptor3d_TopolTool)& theD2, |
1175 | const Standard_Real TolArc, |
1176 | const Standard_Real TolTang, |
1177 | IntSurf_ListOfPntOn2S& ListOfPnts, |
1178 | const Standard_Boolean RestrictLine, |
1179 | const GeomAbs_SurfaceType typs1, |
1180 | const GeomAbs_SurfaceType typs2) |
1181 | { |
1182 | IntPatch_ImpImpIntersection interii(theS1,theD1,theS2,theD2,myTolArc,myTolTang); |
1183 | const Standard_Boolean anIS = interii.IsDone(); |
1184 | if (anIS) |
1185 | { |
1186 | done = anIS; |
1187 | empt = interii.IsEmpty(); |
1188 | if (!empt) |
1189 | { |
1190 | tgte = interii.TangentFaces(); |
1191 | if (tgte) |
1192 | oppo = interii.OppositeFaces(); |
1193 | |
1194 | for (Standard_Integer i = 1; i <= interii.NbLines(); i++) |
1195 | { |
1196 | const Handle_IntPatch_Line& line = interii.Line(i); |
1197 | if (line->ArcType() == IntPatch_Analytic) |
1198 | { |
1199 | const GeomAbs_SurfaceType typs1 = theS1->GetType(); |
1200 | const GeomAbs_SurfaceType typs2 = theS2->GetType(); |
1201 | IntSurf_Quadric Quad1,Quad2; |
1202 | |
1203 | switch(typs1) |
1204 | { |
1205 | case GeomAbs_Plane: |
1206 | Quad1.SetValue(theS1->Plane()); |
1207 | break; |
1208 | |
1209 | case GeomAbs_Cylinder: |
1210 | Quad1.SetValue(theS1->Cylinder()); |
1211 | break; |
1212 | |
1213 | case GeomAbs_Sphere: |
1214 | Quad1.SetValue(theS1->Sphere()); |
1215 | break; |
1216 | |
1217 | case GeomAbs_Cone: |
1218 | Quad1.SetValue(theS1->Cone()); |
1219 | break; |
1220 | |
1221 | default: |
1222 | break; |
1223 | } |
1224 | |
1225 | switch(typs2) |
1226 | { |
1227 | case GeomAbs_Plane: |
1228 | Quad2.SetValue(theS2->Plane()); |
1229 | break; |
1230 | case GeomAbs_Cylinder: |
1231 | Quad2.SetValue(theS2->Cylinder()); |
1232 | break; |
1233 | |
1234 | case GeomAbs_Sphere: |
1235 | Quad2.SetValue(theS2->Sphere()); |
1236 | break; |
1237 | |
1238 | case GeomAbs_Cone: |
1239 | Quad2.SetValue(theS2->Cone()); |
1240 | break; |
1241 | |
1242 | default: |
1243 | break; |
1244 | } |
1245 | |
1246 | IntPatch_ALineToWLine AToW(Quad1,Quad2,0.01,0.05,aNbPointsInALine); |
1247 | Handle(IntPatch_Line) wlin=AToW.MakeWLine((*((Handle_IntPatch_ALine *)(&line)))); |
1248 | slin.Append(wlin); |
1249 | } |
1250 | else |
1251 | slin.Append(interii.Line(i)); |
1252 | } |
1253 | |
1254 | for (Standard_Integer i = 1; i <= interii.NbPnts(); i++) |
1255 | { |
1256 | spnt.Append(interii.Point(i)); |
1257 | } |
1258 | } |
1259 | } |
1260 | else |
1261 | ParamParamPerfom(theS1, theD1, theS2, theD2, TolArc, TolTang, ListOfPnts, RestrictLine, typs1, typs2); |
1262 | } |
1263 | |
1264 | //======================================================================= |
1265 | ////function : GeomParamPerfom |
1266 | //purpose : |
1267 | //======================================================================= |
1268 | void IntPatch_Intersection::GeomParamPerfom(const Handle(Adaptor3d_HSurface)& theS1, |
1269 | const Handle(Adaptor3d_TopolTool)& theD1, |
1270 | const Handle(Adaptor3d_HSurface)& theS2, |
1271 | const Handle(Adaptor3d_TopolTool)& theD2, |
1272 | const Standard_Boolean isNotAnalitical, |
1273 | const GeomAbs_SurfaceType typs1, |
1274 | const GeomAbs_SurfaceType typs2) |
1275 | { |
1276 | IntPatch_ImpPrmIntersection interip; |
1277 | if (myIsStartPnt) |
1278 | { |
1279 | if (isNotAnalitical/*ts1 == 0*/) |
1280 | interip.SetStartPoint(myU1Start,myV1Start); |
1281 | else |
1282 | interip.SetStartPoint(myU2Start,myV2Start); |
1283 | } |
1284 | |
1285 | if(theD1->DomainIsInfinite() && theD2->DomainIsInfinite()) |
1286 | { |
1287 | Standard_Boolean IsPLInt = Standard_False; |
1288 | TColgp_SequenceOfPnt sop; |
1289 | gp_Vec v; |
1290 | FUN_PL_Intersection(theS1,typs1,theS2,typs2,IsPLInt,sop,v); |
1291 | |
1292 | if(IsPLInt) |
1293 | { |
1294 | if(sop.Length() > 0) |
1295 | { |
1296 | for(Standard_Integer ip = 1; ip <= sop.Length(); ip++) |
1297 | { |
1298 | gp_Lin lin(sop.Value(ip),gp_Dir(v)); |
1299 | Handle(IntPatch_GLine) gl = new IntPatch_GLine(lin,Standard_False); |
1300 | slin.Append(*(Handle_IntPatch_Line *)&gl); |
1301 | } |
1302 | |
1303 | done = Standard_True; |
1304 | } |
1305 | else |
1306 | done = Standard_False; |
1307 | |
1308 | return; |
1309 | } |
1310 | else |
1311 | { |
1312 | Handle(Adaptor3d_HSurface) nS1 = theS1; |
1313 | Handle(Adaptor3d_HSurface) nS2 = theS2; |
1314 | FUN_TrimBothSurf(theS1,typs1,theS2,typs2,1.e+5,nS1,nS2); |
1315 | interip.Perform(nS1,theD1,nS2,theD2,myTolArc,myTolTang,myFleche,myUVMaxStep); |
1316 | } |
1317 | } |
1318 | else |
1319 | interip.Perform(theS1,theD1,theS2,theD2,myTolArc,myTolTang,myFleche,myUVMaxStep); |
1320 | |
1321 | if (interip.IsDone()) |
1322 | { |
1323 | done = Standard_True; |
1324 | empt = interip.IsEmpty(); |
1325 | |
1326 | if (!empt) |
1327 | { |
1328 | for(Standard_Integer i = 1; i <= interip.NbLines(); i++) |
1329 | { |
1330 | if(interip.Line(i)->ArcType() != IntPatch_Walking) |
1331 | slin.Append(interip.Line(i)); |
1332 | } |
1333 | |
1334 | for(Standard_Integer i = 1; i <= interip.NbLines(); i++) |
1335 | { |
1336 | if(interip.Line(i)->ArcType() == IntPatch_Walking) |
1337 | slin.Append(interip.Line(i)); |
1338 | } |
1339 | |
1340 | for (Standard_Integer i = 1; i <= interip.NbPnts(); i++) |
1341 | spnt.Append(interip.Point(i)); |
1342 | } |
7fd59977 |
1343 | } |
1344 | } |
1345 | |
788cbaf4 |
1346 | |
7fd59977 |
1347 | void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& S1, |
1348 | const Handle(Adaptor3d_TopolTool)& D1, |
1349 | const Handle(Adaptor3d_HSurface)& S2, |
1350 | const Handle(Adaptor3d_TopolTool)& D2, |
1351 | const Standard_Real U1, |
1352 | const Standard_Real V1, |
1353 | const Standard_Real U2, |
1354 | const Standard_Real V2, |
1355 | const Standard_Real TolArc, |
1356 | const Standard_Real TolTang) |
1357 | { |
1358 | myTolArc = TolArc; |
1359 | myTolTang = TolTang; |
1360 | if(myFleche == 0.0) { |
1361 | #if DEBUG |
1362 | //cout<<" -- IntPatch_Intersection::myFleche fixe par defaut a 0.01 --"<<endl; |
1363 | //cout<<" -- Utiliser la Methode SetTolerances( ... ) "<<endl; |
1364 | #endif |
1365 | myFleche = 0.01; |
1366 | } |
1367 | if(myUVMaxStep==0.0) { |
1368 | #if DEBUG |
1369 | //cout<<" -- IntPatch_Intersection::myUVMaxStep fixe par defaut a 0.01 --"<<endl; |
1370 | //cout<<" -- Utiliser la Methode SetTolerances( ... ) "<<endl; |
1371 | #endif |
1372 | myUVMaxStep = 0.01; |
1373 | } |
1374 | |
1375 | done = Standard_False; |
1376 | spnt.Clear(); |
1377 | slin.Clear(); |
1378 | |
1379 | empt = Standard_True; |
1380 | tgte = Standard_False; |
1381 | oppo = Standard_False; |
1382 | |
1383 | const GeomAbs_SurfaceType typs1 = S1->GetType(); |
1384 | const GeomAbs_SurfaceType typs2 = S2->GetType(); |
1385 | |
1386 | if( typs1==GeomAbs_Plane |
1387 | || typs1==GeomAbs_Cylinder |
1388 | || typs1==GeomAbs_Sphere |
1389 | || typs1==GeomAbs_Cone |
1390 | || typs2==GeomAbs_Plane |
1391 | || typs2==GeomAbs_Cylinder |
1392 | || typs2==GeomAbs_Sphere |
1393 | || typs2==GeomAbs_Cone) |
1394 | { |
1395 | myIsStartPnt = Standard_True; |
1396 | myU1Start = U1; myV1Start = V1; myU2Start = U2; myV2Start = V2; |
1397 | Perform(S1,D1,S2,D2,TolArc,TolTang); |
1398 | myIsStartPnt = Standard_False; |
1399 | } |
1400 | else |
1401 | { |
1402 | IntPatch_PrmPrmIntersection interpp; |
1403 | interpp.Perform(S1,D1,S2,D2,U1,V1,U2,V2,TolArc,TolTang,myFleche,myUVMaxStep); |
1404 | if (interpp.IsDone()) |
1405 | { |
1406 | done = Standard_True; |
1407 | tgte = Standard_False; |
1408 | empt = interpp.IsEmpty(); |
1409 | const Standard_Integer nblm = interpp.NbLines(); |
1410 | Standard_Integer i = 1; |
1411 | for (; i<=nblm; i++) slin.Append(interpp.Line(i)); |
1412 | } |
1413 | } |
1414 | } |
1415 | //====================================================================== |
1416 | #include <IntPatch_IType.hxx> |
1417 | #include <IntPatch_LineConstructor.hxx> |
1418 | #include <Handle_Adaptor2d_HCurve2d.hxx> |
1419 | #define MAXR 200 |
1420 | |
1421 | |
1422 | //void IntPatch_Intersection__MAJ_R(Handle_Adaptor2d_HCurve2d *R1, |
1423 | // Handle_Adaptor2d_HCurve2d *R2, |
1424 | // int *NR1, |
1425 | // int *NR2, |
1426 | // Standard_Integer nbR1, |
1427 | // Standard_Integer nbR2, |
1428 | // const IntPatch_Point& VTX) |
1429 | void IntPatch_Intersection__MAJ_R(Handle_Adaptor2d_HCurve2d *, |
1430 | Handle_Adaptor2d_HCurve2d *, |
1431 | int *, |
1432 | int *, |
1433 | Standard_Integer , |
1434 | Standard_Integer , |
1435 | const IntPatch_Point& ) |
1436 | { |
1437 | /* |
1438 | if(VTX.IsOnDomS1()) { |
1439 | |
1440 | //-- long unsigned ptr= *((long unsigned *)(((Handle_Standard_Transient *)(&(VTX.ArcOnS1()))))); |
1441 | for(Standard_Integer i=0; i<nbR1;i++) { |
1442 | if(VTX.ArcOnS1()==R1[i]) { |
1443 | NR1[i]++; |
1444 | printf("\n ******************************"); |
1445 | return; |
1446 | } |
1447 | } |
1448 | printf("\n R Pas trouvee (IntPatch)\n"); |
1449 | |
1450 | } |
1451 | */ |
1452 | } |
1453 | |
1454 | |
1455 | //void IntPatch_Intersection::Dump(const Standard_Integer Mode, |
1456 | void IntPatch_Intersection::Dump(const Standard_Integer , |
1457 | const Handle(Adaptor3d_HSurface)& S1, |
1458 | const Handle(Adaptor3d_TopolTool)& D1, |
1459 | const Handle(Adaptor3d_HSurface)& S2, |
1460 | const Handle(Adaptor3d_TopolTool)& D2) const |
1461 | { |
1462 | |
1463 | //-- ---------------------------------------------------------------------- |
1464 | //-- construction de la liste des restrictions & vertex |
1465 | //-- |
1466 | int NR1[MAXR],NR2[MAXR]; |
1467 | Handle_Adaptor2d_HCurve2d R1[MAXR],R2[MAXR]; |
1468 | Standard_Integer nbR1=0,nbR2=0; |
1469 | for(D1->Init();D1->More() && nbR1<MAXR; D1->Next()) { |
1470 | R1[nbR1]=D1->Value(); |
1471 | NR1[nbR1]=0; |
1472 | nbR1++; |
1473 | } |
1474 | for(D2->Init();D2->More() && nbR2<MAXR; D2->Next()) { |
1475 | R2[nbR2]=D2->Value(); |
1476 | NR2[nbR2]=0; |
1477 | nbR2++; |
1478 | } |
1479 | |
1480 | printf("\nDUMP_INT: ----empt:%2d tgte:%2d oppo:%2d ---------------------------------",empt,tgte,empt); |
1481 | Standard_Integer i,j,nbr1,nbr2,nbgl,nbgc,nbge,nbgp,nbgh,nbl,nbr,nbg,nbw,nba; |
1482 | nbl=nbr=nbg=nbw=nba=nbgl=nbge=nbr1=nbr2=nbgc=nbgp=nbgh=0; |
1483 | nbl=NbLines(); |
1484 | for(i=1;i<=nbl;i++) { |
1485 | const Handle(IntPatch_Line)& line=Line(i); |
1486 | const IntPatch_IType IType=line->ArcType(); |
1487 | if(IType == IntPatch_Walking) nbw++; |
1488 | else if(IType == IntPatch_Restriction) { |
1489 | nbr++; |
1490 | Handle(IntPatch_RLine)& rlin = |
1491 | *((Handle(IntPatch_RLine) *)&line); |
1492 | if(rlin->IsArcOnS1()) nbr1++; |
1493 | if(rlin->IsArcOnS2()) nbr2++; |
1494 | } |
1495 | else if(IType == IntPatch_Analytic) nba++; |
1496 | else { nbg++; |
1497 | if(IType == IntPatch_Lin) nbgl++; |
1498 | else if(IType == IntPatch_Circle) nbgc++; |
1499 | else if(IType == IntPatch_Parabola) nbgp++; |
1500 | else if(IType == IntPatch_Hyperbola) nbgh++; |
1501 | else if(IType == IntPatch_Ellipse) nbge++; |
1502 | } |
1503 | } |
1504 | |
1505 | |
1506 | 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)", |
1507 | nbl,nbw,nbr,nbr1,nbr2,nba,nbg,nbgl,nbgc,nbge,nbgh,nbgp); |
1508 | |
1509 | IntPatch_LineConstructor LineConstructor(2); |
1510 | |
1511 | Standard_Integer nbllc=0; |
1512 | nbw=nbr=nbg=nba=0; |
1513 | Standard_Integer nbva,nbvw,nbvr,nbvg; |
1514 | nbva=nbvr=nbvw=nbvg=0; |
1515 | for (j=1; j<=nbl; j++) { |
1516 | Standard_Integer v,nbvtx; |
1517 | const Handle(IntPatch_Line)& intersLinej = Line(j); |
1518 | Standard_Integer NbLines; |
1519 | LineConstructor.Perform(SequenceOfLine(),intersLinej,S1,D1,S2,D2,1e-7); |
1520 | NbLines = LineConstructor.NbLines(); |
1521 | |
1522 | for(Standard_Integer k=1;k<=NbLines;k++) { |
1523 | nbllc++; |
1524 | const Handle(IntPatch_Line)& LineK = LineConstructor.Line(k); |
1525 | if (LineK->ArcType() == IntPatch_Analytic) { |
1526 | Handle(IntPatch_ALine)& alin = |
1527 | *((Handle(IntPatch_ALine) *)&LineK); |
1528 | nbvtx=alin->NbVertex(); |
1529 | nbva+=nbvtx; nba++; |
1530 | for(v=1;v<=nbvtx;v++) { |
1531 | IntPatch_Intersection__MAJ_R(R1,R2,NR1,NR2,nbR1,nbR2,alin->Vertex(v)); |
1532 | } |
1533 | } |
1534 | else if (LineK->ArcType() == IntPatch_Restriction) { |
1535 | Handle(IntPatch_RLine)& rlin = |
1536 | *((Handle(IntPatch_RLine) *)&LineK); |
1537 | nbvtx=rlin->NbVertex(); |
1538 | nbvr+=nbvtx; nbr++; |
1539 | for(v=1;v<=nbvtx;v++) { |
1540 | IntPatch_Intersection__MAJ_R(R1,R2,NR1,NR2,nbR1,nbR2,rlin->Vertex(v)); |
1541 | } |
1542 | } |
1543 | else if (LineK->ArcType() == IntPatch_Walking) { |
1544 | Handle(IntPatch_WLine)& wlin = |
1545 | *((Handle(IntPatch_WLine) *)&LineK); |
1546 | nbvtx=wlin->NbVertex(); |
1547 | nbvw+=nbvtx; nbw++; |
1548 | for(v=1;v<=nbvtx;v++) { |
1549 | IntPatch_Intersection__MAJ_R(R1,R2,NR1,NR2,nbR1,nbR2,wlin->Vertex(v)); |
1550 | } |
1551 | } |
1552 | else { |
1553 | Handle(IntPatch_GLine)& glin = |
1554 | *((Handle(IntPatch_GLine) *)&LineK); |
1555 | nbvtx=glin->NbVertex(); |
1556 | nbvg+=nbvtx; nbg++; |
1557 | for(v=1;v<=nbvtx;v++) { |
1558 | IntPatch_Intersection__MAJ_R(R1,R2,NR1,NR2,nbR1,nbR2,glin->Vertex(v)); |
1559 | } |
1560 | } |
1561 | } |
1562 | } |
1563 | printf("\nDUMP_LC :Lines:%2d WLin:%2d Restr:%2d Ana:%2d Geom:%2d", |
1564 | nbllc,nbw,nbr,nba,nbg); |
1565 | printf("\nDUMP_LC :vtx :%2d r:%2d :%2d :%2d", |
1566 | nbvw,nbvr,nbva,nbvg); |
1567 | |
1568 | |
1569 | |
1570 | printf("\n"); |
1571 | } |