5805221e |
1 | set mist 0 |
2 | if { [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 | |
19 | if { [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] |
42 | puts [nbshapes result] |
43 | puts [checksection result] |
44 | } else { |
94a57f1f |
45 | puts [format "The resulting shape contains %s wires" $ll_w] |
5805221e |
46 | foreach wire $wire_list { |
47 | puts "Info for $wire:" |
48 | regexp {Tolerance +MAX=([-0-9.+eE]+) +AVG=([-0-9.+eE]+) +MIN=[-0-9.+eE]+} [tolerance $wire] full MaxTol_res AvgTol_res |
49 | if { $MaxTol_res > $MaxTol_s } { |
50 | puts "Error : big tolerance of shape $wire" |
51 | } |
52 | regexp {nb +alone +Vertices +: +([-0-9.+eE]+)} [checksection $wire] full num |
53 | if { $num != 0 } { |
94a57f1f |
54 | puts [format "Error : $wire is NOT a closed wire"] |
5805221e |
55 | } |
56 | mkplane res_plane $wire |
57 | set chsh_res_plane [checkshape res_plane] |
58 | if { [regexp {Faulty +shapes +in +variables +faulty_([-0-9.+eE]+) +to +faulty_([-0-9.+eE]+)} $chsh_res_plane full from_faulty to_faulty ] } { |
59 | puts "Shape $wire has self-intersection" |
60 | } |
61 | } |
62 | } |
40093367 |
63 | |
5805221e |
64 | if { [string compare $length "empty"] != 0 } { |
65 | puts "The expected length is $length" |
66 | #check of change of length is < 1% |
49c093ae |
67 | if { ($length != 0 && [expr 1.*abs($length - $m)/$length] > 0.01) || ($length == 0 && $m != 0) } { |
94a57f1f |
68 | puts "Error : The length of the resulting shape is $m" |
5805221e |
69 | } |
70 | } else { |
71 | if { $m != 0 } { |
72 | puts "Error : The offset is not valid. The length is $m" |
73 | } |
74 | } |
75 | # check for number of vertexes |
76 | if { [info exists nbsh_v ] } { |
77 | if { ($ll_v != $nbsh_v) || ($nbsh_v == 0 && $ll_v != 0) } { |
94a57f1f |
78 | puts "Error : The resulting shape is WRONG because it must contain $nbsh_v vertexes instead of $ll_v" |
5805221e |
79 | } else { |
94a57f1f |
80 | puts "The resulting shape contains $ll_v vertexes" |
5805221e |
81 | } |
82 | } |
83 | # check for number of edges |
84 | if { [info exists nbsh_e ] } { |
85 | if { ($ll_e != $nbsh_e) || ($nbsh_e == 0 && $ll_e != 0) } { |
94a57f1f |
86 | puts "Error : The resulting shape is WRONG because it must contain $nbsh_e edges instead of $ll_e" |
5805221e |
87 | } else { |
94a57f1f |
88 | puts "The resulting shape contains $ll_e edges" |
5805221e |
89 | } |
90 | } |
91 | # check for number of wires |
92 | if { [info exists nbsh_w ] } { |
93 | if { ($ll_w != $nbsh_w) || ($nbsh_w == 0 && $ll_w != 0) } { |
94a57f1f |
94 | puts "Error : The resulting shape is WRONG because it must contain $nbsh_w wires instead of $ll_w" |
5805221e |
95 | } else { |
94a57f1f |
96 | puts "The resulting shape contains $ll_w wires" |
5805221e |
97 | } |
98 | } |
99 | } else { |
100 | regexp {Mass +: +([-0-9.+eE]+)} [vprops s] full sm |
101 | regexp {Mass +: +([-0-9.+eE]+)} [vprops result] full m |
102 | |
103 | #check if result is valid |
104 | puts [checkshape result] |
105 | if { $m == 0 || $sm == $m } { |
106 | puts "Error : The offset is not valid. The volume is $m." |
107 | } |
108 | |
109 | #check of face's square value |
110 | foreach ResultFace [ explode result f ] { |
111 | regexp {Mass +: +([-0-9.+eE]+)} [sprops $ResultFace] full fmass |
112 | if { $fmass < 0 } { |
94a57f1f |
113 | puts "Error : The area of face $ResultFace of the resulting shape is negative." |
5805221e |
114 | } |
115 | } |
116 | #check for bsection |
117 | if { [info exists GlobFaces] && [llength $GlobFaces] == 0 } { |
191082ac |
118 | puts [ bsection re result s ] |
5805221e |
119 | if { [ isdraw re ] } { |
120 | regexp {Mass +: +([-0-9.+eE]+)} [lprops $re] full remass |
121 | if { $remass != 0 } { |
94a57f1f |
122 | puts "Error: bsection of the result and s is not equal to zero." |
5805221e |
123 | } |
124 | } |
125 | } |
126 | |
127 | if { $volume > 0 } { |
128 | puts "The expected volume is $volume" |
129 | } |
130 | #check of change of volume is < 1% |
49c093ae |
131 | if { ($volume > 0 && [expr 1.*abs($volume - $m)/$volume] > 0.01) || ($volume == 0 && $m != 0 && $sm != $m) } { |
94a57f1f |
132 | puts "Error : The volume of the resulting shape is $m" |
5805221e |
133 | } |
134 | } |
135 | if { $m > 0 } { |
136 | clear |
137 | smallview |
138 | donly result |
139 | fit |
88f8fc81 |
140 | xwd $imagedir/${test_image}.png |
5805221e |
141 | } |
40093367 |
142 | } else { |
94a57f1f |
143 | puts "Error : The offset cannot be built." |
40093367 |
144 | } |
145 | |
146 | # to end a test script |
147 | puts "TEST COMPLETED" |