0026855: Draw commands to debug Boolean Operations Algorithm
[occt.git] / tests / offset / end
CommitLineData
5805221e 1set mist 0
2if { [info exists command] && [string compare $command "mkoffset"] == 0 } {
3 regexp {Mass +: +([-0-9.+eE]+)} [lprops s] full sm
4 regexp {Tolerance +MAX=([-0-9.+eE]+) +AVG=([-0-9.+eE]+) +MIN=[-0-9.+eE]+} [tolerance s] full MaxTol_s AvgTol_s
5 puts "Length of shape a is equal to $sm"
6 set theOff [expr $sm * $off_param ]
7 puts [format "Considered Offset value is %s " $theOff]
8 if { ![catch { mkoffset result s 1 $theOff } catch_res] } {
9 renamevar result_1 result
10 if { ![catch { set chsh [checkshape result] } catch_chsh] } {
11 puts $chsh
12 } else {
13 puts "Error : $catch_chsh"
14 set mist 1
15 }
16 }
17}
18
19if { [isdraw result] && $mist == 0} {
20 if { [info exists command] && [string compare $command "mkoffset"] == 0 } {
21 regexp {Mass +: +([-0-9.+eE]+)} [lprops result] full m
22
23 set vertex_list [explode result v]
24 set ll_v [llength $vertex_list]
40093367 25
5805221e 26 set edge_list [explode result e]
27 set ll_e [llength $edge_list]
40093367 28
5805221e 29 set wire_list [explode result w]
30 if { [string compare $wire_list ""] == 0} {
31 set wire_list result
32 }
33 set ll_w [llength $wire_list]
40093367 34
5805221e 35 if { $ll_v == 0 } {
36 if { $theOff < 0 } {
94a57f1f 37 puts [format "Warning : The resulting shape is an empty COMPOUND"]
5805221e 38 } else {
94a57f1f 39 puts [format "Error : The resulting shape is an empty COMPOUND"]
5805221e 40 }
41 puts [whatis result]
5805221e 42 puts [checksection result]
43 } else {
94a57f1f 44 puts [format "The resulting shape contains %s wires" $ll_w]
5805221e 45 foreach wire $wire_list {
46 puts "Info for $wire:"
47 regexp {Tolerance +MAX=([-0-9.+eE]+) +AVG=([-0-9.+eE]+) +MIN=[-0-9.+eE]+} [tolerance $wire] full MaxTol_res AvgTol_res
48 if { $MaxTol_res > $MaxTol_s } {
49 puts "Error : big tolerance of shape $wire"
50 }
51 regexp {nb +alone +Vertices +: +([-0-9.+eE]+)} [checksection $wire] full num
52 if { $num != 0 } {
94a57f1f 53 puts [format "Error : $wire is NOT a closed wire"]
5805221e 54 }
55 mkplane res_plane $wire
56 set chsh_res_plane [checkshape res_plane]
57 if { [regexp {Faulty +shapes +in +variables +faulty_([-0-9.+eE]+) +to +faulty_([-0-9.+eE]+)} $chsh_res_plane full from_faulty to_faulty ] } {
58 puts "Shape $wire has self-intersection"
59 }
60 }
61 }
40093367 62
5805221e 63 if { [string compare $length "empty"] != 0 } {
64 puts "The expected length is $length"
65 #check of change of length is < 1%
49c093ae 66 if { ($length != 0 && [expr 1.*abs($length - $m)/$length] > 0.01) || ($length == 0 && $m != 0) } {
94a57f1f 67 puts "Error : The length of the resulting shape is $m"
5805221e 68 }
69 } else {
70 if { $m != 0 } {
71 puts "Error : The offset is not valid. The length is $m"
72 }
73 }
74 # check for number of vertexes
75 if { [info exists nbsh_v ] } {
76 if { ($ll_v != $nbsh_v) || ($nbsh_v == 0 && $ll_v != 0) } {
94a57f1f 77 puts "Error : The resulting shape is WRONG because it must contain $nbsh_v vertexes instead of $ll_v"
5805221e 78 } else {
94a57f1f 79 puts "The resulting shape contains $ll_v vertexes"
5805221e 80 }
81 }
82 # check for number of edges
83 if { [info exists nbsh_e ] } {
84 if { ($ll_e != $nbsh_e) || ($nbsh_e == 0 && $ll_e != 0) } {
94a57f1f 85 puts "Error : The resulting shape is WRONG because it must contain $nbsh_e edges instead of $ll_e"
5805221e 86 } else {
94a57f1f 87 puts "The resulting shape contains $ll_e edges"
5805221e 88 }
89 }
90 # check for number of wires
91 if { [info exists nbsh_w ] } {
92 if { ($ll_w != $nbsh_w) || ($nbsh_w == 0 && $ll_w != 0) } {
94a57f1f 93 puts "Error : The resulting shape is WRONG because it must contain $nbsh_w wires instead of $ll_w"
5805221e 94 } else {
94a57f1f 95 puts "The resulting shape contains $ll_w wires"
5805221e 96 }
97 }
e9102e99 98 } elseif {[info exists command] && [string compare $command "withintersect"] == 0} {
99 regexp {Mass +: +([-0-9.+eE]+)} [sprops result] full m
100 checkshape result
5805221e 101 } else {
102 regexp {Mass +: +([-0-9.+eE]+)} [vprops s] full sm
103 regexp {Mass +: +([-0-9.+eE]+)} [vprops result] full m
104
105 #check if result is valid
106 puts [checkshape result]
107 if { $m == 0 || $sm == $m } {
108 puts "Error : The offset is not valid. The volume is $m."
109 }
110
111 #check of face's square value
112 foreach ResultFace [ explode result f ] {
113 regexp {Mass +: +([-0-9.+eE]+)} [sprops $ResultFace] full fmass
114 if { $fmass < 0 } {
94a57f1f 115 puts "Error : The area of face $ResultFace of the resulting shape is negative."
5805221e 116 }
117 }
118 #check for bsection
119 if { [info exists GlobFaces] && [llength $GlobFaces] == 0 } {
191082ac 120 puts [ bsection re result s ]
5805221e 121 if { [ isdraw re ] } {
122 regexp {Mass +: +([-0-9.+eE]+)} [lprops $re] full remass
123 if { $remass != 0 } {
94a57f1f 124 puts "Error: bsection of the result and s is not equal to zero."
5805221e 125 }
126 }
127 }
e9102e99 128 if {[info exists volume]} {
129 if { $volume > 0 } {
130 puts "The expected volume is $volume"
131 }
132 #check of change of volume is < 1%
133 if { ($volume > 0 && [expr 1.*abs($volume - $m)/$volume] > 0.01) || ($volume == 0 && $m != 0 && $sm != $m) } {
134 puts "Error : The volume of the resulting shape is $m"
135 }
136 }
5805221e 137 }
138 if { $m > 0 } {
139 clear
140 smallview
141 donly result
142 fit
88f8fc81 143 xwd $imagedir/${test_image}.png
5805221e 144 }
40093367 145} else {
94a57f1f 146 puts "Error : The offset cannot be built."
40093367 147}
148
149# to end a test script
150puts "TEST COMPLETED"