0025230: Test case for selection in perspective views
[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:Error: Cross face errors"
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:Error: Free nodes"
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   set area [triarea $shape $eps]
142   set t_area [lindex $area 0]
143   set g_area [expr abs([lindex $area 1])]
144   puts "area by triangles: $t_area"
145   puts "area by geometry:  $g_area"
146   expr ($t_area - $g_area) / $g_area * 100
147 }
148
149 puts "\nChecking triangulation area (triarea command)..."
150 set rel_err [expr abs([CheckTriArea res $area_eps])]
151 if { $rel_err > $rel_tol } {
152     puts "Error   : area by triangles differs from the actual area by $rel_err %"
153 } else {
154     if { $rel_tol > 1 && $rel_tol < 100 } {
155         puts "Error: Improvement: The current area difference is $rel_err instead of $rel_tol"
156     }
157 }
158
159 # Check if topology of mesh is valid
160 puts "\nChecking mesh topology (tricheck command)..."
161 set l [tricheck res]
162 if {$l != ""} {
163     puts $l
164     set withouttri [regsub -all "face \[0-9\]+ has no triangulation" $l "FOUND" ll]
165     if { $withouttri != 0 } {
166         puts "Error: Faces without triangulation: $withouttri"
167     }
168     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] } {
169         if { $freelinks != 0 } {
170             puts "Error: Free links: $freelinks"
171         }
172         if { $crossfaces != 0 } {
173             puts "Error: Cross face errors: $crossfaces"
174         }
175         if { $asyncedges != 0 } {
176             puts "Error: Async edges: $asyncedges"
177         }
178         if { $freenodes != 0 } {
179             puts "Error: Free nodes: $freenodes"
180         }
181     }
182 }
183
184 if { [info exists imagedir] == 0 } {
185    set imagedir .
186 }
187 if { [info exists test_image ] == 0 } {
188    set test_image photo
189 }
190
191 if { [string compare $command "shading"] == 0 } {
192     vdump $imagedir/${test_image}.png
193 } else {
194     isos 0
195     smallview
196     donly res
197     fit
198     triangles res
199     xwd $imagedir/${test_image}.png
200 }
201
202 puts ""
203 puts "TEST COMPLETED" 
204 puts ""