0026663: Test cases for BRepOffset_Makeoffset
[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]
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 }
e9102e99 99 } elseif {[info exists command] && [string compare $command "withintersect"] == 0} {
100 regexp {Mass +: +([-0-9.+eE]+)} [sprops result] full m
101 checkshape result
5805221e 102 } else {
103 regexp {Mass +: +([-0-9.+eE]+)} [vprops s] full sm
104 regexp {Mass +: +([-0-9.+eE]+)} [vprops result] full m
105
106 #check if result is valid
107 puts [checkshape result]
108 if { $m == 0 || $sm == $m } {
109 puts "Error : The offset is not valid. The volume is $m."
110 }
111
112 #check of face's square value
113 foreach ResultFace [ explode result f ] {
114 regexp {Mass +: +([-0-9.+eE]+)} [sprops $ResultFace] full fmass
115 if { $fmass < 0 } {
94a57f1f 116 puts "Error : The area of face $ResultFace of the resulting shape is negative."
5805221e 117 }
118 }
119 #check for bsection
120 if { [info exists GlobFaces] && [llength $GlobFaces] == 0 } {
191082ac 121 puts [ bsection re result s ]
5805221e 122 if { [ isdraw re ] } {
123 regexp {Mass +: +([-0-9.+eE]+)} [lprops $re] full remass
124 if { $remass != 0 } {
94a57f1f 125 puts "Error: bsection of the result and s is not equal to zero."
5805221e 126 }
127 }
128 }
e9102e99 129 if {[info exists volume]} {
130 if { $volume > 0 } {
131 puts "The expected volume is $volume"
132 }
133 #check of change of volume is < 1%
134 if { ($volume > 0 && [expr 1.*abs($volume - $m)/$volume] > 0.01) || ($volume == 0 && $m != 0 && $sm != $m) } {
135 puts "Error : The volume of the resulting shape is $m"
136 }
137 }
5805221e 138 }
139 if { $m > 0 } {
140 clear
141 smallview
142 donly result
143 fit
88f8fc81 144 xwd $imagedir/${test_image}.png
5805221e 145 }
40093367 146} else {
94a57f1f 147 puts "Error : The offset cannot be built."
40093367 148}
149
150# to end a test script
151puts "TEST COMPLETED"