1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-03 14:10:33 +03:00

0033017: Implement an algorithm to find a proximity between a pair of shapes

Extend "proximity" command to be able to compute the proximity value;
Implement classes for calculate proximity value between two shapes;
Add possibility to set up the number of sample points for the input shapes;
Add tests lowalgos/proximity.
This commit is contained in:
knosulko
2022-08-05 12:44:29 +03:00
committed by jfa
parent cfcbf4e486
commit 080db9db12
34 changed files with 2093 additions and 151 deletions

View File

@@ -7,3 +7,6 @@
007 intss
008 classifier
009 bvh
010 progress
011 2ddeviation
012 proximity

View File

@@ -0,0 +1,24 @@
puts "============"
puts "0033017: Implement an algorithm to find a proximity between a pair of shapes"
puts "==========="
puts ""
circle c 0 0 0 1 0 0 5
mkedge e1 c pi/2 pi
mkedge e2 c -pi/2 0
incmesh e1 1.e-3
incmesh e2 1.e-3
set log [proximity e1 e2 -value -profile]
regexp {Proximity value: ([0-9+-.eE]*)} $log full val
set tol 1.e-3
set expected 10.0
regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status1 ${val2}
set expected_status1 Middle
regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status2 ${val2}
set expected_status2 Middle

View File

@@ -0,0 +1,26 @@
puts "============"
puts "0033017: Implement an algorithm to find a proximity between a pair of shapes"
puts "==========="
puts ""
circle c1 0 0 0 1 0 0 1
mkedge e1 c1
incmesh e1 1.e-3
circle c2 0 0 0 0 1 0 1
mkedge e2 c2
incmesh e2 1.e-3
set log [proximity e1 e2 -value -profile]
regexp {Proximity value: ([0-9+-.eE]*)} $log full val;
set tol 1.e-3
set expected 2.0
regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status1 ${val2}
set expected_status1 Middle
regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status2 ${val2}
set expected_status2 Middle

View File

@@ -0,0 +1,28 @@
puts "============"
puts "0033017: Implement an algorithm to find a proximity between a pair of shapes"
puts "==========="
puts ""
circle c1 0 -1 0 1 0 0 1
trim c1 c1 -pi 0
mkedge e1 c1
incmesh e1 1.e-3
circle c2 0 1 0 1 0 0 1
trim c2 c2 0 pi
mkedge e2 c2
incmesh e2 1.e-3
set log [proximity e1 e2 -value -profile]
regexp {Proximity value: ([0-9+-.eE]*)} $log full val;
set tol 1.e-3
set expected [expr {sqrt(5.0) - 1.}]
regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status1 ${val2}
set expected_status1 Middle
regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status2 ${val2}
set expected_status2 Border

View File

@@ -0,0 +1,26 @@
puts "============"
puts "0033017: Implement an algorithm to find a proximity between a pair of shapes"
puts "==========="
puts ""
circle c1 0 0 0 1 0 0 1
mkedge e1 c1
incmesh e1 1.e-3
circle c2 0 0 0 -1 0.5 0 1
mkedge e2 c2
incmesh e2 1.e-3
set log [proximity e1 e2 -value -profile]
regexp {Proximity value: ([0-9+-.eE]*)} $log full val;
set tol 1.e-3
set expected 2.0
regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status1 ${val2}
set expected_status1 Middle
regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status2 ${val2}
set expected_status2 Middle

View File

@@ -0,0 +1,31 @@
puts "============"
puts "0033017: Implement an algorithm to find a proximity between a pair of shapes"
puts "==========="
puts ""
circle c1 0 0 0 1 0 0 1
trim c1 c1 -pi/2. pi/2.
mkedge e1 c1
incmesh e1 1.e-3
circle c2 0 0 0 1 0.5 0 1
trim c2 c2 0 pi
mkedge e2 c2
incmesh e2 1.e-3
set log [proximity e1 e2 -value -profile]
regexp {Proximity value: ([0-9+-.eE]*)} $log full val;
set tol 1.e-3
explode e1 v
explode e2 v
distmini d e1_1 e2_1
regexp {([-0-9.+eE]+)$} [dump d_val] full expected
regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status1 ${val2}
set expected_status1 Middle
regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status2 ${val2}
set expected_status2 Border

