]> OCCT Git - occt.git/commitdiff
0030217: Intersection between a circle and a line not detected WHEN TANGENT CR30217_1
authormaxsson <maxsson9@gmail.com>
Wed, 27 Feb 2019 10:39:26 +0000 (13:39 +0300)
committerazv <azv@opencascade.com>
Fri, 29 Jul 2022 07:03:31 +0000 (10:03 +0300)
* 2D intersector takes into account the given tolerance when intersects line with circle.
* Extrema curve-curve executes parametric branch in case of analytical has given zero solutions.
* Command 'intersect' has been improved to show additional information about the area of tangency (start and end parameters on each curve).

src/GeomliteTest/GeomliteTest_API2dCommands.cxx
src/IntCurve/IntCurve_IntConicConic_1.cxx
tests/bugs/modalg_7/bug30217_1 [new file with mode: 0644]
tests/bugs/modalg_7/bug30217_2 [new file with mode: 0644]
tests/bugs/modalg_7/bug30217_3 [new file with mode: 0644]
tests/bugs/modalg_7/bug30217_4 [new file with mode: 0644]

index 46a4b68239666d8344a749a0a5010e4285305db3..78e9b5fccd2d027a528b9e88250ff969831e3811 100644 (file)
@@ -432,8 +432,10 @@ static Standard_Integer intersect(Draw_Interpretor& di, Standard_Integer n, cons
   Standard_Integer aNbSegments = Intersector.NbSegments();
   for (Standard_Integer i = 1; i <= aNbSegments; i++)
   {
-    di << "Segment #" << i << " found.\n";
     Intersector.Segment(i,S1,S2);
+    di << "Segment #" << i << " found.\n";
+    di << "Curve 1 first parameter: " << S1->FirstParameter() << " last parameter: " << S1->LastParameter() <<"\n";
+    di << "Curve 2 first parameter: " << S2->FirstParameter() << " last parameter: " << S2->LastParameter() <<"\n";
     CD = new DrawTrSurf_Curve2d(S1, Draw_bleu, 30);
     dout << CD;
     CD = new DrawTrSurf_Curve2d(S2, Draw_violet, 30);
index 4ecd7bce427467374c4b8354ef5f5db4a9365ce7..690600f8d0d6a0262759804fb54f84b15738bdc2 100644 (file)
@@ -392,6 +392,7 @@ void LineCircleGeometricIntersection(const gp_Lin2d& Line,
   Standard_Real dO1O2=Line.Distance(Circle.Location());
   Standard_Real R=Circle.Radius();
   Standard_Real RmTol=R-Tol;
+  Standard_Real RpTol = R + Tol;
   Standard_Real binf1,binf2=0,bsup1,bsup2=0;
     
   //---------------------------------------------------------------- 
@@ -425,7 +426,7 @@ void LineCircleGeometricIntersection(const gp_Lin2d& Line,
     if(dO1O2 > RmTol && !b2Sol) { 
     //if(dO1O2 > RmTol) { 
       Standard_Real dx=dO1O2;
-      Standard_Real dy=0.0;     //(RpTol*RpTol-dx*dx); //Patch !!!
+      Standard_Real dy = RpTol * RpTol - dx * dx;
       dy=(dy>=0.0)? Sqrt(dy) : 0.0;
       dAlpha1=ATan2(dy,dx);
       
@@ -439,7 +440,7 @@ void LineCircleGeometricIntersection(const gp_Lin2d& Line,
     else {
       //------------------- Intersection Line Circle+ --------------------------
       Standard_Real dx=dO1O2;
-      Standard_Real dy=R*R-dx*dx;    //(RpTol*RpTol-dx*dx); //Patch !!!
+      Standard_Real dy = RpTol * RpTol - dx * dx;
       dy=(dy>=0.0)? Sqrt(dy) : 0.0;
       
       dAlpha1=ATan2(dy,dx);
diff --git a/tests/bugs/modalg_7/bug30217_1 b/tests/bugs/modalg_7/bug30217_1
new file mode 100644 (file)
index 0000000..78dc99a
--- /dev/null
@@ -0,0 +1,29 @@
+puts "============"
+puts "OCC30217_1"
+puts "============"
+puts ""
+#########################################################################
+# Intersection between a circle and a line not detected (2d)
+#########################################################################
+
+2ddrseg s2 -80.461134694338 53.07587187722 -31.501464018476 67.029737602069
+circle c2 -18.339655323916 20.849340929486 48.019394466707
+# Set tolerance.
+set tol_abs 1.0e-7 
+set tol_rel 1.0e-2
+
+# Set reference data.
+set param11 1.8484218380721342
+set param12 1.8484627151687805
+set param21 50.908401295062035
+set param22 50.909328431594709
+
+set info [2dintersect c2 s2 -tol 1e-8]
+regexp {Curve 1 first parameter: +([-0-9.+eE]+) last parameter: +([-0-9.+eE]+)} ${info} full curve1p1 curve1p2
+regexp {Curve 2 first parameter: +([-0-9.+eE]+) last parameter: +([-0-9.+eE]+)} ${info} full curve2p1 curve2p2
+
+checkreal "Curve 1 param 1" ${curve1p1} ${param11} ${tol_abs} ${tol_rel}
+checkreal "Curve 1 param 2" ${curve1p2} ${param12} ${tol_abs} ${tol_rel}
+
+checkreal "Curve 2 param 1" ${curve2p1} ${param21} ${tol_abs} ${tol_rel}
+checkreal "Curve 2 param 2" ${curve2p2} ${param22} ${tol_abs} ${tol_rel}
\ No newline at end of file
diff --git a/tests/bugs/modalg_7/bug30217_2 b/tests/bugs/modalg_7/bug30217_2
new file mode 100644 (file)
index 0000000..6a12fcd
--- /dev/null
@@ -0,0 +1,26 @@
+puts "============"
+puts "OCC30217_2"
+puts "============"
+puts ""
+#########################################################################
+# Intersection between a circle and a line not detected (3d)
+#########################################################################
+set tol_abs 2.e-7
+
+drseg s -80.461134694338 53.07587187722 0.0 -31.501464018476 67.029737602069 0.0
+circle c -18.339655323916 20.849340929486 0.0 48.019394466707
+set info1 [extrema c s]
+if {[regexp "ext" ${info1}] != 1} {
+  puts "Error : No intersection detected"
+} else {
+  puts "OK: Intersection are detected"
+}
+
+# Distance check
+set info2 [dump ext_1]
+regexp "Parameters : 0 +(\[-0-9*\.+eE\]+)" $info2 full extLength
+if { ${extLength} > $tol_abs } {
+  puts "Error: bad distance poins obtained"
+} else {
+  puts "OK: good distance between obtained points"
+}
\ No newline at end of file
diff --git a/tests/bugs/modalg_7/bug30217_3 b/tests/bugs/modalg_7/bug30217_3
new file mode 100644 (file)
index 0000000..c5ed10a
--- /dev/null
@@ -0,0 +1,28 @@
+puts "============"
+puts "OCC30217_3"
+puts "============"
+puts ""
+#########################################################################
+# Intersection between a circle and a line not detected (3d)
+#########################################################################
+set tol_abs 2.e-7
+
+drseg s -31.501464018476 67.029737602069 -10.0 -31.501464018476 67.029737602069 0.0
+circle c -18.339655323916 20.849340929486 0.0 48.019394466707
+set info1 [extrema c s]       
+if {[regexp "ext" ${info1}] != 1} {
+  puts "Error : No intersection detected"
+} else {
+  puts "OK: Intersection are detected"
+}
+
+# Distance check
+set infoext1 [dump ext_1]
+
+
+regexp "Parameters : 0 +(\[-0-9*\.+eE\]+)" $infoext1 full  ext1Length ext2Length 
+if { $ext1Length > $tol_abs || $ext2Length > $tol_abs } {
+  puts "Error: bad distance poins obtained"
+} else {
+  puts "OK: good distance between obtained points"
+}                                                                 
\ No newline at end of file
diff --git a/tests/bugs/modalg_7/bug30217_4 b/tests/bugs/modalg_7/bug30217_4
new file mode 100644 (file)
index 0000000..11930cd
--- /dev/null
@@ -0,0 +1,20 @@
+puts "============"
+puts "OCC30217_4"
+puts "============"
+puts ""
+#########################################################################
+# Intersection between a circle and a line not detected (3d)
+#########################################################################
+
+set ExpDist 5
+
+circle c1 0 0 0 0 0 1 5
+line c2 0 0 0 0 0 1
+trim c2 c2 -1 -5e-8
+
+regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1
+checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0
+
+regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2
+checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0
+                                                         
\ No newline at end of file