0025952: Wrong intersection curve
[occt.git] / tests / lowalgos / intss / bug29972_5
1 puts "========"
2 puts "OCC29972: Intersection curve has a weird gap in the middle of it"
3 puts "========"
4 puts ""
5
6 puts "TODO OCC27243 ALL: Error: The curve res_1 possibly has a bend"
7
8 set GoodNbCurves 2
9
10 foreach a [directory res*] {unset $a}
11
12 binrestore [locate_data_file bug29972_f1.bin] f1
13
14 mksurface s1 f1
15 plane s2 -145.136225014162, -136.038366, -73.563687 0 0 1 -1 0 0
16
17 intersect res s1 s2
18
19 if { [info exists res] } {
20   #Only variable "res" exists
21   renamevar res res_1
22 }
23
24 dset aLambda1 1.0e-5
25 dset aLambda2 [dval 1-aLambda1]
26
27 set ic 1
28 set AllowRepeat 1
29 while { $AllowRepeat != 0 } {
30   if { ![info exists res_$ic] } {
31     set AllowRepeat 0
32   } else {
33     bounds res_$ic U1 U2
34     
35     if {[dval U2-U1] < 1.0e-9} {
36       puts "Error: Wrong curve's range!"
37     }
38     
39     xdistcs res_$ic s1 U1 U2 100 1.0e-7
40     xdistcs res_$ic s2 U1 U2 100 1.0e-7  
41     
42     #check whether the curve has a loop
43     set aFpar [dval U1*aLambda1+aLambda2*U2]
44     set aLpar [dval U2]
45     
46     set delta [expr ($aLpar-$aFpar)/10.0]
47     cvalue res_$ic $aFpar xp yp zp dx1 dy1 dz1
48     for {set p $aFpar} {$p <= $aLpar} {set p [expr $p + $delta]} {
49       cvalue res_$ic $p xp yp zp dx2 dy2 dz2
50       
51       #Check if the angle between the vectors {dx1 dy1 dz1} and {dx2 dy2 dz2} is less than 40deg.
52       set nv1 [ dval dx1*dx1+dy1*dy1+dz1*dz1 ] 
53       set nv2 [ dval dx2*dx2+dy2*dy2+dz2*dz2 ] 
54       
55       set nv1 [ expr sqrt($nv1) ]
56       set nv2 [ expr sqrt($nv2) ]
57       
58       set dp [ dval dx1*dx2+dy2*dy2+dz1*dz2 ] 
59       
60       if {$dp < [ expr 0.76604444311897803520239265055542 * $nv1 * $nv2 ] } {
61         puts "Error: The curve res_$ic possibly has a bend at parameter $p. Please check carefully"
62       }      
63       
64       dset dx1 dx2
65       dset dy1 dy2
66       dset dz1 dz2
67     }
68     
69     incr ic
70   }
71 }
72
73 incr ic -1
74
75 if { $ic != $GoodNbCurves } {
76   puts "Error: $GoodNbCurves are expected but $ic ones are found"
77 }
78
79 smallview
80 clear
81 point p1 57.478209319525746 -120.6955841545726 -125.98789759526636
82 point p2 57.478010564066473 -120.69677875685414 -125.98860176530741
83 fit
84
85 clpoles s1
86 don s1 s2
87 disp res_*
88
89 checkview -screenshot -2d -path ${imagedir}/${test_image}.png