View File

@@ -0,0 +1,28 @@
puts "============"
puts "0033017: Implement an algorithm to find a proximity between a pair of shapes"
puts "==========="
puts ""
plane p1 0 0 0 0 0 1
trim p1 p1 -1 1 -1 1
mkface f1 p1
incmesh f1 1.e-1
plane p2 0 0 1 0 0 1
trim p2 p2 -1 1 -1 1
mkface f2 p2
incmesh f2 1.e-1
set log [proximity f1 f2 -value -profile]
regexp {Proximity value: ([0-9+-.eE]*)} $log full val;
set tol 1.e-3
set expected 1.0
regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status1 ${val2}
set expected_status1 Border
regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status2 ${val2}
set expected_status2 Border

View File

@@ -0,0 +1,28 @@
puts "============"
puts "0033017: Implement an algorithm to find a proximity between a pair of shapes"
puts "==========="
puts ""
plane p1 0 0 0 0 0 1
trim p1 p1 -1 1 -1 1
mkface f1 p1
incmesh f1 1.e-1
plane p2 0 0 1 -1 0 0
trim p2 p2 -1 1 -1 1
mkface f2 p2
incmesh f2 1.e-1
set log [proximity f1 f2 -value -profile]
regexp {Proximity value: ([0-9+-.eE]*)} $log full val;
set tol 1.e-3
set expected 1.0
regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status1 ${val2}
set expected_status1 Border
regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status2 ${val2}
set expected_status2 Border

View File

@@ -0,0 +1,28 @@
puts "============"
puts "0033017: Implement an algorithm to find a proximity between a pair of shapes"
puts "==========="
puts ""
plane p1 0 0 0 0 0 1
trim p1 p1 -1 1 -1 1
mkface f1 p1
incmesh f1 1.e-1
plane p2 0 0 0 -1 0 0
trim p2 p2 -1 1 -1 1
mkface f2 p2
incmesh f2 1.e-1
set log [proximity f1 f2 -value -profile]
regexp {Proximity value: ([0-9+-.eE]*)} $log full val;
set tol 1.e-3
set expected 1.0
regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status1 ${val2}
set expected_status1 Border
regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status2 ${val2}
set expected_status2 Border

View File

@@ -0,0 +1,28 @@
puts "============"
puts "0033017: Implement an algorithm to find a proximity between a pair of shapes"
puts "==========="
puts ""
plane p1 0 0 0 0 0 1
trim p1 p1 -1 1 -1 1
mkface f1 p1
incmesh f1 1.e-1
plane p2 0 0 0.5 -1 0 0
trim p2 p2 -1 1 -1 1
mkface f2 p2
incmesh f2 1.e-1
set log [proximity f1 f2 -value -profile]
regexp {Proximity value: ([0-9+-.eE]*)} $log full val;
set tol 1.e-3
set expected 1.0
regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status1 ${val2}
set expected_status1 Border
regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status2 ${val2}
set expected_status2 Border

View File

@@ -0,0 +1,27 @@
puts "============"
puts "0033017: Implement an algorithm to find a proximity between a pair of shapes"
puts "==========="
puts ""
plane p1 0 0 0 0 0 1
trim p1 p1 -1 1 -1 1
mkface f1 p1
incmesh f1 1.e-3
polyline f2 -1 -1 1 -1 1 1 1 1 2 1 -1 2 -1 -1 1
mkplane f2 f2
incmesh f2 1.e-3
set log [proximity f1 f2 -value -profile]
regexp {Proximity value: ([0-9+-.eE]*)} $log full val;
set tol 1.e-3
set expected [expr {0.8 * sqrt(5.0)}]
regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status1 ${val2}
set expected_status1 Border
regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status2 ${val2}
set expected_status2 Border

View File

