Adjusting testing cases for current state of OCCT
[occt.git] / tests / mesh / end
1 # Get name of shape
2
3 if { [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
20 puts [checkshape res]
21
22 tclean res
23
24 if { [string compare $command "shading"] == 0 } {
25     vinit
26     vdisplay res
27     vsetdispmode res 1
28     vfit
29 }
30
31 if { [string compare $command "incmesh"] == 0 } {
32     set os "ALL"
33     if {[array get env os_type] != ""} {
34         set os $env(os_type)
35     }
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
46 if { [string compare $command "mesh"] == 0 } {
47     set ResultList [mesh res_mesh res ${Deflection}]
48 }
49
50 # Collect TODO for area
51 if { [string compare $bug_area ""] != 0 } {
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.
54     if { $rel_tol == 100 } {
55         puts "TODO $bug_area All:^\\s*Error  : The meshing algo cannot create mesh.\\s*$"
56     } else {
57         puts "TODO $bug_area All:^\\s*Error   : area by triangles differs from the actual area by \[-.0-9\]+ %\\s*$"
58     }
59 }
60
61 # Collect TODO for number of triangles without mesh
62 if { [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
72 if { [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
82 if { [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 } { 
86             puts "TODO $bug_cross $os_cross:^\\s*Error: Cross face errors: $nbcross($os_cross)\\b\\s*"
87         }
88     }
89 }
90
91 # Collect TODO for number of async edges
92 if { [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
102 if { [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 } { 
106             puts "TODO $bug_freenodes $os_freenodes:^\\s*Error: Free nodes: $nbfreenodes($os_freenodes)\\b\\s*"
107         }
108     }
109 }
110
111 # Number of triangles
112 set tri 0
113 # Number of nodes
114 set nod 0
115 # Deflection
116 set def 0
117
118 # Collect number of triangles, number of nodes and deflection.
119 if { [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
129 if { $tri == 0 || $nod == 0 } {                                                                     
130     puts " "
131     puts "Error  : The meshing algo cannot create mesh."    
132 }             
133
134 puts " "
135 puts "XML property: triangles $tri"
136 puts "XML property: nodes $nod"
137 puts " "
138
139 # Check if area of triangles is valid
140 proc 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
150 puts "\nChecking triangulation area (triarea command)..."
151 set rel_err [expr abs([CheckTriArea res $area_eps])]
152 if { $rel_err > $rel_tol } {
153     puts "Error   : area by triangles differs from the actual area by $rel_err %"
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
161 puts "\nChecking mesh topology (tricheck command)..."
162 set l [tricheck res]
163 if {$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
185 if { [info exists imagedir] == 0 } {
186    set imagedir .
187 }
188 if { [info exists test_image ] == 0 } {
189    set test_image photo
190 }
191
192 if { [string compare $command "shading"] == 0 } {
193     vdump $imagedir/${test_image}.png
194 } else {
195     isos 0
196     smallview
197     donly res
198     fit
199     triangles res
200     xwd $imagedir/${test_image}.png
201 }
202
203 puts ""
204 puts "TEST COMPLETED" 
205 puts ""