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