@@ -0,0 +1,27 @@
puts "============"
puts "0033017: Implement an algorithm to find a proximity between a pair of shapes"
puts "==========="
puts ""
plane p1 0 0 0 0 0 1
trim p1 p1 -1 1 -1 1
mkface f1 p1
incmesh f1 1.e-3
circle c 0 0 1 1
mkedge e1 c
incmesh e1 1.e-3
set log [proximity f1 e1 -value -profile]
regexp {Proximity value: ([0-9+-.eE]*)} $log full val;
set tol 1.e-3
set expected 1.0
regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status1 ${val2}
set expected_status1 Border
regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status2 ${val2}
set expected_status2 Middle

View File

@@ -0,0 +1,29 @@
puts "============"
puts "0033017: Implement an algorithm to find a proximity between a pair of shapes"
puts "==========="
puts ""
plane p1 0 0 0 0 0 1
trim p1 p1 -1 1 -1 1
mkface f1 p1
incmesh f1 1.e-3
dset lo pi/2. la 0.
cylinder cy1 0 0 0 cos(la)*cos(lo) cos(la)*sin(lo) sin(la) 0.1
trimv cy1 cy1 0 1
mkface fcy1 cy1
incmesh fcy1 1.e-3
set log [proximity f1 fcy1 -value -profile]
regexp {Proximity value: ([0-9+-.eE]*)} $log full val;
set tol 1.e-3
set expected 0.1
regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status1 ${val2}
set expected_status1 Middle
regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status2 ${val2}
set expected_status2 Border

View File

@@ -0,0 +1,29 @@
puts "============"
puts "0033017: Implement an algorithm to find a proximity between a pair of shapes"
puts "==========="
puts ""
plane p1 0 0 0 0 0 1
trim p1 p1 -2 2 -2 2
mkface f1 p1
incmesh f1 1.e-3
dset lo pi/2. la pi/4.
cylinder cy1 0 0 1 cos(la)*cos(lo) cos(la)*sin(lo) sin(la) 0.1
trimv cy1 cy1 0 1
mkface fcy1 cy1
incmesh fcy1 1.e-3
set log [proximity f1 fcy1 -value -profile]
regexp {Proximity value: ([0-9+-.eE]*)} $log full val;
set tol 1.e-3
set expected [expr {1. + 1.1 * sqrt(2.)/2.}]
regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status1 ${val2}
set expected_status1 Middle
regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status2 ${val2}
set expected_status2 Border

View File

@@ -0,0 +1,28 @@
puts "============"
puts "0033017: Implement an algorithm to find a proximity between a pair of shapes"
puts "==========="
puts ""
cylinder cy1 0 0 1 1 0 0 0.1
trimv cy1 cy1 0 1
mkface fcy1 cy1
incmesh fcy1 1.e-3
cylinder cy2 0 0 0 1 0 0 0.1
trimv cy2 cy2 0 1
mkface fcy2 cy2
incmesh fcy2 1.e-3
set log [proximity fcy1 fcy2 -value -profile]
regexp {Proximity value: ([0-9+-.eE]*)} $log full val;
set tol 1.e-3
set expected 1.0
regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status1 ${val2}
set expected_status1 Border
regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status2 ${val2}
set expected_status2 Border

View File

@@ -0,0 +1,28 @@
puts "============"
puts "0033017: Implement an algorithm to find a proximity between a pair of shapes"
puts "==========="
puts ""
cylinder cy1 0 0 1 1 0 0 0.1
trim cy1 cy1 -pi/2. pi/2. 0 1
mkface fcy1 cy1
incmesh fcy1 1.e-5
cylinder cy2 0 0 0 1 0 0 0.1
trim cy2 cy2 pi/2. -pi/2. 0 1
mkface fcy2 cy2
incmesh fcy2 1.e-5
set log [proximity fcy1 fcy2 -value -profile]
regexp {Proximity value: ([0-9+-.eE]*)} $log full val;
set tol 1.e-3
set expected 1.2
regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status1 ${val2}
set expected_status1 Border
regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status2 ${val2}
set expected_status2 Border

View File

@@ -0,0 +1,28 @@
puts "============"
puts "0033017: Implement an algorithm to find a proximity between a pair of shapes"
puts "==========="
puts ""
sphere s1 0 1 0 0 0 1 1
trimu s1 s1 0 pi
mkface fs1 s1
incmesh fs1 1e-3
sphere s2 0 -1 0 0 0 1 1
trimu s2 s2 -pi 0
mkface fs2 s2
incmesh fs2 1e-3
set log [proximity fs1 fs2 -value -profile]
regexp {Proximity value: ([0-9+-.eE]*)} $log full val;
set tol 1.e-2
set expected 4.0
regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status1 ${val2}
set expected_status1 Middle
regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status2 ${val2}
set expected_status2 Middle

