0026106: BRepMesh - revision of data model
[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 } {
a1954302 25 vinit View1
26 vdisplay -noupdate -redisplay res
40093367 27 vsetdispmode res 1
28 vfit
29}
30
31if { [string compare $command "incmesh"] == 0 } {
49cfd13d 32 if { [string compare $parallel "-parallel"] != 0 || [info exists count_parallel] == 0 } {
40093367 33 set count_parallel 1
34 }
35 for {set i 1} {$i <= $count_parallel} {incr i} {
36 tclean res
37 puts "i = $i"
38 incmesh res ${Deflection} ${parallel}
39 }
40}
41
42if { [string compare $command "mesh"] == 0 } {
43 set ResultList [mesh res_mesh res ${Deflection}]
44}
45
46# Collect TODO for area
47if { [string compare $bug_area ""] != 0 } {
94a57f1f 48# The difference between the area of a geometry surface and the area of mesh triangles should be less than rel_tol value.
49# If rel_tol is 100 we suppose that the mesh cannot be created.
40093367 50 if { $rel_tol == 100 } {
6aac585a 51 puts "TODO $bug_area All:^\\s*Error : The meshing algo cannot create mesh.\\s*$"
40093367 52 } else {
7bd071ed 53 puts "TODO ?$bug_area All: Error: area difference = .* is not equal to expected"
40093367 54 }
55}
56
57# Collect TODO for number of triangles without mesh
58if { [string compare $bug_withouttri ""] != 0 } {
59# It may be different for different OS
60 foreach os_withouttri [array names nbwithouttri] {
61 if { $nbwithouttri($os_withouttri) != 0 } {
62 puts "TODO $bug_withouttri $os_withouttri:^\\s*Error: Faces without triangulation: $nbwithouttri($os_withouttri)\\b\\s*"
63 }
64 }
65}
66
67# Collect TODO for number of free links
68if { [string compare $bug_freelinks ""] != 0 } {
69# It may be different for different OS
70 foreach os_freelinks [array names nbfree] {
71 if { $nbfree($os_freelinks) != 0 } {
4b445d18 72 puts "TODO $bug_freelinks $os_freelinks:^\\s*Error: Free links"
40093367 73 }
74 }
75}
76
77# Collect TODO for number of cross faces
78if { [string compare $bug_cross ""] != 0 } {
79# It may be different for different OS
80 foreach os_cross [array names nbcross] {
81 if { $nbcross($os_cross) != 0 } {
74f764ba 82 puts "TODO $bug_cross $os_cross:Error: Cross face errors"
40093367 83 }
84 }
85}
86
87# Collect TODO for number of async edges
88if { [string compare $bug_async ""] != 0 } {
89# It may be different for different OS
90 foreach os_async [array names nbasync] {
91 if { $nbasync($os_async) != 0 } {
92 puts "TODO $bug_async $os_async:^\\s*Error: Async edges: $nbasync($os_async)\\b\\s*"
93 }
94 }
95}
96
97# Collect TODO for number of free nodes
98if { [string compare $bug_freenodes ""] != 0 } {
99# It may be different for different OS
100 foreach os_freenodes [array names nbfreenodes] {
101 if { $nbfreenodes($os_freenodes) != 0 } {
74f764ba 102 puts "TODO $bug_freenodes $os_freenodes:Error: Free nodes"
40093367 103 }
104 }
105}
106
107# Number of triangles
108set tri 0
109# Number of nodes
110set nod 0
111# Deflection
112set def 0
113
94a57f1f 114# Collect number of triangles, number of nodes and deflection.
40093367 115if { [string compare $command "mesh"] != 0 } {
116 set full [trinfo res]
117 regexp "(\[0-9\]+) +triangles.*\[^0-9]\(\[0-9\]+) +nodes.*deflection +(\[0-9\]|\.+)" $full reg_out tri nod def
118} else {
119 set full [split $ResultList "()"]
120 set tri [lindex [lindex $full 2] 0]
121 set lin [lindex [lindex $full 4] 0]
122 set nod [lindex [lindex $full 6] 0]
123}
124
125if { $tri == 0 || $nod == 0 } {
126 puts " "
94a57f1f 127 puts "Error : The meshing algo cannot create mesh."
40093367 128}
129
130puts " "
131puts "XML property: triangles $tri"
132puts "XML property: nodes $nod"
133puts " "
134
135# Check if area of triangles is valid
136proc CheckTriArea {shape {eps 0}} {
191082ac 137 upvar #0 $shape a
138 set area [triarea a $eps]
40093367 139 set t_area [lindex $area 0]
140 set g_area [expr abs([lindex $area 1])]
141 puts "area by triangles: $t_area"
142 puts "area by geometry: $g_area"
143 expr ($t_area - $g_area) / $g_area * 100
144}
145
146puts "\nChecking triangulation area (triarea command)..."
147set rel_err [expr abs([CheckTriArea res $area_eps])]
7bd071ed 148if { [info exists max_rel_tol_diff] && $max_rel_tol_diff > 0 } {
149 checkreal "area difference" $rel_err $rel_tol $max_rel_tol_diff 0
40093367 150}
151
152# Check if topology of mesh is valid
153puts "\nChecking mesh topology (tricheck command)..."
154set l [tricheck res]
155if {$l != ""} {
156 puts $l
157 set withouttri [regsub -all "face \[0-9\]+ has no triangulation" $l "FOUND" ll]
158 if { $withouttri != 0 } {
159 puts "Error: Faces without triangulation: $withouttri"
160 }
161 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] } {
162 if { $freelinks != 0 } {
163 puts "Error: Free links: $freelinks"
164 }
165 if { $crossfaces != 0 } {
166 puts "Error: Cross face errors: $crossfaces"
167 }
168 if { $asyncedges != 0 } {
169 puts "Error: Async edges: $asyncedges"
170 }
171 if { $freenodes != 0 } {
172 puts "Error: Free nodes: $freenodes"
173 }
174 }
175}
176
177if { [info exists imagedir] == 0 } {
178 set imagedir .
179}
180if { [info exists test_image ] == 0 } {
181 set test_image photo
182}
183
184if { [string compare $command "shading"] == 0 } {
b86bb3df 185 vglinfo
88f8fc81 186 vdump $imagedir/${test_image}.png
40093367 187} else {
188 isos 0
189 smallview
190 donly res
191 fit
192 triangles res
88f8fc81 193 xwd $imagedir/${test_image}.png
40093367 194}
195
196puts ""
197puts "TEST COMPLETED"
198puts ""