0026855: Draw commands to debug Boolean Operations Algorithm
[occt.git] / tests / offset / end
... / ...
CommitLineData
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]
25
26 set edge_list [explode result e]
27 set ll_e [llength $edge_list]
28
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]
34
35 if { $ll_v == 0 } {
36 if { $theOff < 0 } {
37 puts [format "Warning : The resulting shape is an empty COMPOUND"]
38 } else {
39 puts [format "Error : The resulting shape is an empty COMPOUND"]
40 }
41 puts [whatis result]
42 puts [checksection result]
43 } else {
44 puts [format "The resulting shape contains %s wires" $ll_w]
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 } {
53 puts [format "Error : $wire is NOT a closed wire"]
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 }
62
63 if { [string compare $length "empty"] != 0 } {
64 puts "The expected length is $length"
65 #check of change of length is < 1%
66 if { ($length != 0 && [expr 1.*abs($length - $m)/$length] > 0.01) || ($length == 0 && $m != 0) } {
67 puts "Error : The length of the resulting shape is $m"
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) } {
77 puts "Error : The resulting shape is WRONG because it must contain $nbsh_v vertexes instead of $ll_v"
78 } else {
79 puts "The resulting shape contains $ll_v vertexes"
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) } {
85 puts "Error : The resulting shape is WRONG because it must contain $nbsh_e edges instead of $ll_e"
86 } else {
87 puts "The resulting shape contains $ll_e edges"
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) } {
93 puts "Error : The resulting shape is WRONG because it must contain $nbsh_w wires instead of $ll_w"
94 } else {
95 puts "The resulting shape contains $ll_w wires"
96 }
97 }
98 } elseif {[info exists command] && [string compare $command "withintersect"] == 0} {
99 regexp {Mass +: +([-0-9.+eE]+)} [sprops result] full m
100 checkshape result
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 } {
115 puts "Error : The area of face $ResultFace of the resulting shape is negative."
116 }
117 }
118 #check for bsection
119 if { [info exists GlobFaces] && [llength $GlobFaces] == 0 } {
120 puts [ bsection re result s ]
121 if { [ isdraw re ] } {
122 regexp {Mass +: +([-0-9.+eE]+)} [lprops $re] full remass
123 if { $remass != 0 } {
124 puts "Error: bsection of the result and s is not equal to zero."
125 }
126 }
127 }
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 }
137 }
138 if { $m > 0 } {
139 clear
140 smallview
141 donly result
142 fit
143 xwd $imagedir/${test_image}.png
144 }
145} else {
146 puts "Error : The offset cannot be built."
147}
148
149# to end a test script
150puts "TEST COMPLETED"