0024809: Exception is raised during perform of "bfillds" command on attached shape
[occt.git] / tests / mesh / end
CommitLineData
40093367 1# Get name of shape
2
3if { [string compare ${TheFileName} ""] != 0 } {
4 set is_brep [regexp "\.brep" $TheFileName]
b725d7c5 5 if {$is_brep == 0} {
6 set is_brep [regexp "\.rle" $TheFileName]
7 }
40093367 8 if {$is_brep == 1} {
b725d7c5 9 puts [brestore [locate_data_file $TheFileName] res]
40093367 10 } else {
11 if { [array get Draw_Groups "DE: STEP"] == "" } {
12 pload XDE
13 }
14
8418c617 15 stepread [locate_data_file ${TheFileName}] a *
40093367 16 tpcompound res
17 }
18}
19
20puts [checkshape res]
21
22tclean res
23
24if { [string compare $command "shading"] == 0 } {
25 vinit
26 vdisplay res
27 vsetdispmode res 1
28 vfit
29}
30
31if { [string compare $command "incmesh"] == 0 } {
32 set os "ALL"
33 if {[array get env os_type] != ""} {
34 set os $env(os_type)
35 }
40093367 36 if { $parallel != 1 || [info exists count_parallel] == 0 } {
37 set count_parallel 1
38 }
39 for {set i 1} {$i <= $count_parallel} {incr i} {
40 tclean res
41 puts "i = $i"
42 incmesh res ${Deflection} ${parallel}
43 }
44}
45
46if { [string compare $command "mesh"] == 0 } {
47 set ResultList [mesh res_mesh res ${Deflection}]
48}
49
50# Collect TODO for area
51if { [string compare $bug_area ""] != 0 } {
94a57f1f 52# The difference between the area of a geometry surface and the area of mesh triangles should be less than rel_tol value.
53# If rel_tol is 100 we suppose that the mesh cannot be created.
40093367 54 if { $rel_tol == 100 } {
6aac585a 55 puts "TODO $bug_area All:^\\s*Error : The meshing algo cannot create mesh.\\s*$"
40093367 56 } else {
74f764ba 57 puts "TODO ?$bug_area All:^\\s*Error : area by triangles differs from the actual area by \[-.0-9\]+ %\\s*$"
40093367 58 }
59}
60
61# Collect TODO for number of triangles without mesh
62if { [string compare $bug_withouttri ""] != 0 } {
63# It may be different for different OS
64 foreach os_withouttri [array names nbwithouttri] {
65 if { $nbwithouttri($os_withouttri) != 0 } {
66 puts "TODO $bug_withouttri $os_withouttri:^\\s*Error: Faces without triangulation: $nbwithouttri($os_withouttri)\\b\\s*"
67 }
68 }
69}
70
71# Collect TODO for number of free links
72if { [string compare $bug_freelinks ""] != 0 } {
73# It may be different for different OS
74 foreach os_freelinks [array names nbfree] {
75 if { $nbfree($os_freelinks) != 0 } {
76 puts "TODO $bug_freelinks $os_freelinks:^\\s*Error: Free links: $nbfree($os_freelinks)\\b\\s*"
77 }
78 }
79}
80
81# Collect TODO for number of cross faces
82if { [string compare $bug_cross ""] != 0 } {
83# It may be different for different OS
84 foreach os_cross [array names nbcross] {
85 if { $nbcross($os_cross) != 0 } {
74f764ba 86 puts "TODO $bug_cross $os_cross:Error: Cross face errors"
40093367 87 }
88 }
89}
90
91# Collect TODO for number of async edges
92if { [string compare $bug_async ""] != 0 } {
93# It may be different for different OS
94 foreach os_async [array names nbasync] {
95 if { $nbasync($os_async) != 0 } {
96 puts "TODO $bug_async $os_async:^\\s*Error: Async edges: $nbasync($os_async)\\b\\s*"
97 }
98 }
99}
100
101# Collect TODO for number of free nodes
102if { [string compare $bug_freenodes ""] != 0 } {
103# It may be different for different OS
104 foreach os_freenodes [array names nbfreenodes] {
105 if { $nbfreenodes($os_freenodes) != 0 } {
74f764ba 106 puts "TODO $bug_freenodes $os_freenodes:Error: Free nodes"
40093367 107 }
108 }
109}
110
111# Number of triangles
112set tri 0
113# Number of nodes
114set nod 0
115# Deflection
116set def 0
117
94a57f1f 118# Collect number of triangles, number of nodes and deflection.
40093367 119if { [string compare $command "mesh"] != 0 } {
120 set full [trinfo res]
121 regexp "(\[0-9\]+) +triangles.*\[^0-9]\(\[0-9\]+) +nodes.*deflection +(\[0-9\]|\.+)" $full reg_out tri nod def
122} else {
123 set full [split $ResultList "()"]
124 set tri [lindex [lindex $full 2] 0]
125 set lin [lindex [lindex $full 4] 0]
126 set nod [lindex [lindex $full 6] 0]
127}
128
129if { $tri == 0 || $nod == 0 } {
130 puts " "
94a57f1f 131 puts "Error : The meshing algo cannot create mesh."
40093367 132}
133
134puts " "
135puts "XML property: triangles $tri"
136puts "XML property: nodes $nod"
137puts " "
138
139# Check if area of triangles is valid
140proc CheckTriArea {shape {eps 0}} {
141 upvar #0 $shape a
142 set area [triarea a $eps]
143 set t_area [lindex $area 0]
144 set g_area [expr abs([lindex $area 1])]
145 puts "area by triangles: $t_area"
146 puts "area by geometry: $g_area"
147 expr ($t_area - $g_area) / $g_area * 100
148}
149
150puts "\nChecking triangulation area (triarea command)..."
151set rel_err [expr abs([CheckTriArea res $area_eps])]
152if { $rel_err > $rel_tol } {
94a57f1f 153 puts "Error : area by triangles differs from the actual area by $rel_err %"
40093367 154} else {
155 if { $rel_tol > 1 && $rel_tol < 100 } {
156 puts "Error: Improvement: The current area difference is $rel_err instead of $rel_tol"
157 }
158}
159
160# Check if topology of mesh is valid
161puts "\nChecking mesh topology (tricheck command)..."
162set l [tricheck res]
163if {$l != ""} {
164 puts $l
165 set withouttri [regsub -all "face \[0-9\]+ has no triangulation" $l "FOUND" ll]
166 if { $withouttri != 0 } {
167 puts "Error: Faces without triangulation: $withouttri"
168 }
169 if { [regexp "Free_links +(\[0-9\]+) +Cross_face_errors +(\[0-9\]+) +Async_edges +(\[0-9\]+) +Free_nodes +(\[0-9\]+)" $l full freelinks crossfaces asyncedges freenodes] } {
170 if { $freelinks != 0 } {
171 puts "Error: Free links: $freelinks"
172 }
173 if { $crossfaces != 0 } {
174 puts "Error: Cross face errors: $crossfaces"
175 }
176 if { $asyncedges != 0 } {
177 puts "Error: Async edges: $asyncedges"
178 }
179 if { $freenodes != 0 } {
180 puts "Error: Free nodes: $freenodes"
181 }
182 }
183}
184
185if { [info exists imagedir] == 0 } {
186 set imagedir .
187}
188if { [info exists test_image ] == 0 } {
189 set test_image photo
190}
191
192if { [string compare $command "shading"] == 0 } {
88f8fc81 193 vdump $imagedir/${test_image}.png
40093367 194} else {
195 isos 0
196 smallview
197 donly res
198 fit
199 triangles res
88f8fc81 200 xwd $imagedir/${test_image}.png
40093367 201}
202
203puts ""
204puts "TEST COMPLETED"
205puts ""