b311480e |
1 | // Created by: Modelization |
973c2be1 |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
3 | // |
973c2be1 |
4 | // This file is part of Open CASCADE Technology software library. |
b311480e |
5 | // |
d5f74e42 |
6 | // This library is free software; you can redistribute it and/or modify it under |
7 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
8 | // by the Free Software Foundation, with special exception defined in the file |
9 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
10 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
11 | // |
973c2be1 |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
7fd59977 |
14 | |
7fd59977 |
15 | |
42cf5bc1 |
16 | #include <Adaptor3d_HSurface.hxx> |
17 | #include <Adaptor3d_TopolTool.hxx> |
18 | #include <IntPatch_ALine.hxx> |
7fd59977 |
19 | #include <IntPatch_ALineToWLine.hxx> |
20 | #include <IntPatch_GLine.hxx> |
7fd59977 |
21 | #include <IntPatch_ImpImpIntersection.hxx> |
42cf5bc1 |
22 | #include <IntPatch_ImpPrmIntersection.hxx> |
23 | #include <IntPatch_Intersection.hxx> |
24 | #include <IntPatch_Line.hxx> |
25 | #include <IntPatch_Point.hxx> |
26 | #include <IntPatch_PrmPrmIntersection.hxx> |
27 | #include <IntPatch_RLine.hxx> |
28 | #include <IntPatch_WLine.hxx> |
7fd59977 |
29 | #include <IntSurf_Quadric.hxx> |
42cf5bc1 |
30 | #include <Standard_ConstructionError.hxx> |
31 | #include <Standard_DomainError.hxx> |
32 | #include <Standard_OutOfRange.hxx> |
33 | #include <StdFail_NotDone.hxx> |
7fd59977 |
34 | |
35 | #include <stdio.h> |
7fd59977 |
36 | #define DEBUG 0 |
788cbaf4 |
37 | static const Standard_Integer aNbPointsInALine = 200; |
7fd59977 |
38 | |
b2af2f56 |
39 | //======================================================================= |
40 | //function : IsSeamOrBound |
41 | //purpose : Returns TRUE if point thePt1 lies in seam-edge |
42 | // (if it exists) or surface boundaries; |
43 | //======================================================================= |
44 | static Standard_Boolean IsSeamOrBound(const IntSurf_PntOn2S& thePt1, |
45 | const Standard_Real theU1Period, |
46 | const Standard_Real theU2Period, |
47 | const Standard_Real theV1Period, |
48 | const Standard_Real theV2Period, |
49 | const Standard_Real theUfSurf1, |
50 | const Standard_Real theUlSurf1, |
51 | const Standard_Real theVfSurf1, |
52 | const Standard_Real theVlSurf1, |
53 | const Standard_Real theUfSurf2, |
54 | const Standard_Real theUlSurf2, |
55 | const Standard_Real theVfSurf2, |
56 | const Standard_Real theVlSurf2) |
57 | { |
58 | Standard_Real aU11 = 0.0, aU12 = 0.0, aV11 = 0.0, aV12 = 0.0; |
59 | thePt1.Parameters(aU11, aV11, aU12, aV12); |
60 | |
61 | Standard_Boolean aCond = Standard_False; |
62 | aCond = aCond || (!IsEqual(theU1Period, 0.0) && |
63 | IsEqual(fmod(aU11, theU1Period), 0.0)); |
64 | |
65 | aCond = aCond || (!IsEqual(theU2Period, 0.0) && |
66 | IsEqual(fmod(aU12, theU2Period), 0.0)); |
67 | |
68 | aCond = aCond || (!IsEqual(theV1Period, 0.0) && |
69 | IsEqual(fmod(aV11, theV1Period), 0.0)); |
70 | |
71 | aCond = aCond || (!IsEqual(theV2Period, 0.0) && |
72 | IsEqual(fmod(aV12, theV2Period), 0.0)); |
73 | |
74 | return aCond || |
75 | IsEqual(aU11, theUfSurf1) || IsEqual(aU11, theUlSurf1) || |
76 | IsEqual(aU12, theUfSurf2) || IsEqual(aU12, theUlSurf2) || |
77 | IsEqual(aV11, theVfSurf1) || IsEqual(aV11, theVlSurf1) || |
78 | IsEqual(aV12, theVfSurf2) || IsEqual(aV12, theVlSurf2); |
79 | } |
80 | |
81 | //======================================================================= |
82 | //function : JoinWLines |
83 | //purpose : joins all WLines from theSlin to one if it is possible and |
84 | // records the result into theSlin again. |
85 | // Lines will be kept to be splitted if: |
86 | // a) they are separated (has no common points); |
87 | // b) resulted line (after joining) go through |
88 | // seam-edges or surface boundaries. |
89 | // |
90 | // In addition, if points in theSPnt lies at least in one of |
91 | // the line in theSlin, this point will be deleted. |
92 | //======================================================================= |
93 | static void JoinWLines(IntPatch_SequenceOfLine& theSlin, |
94 | IntPatch_SequenceOfPoint& theSPnt, |
95 | const Standard_Real theTol3D, |
96 | const Standard_Real theU1Period, |
97 | const Standard_Real theU2Period, |
98 | const Standard_Real theV1Period, |
99 | const Standard_Real theV2Period, |
100 | const Standard_Real theUfSurf1, |
101 | const Standard_Real theUlSurf1, |
102 | const Standard_Real theVfSurf1, |
103 | const Standard_Real theVlSurf1, |
104 | const Standard_Real theUfSurf2, |
105 | const Standard_Real theUlSurf2, |
106 | const Standard_Real theVfSurf2, |
107 | const Standard_Real theVlSurf2) |
108 | { |
109 | if(theSlin.Length() == 0) |
110 | return; |
111 | |
112 | for(Standard_Integer aNumOfLine1 = 1; aNumOfLine1 <= theSlin.Length(); aNumOfLine1++) |
113 | { |
c5f3a425 |
114 | Handle(IntPatch_WLine) aWLine1 (Handle(IntPatch_WLine)::DownCast(theSlin.Value(aNumOfLine1))); |
b2af2f56 |
115 | |
116 | if(aWLine1.IsNull()) |
5b9e1842 |
117 | {//We must have failed to join not-point-lines |
b2af2f56 |
118 | return; |
119 | } |
120 | |
121 | const Standard_Integer aNbPntsWL1 = aWLine1->NbPnts(); |
122 | const IntSurf_PntOn2S& aPntFWL1 = aWLine1->Point(1); |
123 | const IntSurf_PntOn2S& aPntLWL1 = aWLine1->Point(aNbPntsWL1); |
124 | |
125 | for(Standard_Integer aNPt = 1; aNPt <= theSPnt.Length(); aNPt++) |
126 | { |
127 | const IntSurf_PntOn2S aPntCur = theSPnt.Value(aNPt).PntOn2S(); |
128 | |
129 | if( aPntCur.IsSame(aPntFWL1, Precision::Confusion()) || |
130 | aPntCur.IsSame(aPntLWL1, Precision::Confusion())) |
131 | { |
132 | theSPnt.Remove(aNPt); |
133 | aNPt--; |
134 | } |
135 | } |
136 | |
137 | Standard_Boolean hasBeenRemoved = Standard_False; |
138 | for(Standard_Integer aNumOfLine2 = aNumOfLine1 + 1; aNumOfLine2 <= theSlin.Length(); aNumOfLine2++) |
139 | { |
c5f3a425 |
140 | Handle(IntPatch_WLine) aWLine2 (Handle(IntPatch_WLine)::DownCast(theSlin.Value(aNumOfLine2))); |
b2af2f56 |
141 | |
142 | const Standard_Integer aNbPntsWL1 = aWLine1->NbPnts(); |
143 | const Standard_Integer aNbPntsWL2 = aWLine2->NbPnts(); |
144 | |
145 | const IntSurf_PntOn2S& aPntFWL1 = aWLine1->Point(1); |
146 | const IntSurf_PntOn2S& aPntLWL1 = aWLine1->Point(aNbPntsWL1); |
147 | |
148 | const IntSurf_PntOn2S& aPntFWL2 = aWLine2->Point(1); |
149 | const IntSurf_PntOn2S& aPntLWL2 = aWLine2->Point(aNbPntsWL2); |
150 | |
151 | if(aPntFWL1.IsSame(aPntFWL2, Precision::Confusion())) |
152 | { |
153 | if(!IsSeamOrBound(aPntFWL1, theU1Period, theU2Period, |
154 | theV1Period, theV2Period, theUfSurf1, theUlSurf1, |
155 | theVfSurf1, theVlSurf1, theUfSurf2, theUlSurf2, |
156 | theVfSurf2, theVlSurf2)) |
157 | { |
158 | aWLine1->ClearVertexes(); |
159 | for(Standard_Integer aNPt = 1; aNPt <= aNbPntsWL2; aNPt++) |
160 | { |
161 | const IntSurf_PntOn2S& aPt = aWLine2->Point(aNPt); |
162 | aWLine1->Curve()->InsertBefore(1, aPt); |
163 | } |
164 | |
165 | aWLine1->ComputeVertexParameters(theTol3D); |
166 | |
167 | theSlin.Remove(aNumOfLine2); |
168 | aNumOfLine2--; |
169 | hasBeenRemoved = Standard_True; |
170 | |
171 | continue; |
172 | } |
173 | } |
174 | |
175 | if(aPntFWL1.IsSame(aPntLWL2, Precision::Confusion())) |
176 | { |
177 | if(!IsSeamOrBound(aPntFWL1, theU1Period, theU2Period, |
178 | theV1Period, theV2Period, theUfSurf1, theUlSurf1, |
179 | theVfSurf1, theVlSurf1, theUfSurf2, theUlSurf2, |
180 | theVfSurf2, theVlSurf2)) |
181 | { |
182 | aWLine1->ClearVertexes(); |
183 | for(Standard_Integer aNPt = aNbPntsWL2; aNPt >= 1; aNPt--) |
184 | { |
185 | const IntSurf_PntOn2S& aPt = aWLine2->Point(aNPt); |
186 | aWLine1->Curve()->InsertBefore(1, aPt); |
187 | } |
188 | |
189 | aWLine1->ComputeVertexParameters(theTol3D); |
190 | |
191 | theSlin.Remove(aNumOfLine2); |
192 | aNumOfLine2--; |
193 | hasBeenRemoved = Standard_True; |
194 | |
195 | continue; |
196 | } |
197 | } |
198 | |
199 | if(aPntLWL1.IsSame(aPntFWL2, Precision::Confusion())) |
200 | { |
201 | if(!IsSeamOrBound(aPntLWL1, theU1Period, theU2Period, |
202 | theV1Period, theV2Period, theUfSurf1, theUlSurf1, |
203 | theVfSurf1, theVlSurf1, theUfSurf2, theUlSurf2, |
204 | theVfSurf2, theVlSurf2)) |
205 | { |
206 | aWLine1->ClearVertexes(); |
207 | for(Standard_Integer aNPt = 1; aNPt <= aNbPntsWL2; aNPt++) |
208 | { |
209 | const IntSurf_PntOn2S& aPt = aWLine2->Point(aNPt); |
210 | aWLine1->Curve()->Add(aPt); |
211 | } |
212 | |
213 | aWLine1->ComputeVertexParameters(theTol3D); |
214 | |
215 | theSlin.Remove(aNumOfLine2); |
216 | aNumOfLine2--; |
217 | hasBeenRemoved = Standard_True; |
218 | |
219 | continue; |
220 | } |
221 | } |
222 | |
223 | if(aPntLWL1.IsSame(aPntLWL2, Precision::Confusion())) |
224 | { |
225 | if(!IsSeamOrBound(aPntLWL1, theU1Period, theU2Period, |
226 | theV1Period, theV2Period, theUfSurf1, theUlSurf1, |
227 | theVfSurf1, theVlSurf1, theUfSurf2, theUlSurf2, |
228 | theVfSurf2, theVlSurf2)) |
229 | { |
230 | aWLine1->ClearVertexes(); |
231 | for(Standard_Integer aNPt = aNbPntsWL2; aNPt >= 1; aNPt--) |
232 | { |
233 | const IntSurf_PntOn2S& aPt = aWLine2->Point(aNPt); |
234 | aWLine1->Curve()->Add(aPt); |
235 | } |
236 | |
237 | aWLine1->ComputeVertexParameters(theTol3D); |
238 | |
239 | theSlin.Remove(aNumOfLine2); |
240 | aNumOfLine2--; |
241 | hasBeenRemoved = Standard_True; |
242 | |
243 | continue; |
244 | } |
245 | } |
246 | } |
247 | |
248 | if(hasBeenRemoved) |
249 | aNumOfLine1--; |
250 | } |
251 | } |
252 | |
7fd59977 |
253 | //====================================================================== |
254 | // function: SequenceOfLine |
255 | //====================================================================== |
256 | const IntPatch_SequenceOfLine& IntPatch_Intersection::SequenceOfLine() const { return(slin); } |
257 | |
258 | //====================================================================== |
259 | // function: IntPatch_Intersection |
260 | //====================================================================== |
261 | IntPatch_Intersection::IntPatch_Intersection () |
262 | : done(Standard_False), |
263 | //empt, tgte, oppo, |
264 | myTolArc(0.0), myTolTang(0.0), |
265 | myUVMaxStep(0.0), myFleche(0.0), |
266 | myIsStartPnt(Standard_False) |
267 | //myU1Start, myV1Start, myU2Start, myV2Start |
268 | { |
269 | } |
270 | |
271 | //====================================================================== |
272 | // function: IntPatch_Intersection |
273 | //====================================================================== |
274 | IntPatch_Intersection::IntPatch_Intersection(const Handle(Adaptor3d_HSurface)& S1, |
275 | const Handle(Adaptor3d_TopolTool)& D1, |
276 | const Handle(Adaptor3d_HSurface)& S2, |
277 | const Handle(Adaptor3d_TopolTool)& D2, |
278 | const Standard_Real TolArc, |
279 | const Standard_Real TolTang) |
280 | : done(Standard_False), |
281 | //empt, tgte, oppo, |
282 | myTolArc(TolArc), myTolTang(TolTang), |
283 | myUVMaxStep(0.0), myFleche(0.0), |
284 | myIsStartPnt(Standard_False) |
285 | //myU1Start, myV1Start, myU2Start, myV2Start |
286 | { |
287 | if(myTolArc<1e-8) myTolArc=1e-8; |
288 | if(myTolTang<1e-8) myTolTang=1e-8; |
289 | if(myTolArc>0.5) myTolArc=0.5; |
290 | if(myTolTang>0.5) myTolTang=0.5; |
291 | Perform(S1,D1,S2,D2,TolArc,TolTang); |
292 | } |
293 | |
294 | //====================================================================== |
295 | // function: IntPatch_Intersection |
296 | //====================================================================== |
297 | IntPatch_Intersection::IntPatch_Intersection(const Handle(Adaptor3d_HSurface)& S1, |
298 | const Handle(Adaptor3d_TopolTool)& D1, |
299 | const Standard_Real TolArc, |
300 | const Standard_Real TolTang) |
301 | : done(Standard_False), |
302 | //empt, tgte, oppo, |
303 | myTolArc(TolArc), myTolTang(TolTang), |
304 | myUVMaxStep(0.0), myFleche(0.0), |
305 | myIsStartPnt(Standard_False) |
306 | //myU1Start, myV1Start, myU2Start, myV2Start |
307 | { |
308 | Perform(S1,D1,TolArc,TolTang); |
309 | } |
310 | |
311 | //====================================================================== |
312 | // function: SetTolerances |
313 | //====================================================================== |
314 | void IntPatch_Intersection::SetTolerances(const Standard_Real TolArc, |
315 | const Standard_Real TolTang, |
316 | const Standard_Real UVMaxStep, |
317 | const Standard_Real Fleche) |
318 | { |
319 | myTolArc = TolArc; |
320 | myTolTang = TolTang; |
321 | myUVMaxStep = UVMaxStep; |
322 | myFleche = Fleche; |
323 | if(myTolArc<1e-8) myTolArc=1e-8; |
324 | if(myTolTang<1e-8) myTolTang=1e-8; |
325 | if(myTolArc>0.5) myTolArc=0.5; |
326 | if(myTolTang>0.5) myTolTang=0.5; |
327 | if(myFleche<1.0e-3) myFleche=1e-3; |
328 | if(myUVMaxStep<1.0e-3) myUVMaxStep=1e-3; |
329 | if(myFleche>10) myFleche=10; |
330 | if(myUVMaxStep>0.5) myUVMaxStep=0.5; |
331 | } |
332 | |
333 | //====================================================================== |
334 | // function: Perform |
335 | //====================================================================== |
336 | void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& S1, |
337 | const Handle(Adaptor3d_TopolTool)& D1, |
338 | const Standard_Real TolArc, |
339 | const Standard_Real TolTang) |
340 | { |
341 | myTolArc = TolArc; |
342 | myTolTang = TolTang; |
343 | if(myFleche == 0.0) myFleche = 0.01; |
344 | if(myUVMaxStep==0.0) myUVMaxStep = 0.01; |
345 | |
346 | done = Standard_True; |
347 | spnt.Clear(); |
348 | slin.Clear(); |
349 | |
350 | empt = Standard_True; |
351 | tgte = Standard_False; |
352 | oppo = Standard_False; |
353 | |
354 | switch (S1->GetType()) |
355 | { |
356 | case GeomAbs_Plane: |
357 | case GeomAbs_Cylinder: |
358 | case GeomAbs_Sphere: |
359 | case GeomAbs_Cone: |
360 | case GeomAbs_Torus: break; |
361 | default: |
362 | { |
1d18c75e |
363 | IntPatch_PrmPrmIntersection interpp; |
364 | interpp.Perform(S1,D1,TolArc,TolTang,myFleche,myUVMaxStep); |
365 | if (interpp.IsDone()) |
366 | { |
367 | done = Standard_True; |
368 | tgte = Standard_False; |
369 | empt = interpp.IsEmpty(); |
370 | const Standard_Integer nblm = interpp.NbLines(); |
371 | for (Standard_Integer i=1; i<=nblm; i++) slin.Append(interpp.Line(i)); |
372 | } |
7fd59977 |
373 | } |
374 | break; |
375 | } |
376 | } |
377 | |
378 | ///////////////////////////////////////////////////////////////////////////// |
379 | // These several support functions provide methods which can help basic // |
380 | // algorithm to intersect infinite surfaces of the following types: // |
381 | // // |
382 | // a.) SurfaceOfExtrusion; // |
383 | // b.) SurfaceOfRevolution; // |
384 | // c.) OffsetSurface. // |
385 | // // |
386 | ///////////////////////////////////////////////////////////////////////////// |
387 | #include <TColgp_Array1OfXYZ.hxx> |
388 | #include <TColgp_Array1OfPnt.hxx> |
389 | #include <TColgp_SequenceOfPnt.hxx> |
390 | #include <Extrema_ExtPS.hxx> |
391 | #include <Extrema_POnSurf.hxx> |
392 | #include <Geom2d_Curve.hxx> |
393 | #include <Geom2dAPI_InterCurveCurve.hxx> |
394 | #include <GeomAdaptor.hxx> |
395 | #include <GeomAdaptor_HCurve.hxx> |
396 | #include <GeomAdaptor_Curve.hxx> |
397 | #include <GeomAdaptor_Surface.hxx> |
cb389a77 |
398 | #include <GeomAdaptor_HSurface.hxx> |
7fd59977 |
399 | #include <Geom_Plane.hxx> |
400 | #include <ProjLib_ProjectOnPlane.hxx> |
401 | #include <GeomProjLib.hxx> |
402 | #include <ElCLib.hxx> |
403 | #include <Geom_TrimmedCurve.hxx> |
404 | #include <Geom_Surface.hxx> |
405 | #include <Geom_SurfaceOfLinearExtrusion.hxx> |
406 | #include <Geom_OffsetSurface.hxx> |
407 | #include <Geom_SurfaceOfRevolution.hxx> |
408 | #include <Geom_RectangularTrimmedSurface.hxx> |
409 | |
410 | //=============================================================== |
411 | //function: FUN_GetMinMaxXYZPnt |
412 | //=============================================================== |
413 | static void FUN_GetMinMaxXYZPnt( const Handle(Adaptor3d_HSurface)& S, |
414 | gp_Pnt& pMin, gp_Pnt& pMax ) |
415 | { |
416 | const Standard_Real DU = 0.25 * Abs(S->LastUParameter() - S->FirstUParameter()); |
417 | const Standard_Real DV = 0.25 * Abs(S->LastVParameter() - S->FirstVParameter()); |
418 | Standard_Real tMinXYZ = RealLast(); |
419 | Standard_Real tMaxXYZ = -tMinXYZ; |
420 | gp_Pnt PUV, ptMax, ptMin; |
421 | for(Standard_Real U = S->FirstUParameter(); U <= S->LastUParameter(); U += DU) |
422 | { |
423 | for(Standard_Real V = S->FirstVParameter(); V <= S->LastVParameter(); V += DV) |
1d18c75e |
424 | { |
425 | S->D0(U,V,PUV); |
7fd59977 |
426 | const Standard_Real cXYZ = PUV.XYZ().Modulus(); |
1d18c75e |
427 | if(cXYZ > tMaxXYZ) { tMaxXYZ = cXYZ; ptMax = PUV; } |
428 | if(cXYZ < tMinXYZ) { tMinXYZ = cXYZ; ptMin = PUV; } |
429 | } |
7fd59977 |
430 | } |
431 | pMin = ptMin; |
432 | pMax = ptMax; |
433 | } |
434 | //========================================================================== |
435 | //function: FUN_TrimInfSurf |
436 | //========================================================================== |
437 | static void FUN_TrimInfSurf(const gp_Pnt& Pmin, |
438 | const gp_Pnt& Pmax, |
439 | const Handle(Adaptor3d_HSurface)& InfSurf, |
440 | const Standard_Real& AlternativeTrimPrm, |
441 | Handle(Adaptor3d_HSurface)& TrimS) |
442 | { |
443 | Standard_Real TP = AlternativeTrimPrm; |
444 | Extrema_ExtPS ext1(Pmin, InfSurf->Surface(), 1.e-7, 1.e-7); |
445 | Extrema_ExtPS ext2(Pmax, InfSurf->Surface(), 1.e-7, 1.e-7); |
446 | if(ext1.IsDone() || ext2.IsDone()) |
447 | { |
448 | Standard_Real Umax = -1.e+100, Umin = 1.e+100, Vmax = -1.e+100, Vmin = 1.e+100, cU, cV; |
449 | if(ext1.IsDone()) |
1d18c75e |
450 | { |
7fd59977 |
451 | for(Standard_Integer i = 1; i <= ext1.NbExt(); i++) |
452 | { |
1d18c75e |
453 | const Extrema_POnSurf & pons = ext1.Point(i); |
454 | pons.Parameter(cU,cV); |
455 | if(cU > Umax) Umax = cU; |
456 | if(cU < Umin) Umin = cU; |
457 | if(cV > Vmax) Vmax = cV; |
458 | if(cV < Vmin) Vmin = cV; |
7fd59977 |
459 | } |
1d18c75e |
460 | } |
7fd59977 |
461 | if(ext2.IsDone()) |
1d18c75e |
462 | { |
7fd59977 |
463 | for(Standard_Integer i = 1; i <= ext2.NbExt(); i++) |
464 | { |
465 | const Extrema_POnSurf & pons = ext2.Point(i); |
466 | pons.Parameter(cU,cV); |
467 | if(cU > Umax) Umax = cU; |
468 | if(cU < Umin) Umin = cU; |
469 | if(cV > Vmax) Vmax = cV; |
470 | if(cV < Vmin) Vmin = cV; |
471 | } |
1d18c75e |
472 | } |
7fd59977 |
473 | TP = Max(Abs(Umin),Max(Abs(Umax),Max(Abs(Vmin),Abs(Vmax)))); |
474 | } |
475 | if(TP == 0.) { TrimS = InfSurf; return; } |
476 | else |
477 | { |
478 | const Standard_Boolean Uinf = Precision::IsNegativeInfinite(InfSurf->FirstUParameter()); |
479 | const Standard_Boolean Usup = Precision::IsPositiveInfinite(InfSurf->LastUParameter()); |
480 | const Standard_Boolean Vinf = Precision::IsNegativeInfinite(InfSurf->FirstVParameter()); |
481 | const Standard_Boolean Vsup = Precision::IsPositiveInfinite(InfSurf->LastVParameter()); |
482 | Handle(Adaptor3d_HSurface) TmpSS; |
483 | Standard_Integer IsTrimed = 0; |
484 | const Standard_Real tp = 1000.0 * TP; |
485 | if(Vinf && Vsup) { TrimS = InfSurf->VTrim(-tp, tp, 1.0e-7); IsTrimed = 1; } |
486 | if(Vinf && !Vsup){ TrimS = InfSurf->VTrim(-tp, InfSurf->LastVParameter(), 1.0e-7); IsTrimed = 1; } |
487 | if(!Vinf && Vsup){ TrimS = InfSurf->VTrim(InfSurf->FirstVParameter(), tp, 1.0e-7); IsTrimed = 1; } |
488 | if(IsTrimed) |
1d18c75e |
489 | { |
490 | TmpSS = TrimS; |
491 | if(Uinf && Usup) TrimS = TmpSS->UTrim(-tp, tp, 1.0e-7); |
492 | if(Uinf && !Usup) TrimS = TmpSS->UTrim(-tp, InfSurf->LastUParameter(), 1.0e-7); |
493 | if(!Uinf && Usup) TrimS = TmpSS->UTrim(InfSurf->FirstUParameter(), tp, 1.0e-7); |
494 | } |
7fd59977 |
495 | else |
1d18c75e |
496 | { |
497 | if(Uinf && Usup) TrimS = InfSurf->UTrim(-tp, tp, 1.0e-7); |
498 | if(Uinf && !Usup) TrimS = InfSurf->UTrim(-tp, InfSurf->LastUParameter(), 1.0e-7); |
499 | if(!Uinf && Usup) TrimS = InfSurf->UTrim(InfSurf->FirstUParameter(), tp, 1.0e-7); |
500 | } |
7fd59977 |
501 | } |
502 | } |
503 | //================================================================================ |
504 | //function: FUN_GetUiso |
505 | //================================================================================ |
506 | static void FUN_GetUiso(const Handle(Geom_Surface)& GS, |
507 | const GeomAbs_SurfaceType& T, |
508 | const Standard_Real& FirstV, |
509 | const Standard_Real& LastV, |
510 | const Standard_Boolean& IsVC, |
511 | const Standard_Boolean& IsVP, |
512 | const Standard_Real& U, |
513 | Handle(Geom_Curve)& I) |
514 | { |
515 | if(T != GeomAbs_OffsetSurface) |
516 | { |
517 | Handle(Geom_Curve) gc = GS->UIso(U); |
c6541a0c |
518 | if(IsVP && (FirstV == 0.0 && LastV == (2.*M_PI))) I = gc; |
7fd59977 |
519 | else |
1d18c75e |
520 | { |
521 | Handle(Geom_TrimmedCurve) gtc = new Geom_TrimmedCurve(gc,FirstV,LastV); |
522 | //szv:I = Handle(Geom_Curve)::DownCast(gtc); |
523 | I = gtc; |
524 | } |
7fd59977 |
525 | } |
526 | else//OffsetSurface |
527 | { |
c5f3a425 |
528 | const Handle(Geom_OffsetSurface) gos = Handle(Geom_OffsetSurface)::DownCast (GS); |
7fd59977 |
529 | const Handle(Geom_Surface) bs = gos->BasisSurface(); |
530 | Handle(Geom_Curve) gcbs = bs->UIso(U); |
531 | GeomAdaptor_Curve gac(gcbs); |
532 | const GeomAbs_CurveType GACT = gac.GetType(); |
533 | if(IsVP || IsVC || GACT == GeomAbs_BSplineCurve || GACT == GeomAbs_BezierCurve || Abs(LastV - FirstV) < 1.e+5) |
1d18c75e |
534 | { |
535 | Handle(Geom_Curve) gc = gos->UIso(U); |
536 | if(IsVP && (FirstV == 0.0 && LastV == (2*M_PI))) I = gc; |
537 | else |
7fd59977 |
538 | { |
1d18c75e |
539 | Handle(Geom_TrimmedCurve) gtc = new Geom_TrimmedCurve(gc,FirstV,LastV); |
540 | //szv:I = Handle(Geom_Curve)::DownCast(gtc); |
541 | I = gtc; |
542 | } |
543 | } |
7fd59977 |
544 | else//Offset Line, Parab, Hyperb |
1d18c75e |
545 | { |
546 | Standard_Real VmTr, VMTr; |
547 | if(GACT != GeomAbs_Hyperbola) |
7fd59977 |
548 | { |
1d18c75e |
549 | if(FirstV >= 0. && LastV >= 0.){ VmTr = FirstV; VMTr = ((LastV - FirstV) > 1.e+4) ? (FirstV + 1.e+4) : LastV; } |
550 | else if(FirstV < 0. && LastV < 0.){ VMTr = LastV; VmTr = ((FirstV - LastV) < -1.e+4) ? (LastV - 1.e+4) : FirstV; } |
551 | else { VmTr = (FirstV < -1.e+4) ? -1.e+4 : FirstV; VMTr = (LastV > 1.e+4) ? 1.e+4 : LastV; } |
552 | } |
553 | else//Hyperbola |
554 | { |
555 | if(FirstV >= 0. && LastV >= 0.) |
556 | { |
557 | if(FirstV > 4.) return; |
558 | VmTr = FirstV; VMTr = (LastV > 4.) ? 4. : LastV; |
559 | } |
560 | else if(FirstV < 0. && LastV < 0.) |
561 | { |
562 | if(LastV < -4.) return; |
563 | VMTr = LastV; VmTr = (FirstV < -4.) ? -4. : FirstV; |
564 | } |
565 | else { VmTr = (FirstV < -4.) ? -4. : FirstV; VMTr = (LastV > 4.) ? 4. : LastV; } |
566 | } |
567 | //Make trimmed surface |
568 | Handle(Geom_RectangularTrimmedSurface) rts = new Geom_RectangularTrimmedSurface(gos,VmTr,VMTr,Standard_True); |
569 | I = rts->UIso(U); |
570 | } |
7fd59977 |
571 | } |
572 | } |
573 | //================================================================================ |
574 | //function: FUN_GetViso |
575 | //================================================================================ |
576 | static void FUN_GetViso(const Handle(Geom_Surface)& GS, |
577 | const GeomAbs_SurfaceType& T, |
578 | const Standard_Real& FirstU, |
579 | const Standard_Real& LastU, |
580 | const Standard_Boolean& IsUC, |
581 | const Standard_Boolean& IsUP, |
582 | const Standard_Real& V, |
583 | Handle(Geom_Curve)& I) |
584 | { |
585 | if(T != GeomAbs_OffsetSurface) |
586 | { |
587 | Handle(Geom_Curve) gc = GS->VIso(V); |
c6541a0c |
588 | if(IsUP && (FirstU == 0.0 && LastU == (2*M_PI))) I = gc; |
7fd59977 |
589 | else |
1d18c75e |
590 | { |
591 | Handle(Geom_TrimmedCurve) gtc = new Geom_TrimmedCurve(gc,FirstU,LastU); |
592 | //szv:I = Handle(Geom_Curve)::DownCast(gtc); |
593 | I = gtc; |
594 | } |
7fd59977 |
595 | } |
596 | else//OffsetSurface |
597 | { |
c5f3a425 |
598 | const Handle(Geom_OffsetSurface) gos = Handle(Geom_OffsetSurface)::DownCast (GS); |
7fd59977 |
599 | const Handle(Geom_Surface) bs = gos->BasisSurface(); |
600 | Handle(Geom_Curve) gcbs = bs->VIso(V); |
601 | GeomAdaptor_Curve gac(gcbs); |
602 | const GeomAbs_CurveType GACT = gac.GetType(); |
603 | if(IsUP || IsUC || GACT == GeomAbs_BSplineCurve || GACT == GeomAbs_BezierCurve || Abs(LastU - FirstU) < 1.e+5) |
1d18c75e |
604 | { |
605 | Handle(Geom_Curve) gc = gos->VIso(V); |
606 | if(IsUP && (FirstU == 0.0 && LastU == (2*M_PI))) I = gc; |
607 | else |
608 | { |
609 | Handle(Geom_TrimmedCurve) gtc = new Geom_TrimmedCurve(gc,FirstU,LastU); |
610 | //szv:I = Handle(Geom_Curve)::DownCast(gtc); |
611 | I = gtc; |
612 | } |
613 | } |
7fd59977 |
614 | else//Offset Line, Parab, Hyperb |
1d18c75e |
615 | { |
616 | Standard_Real UmTr, UMTr; |
617 | if(GACT != GeomAbs_Hyperbola) |
618 | { |
619 | if(FirstU >= 0. && LastU >= 0.){ UmTr = FirstU; UMTr = ((LastU - FirstU) > 1.e+4) ? (FirstU + 1.e+4) : LastU; } |
620 | else if(FirstU < 0. && LastU < 0.){ UMTr = LastU; UmTr = ((FirstU - LastU) < -1.e+4) ? (LastU - 1.e+4) : FirstU; } |
621 | else { UmTr = (FirstU < -1.e+4) ? -1.e+4 : FirstU; UMTr = (LastU > 1.e+4) ? 1.e+4 : LastU; } |
622 | } |
623 | else//Hyperbola |
624 | { |
625 | if(FirstU >= 0. && LastU >= 0.) |
626 | { |
627 | if(FirstU > 4.) return; |
628 | UmTr = FirstU; UMTr = (LastU > 4.) ? 4. : LastU; |
629 | } |
630 | else if(FirstU < 0. && LastU < 0.) |
631 | { |
632 | if(LastU < -4.) return; |
633 | UMTr = LastU; UmTr = (FirstU < -4.) ? -4. : FirstU; |
634 | } |
635 | else { UmTr = (FirstU < -4.) ? -4. : FirstU; UMTr = (LastU > 4.) ? 4. : LastU; } |
636 | } |
637 | //Make trimmed surface |
638 | Handle(Geom_RectangularTrimmedSurface) rts = new Geom_RectangularTrimmedSurface(gos,UmTr,UMTr,Standard_True); |
639 | I = rts->VIso(V); |
640 | } |
7fd59977 |
641 | } |
642 | } |
643 | //================================================================================ |
644 | //function: FUN_PL_Intersection |
645 | //================================================================================ |
646 | static void FUN_PL_Intersection(const Handle(Adaptor3d_HSurface)& S1, |
647 | const GeomAbs_SurfaceType& T1, |
648 | const Handle(Adaptor3d_HSurface)& S2, |
649 | const GeomAbs_SurfaceType& T2, |
650 | Standard_Boolean& IsOk, |
651 | TColgp_SequenceOfPnt& SP, |
652 | gp_Vec& DV) |
653 | { |
654 | IsOk = Standard_False; |
655 | // 1. Check: both surfaces have U(V)isos - lines. |
656 | DV = gp_Vec(0.,0.,1.); |
657 | Standard_Boolean isoS1isLine[2] = {0, 0}; |
658 | Standard_Boolean isoS2isLine[2] = {0, 0}; |
659 | Handle(Geom_Curve) C1, C2; |
660 | const GeomAdaptor_Surface & gas1 = *(GeomAdaptor_Surface*)(&(S1->Surface())); |
661 | const GeomAdaptor_Surface & gas2 = *(GeomAdaptor_Surface*)(&(S2->Surface())); |
662 | const Handle(Geom_Surface) gs1 = gas1.Surface(); |
663 | const Handle(Geom_Surface) gs2 = gas2.Surface(); |
664 | Standard_Real MS1[2], MS2[2]; |
665 | MS1[0] = 0.5 * (S1->LastUParameter() + S1->FirstUParameter()); |
666 | MS1[1] = 0.5 * (S1->LastVParameter() + S1->FirstVParameter()); |
667 | MS2[0] = 0.5 * (S2->LastUParameter() + S2->FirstUParameter()); |
668 | MS2[1] = 0.5 * (S2->LastVParameter() + S2->FirstVParameter()); |
669 | if(T1 == GeomAbs_SurfaceOfExtrusion) isoS1isLine[0] = Standard_True; |
670 | else if(!S1->IsVPeriodic() && !S1->IsVClosed()) { |
671 | if(T1 != GeomAbs_OffsetSurface) C1 = gs1->UIso(MS1[0]); |
672 | else { |
c5f3a425 |
673 | const Handle(Geom_OffsetSurface) gos = Handle(Geom_OffsetSurface)::DownCast (gs1); |
7fd59977 |
674 | const Handle(Geom_Surface) bs = gos->BasisSurface(); |
675 | C1 = bs->UIso(MS1[0]); |
676 | } |
677 | GeomAdaptor_Curve gac(C1); |
678 | if(gac.GetType() == GeomAbs_Line) isoS1isLine[0] = Standard_True; |
679 | } |
680 | if(!S1->IsUPeriodic() && !S1->IsUClosed()) { |
681 | if(T1 != GeomAbs_OffsetSurface) C1 = gs1->VIso(MS1[1]); |
682 | else { |
c5f3a425 |
683 | const Handle(Geom_OffsetSurface) gos = Handle(Geom_OffsetSurface)::DownCast (gs1); |
7fd59977 |
684 | const Handle(Geom_Surface) bs = gos->BasisSurface(); |
685 | C1 = bs->VIso(MS1[1]); |
686 | } |
687 | GeomAdaptor_Curve gac(C1); |
688 | if(gac.GetType() == GeomAbs_Line) isoS1isLine[1] = Standard_True; |
689 | } |
690 | if(T2 == GeomAbs_SurfaceOfExtrusion) isoS2isLine[0] = Standard_True; |
691 | else if(!S2->IsVPeriodic() && !S2->IsVClosed()) { |
692 | if(T2 != GeomAbs_OffsetSurface) C2 = gs2->UIso(MS2[0]); |
693 | else { |
c5f3a425 |
694 | const Handle(Geom_OffsetSurface) gos = Handle(Geom_OffsetSurface)::DownCast (gs2); |
7fd59977 |
695 | const Handle(Geom_Surface) bs = gos->BasisSurface(); |
696 | C2 = bs->UIso(MS2[0]); |
697 | } |
698 | GeomAdaptor_Curve gac(C2); |
699 | if(gac.GetType() == GeomAbs_Line) isoS2isLine[0] = Standard_True; |
700 | } |
701 | if(!S2->IsUPeriodic() && !S2->IsUClosed()) { |
702 | if(T2 != GeomAbs_OffsetSurface) C2 = gs2->VIso(MS2[1]); |
703 | else { |
c5f3a425 |
704 | const Handle(Geom_OffsetSurface) gos = Handle(Geom_OffsetSurface)::DownCast (gs2); |
7fd59977 |
705 | const Handle(Geom_Surface) bs = gos->BasisSurface(); |
706 | C2 = bs->VIso(MS2[1]); |
707 | } |
708 | GeomAdaptor_Curve gac(C2); |
709 | if(gac.GetType() == GeomAbs_Line) isoS2isLine[1] = Standard_True; |
710 | } |
711 | Standard_Boolean IsBothLines = ((isoS1isLine[0] || isoS1isLine[1]) && |
712 | (isoS2isLine[0] || isoS2isLine[1])); |
713 | if(!IsBothLines){ |
714 | return; |
715 | } |
716 | // 2. Check: Uiso lines of both surfaces are collinear. |
717 | gp_Pnt puvS1, puvS2; |
718 | gp_Vec derS1[2], derS2[2]; |
719 | S1->D1(MS1[0], MS1[1], puvS1, derS1[0], derS1[1]); |
720 | S2->D1(MS2[0], MS2[1], puvS2, derS2[0], derS2[1]); |
721 | C1.Nullify(); C2.Nullify(); |
722 | Standard_Integer iso = 0; |
723 | if(isoS1isLine[0] && isoS2isLine[0] && |
724 | derS1[1].IsParallel(derS2[1],Precision::Angular())) { |
725 | iso = 1; |
726 | FUN_GetViso(gs1,T1,S1->FirstUParameter(),S1->LastUParameter(), |
727 | S1->IsUClosed(),S1->IsUPeriodic(),MS1[1],C1); |
728 | FUN_GetViso(gs2,T2,S2->FirstUParameter(),S2->LastUParameter(), |
729 | S2->IsUClosed(),S2->IsUPeriodic(),MS2[1],C2); |
730 | } |
731 | else if(isoS1isLine[0] && isoS2isLine[1] && |
732 | derS1[1].IsParallel(derS2[0],Precision::Angular())) { |
733 | iso = 1; |
734 | FUN_GetViso(gs1,T1,S1->FirstUParameter(),S1->LastUParameter(), |
735 | S1->IsUClosed(),S1->IsUPeriodic(),MS1[1],C1); |
736 | FUN_GetUiso(gs2,T2,S2->FirstVParameter(),S2->LastVParameter(), |
737 | S2->IsVClosed(),S2->IsVPeriodic(),MS2[0],C2); |
738 | } |
739 | else if(isoS1isLine[1] && isoS2isLine[0] && |
740 | derS1[0].IsParallel(derS2[1],Precision::Angular())) { |
741 | iso = 0; |
742 | FUN_GetUiso(gs1,T1,S1->FirstVParameter(),S1->LastVParameter(), |
743 | S1->IsVClosed(),S1->IsVPeriodic(),MS1[0],C1); |
744 | FUN_GetViso(gs2,T2,S2->FirstUParameter(),S2->LastUParameter(), |
745 | S2->IsUClosed(),S2->IsUPeriodic(),MS2[1],C2); |
746 | } |
747 | else if(isoS1isLine[1] && isoS2isLine[1] && |
748 | derS1[0].IsParallel(derS2[0],Precision::Angular())) { |
749 | iso = 0; |
750 | FUN_GetUiso(gs1,T1,S1->FirstVParameter(),S1->LastVParameter(), |
751 | S1->IsVClosed(),S1->IsVPeriodic(),MS1[0],C1); |
752 | FUN_GetUiso(gs2,T2,S2->FirstVParameter(),S2->LastVParameter(), |
753 | S2->IsVClosed(),S2->IsVPeriodic(),MS2[0],C2); |
754 | } |
755 | else { |
756 | IsOk = Standard_False; |
757 | return; |
758 | } |
759 | IsOk = Standard_True; |
760 | // 3. Make intersections of V(U)isos |
761 | if(C1.IsNull() || C2.IsNull()) return; |
762 | DV = derS1[iso]; |
763 | Handle(Geom_Plane) GPln = new Geom_Plane(gp_Pln(puvS1,gp_Dir(DV))); |
764 | Handle(Geom_Curve) C1Prj = |
765 | GeomProjLib::ProjectOnPlane(C1,GPln,gp_Dir(DV),Standard_True); |
766 | Handle(Geom_Curve) C2Prj = |
767 | GeomProjLib::ProjectOnPlane(C2,GPln,gp_Dir(DV),Standard_True); |
768 | if(C1Prj.IsNull() || C2Prj.IsNull()) return; |
769 | Handle(Geom2d_Curve) C1Prj2d = |
c5f3a425 |
770 | GeomProjLib::Curve2d(C1Prj,Handle(Geom_Surface)::DownCast (GPln)); |
7fd59977 |
771 | Handle(Geom2d_Curve) C2Prj2d = |
c5f3a425 |
772 | GeomProjLib::Curve2d(C2Prj,Handle(Geom_Surface)::DownCast (GPln)); |
7fd59977 |
773 | Geom2dAPI_InterCurveCurve ICC(C1Prj2d,C2Prj2d,1.0e-7); |
774 | if(ICC.NbPoints() > 0 ) |
775 | { |
776 | for(Standard_Integer ip = 1; ip <= ICC.NbPoints(); ip++) |
1d18c75e |
777 | { |
778 | gp_Pnt2d P = ICC.Point(ip); |
779 | gp_Pnt P3d = ElCLib::To3d(gp_Ax2(puvS1,gp_Dir(DV)),P); |
780 | SP.Append(P3d); |
781 | } |
7fd59977 |
782 | } |
783 | } |
784 | //================================================================================ |
785 | //function: FUN_NewFirstLast |
786 | //================================================================================ |
787 | static void FUN_NewFirstLast(const GeomAbs_CurveType& ga_ct, |
788 | const Standard_Real& Fst, |
789 | const Standard_Real& Lst, |
790 | const Standard_Real& TrVal, |
791 | Standard_Real& NewFst, |
792 | Standard_Real& NewLst, |
793 | Standard_Boolean& NeedTr) |
794 | { |
795 | NewFst = Fst; NewLst = Lst; NeedTr = Standard_False; |
796 | switch (ga_ct) |
797 | { |
798 | case GeomAbs_Line: |
799 | case GeomAbs_Parabola: |
800 | { |
801 | if(Abs(Lst - Fst) > TrVal) |
1d18c75e |
802 | { |
803 | if(Fst >= 0. && Lst >= 0.) |
7fd59977 |
804 | { |
1d18c75e |
805 | NewFst = Fst; |
806 | NewLst = ((Fst + TrVal) < Lst) ? (Fst + TrVal) : Lst; |
807 | } |
808 | if(Fst < 0. && Lst < 0.) |
809 | { |
810 | NewLst = Lst; |
811 | NewFst = ((Lst - TrVal) > Fst) ? (Lst - TrVal) : Fst; |
812 | } |
813 | else |
814 | { |
815 | NewFst = (Fst < -TrVal) ? -TrVal : Fst; |
816 | NewLst = (Lst > TrVal) ? TrVal : Lst; |
817 | } |
818 | NeedTr = Standard_True; |
819 | } |
820 | break; |
7fd59977 |
821 | } |
1d18c75e |
822 | case GeomAbs_Hyperbola: |
7fd59977 |
823 | { |
824 | if(Abs(Lst - Fst) > 10.) |
1d18c75e |
825 | { |
826 | if(Fst >= 0. && Lst >= 0.) |
827 | { |
828 | if(Fst > 4.) return; |
829 | NewFst = Fst; |
830 | NewLst = (Lst > 4.) ? 4. : Lst; |
831 | } |
832 | if(Fst < 0. && Lst < 0.) |
833 | { |
834 | if(Lst < -4.) return; |
835 | NewLst = Lst; |
836 | NewFst = (Fst < -4.) ? -4. : Fst; |
837 | } |
838 | else |
839 | { |
840 | NewFst = (Fst < -4.) ? -4. : Fst; |
841 | NewLst = (Lst > 4.) ? 4. : Lst; |
842 | } |
843 | NeedTr = Standard_True; |
844 | } |
7fd59977 |
845 | break; |
846 | } |
1d18c75e |
847 | default: |
566f8441 |
848 | break; |
7fd59977 |
849 | } |
850 | } |
851 | //================================================================================ |
852 | //function: FUN_TrimBothSurf |
1d18c75e |
853 | //================================================================================ |
7fd59977 |
854 | static void FUN_TrimBothSurf(const Handle(Adaptor3d_HSurface)& S1, |
855 | const GeomAbs_SurfaceType& T1, |
856 | const Handle(Adaptor3d_HSurface)& S2, |
857 | const GeomAbs_SurfaceType& T2, |
858 | const Standard_Real& TV, |
859 | Handle(Adaptor3d_HSurface)& NS1, |
860 | Handle(Adaptor3d_HSurface)& NS2) |
861 | { |
862 | const GeomAdaptor_Surface & gas1 = *(GeomAdaptor_Surface*)(&(S1->Surface())); |
863 | const GeomAdaptor_Surface & gas2 = *(GeomAdaptor_Surface*)(&(S2->Surface())); |
864 | const Handle(Geom_Surface) gs1 = gas1.Surface(); |
865 | const Handle(Geom_Surface) gs2 = gas2.Surface(); |
866 | const Standard_Real UM1 = 0.5 * (S1->LastUParameter() + S1->FirstUParameter()); |
867 | const Standard_Real UM2 = 0.5 * (S2->LastUParameter() + S2->FirstUParameter()); |
868 | const Standard_Real VM1 = 0.5 * (S1->LastVParameter() + S1->FirstVParameter()); |
869 | const Standard_Real VM2 = 0.5 * (S2->LastVParameter() + S2->FirstVParameter()); |
870 | Handle(Geom_Curve) visoS1, visoS2, uisoS1, uisoS2; |
871 | if(T1 != GeomAbs_OffsetSurface){ visoS1 = gs1->VIso(VM1); uisoS1 = gs1->UIso(UM1); } |
872 | else |
873 | { |
c5f3a425 |
874 | const Handle(Geom_OffsetSurface) gos = Handle(Geom_OffsetSurface)::DownCast (gs1); |
7fd59977 |
875 | const Handle(Geom_Surface) bs = gos->BasisSurface(); |
876 | visoS1 = bs->VIso(VM1); uisoS1 = bs->UIso(UM1); |
877 | } |
878 | if(T2 != GeomAbs_OffsetSurface){ visoS2 = gs2->VIso(VM2); uisoS2 = gs2->UIso(UM2); } |
879 | else |
880 | { |
c5f3a425 |
881 | const Handle(Geom_OffsetSurface) gos = Handle(Geom_OffsetSurface)::DownCast (gs2); |
7fd59977 |
882 | const Handle(Geom_Surface) bs = gos->BasisSurface(); |
883 | visoS2 = bs->VIso(VM2); uisoS2 = bs->UIso(UM2); |
884 | } |
885 | if(uisoS1.IsNull() || uisoS2.IsNull() || visoS1.IsNull() || visoS2.IsNull()){ NS1 = S1; NS2 = S2; return; } |
886 | GeomAdaptor_Curve gau1(uisoS1); |
887 | GeomAdaptor_Curve gav1(visoS1); |
888 | GeomAdaptor_Curve gau2(uisoS2); |
889 | GeomAdaptor_Curve gav2(visoS2); |
890 | GeomAbs_CurveType GA_U1 = gau1.GetType(); |
891 | GeomAbs_CurveType GA_V1 = gav1.GetType(); |
892 | GeomAbs_CurveType GA_U2 = gau2.GetType(); |
893 | GeomAbs_CurveType GA_V2 = gav2.GetType(); |
894 | Standard_Boolean TrmU1 = Standard_False; |
895 | Standard_Boolean TrmV1 = Standard_False; |
896 | Standard_Boolean TrmU2 = Standard_False; |
897 | Standard_Boolean TrmV2 = Standard_False; |
898 | Standard_Real V1S1,V2S1,U1S1,U2S1, V1S2,V2S2,U1S2,U2S2; |
899 | FUN_NewFirstLast(GA_U1,S1->FirstVParameter(),S1->LastVParameter(),TV,V1S1,V2S1,TrmV1); |
900 | FUN_NewFirstLast(GA_V1,S1->FirstUParameter(),S1->LastUParameter(),TV,U1S1,U2S1,TrmU1); |
901 | FUN_NewFirstLast(GA_U2,S2->FirstVParameter(),S2->LastVParameter(),TV,V1S2,V2S2,TrmV2); |
902 | FUN_NewFirstLast(GA_V2,S2->FirstUParameter(),S2->LastUParameter(),TV,U1S2,U2S2,TrmU2); |
903 | if(TrmV1) NS1 = S1->VTrim(V1S1, V2S1, 1.0e-7); |
904 | if(TrmV2) NS2 = S2->VTrim(V1S2, V2S2, 1.0e-7); |
905 | if(TrmU1) |
906 | { |
907 | if(TrmV1) |
1d18c75e |
908 | { |
909 | Handle(Adaptor3d_HSurface) TS = NS1; |
910 | NS1 = TS->UTrim(U1S1, U2S1, 1.0e-7); |
911 | } |
7fd59977 |
912 | else NS1 = S1->UTrim(U1S1, U2S1, 1.0e-7); |
913 | } |
914 | if(TrmU2) |
915 | { |
916 | if(TrmV2) |
1d18c75e |
917 | { |
918 | Handle(Adaptor3d_HSurface) TS = NS2; |
919 | NS2 = TS->UTrim(U1S2, U2S2, 1.0e-7); |
920 | } |
7fd59977 |
921 | else NS2 = S2->UTrim(U1S2, U2S2, 1.0e-7); |
922 | } |
923 | } |
924 | |
925 | //======================================================================= |
926 | //function : Perform |
927 | //purpose : |
928 | //======================================================================= |
788cbaf4 |
929 | void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& theS1, |
930 | const Handle(Adaptor3d_TopolTool)& theD1, |
931 | const Handle(Adaptor3d_HSurface)& theS2, |
932 | const Handle(Adaptor3d_TopolTool)& theD2, |
7fd59977 |
933 | const Standard_Real TolArc, |
788cbaf4 |
934 | const Standard_Real TolTang, |
d4b867e6 |
935 | const Standard_Boolean isGeomInt, |
936 | const Standard_Boolean theIsReqToKeepRLine) |
788cbaf4 |
937 | { |
7fd59977 |
938 | myTolArc = TolArc; |
939 | myTolTang = TolTang; |
788cbaf4 |
940 | if(myFleche <= Precision::PConfusion()) |
941 | myFleche = 0.01; |
942 | if(myUVMaxStep <= Precision::PConfusion()) |
943 | myUVMaxStep = 0.01; |
944 | |
7fd59977 |
945 | done = Standard_False; |
946 | spnt.Clear(); |
947 | slin.Clear(); |
948 | empt = Standard_True; |
949 | tgte = Standard_False; |
950 | oppo = Standard_False; |
951 | |
788cbaf4 |
952 | GeomAbs_SurfaceType typs1 = theS1->GetType(); |
953 | GeomAbs_SurfaceType typs2 = theS2->GetType(); |
7fd59977 |
954 | |
18d25b93 |
955 | //treatment of the cases with cone or torus |
7fd59977 |
956 | Standard_Boolean TreatAsBiParametric = Standard_False; |
1d18c75e |
957 | Standard_Integer bGeomGeom = 0; |
18d25b93 |
958 | // |
959 | if (typs1 == GeomAbs_Cone || typs2 == GeomAbs_Cone || |
960 | typs1 == GeomAbs_Torus || typs2 == GeomAbs_Torus) { |
961 | gp_Ax1 aCTAx, aGeomAx; |
962 | GeomAbs_SurfaceType aCTType; |
963 | Standard_Boolean bToCheck; |
964 | // |
965 | const Handle(Adaptor3d_HSurface)& aCTSurf = |
966 | (typs1 == GeomAbs_Cone || typs1 == GeomAbs_Torus) ? theS1 : theS2; |
967 | const Handle(Adaptor3d_HSurface)& aGeomSurf = |
968 | (typs1 == GeomAbs_Cone || typs1 == GeomAbs_Torus) ? theS2 : theS1; |
969 | // |
970 | aCTType = aCTSurf->GetType(); |
971 | bToCheck = Standard_False; |
972 | // |
1d18c75e |
973 | if (typs1 == GeomAbs_Cone || typs2 == GeomAbs_Cone) { |
974 | const gp_Cone aCon1 = (aCTType == GeomAbs_Cone) ? |
975 | aCTSurf->Cone() : aGeomSurf->Cone(); |
976 | Standard_Real a1 = Abs(aCon1.SemiAngle()); |
18d25b93 |
977 | bToCheck = (a1 < 0.02) || (a1 > 1.55); |
1d18c75e |
978 | // |
18d25b93 |
979 | if (typs1 == typs2) { |
1d18c75e |
980 | const gp_Cone aCon2 = aGeomSurf->Cone(); |
981 | Standard_Real a2 = Abs(aCon2.SemiAngle()); |
18d25b93 |
982 | bToCheck = bToCheck || (a2 < 0.02) || (a2 > 1.55); |
983 | // |
984 | if (a1 > 1.55 && a2 > 1.55) {//quasi-planes: if same domain, treat as canonic |
18d25b93 |
985 | const gp_Ax1 A1 = aCon1.Axis(), A2 = aCon2.Axis(); |
986 | if (A1.IsParallel(A2,Precision::Angular())) { |
987 | const gp_Pnt Apex1 = aCon1.Apex(), Apex2 = aCon2.Apex(); |
988 | const gp_Pln Plan1( Apex1, A1.Direction() ); |
989 | if (Plan1.Distance( Apex2 ) <= Precision::Confusion()) { |
990 | bToCheck = Standard_False; |
18d25b93 |
991 | } |
788cbaf4 |
992 | } |
993 | } |
7fd59977 |
994 | } |
18d25b93 |
995 | // |
1d18c75e |
996 | TreatAsBiParametric = bToCheck; |
997 | if (aCTType == GeomAbs_Cone) { |
998 | aCTAx = aCon1.Axis(); |
999 | } |
7fd59977 |
1000 | } |
1d18c75e |
1001 | // |
1002 | if (typs1 == GeomAbs_Torus || typs2 == GeomAbs_Torus) { |
1003 | const gp_Torus aTor1 = (aCTType == GeomAbs_Torus) ? |
1004 | aCTSurf->Torus() : aGeomSurf->Torus(); |
1005 | bToCheck = aTor1.MajorRadius() > aTor1.MinorRadius(); |
1006 | if (typs1 == typs2) { |
1007 | const gp_Torus aTor2 = aGeomSurf->Torus(); |
1008 | bToCheck = aTor2.MajorRadius() > aTor2.MinorRadius(); |
1009 | } |
1010 | // |
1011 | if (aCTType == GeomAbs_Torus) { |
1012 | aCTAx = aTor1.Axis(); |
18d25b93 |
1013 | } |
18d25b93 |
1014 | } |
1015 | // |
1016 | if (bToCheck) { |
1017 | const gp_Lin aL1(aCTAx); |
1018 | // |
1019 | switch (aGeomSurf->GetType()) { |
1020 | case GeomAbs_Plane: { |
1021 | aGeomAx = aGeomSurf->Plane().Axis(); |
1022 | if (aCTType == GeomAbs_Cone) { |
1d18c75e |
1023 | bGeomGeom = 1; |
18d25b93 |
1024 | if (Abs(aCTSurf->Cone().SemiAngle()) < 0.02) { |
1025 | Standard_Real ps = Abs(aCTAx.Direction().Dot(aGeomAx.Direction())); |
1026 | if(ps < 0.015) { |
1d18c75e |
1027 | bGeomGeom = 0; |
18d25b93 |
1028 | } |
788cbaf4 |
1029 | } |
1030 | } |
18d25b93 |
1031 | else { |
1032 | if (aCTAx.IsParallel(aGeomAx, Precision::Angular()) || |
1033 | (aCTAx.IsNormal(aGeomAx, Precision::Angular()) && |
1034 | (aGeomSurf->Plane().Distance(aCTAx.Location()) < Precision::Confusion()))) { |
1d18c75e |
1035 | bGeomGeom = 1; |
18d25b93 |
1036 | } |
1037 | } |
1038 | bToCheck = Standard_False; |
1039 | break; |
7fd59977 |
1040 | } |
18d25b93 |
1041 | case GeomAbs_Sphere: { |
1042 | if (aL1.Distance(aGeomSurf->Sphere().Location()) < Precision::Confusion()) { |
1d18c75e |
1043 | bGeomGeom = 1; |
18d25b93 |
1044 | } |
1045 | bToCheck = Standard_False; |
1046 | break; |
7fd59977 |
1047 | } |
18d25b93 |
1048 | case GeomAbs_Cylinder: |
1049 | aGeomAx = aGeomSurf->Cylinder().Axis(); |
1050 | break; |
1051 | case GeomAbs_Cone: |
1052 | aGeomAx = aGeomSurf->Cone().Axis(); |
1053 | break; |
1054 | case GeomAbs_Torus: |
1055 | aGeomAx = aGeomSurf->Torus().Axis(); |
1056 | break; |
1057 | default: |
1058 | bToCheck = Standard_False; |
1059 | break; |
1060 | } |
1061 | // |
1062 | if (bToCheck) { |
1063 | if (aCTAx.IsParallel(aGeomAx, Precision::Angular()) && |
1064 | (aL1.Distance(aGeomAx.Location()) <= Precision::Confusion())) { |
1d18c75e |
1065 | bGeomGeom = 1; |
788cbaf4 |
1066 | } |
7fd59977 |
1067 | } |
18d25b93 |
1068 | // |
1d18c75e |
1069 | if (bGeomGeom == 1) { |
1070 | TreatAsBiParametric = Standard_False; |
18d25b93 |
1071 | } |
1072 | } |
1073 | } |
1074 | // |
788cbaf4 |
1075 | |
1076 | if(theD1->DomainIsInfinite() || theD2->DomainIsInfinite()) { |
bf0ba813 |
1077 | TreatAsBiParametric= Standard_False; |
1078 | } |
7fd59977 |
1079 | |
1080 | // Modified by skv - Mon Sep 26 14:58:30 2005 Begin |
1081 | // if(TreatAsBiParametric) { typs1 = typs2 = GeomAbs_BezierSurface; } |
788cbaf4 |
1082 | if(TreatAsBiParametric) |
1083 | { |
7fd59977 |
1084 | if (typs1 == GeomAbs_Cone && typs2 == GeomAbs_Plane) |
1085 | typs1 = GeomAbs_BezierSurface; // Using Imp-Prm Intersector |
1086 | else if (typs1 == GeomAbs_Plane && typs2 == GeomAbs_Cone) |
1087 | typs2 = GeomAbs_BezierSurface; // Using Imp-Prm Intersector |
1088 | else { |
1089 | // Using Prm-Prm Intersector |
1090 | typs1 = GeomAbs_BezierSurface; |
1091 | typs2 = GeomAbs_BezierSurface; |
1092 | } |
1093 | } |
1094 | // Modified by skv - Mon Sep 26 14:58:30 2005 End |
1095 | |
1096 | // Surface type definition |
1097 | Standard_Integer ts1 = 0; |
1098 | switch (typs1) |
1099 | { |
1100 | case GeomAbs_Plane: |
1101 | case GeomAbs_Cylinder: |
1102 | case GeomAbs_Sphere: |
1103 | case GeomAbs_Cone: ts1 = 1; break; |
1d18c75e |
1104 | case GeomAbs_Torus: ts1 = bGeomGeom; break; |
7fd59977 |
1105 | default: break; |
1106 | } |
788cbaf4 |
1107 | |
7fd59977 |
1108 | Standard_Integer ts2 = 0; |
1109 | switch (typs2) |
1110 | { |
1111 | case GeomAbs_Plane: |
1112 | case GeomAbs_Cylinder: |
1113 | case GeomAbs_Sphere: |
1114 | case GeomAbs_Cone: ts2 = 1; break; |
1d18c75e |
1115 | case GeomAbs_Torus: ts2 = bGeomGeom; break; |
7fd59977 |
1116 | default: break; |
1117 | } |
7eed5d29 |
1118 | // |
1119 | // treatment of the cases with torus and any other geom surface |
7eed5d29 |
1120 | // |
7fd59977 |
1121 | // Possible intersection types: 1. ts1 == ts2 == 1 <Geom-Geom> |
1122 | // 2. ts1 != ts2 <Geom-Param> |
1123 | // 3. ts1 == ts2 == 0 <Param-Param> |
1124 | |
1125 | // Geom - Geom |
1126 | if(ts1 == ts2 && ts1 == 1) |
1127 | { |
788cbaf4 |
1128 | const Standard_Boolean RestrictLine = Standard_True; |
1129 | IntSurf_ListOfPntOn2S ListOfPnts; |
1130 | ListOfPnts.Clear(); |
1131 | if(isGeomInt) |
1132 | { |
02effd35 |
1133 | if(theD1->DomainIsInfinite() || theD2->DomainIsInfinite()) |
1134 | { |
d4b867e6 |
1135 | GeomGeomPerfom( theS1, theD1, theS2, theD2, TolArc, |
1136 | TolTang, ListOfPnts, RestrictLine, |
1137 | typs1, typs2, theIsReqToKeepRLine); |
02effd35 |
1138 | } |
1139 | else |
1140 | { |
d4b867e6 |
1141 | GeomGeomPerfomTrimSurf( theS1, theD1, theS2, theD2, |
1142 | TolArc, TolTang, ListOfPnts, RestrictLine, |
1143 | typs1, typs2, theIsReqToKeepRLine); |
02effd35 |
1144 | } |
788cbaf4 |
1145 | } |
1146 | else |
1147 | { |
02effd35 |
1148 | ParamParamPerfom(theS1, theD1, theS2, theD2, |
1149 | TolArc, TolTang, ListOfPnts, RestrictLine, typs1, typs2); |
788cbaf4 |
1150 | } |
7fd59977 |
1151 | } |
788cbaf4 |
1152 | |
7fd59977 |
1153 | // Geom - Param |
1154 | if(ts1 != ts2) |
1155 | { |
788cbaf4 |
1156 | GeomParamPerfom(theS1, theD1, theS2, theD2, ts1 == 0, typs1, typs2); |
7fd59977 |
1157 | } |
788cbaf4 |
1158 | |
7fd59977 |
1159 | // Param - Param |
1160 | if(ts1 == ts2 && ts1 == 0) |
1161 | { |
788cbaf4 |
1162 | const Standard_Boolean RestrictLine = Standard_True; |
1163 | IntSurf_ListOfPntOn2S ListOfPnts; |
1164 | ListOfPnts.Clear(); |
1165 | |
02effd35 |
1166 | ParamParamPerfom(theS1, theD1, theS2, theD2, TolArc, |
1167 | TolTang, ListOfPnts, RestrictLine, typs1, typs2); |
7fd59977 |
1168 | } |
1169 | } |
18d25b93 |
1170 | |
7fd59977 |
1171 | //======================================================================= |
1172 | //function : Perform |
1173 | //purpose : |
1174 | //======================================================================= |
788cbaf4 |
1175 | void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& theS1, |
1176 | const Handle(Adaptor3d_TopolTool)& theD1, |
1177 | const Handle(Adaptor3d_HSurface)& theS2, |
1178 | const Handle(Adaptor3d_TopolTool)& theD2, |
7fd59977 |
1179 | const Standard_Real TolArc, |
1180 | const Standard_Real TolTang, |
1181 | IntSurf_ListOfPntOn2S& ListOfPnts, |
788cbaf4 |
1182 | const Standard_Boolean RestrictLine, |
1183 | const Standard_Boolean isGeomInt) |
7fd59977 |
1184 | { |
1185 | myTolArc = TolArc; |
1186 | myTolTang = TolTang; |
788cbaf4 |
1187 | if(myFleche <= Precision::PConfusion()) |
1188 | myFleche = 0.01; |
1189 | if(myUVMaxStep <= Precision::PConfusion()) |
1190 | myUVMaxStep = 0.01; |
7fd59977 |
1191 | |
1192 | done = Standard_False; |
1193 | spnt.Clear(); |
1194 | slin.Clear(); |
1195 | empt = Standard_True; |
1196 | tgte = Standard_False; |
1197 | oppo = Standard_False; |
1198 | |
788cbaf4 |
1199 | GeomAbs_SurfaceType typs1 = theS1->GetType(); |
1200 | GeomAbs_SurfaceType typs2 = theS2->GetType(); |
18d25b93 |
1201 | // |
1202 | //treatment of the cases with cone or torus |
7fd59977 |
1203 | Standard_Boolean TreatAsBiParametric = Standard_False; |
1d18c75e |
1204 | Standard_Integer bGeomGeom = 0; |
18d25b93 |
1205 | // |
1206 | if (typs1 == GeomAbs_Cone || typs2 == GeomAbs_Cone || |
1207 | typs1 == GeomAbs_Torus || typs2 == GeomAbs_Torus) { |
1208 | gp_Ax1 aCTAx, aGeomAx; |
1209 | GeomAbs_SurfaceType aCTType; |
1210 | Standard_Boolean bToCheck; |
1211 | // |
1212 | const Handle(Adaptor3d_HSurface)& aCTSurf = |
1213 | (typs1 == GeomAbs_Cone || typs1 == GeomAbs_Torus) ? theS1 : theS2; |
1214 | const Handle(Adaptor3d_HSurface)& aGeomSurf = |
1215 | (typs1 == GeomAbs_Cone || typs1 == GeomAbs_Torus) ? theS2 : theS1; |
1216 | // |
1217 | aCTType = aCTSurf->GetType(); |
1218 | bToCheck = Standard_False; |
1219 | // |
1d18c75e |
1220 | if (typs1 == GeomAbs_Cone || typs2 == GeomAbs_Cone) { |
1221 | const gp_Cone aCon1 = (aCTType == GeomAbs_Cone) ? |
1222 | aCTSurf->Cone() : aGeomSurf->Cone(); |
1223 | Standard_Real a1 = Abs(aCon1.SemiAngle()); |
18d25b93 |
1224 | bToCheck = (a1 < 0.02) || (a1 > 1.55); |
1d18c75e |
1225 | // |
18d25b93 |
1226 | if (typs1 == typs2) { |
1d18c75e |
1227 | const gp_Cone aCon2 = aGeomSurf->Cone(); |
1228 | Standard_Real a2 = Abs(aCon2.SemiAngle()); |
18d25b93 |
1229 | bToCheck = bToCheck || (a2 < 0.02) || (a2 > 1.55); |
1230 | // |
1231 | if (a1 > 1.55 && a2 > 1.55) {//quasi-planes: if same domain, treat as canonic |
18d25b93 |
1232 | const gp_Ax1 A1 = aCon1.Axis(), A2 = aCon2.Axis(); |
1233 | if (A1.IsParallel(A2,Precision::Angular())) { |
1234 | const gp_Pnt Apex1 = aCon1.Apex(), Apex2 = aCon2.Apex(); |
1235 | const gp_Pln Plan1( Apex1, A1.Direction() ); |
1236 | if (Plan1.Distance( Apex2 ) <= Precision::Confusion()) { |
1237 | bToCheck = Standard_False; |
18d25b93 |
1238 | } |
788cbaf4 |
1239 | } |
1240 | } |
7fd59977 |
1241 | } |
18d25b93 |
1242 | // |
1d18c75e |
1243 | TreatAsBiParametric = bToCheck; |
1244 | if (aCTType == GeomAbs_Cone) { |
1245 | aCTAx = aCon1.Axis(); |
1246 | } |
788cbaf4 |
1247 | } |
1d18c75e |
1248 | // |
1249 | if (typs1 == GeomAbs_Torus || typs2 == GeomAbs_Torus) { |
1250 | const gp_Torus aTor1 = (aCTType == GeomAbs_Torus) ? |
1251 | aCTSurf->Torus() : aGeomSurf->Torus(); |
1252 | bToCheck = aTor1.MajorRadius() > aTor1.MinorRadius(); |
1253 | if (typs1 == typs2) { |
1254 | const gp_Torus aTor2 = aGeomSurf->Torus(); |
1255 | bToCheck = aTor2.MajorRadius() > aTor2.MinorRadius(); |
1256 | } |
1257 | // |
1258 | if (aCTType == GeomAbs_Torus) { |
1259 | aCTAx = aTor1.Axis(); |
18d25b93 |
1260 | } |
18d25b93 |
1261 | } |
1262 | // |
1263 | if (bToCheck) { |
1264 | const gp_Lin aL1(aCTAx); |
1265 | // |
1266 | switch (aGeomSurf->GetType()) { |
1267 | case GeomAbs_Plane: { |
1268 | aGeomAx = aGeomSurf->Plane().Axis(); |
1269 | if (aCTType == GeomAbs_Cone) { |
1d18c75e |
1270 | bGeomGeom = 1; |
18d25b93 |
1271 | if (Abs(aCTSurf->Cone().SemiAngle()) < 0.02) { |
1272 | Standard_Real ps = Abs(aCTAx.Direction().Dot(aGeomAx.Direction())); |
1273 | if(ps < 0.015) { |
1d18c75e |
1274 | bGeomGeom = 0; |
18d25b93 |
1275 | } |
788cbaf4 |
1276 | } |
1277 | } |
18d25b93 |
1278 | else { |
1279 | if (aCTAx.IsParallel(aGeomAx, Precision::Angular()) || |
1280 | (aCTAx.IsNormal(aGeomAx, Precision::Angular()) && |
1281 | (aGeomSurf->Plane().Distance(aCTAx.Location()) < Precision::Confusion()))) { |
1d18c75e |
1282 | bGeomGeom = 1; |
18d25b93 |
1283 | } |
1284 | } |
1285 | bToCheck = Standard_False; |
1286 | break; |
7fd59977 |
1287 | } |
18d25b93 |
1288 | case GeomAbs_Sphere: { |
1289 | if (aL1.Distance(aGeomSurf->Sphere().Location()) < Precision::Confusion()) { |
1d18c75e |
1290 | bGeomGeom = 1; |
18d25b93 |
1291 | } |
1292 | bToCheck = Standard_False; |
1293 | break; |
7fd59977 |
1294 | } |
18d25b93 |
1295 | case GeomAbs_Cylinder: |
1296 | aGeomAx = aGeomSurf->Cylinder().Axis(); |
1297 | break; |
1298 | case GeomAbs_Cone: |
1299 | aGeomAx = aGeomSurf->Cone().Axis(); |
1300 | break; |
1301 | case GeomAbs_Torus: |
1302 | aGeomAx = aGeomSurf->Torus().Axis(); |
1303 | break; |
1304 | default: |
1305 | bToCheck = Standard_False; |
1306 | break; |
1307 | } |
1308 | // |
1309 | if (bToCheck) { |
1310 | if (aCTAx.IsParallel(aGeomAx, Precision::Angular()) && |
1311 | (aL1.Distance(aGeomAx.Location()) <= Precision::Confusion())) { |
1d18c75e |
1312 | bGeomGeom = 1; |
788cbaf4 |
1313 | } |
7fd59977 |
1314 | } |
18d25b93 |
1315 | // |
1d18c75e |
1316 | if (bGeomGeom == 1) { |
1317 | TreatAsBiParametric = Standard_False; |
18d25b93 |
1318 | } |
1319 | } |
1320 | } |
1321 | // |
7fd59977 |
1322 | |
788cbaf4 |
1323 | if(theD1->DomainIsInfinite() || theD2->DomainIsInfinite()) { |
bf0ba813 |
1324 | TreatAsBiParametric= Standard_False; |
1325 | } |
788cbaf4 |
1326 | |
1327 | if(TreatAsBiParametric) |
1328 | { |
1329 | // Using Prm-Prm Intersector |
1330 | typs1 = GeomAbs_BezierSurface; |
1331 | typs2 = GeomAbs_BezierSurface; |
bf0ba813 |
1332 | } |
7fd59977 |
1333 | |
1334 | // Surface type definition |
1335 | Standard_Integer ts1 = 0; |
1336 | switch (typs1) |
1337 | { |
1338 | case GeomAbs_Plane: |
1339 | case GeomAbs_Cylinder: |
1340 | case GeomAbs_Sphere: |
1341 | case GeomAbs_Cone: ts1 = 1; break; |
1d18c75e |
1342 | case GeomAbs_Torus: ts1 = bGeomGeom; break; |
7fd59977 |
1343 | default: break; |
1344 | } |
788cbaf4 |
1345 | |
7fd59977 |
1346 | Standard_Integer ts2 = 0; |
1347 | switch (typs2) |
1348 | { |
1349 | case GeomAbs_Plane: |
1350 | case GeomAbs_Cylinder: |
1351 | case GeomAbs_Sphere: |
1352 | case GeomAbs_Cone: ts2 = 1; break; |
1d18c75e |
1353 | case GeomAbs_Torus: ts2 = bGeomGeom; break; |
7fd59977 |
1354 | default: break; |
1355 | } |
7eed5d29 |
1356 | // |
7fd59977 |
1357 | // Possible intersection types: 1. ts1 == ts2 == 1 <Geom-Geom> |
1358 | // 2. ts1 != ts2 <Geom-Param> |
1359 | // 3. ts1 == ts2 == 0 <Param-Param> |
1360 | |
788cbaf4 |
1361 | if(!isGeomInt) |
7fd59977 |
1362 | { |
02effd35 |
1363 | ParamParamPerfom(theS1, theD1, theS2, theD2, |
1364 | TolArc, TolTang, ListOfPnts, RestrictLine, typs1, typs2); |
7fd59977 |
1365 | } |
788cbaf4 |
1366 | else if(ts1 != ts2) |
1367 | { |
1368 | GeomParamPerfom(theS1, theD1, theS2, theD2, ts1 == 0, typs1, typs2); |
1369 | } |
1370 | else if (ts1 == 0) |
1371 | { |
02effd35 |
1372 | ParamParamPerfom(theS1, theD1, theS2, theD2, |
1373 | TolArc, TolTang, ListOfPnts, RestrictLine, typs1, typs2); |
788cbaf4 |
1374 | } |
1375 | else if(ts1 == 1) |
1376 | { |
ecc4f148 |
1377 | if(theD1->DomainIsInfinite() || theD2->DomainIsInfinite()) |
1378 | { |
1379 | GeomGeomPerfom(theS1, theD1, theS2, theD2, TolArc, |
1380 | TolTang, ListOfPnts, RestrictLine, typs1, typs2); |
1381 | } |
1382 | else |
1383 | { |
1384 | GeomGeomPerfomTrimSurf(theS1, theD1, theS2, theD2, |
1385 | TolArc, TolTang, ListOfPnts, RestrictLine, typs1, typs2); |
1386 | } |
788cbaf4 |
1387 | } |
1388 | } |
1389 | |
1390 | //======================================================================= |
1391 | //function : ParamParamPerfom |
1392 | //purpose : |
1393 | //======================================================================= |
1394 | void IntPatch_Intersection::ParamParamPerfom(const Handle(Adaptor3d_HSurface)& theS1, |
1395 | const Handle(Adaptor3d_TopolTool)& theD1, |
1396 | const Handle(Adaptor3d_HSurface)& theS2, |
1397 | const Handle(Adaptor3d_TopolTool)& theD2, |
1398 | const Standard_Real TolArc, |
1399 | const Standard_Real TolTang, |
1400 | IntSurf_ListOfPntOn2S& ListOfPnts, |
1401 | const Standard_Boolean RestrictLine, |
1402 | const GeomAbs_SurfaceType typs1, |
1403 | const GeomAbs_SurfaceType typs2) |
1404 | { |
1405 | IntPatch_PrmPrmIntersection interpp; |
1406 | if(!theD1->DomainIsInfinite() && !theD2->DomainIsInfinite()) |
7fd59977 |
1407 | { |
788cbaf4 |
1408 | Standard_Boolean ClearFlag = Standard_True; |
1409 | if(!ListOfPnts.IsEmpty()) |
1410 | { |
1411 | interpp.Perform(theS1,theD1,theS2,theD2,TolArc,TolTang,myFleche,myUVMaxStep, ListOfPnts, RestrictLine); |
1412 | ClearFlag = Standard_False; |
7fd59977 |
1413 | } |
788cbaf4 |
1414 | interpp.Perform(theS1,theD1,theS2,theD2,TolArc,TolTang,myFleche,myUVMaxStep,ClearFlag); //double call!!!!!!! |
7fd59977 |
1415 | } |
788cbaf4 |
1416 | else if((theD1->DomainIsInfinite()) ^ (theD2->DomainIsInfinite())) |
7fd59977 |
1417 | { |
788cbaf4 |
1418 | gp_Pnt pMaxXYZ, pMinXYZ; |
1419 | if(theD1->DomainIsInfinite()) |
1420 | { |
1421 | FUN_GetMinMaxXYZPnt( theS2, pMinXYZ, pMaxXYZ ); |
1422 | const Standard_Real MU = Max(Abs(theS2->FirstUParameter()),Abs(theS2->LastUParameter())); |
1423 | const Standard_Real MV = Max(Abs(theS2->FirstVParameter()),Abs(theS2->LastVParameter())); |
1424 | const Standard_Real AP = Max(MU, MV); |
1425 | Handle(Adaptor3d_HSurface) SS; |
1426 | FUN_TrimInfSurf(pMinXYZ, pMaxXYZ, theS1, AP, SS); |
1427 | interpp.Perform(SS,theD1,theS2,theD2,TolArc,TolTang,myFleche,myUVMaxStep); |
1428 | } |
1429 | else |
1430 | { |
1431 | FUN_GetMinMaxXYZPnt( theS1, pMinXYZ, pMaxXYZ ); |
1432 | const Standard_Real MU = Max(Abs(theS1->FirstUParameter()),Abs(theS1->LastUParameter())); |
1433 | const Standard_Real MV = Max(Abs(theS1->FirstVParameter()),Abs(theS1->LastVParameter())); |
1434 | const Standard_Real AP = Max(MU, MV); |
1435 | Handle(Adaptor3d_HSurface) SS; |
1436 | FUN_TrimInfSurf(pMinXYZ, pMaxXYZ, theS2, AP, SS); |
1437 | interpp.Perform(theS1, theD1, SS, theD2,TolArc,TolTang,myFleche,myUVMaxStep); |
1438 | } |
1439 | }//(theD1->DomainIsInfinite()) ^ (theD2->DomainIsInfinite()) |
1440 | else |
1441 | { |
1442 | if(typs1 == GeomAbs_OtherSurface || typs2 == GeomAbs_OtherSurface) |
1443 | { |
1444 | done = Standard_False; |
1445 | return; |
1446 | } |
1447 | |
1448 | Standard_Boolean IsPLInt = Standard_False; |
1449 | TColgp_SequenceOfPnt sop; |
1450 | gp_Vec v; |
1451 | FUN_PL_Intersection(theS1,typs1,theS2,typs2,IsPLInt,sop,v); |
1452 | |
1453 | if(IsPLInt) |
1454 | { |
1455 | if(sop.Length() > 0) |
1456 | { |
1457 | for(Standard_Integer ip = 1; ip <= sop.Length(); ip++) |
1458 | { |
1459 | gp_Lin lin(sop.Value(ip),gp_Dir(v)); |
1460 | Handle(IntPatch_GLine) gl = new IntPatch_GLine(lin,Standard_False); |
c5f3a425 |
1461 | slin.Append(Handle(IntPatch_Line)::DownCast (gl)); |
788cbaf4 |
1462 | } |
1463 | |
1464 | done = Standard_True; |
7fd59977 |
1465 | } |
788cbaf4 |
1466 | else |
1467 | done = Standard_False; |
1468 | |
1469 | return; |
1470 | }// 'COLLINEAR LINES' |
1471 | else |
1472 | { |
1473 | Handle(Adaptor3d_HSurface) nS1 = theS1; |
1474 | Handle(Adaptor3d_HSurface) nS2 = theS2; |
1475 | FUN_TrimBothSurf(theS1,typs1,theS2,typs2,1.e+8,nS1,nS2); |
1476 | interpp.Perform(nS1,theD1,nS2,theD2,TolArc,TolTang,myFleche,myUVMaxStep); |
1477 | }// 'NON - COLLINEAR LINES' |
1478 | }// both domains are infinite |
1479 | |
1480 | if (interpp.IsDone()) |
1481 | { |
1482 | done = Standard_True; |
1483 | tgte = Standard_False; |
1484 | empt = interpp.IsEmpty(); |
1485 | |
1486 | for(Standard_Integer i = 1; i <= interpp.NbLines(); i++) |
1487 | { |
1488 | if(interpp.Line(i)->ArcType() != IntPatch_Walking) |
1489 | slin.Append(interpp.Line(i)); |
1490 | } |
1491 | |
1492 | for (Standard_Integer i = 1; i <= interpp.NbLines(); i++) |
1493 | { |
1494 | if(interpp.Line(i)->ArcType() == IntPatch_Walking) |
1495 | slin.Append(interpp.Line(i)); |
1496 | } |
1497 | } |
1498 | } |
1499 | |
1500 | //======================================================================= |
1501 | ////function : GeomGeomPerfom |
1502 | //purpose : |
1503 | //======================================================================= |
1504 | void IntPatch_Intersection::GeomGeomPerfom(const Handle(Adaptor3d_HSurface)& theS1, |
1505 | const Handle(Adaptor3d_TopolTool)& theD1, |
1506 | const Handle(Adaptor3d_HSurface)& theS2, |
1507 | const Handle(Adaptor3d_TopolTool)& theD2, |
1508 | const Standard_Real TolArc, |
1509 | const Standard_Real TolTang, |
1510 | IntSurf_ListOfPntOn2S& ListOfPnts, |
1511 | const Standard_Boolean RestrictLine, |
1512 | const GeomAbs_SurfaceType typs1, |
d4b867e6 |
1513 | const GeomAbs_SurfaceType typs2, |
1514 | const Standard_Boolean theIsReqToKeepRLine) |
788cbaf4 |
1515 | { |
d4b867e6 |
1516 | IntPatch_ImpImpIntersection interii(theS1,theD1,theS2,theD2, |
1517 | myTolArc,myTolTang, theIsReqToKeepRLine); |
788cbaf4 |
1518 | const Standard_Boolean anIS = interii.IsDone(); |
1519 | if (anIS) |
1520 | { |
1521 | done = anIS; |
1522 | empt = interii.IsEmpty(); |
1523 | if (!empt) |
1524 | { |
1525 | tgte = interii.TangentFaces(); |
1526 | if (tgte) |
1527 | oppo = interii.OppositeFaces(); |
1528 | |
1529 | for (Standard_Integer i = 1; i <= interii.NbLines(); i++) |
1530 | { |
857ffd5e |
1531 | const Handle(IntPatch_Line)& line = interii.Line(i); |
788cbaf4 |
1532 | if (line->ArcType() == IntPatch_Analytic) |
1533 | { |
1534 | const GeomAbs_SurfaceType typs1 = theS1->GetType(); |
1535 | const GeomAbs_SurfaceType typs2 = theS2->GetType(); |
1536 | IntSurf_Quadric Quad1,Quad2; |
1537 | |
1538 | switch(typs1) |
1539 | { |
1540 | case GeomAbs_Plane: |
1541 | Quad1.SetValue(theS1->Plane()); |
1542 | break; |
1543 | |
1544 | case GeomAbs_Cylinder: |
1545 | Quad1.SetValue(theS1->Cylinder()); |
1546 | break; |
1547 | |
1548 | case GeomAbs_Sphere: |
1549 | Quad1.SetValue(theS1->Sphere()); |
1550 | break; |
1551 | |
1552 | case GeomAbs_Cone: |
1553 | Quad1.SetValue(theS1->Cone()); |
1554 | break; |
1555 | |
7eed5d29 |
1556 | case GeomAbs_Torus: |
1557 | Quad1.SetValue(theS1->Torus()); |
1558 | break; |
1559 | |
788cbaf4 |
1560 | default: |
1561 | break; |
1562 | } |
1563 | |
1564 | switch(typs2) |
1565 | { |
1566 | case GeomAbs_Plane: |
1567 | Quad2.SetValue(theS2->Plane()); |
1568 | break; |
1569 | case GeomAbs_Cylinder: |
1570 | Quad2.SetValue(theS2->Cylinder()); |
1571 | break; |
1572 | |
1573 | case GeomAbs_Sphere: |
1574 | Quad2.SetValue(theS2->Sphere()); |
1575 | break; |
1576 | |
1577 | case GeomAbs_Cone: |
1578 | Quad2.SetValue(theS2->Cone()); |
1579 | break; |
1580 | |
7eed5d29 |
1581 | case GeomAbs_Torus: |
1582 | Quad2.SetValue(theS2->Torus()); |
1583 | break; |
1584 | |
788cbaf4 |
1585 | default: |
1586 | break; |
1587 | } |
1588 | |
1589 | IntPatch_ALineToWLine AToW(Quad1,Quad2,0.01,0.05,aNbPointsInALine); |
857ffd5e |
1590 | Handle(IntPatch_Line) wlin=AToW.MakeWLine((*((Handle(IntPatch_ALine) *)(&line)))); |
788cbaf4 |
1591 | slin.Append(wlin); |
1592 | } |
1593 | else |
1594 | slin.Append(interii.Line(i)); |
1595 | } |
1596 | |
1597 | for (Standard_Integer i = 1; i <= interii.NbPnts(); i++) |
1598 | { |
1599 | spnt.Append(interii.Point(i)); |
1600 | } |
1601 | } |
1602 | } |
1603 | else |
02effd35 |
1604 | ParamParamPerfom(theS1, theD1, theS2, theD2, |
1605 | TolArc, TolTang, ListOfPnts, RestrictLine, typs1, typs2); |
788cbaf4 |
1606 | } |
1607 | |
1608 | //======================================================================= |
ecc4f148 |
1609 | //function : GeomParamPerfom |
788cbaf4 |
1610 | //purpose : |
1611 | //======================================================================= |
ecc4f148 |
1612 | void IntPatch_Intersection:: |
1613 | GeomParamPerfom(const Handle(Adaptor3d_HSurface)& theS1, |
1614 | const Handle(Adaptor3d_TopolTool)& theD1, |
1615 | const Handle(Adaptor3d_HSurface)& theS2, |
1616 | const Handle(Adaptor3d_TopolTool)& theD2, |
1617 | const Standard_Boolean isNotAnalitical, |
1618 | const GeomAbs_SurfaceType typs1, |
1619 | const GeomAbs_SurfaceType typs2) |
788cbaf4 |
1620 | { |
1621 | IntPatch_ImpPrmIntersection interip; |
1622 | if (myIsStartPnt) |
1623 | { |
1624 | if (isNotAnalitical/*ts1 == 0*/) |
1625 | interip.SetStartPoint(myU1Start,myV1Start); |
1626 | else |
1627 | interip.SetStartPoint(myU2Start,myV2Start); |
1628 | } |
1629 | |
1630 | if(theD1->DomainIsInfinite() && theD2->DomainIsInfinite()) |
1631 | { |
1632 | Standard_Boolean IsPLInt = Standard_False; |
1633 | TColgp_SequenceOfPnt sop; |
1634 | gp_Vec v; |
1635 | FUN_PL_Intersection(theS1,typs1,theS2,typs2,IsPLInt,sop,v); |
1636 | |
1637 | if(IsPLInt) |
1638 | { |
1639 | if(sop.Length() > 0) |
1640 | { |
1641 | for(Standard_Integer ip = 1; ip <= sop.Length(); ip++) |
1642 | { |
1643 | gp_Lin lin(sop.Value(ip),gp_Dir(v)); |
1644 | Handle(IntPatch_GLine) gl = new IntPatch_GLine(lin,Standard_False); |
c5f3a425 |
1645 | slin.Append(Handle(IntPatch_Line)::DownCast (gl)); |
788cbaf4 |
1646 | } |
1647 | |
1648 | done = Standard_True; |
1649 | } |
1650 | else |
1651 | done = Standard_False; |
1652 | |
1653 | return; |
1654 | } |
1655 | else |
1656 | { |
1657 | Handle(Adaptor3d_HSurface) nS1 = theS1; |
1658 | Handle(Adaptor3d_HSurface) nS2 = theS2; |
1659 | FUN_TrimBothSurf(theS1,typs1,theS2,typs2,1.e+5,nS1,nS2); |
1660 | interip.Perform(nS1,theD1,nS2,theD2,myTolArc,myTolTang,myFleche,myUVMaxStep); |
1661 | } |
1662 | } |
1663 | else |
1664 | interip.Perform(theS1,theD1,theS2,theD2,myTolArc,myTolTang,myFleche,myUVMaxStep); |
1665 | |
1666 | if (interip.IsDone()) |
1667 | { |
1668 | done = Standard_True; |
1669 | empt = interip.IsEmpty(); |
1670 | |
1671 | if (!empt) |
1672 | { |
b92f3572 |
1673 | const Standard_Integer aNbLines = interip.NbLines(); |
1674 | for(Standard_Integer i = 1; i <= aNbLines; i++) |
788cbaf4 |
1675 | { |
1676 | if(interip.Line(i)->ArcType() != IntPatch_Walking) |
1677 | slin.Append(interip.Line(i)); |
1678 | } |
1679 | |
b92f3572 |
1680 | for(Standard_Integer i = 1; i <= aNbLines; i++) |
788cbaf4 |
1681 | { |
1682 | if(interip.Line(i)->ArcType() == IntPatch_Walking) |
1683 | slin.Append(interip.Line(i)); |
1684 | } |
1685 | |
1686 | for (Standard_Integer i = 1; i <= interip.NbPnts(); i++) |
1687 | spnt.Append(interip.Point(i)); |
1688 | } |
7fd59977 |
1689 | } |
1690 | } |
1691 | |
ecc4f148 |
1692 | //======================================================================= |
1693 | //function : GeomGeomPerfomTrimSurf |
1694 | //purpose : This function returns ready walking-line (which is not need |
1695 | // in convertation) as an intersection line between two |
1696 | // trimmed surfaces. |
1697 | //======================================================================= |
1698 | void IntPatch_Intersection:: |
1699 | GeomGeomPerfomTrimSurf( const Handle(Adaptor3d_HSurface)& theS1, |
1700 | const Handle(Adaptor3d_TopolTool)& theD1, |
1701 | const Handle(Adaptor3d_HSurface)& theS2, |
1702 | const Handle(Adaptor3d_TopolTool)& theD2, |
1703 | const Standard_Real theTolArc, |
1704 | const Standard_Real theTolTang, |
1705 | IntSurf_ListOfPntOn2S& theListOfPnts, |
1706 | const Standard_Boolean RestrictLine, |
1707 | const GeomAbs_SurfaceType theTyps1, |
d4b867e6 |
1708 | const GeomAbs_SurfaceType theTyps2, |
1709 | const Standard_Boolean theIsReqToKeepRLine) |
ecc4f148 |
1710 | { |
1711 | IntSurf_Quadric Quad1,Quad2; |
1712 | |
1713 | if((theTyps1 == GeomAbs_Cylinder) && (theTyps2 == GeomAbs_Cylinder)) |
1714 | { |
1715 | IntPatch_ImpImpIntersection anInt; |
d4b867e6 |
1716 | anInt.Perform(theS1, theD1, theS2, theD2, myTolArc, |
1717 | myTolTang, Standard_True, theIsReqToKeepRLine); |
ecc4f148 |
1718 | |
1719 | done = anInt.IsDone(); |
1720 | |
02effd35 |
1721 | if(done) |
ecc4f148 |
1722 | { |
02effd35 |
1723 | empt = anInt.IsEmpty(); |
1724 | if (!empt) |
1725 | { |
1726 | tgte = anInt.TangentFaces(); |
1727 | if (tgte) |
1728 | oppo = anInt.OppositeFaces(); |
ecc4f148 |
1729 | |
02effd35 |
1730 | const Standard_Integer aNbLin = anInt.NbLines(); |
1731 | const Standard_Integer aNbPts = anInt.NbPnts(); |
1732 | |
1733 | for(Standard_Integer aLID = 1; aLID <= aNbLin; aLID++) |
1734 | { |
1735 | const Handle(IntPatch_Line)& aLine = anInt.Line(aLID); |
1736 | slin.Append(aLine); |
1737 | } |
1738 | |
1739 | for(Standard_Integer aPID = 1; aPID <= aNbPts; aPID++) |
1740 | { |
1741 | const IntPatch_Point& aPoint = anInt.Point(aPID); |
1742 | spnt.Append(aPoint); |
1743 | } |
b2af2f56 |
1744 | |
1745 | JoinWLines( slin, spnt, theTolTang, |
1746 | theS1->IsUPeriodic()? theS1->UPeriod() : 0.0, |
1747 | theS2->IsUPeriodic()? theS2->UPeriod() : 0.0, |
1748 | theS1->IsVPeriodic()? theS1->VPeriod() : 0.0, |
1749 | theS2->IsVPeriodic()? theS2->VPeriod() : 0.0, |
1750 | theS1->FirstUParameter(), theS1->LastUParameter(), |
1751 | theS1->FirstVParameter(), theS1->LastVParameter(), |
1752 | theS2->FirstUParameter(), theS2->LastUParameter(), |
1753 | theS2->FirstVParameter(), theS2->LastVParameter()); |
02effd35 |
1754 | } |
ecc4f148 |
1755 | } |
1756 | } |
1757 | else |
1758 | { |
02effd35 |
1759 | GeomGeomPerfom(theS1, theD1, theS2, theD2, |
d4b867e6 |
1760 | theTolArc, theTolTang, theListOfPnts, |
1761 | RestrictLine, theTyps1, theTyps2, theIsReqToKeepRLine); |
ecc4f148 |
1762 | } |
1763 | } |
1764 | |
788cbaf4 |
1765 | |
7fd59977 |
1766 | void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& S1, |
1767 | const Handle(Adaptor3d_TopolTool)& D1, |
1768 | const Handle(Adaptor3d_HSurface)& S2, |
1769 | const Handle(Adaptor3d_TopolTool)& D2, |
1770 | const Standard_Real U1, |
1771 | const Standard_Real V1, |
1772 | const Standard_Real U2, |
1773 | const Standard_Real V2, |
1774 | const Standard_Real TolArc, |
1775 | const Standard_Real TolTang) |
1776 | { |
1777 | myTolArc = TolArc; |
1778 | myTolTang = TolTang; |
1779 | if(myFleche == 0.0) { |
1780 | #if DEBUG |
1781 | //cout<<" -- IntPatch_Intersection::myFleche fixe par defaut a 0.01 --"<<endl; |
1782 | //cout<<" -- Utiliser la Methode SetTolerances( ... ) "<<endl; |
1783 | #endif |
1784 | myFleche = 0.01; |
1785 | } |
1786 | if(myUVMaxStep==0.0) { |
1787 | #if DEBUG |
1788 | //cout<<" -- IntPatch_Intersection::myUVMaxStep fixe par defaut a 0.01 --"<<endl; |
1789 | //cout<<" -- Utiliser la Methode SetTolerances( ... ) "<<endl; |
1790 | #endif |
1791 | myUVMaxStep = 0.01; |
1792 | } |
1793 | |
1794 | done = Standard_False; |
1795 | spnt.Clear(); |
1796 | slin.Clear(); |
1797 | |
1798 | empt = Standard_True; |
1799 | tgte = Standard_False; |
1800 | oppo = Standard_False; |
1801 | |
1802 | const GeomAbs_SurfaceType typs1 = S1->GetType(); |
1803 | const GeomAbs_SurfaceType typs2 = S2->GetType(); |
1804 | |
1805 | if( typs1==GeomAbs_Plane |
1806 | || typs1==GeomAbs_Cylinder |
1807 | || typs1==GeomAbs_Sphere |
1808 | || typs1==GeomAbs_Cone |
1809 | || typs2==GeomAbs_Plane |
1810 | || typs2==GeomAbs_Cylinder |
1811 | || typs2==GeomAbs_Sphere |
1812 | || typs2==GeomAbs_Cone) |
1813 | { |
1814 | myIsStartPnt = Standard_True; |
1815 | myU1Start = U1; myV1Start = V1; myU2Start = U2; myV2Start = V2; |
1816 | Perform(S1,D1,S2,D2,TolArc,TolTang); |
1817 | myIsStartPnt = Standard_False; |
1818 | } |
1819 | else |
1820 | { |
1821 | IntPatch_PrmPrmIntersection interpp; |
1822 | interpp.Perform(S1,D1,S2,D2,U1,V1,U2,V2,TolArc,TolTang,myFleche,myUVMaxStep); |
1823 | if (interpp.IsDone()) |
1d18c75e |
1824 | { |
7fd59977 |
1825 | done = Standard_True; |
1826 | tgte = Standard_False; |
1827 | empt = interpp.IsEmpty(); |
1828 | const Standard_Integer nblm = interpp.NbLines(); |
1829 | Standard_Integer i = 1; |
1830 | for (; i<=nblm; i++) slin.Append(interpp.Line(i)); |
1831 | } |
1832 | } |
1833 | } |
1834 | //====================================================================== |
1835 | #include <IntPatch_IType.hxx> |
1836 | #include <IntPatch_LineConstructor.hxx> |
cb389a77 |
1837 | #include <Adaptor2d_HCurve2d.hxx> |
ec357c5c |
1838 | #include <Geom_Curve.hxx> |
7fd59977 |
1839 | #define MAXR 200 |
1840 | |
1841 | |
857ffd5e |
1842 | //void IntPatch_Intersection__MAJ_R(Handle(Adaptor2d_HCurve2d) *R1, |
1843 | // Handle(Adaptor2d_HCurve2d) *R2, |
1d18c75e |
1844 | // int *NR1, |
1845 | // int *NR2, |
1846 | // Standard_Integer nbR1, |
1847 | // Standard_Integer nbR2, |
1848 | // const IntPatch_Point& VTX) |
857ffd5e |
1849 | void IntPatch_Intersection__MAJ_R(Handle(Adaptor2d_HCurve2d) *, |
1850 | Handle(Adaptor2d_HCurve2d) *, |
1d18c75e |
1851 | int *, |
1852 | int *, |
1853 | Standard_Integer , |
1854 | Standard_Integer , |
1855 | const IntPatch_Point& ) |
7fd59977 |
1856 | { |
1857 | /* |
1858 | if(VTX.IsOnDomS1()) { |
1859 | |
857ffd5e |
1860 | //-- long unsigned ptr= *((long unsigned *)(((Handle(Standard_Transient) *)(&(VTX.ArcOnS1()))))); |
7fd59977 |
1861 | for(Standard_Integer i=0; i<nbR1;i++) { |
1862 | if(VTX.ArcOnS1()==R1[i]) { |
1d18c75e |
1863 | NR1[i]++; |
1864 | printf("\n ******************************"); |
1865 | return; |
7fd59977 |
1866 | } |
1867 | } |
1868 | printf("\n R Pas trouvee (IntPatch)\n"); |
1869 | |
1870 | } |
1871 | */ |
1872 | } |
1873 | |
1874 | |
1875 | //void IntPatch_Intersection::Dump(const Standard_Integer Mode, |
1876 | void IntPatch_Intersection::Dump(const Standard_Integer , |
1d18c75e |
1877 | const Handle(Adaptor3d_HSurface)& S1, |
1878 | const Handle(Adaptor3d_TopolTool)& D1, |
1879 | const Handle(Adaptor3d_HSurface)& S2, |
1880 | const Handle(Adaptor3d_TopolTool)& D2) const |
7fd59977 |
1881 | { |
1882 | |
1883 | //-- ---------------------------------------------------------------------- |
1884 | //-- construction de la liste des restrictions & vertex |
1885 | //-- |
1886 | int NR1[MAXR],NR2[MAXR]; |
857ffd5e |
1887 | Handle(Adaptor2d_HCurve2d) R1[MAXR],R2[MAXR]; |
7fd59977 |
1888 | Standard_Integer nbR1=0,nbR2=0; |
1889 | for(D1->Init();D1->More() && nbR1<MAXR; D1->Next()) { |
1890 | R1[nbR1]=D1->Value(); |
1891 | NR1[nbR1]=0; |
1892 | nbR1++; |
1893 | } |
1894 | for(D2->Init();D2->More() && nbR2<MAXR; D2->Next()) { |
1895 | R2[nbR2]=D2->Value(); |
1896 | NR2[nbR2]=0; |
1897 | nbR2++; |
1898 | } |
1899 | |
566f8441 |
1900 | printf("\nDUMP_INT: ----empt:%2ud tgte:%2ud oppo:%2ud ---------------------------------",empt,tgte,empt); |
7fd59977 |
1901 | Standard_Integer i,j,nbr1,nbr2,nbgl,nbgc,nbge,nbgp,nbgh,nbl,nbr,nbg,nbw,nba; |
1902 | nbl=nbr=nbg=nbw=nba=nbgl=nbge=nbr1=nbr2=nbgc=nbgp=nbgh=0; |
1903 | nbl=NbLines(); |
1904 | for(i=1;i<=nbl;i++) { |
1905 | const Handle(IntPatch_Line)& line=Line(i); |
1906 | const IntPatch_IType IType=line->ArcType(); |
1907 | if(IType == IntPatch_Walking) nbw++; |
1908 | else if(IType == IntPatch_Restriction) { |
1909 | nbr++; |
a1eb3afd |
1910 | Handle(IntPatch_RLine) rlin (Handle(IntPatch_RLine)::DownCast (line)); |
7fd59977 |
1911 | if(rlin->IsArcOnS1()) nbr1++; |
1912 | if(rlin->IsArcOnS2()) nbr2++; |
1913 | } |
1914 | else if(IType == IntPatch_Analytic) nba++; |
1d18c75e |
1915 | else { |
1916 | nbg++; |
1917 | if(IType == IntPatch_Lin) nbgl++; |
1918 | else if(IType == IntPatch_Circle) nbgc++; |
1919 | else if(IType == IntPatch_Parabola) nbgp++; |
1920 | else if(IType == IntPatch_Hyperbola) nbgh++; |
1921 | else if(IType == IntPatch_Ellipse) nbge++; |
1922 | } |
7fd59977 |
1923 | } |
1924 | |
1925 | |
1926 | 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)", |
1d18c75e |
1927 | nbl,nbw,nbr,nbr1,nbr2,nba,nbg,nbgl,nbgc,nbge,nbgh,nbgp); |
7fd59977 |
1928 | |
1929 | IntPatch_LineConstructor LineConstructor(2); |
1930 | |
1931 | Standard_Integer nbllc=0; |
1932 | nbw=nbr=nbg=nba=0; |
1933 | Standard_Integer nbva,nbvw,nbvr,nbvg; |
1934 | nbva=nbvr=nbvw=nbvg=0; |
1935 | for (j=1; j<=nbl; j++) { |
1936 | Standard_Integer v,nbvtx; |
1937 | const Handle(IntPatch_Line)& intersLinej = Line(j); |
1938 | Standard_Integer NbLines; |
1939 | LineConstructor.Perform(SequenceOfLine(),intersLinej,S1,D1,S2,D2,1e-7); |
1940 | NbLines = LineConstructor.NbLines(); |
1941 | |
1942 | for(Standard_Integer k=1;k<=NbLines;k++) { |
1943 | nbllc++; |
1944 | const Handle(IntPatch_Line)& LineK = LineConstructor.Line(k); |
1945 | if (LineK->ArcType() == IntPatch_Analytic) { |
a1eb3afd |
1946 | Handle(IntPatch_ALine) alin (Handle(IntPatch_ALine)::DownCast (LineK)); |
1d18c75e |
1947 | nbvtx=alin->NbVertex(); |
1948 | nbva+=nbvtx; nba++; |
1949 | for(v=1;v<=nbvtx;v++) { |
1950 | IntPatch_Intersection__MAJ_R(R1,R2,NR1,NR2,nbR1,nbR2,alin->Vertex(v)); |
1951 | } |
7fd59977 |
1952 | } |
1953 | else if (LineK->ArcType() == IntPatch_Restriction) { |
a1eb3afd |
1954 | Handle(IntPatch_RLine) rlin (Handle(IntPatch_RLine)::DownCast (LineK)); |
1d18c75e |
1955 | nbvtx=rlin->NbVertex(); |
1956 | nbvr+=nbvtx; nbr++; |
1957 | for(v=1;v<=nbvtx;v++) { |
1958 | IntPatch_Intersection__MAJ_R(R1,R2,NR1,NR2,nbR1,nbR2,rlin->Vertex(v)); |
1959 | } |
7fd59977 |
1960 | } |
1961 | else if (LineK->ArcType() == IntPatch_Walking) { |
a1eb3afd |
1962 | Handle(IntPatch_WLine) wlin (Handle(IntPatch_WLine)::DownCast (LineK)); |
1d18c75e |
1963 | nbvtx=wlin->NbVertex(); |
1964 | nbvw+=nbvtx; nbw++; |
1965 | for(v=1;v<=nbvtx;v++) { |
1966 | IntPatch_Intersection__MAJ_R(R1,R2,NR1,NR2,nbR1,nbR2,wlin->Vertex(v)); |
1967 | } |
7fd59977 |
1968 | } |
1969 | else { |
a1eb3afd |
1970 | Handle(IntPatch_GLine) glin (Handle(IntPatch_GLine)::DownCast (LineK)); |
1d18c75e |
1971 | nbvtx=glin->NbVertex(); |
1972 | nbvg+=nbvtx; nbg++; |
1973 | for(v=1;v<=nbvtx;v++) { |
1974 | IntPatch_Intersection__MAJ_R(R1,R2,NR1,NR2,nbR1,nbR2,glin->Vertex(v)); |
1975 | } |
7fd59977 |
1976 | } |
1977 | } |
1978 | } |
1979 | printf("\nDUMP_LC :Lines:%2d WLin:%2d Restr:%2d Ana:%2d Geom:%2d", |
1d18c75e |
1980 | nbllc,nbw,nbr,nba,nbg); |
7fd59977 |
1981 | printf("\nDUMP_LC :vtx :%2d r:%2d :%2d :%2d", |
1d18c75e |
1982 | nbvw,nbvr,nbva,nbvg); |
7fd59977 |
1983 | |
1984 | |
1985 | |
1986 | printf("\n"); |
1987 | } |