View File

@@ -0,0 +1,26 @@
puts "============"
puts "0033017: Implement an algorithm to find a proximity between a pair of shapes"
puts "==========="
puts ""
sphere s1 0 1 0 0 0 1 1
mkface fs1 s1
incmesh fs1 1e-3
sphere s2 0 -1 0 0 0 1 1
mkface fs2 s2
incmesh fs2 1e-3
set log [proximity fs1 fs2 -value -profile]
regexp {Proximity value: ([0-9+-.eE]*)} $log full val;
set tol 1.e-2
set expected 4.0
regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status1 ${val2}
set expected_status1 Middle
regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status2 ${val2}
set expected_status2 Middle

View File

@@ -0,0 +1,33 @@
puts "============"
puts "0033017: Implement an algorithm to find a proximity between a pair of shapes"
puts "==========="
puts ""
sphere s1 0 1 0 0 0 1 1
trimu s1_1 s1 0 0.5*pi
trimu s1_2 s1 0.5*pi pi
mkface fs1_1 s1_1
mkface fs1_2 s1_2
compound fs1_1 fs1_2 fs1
incmesh fs1 1e-3
plane p1 0 0 0 0 1 0
trim p1 p1 -2 2 -2 2
mkface f2 p1
incmesh f2 0.001
set log [proximity fs1 f2 -value -profile]
regexp {Proximity value: ([0-9+-.eE]*)} $log full val;
set tol 1.e-2
set expected 2.0
regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status1 ${val2}
set expected_status1 Border
regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status2 ${val2}
set expected_status2 Middle

View File

@@ -0,0 +1,30 @@
puts "============"
puts "0033017: Implement an algorithm to find a proximity between a pair of shapes"
puts "==========="
puts ""
beziercurve bc1 7 10 84 0 54 96 0 145 146 0 167 167 0 185 212 0 187 234 0 176 302 0
beziercurve bc2 8 120 72 0 170 87 0 227 118 0 238 126 0 243 157 0 203 216 0 134 281 0 94 324 0
mkedge e1 bc1
mkedge e2 bc2
incmesh e1 1.e-3
incmesh e2 1.e-3
set log [proximity e1 e2 -value -profile]
regexp {Proximity value: ([0-9+-.eE]*)} $log full val;
set tol 1.e-3
explode e1 v
explode e2 v
distmini d e1_2 e2_2
regexp {([-0-9.+eE]+)$} [dump d_val] full expected
regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status1 ${val2}
set expected_status1 Border
regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status2 ${val2}
set expected_status2 Border

View File

@@ -0,0 +1,27 @@
puts "============"
puts "0033017: Implement an algorithm to find a proximity between a pair of shapes"
puts "==========="
puts ""
beziercurve bc1 6 54 96 0 145 146 0 167 167 0 185 212 0 187 234 0 176 302 0
beziercurve bc2 7 120 72 0 170 87 0 227 118 0 238 126 0 243 157 0 203 216 0 134 281 0
mkedge e1 bc1
mkedge e2 bc2
incmesh e1 1.e-3
incmesh e2 1.e-3
set log [proximity e1 e2 -value -profile]
regexp {Proximity value: ([0-9+-.eE]*)} $log full val;
set tol 1.e-3
set expected 76.34
regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status1 ${val2}
set expected_status1 Middle
regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2
set status2 ${val2}
set expected_status2 Middle

View File

@@ -0,0 +1,19 @@
set er [expr abs(${expected} - ${val})]
if {${er} > ${tol}} {
puts "Error: bad proximity value"
} else {
puts "OK"
}
if {${status1} != ${expected_status1}} {
puts "Error: bad 1st proximity point status"
} else {
puts "OK"
}
if {${status2} != ${expected_status2}} {
puts "Error: bad 2nd proximity point status"
} else {
puts "OK"
}