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