1 # Copyright (c) 2013-2014 OPEN CASCADE SAS
3 # This file is part of Open CASCADE Technology software library.
5 # This library is free software; you can redistribute it and/or modify it under
6 # the terms of the GNU Lesser General Public License version 2.1 as published
7 # by the Free Software Foundation, with special exception defined in the file
8 # OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 # distribution for complete text of the license and disclaimer of any warranty.
11 # Alternatively, this file may be used under the terms of Open CASCADE
12 # commercial license or contractual agreement.
14 ############################################################################
15 # This file defines scripts for verification of OCCT tests.
16 # It provides top-level commands starting with 'check'.
17 # Type 'help check*' to get their synopsys.
18 # See OCCT Tests User Guide for description of the test system.
20 # Note: procedures with names starting with underscore are for internal use
21 # inside the test system.
22 ############################################################################
26 Use: checkcolor x y red green blue
27 x y - pixel coordinates
28 red green blue - expected pixel color (values from 0 to 1)
29 Function check color with tolerance (5x5 area)
31 # Procedure to check color using command vreadpixel with tolerance
32 proc checkcolor { coord_x coord_y rd_get gr_get bl_get } {
33 puts "Coordinate x = $coord_x"
34 puts "Coordinate y = $coord_y"
35 puts "RED color of RGB is $rd_get"
36 puts "GREEN color of RGB is $gr_get"
37 puts "BLUE color of RGB is $bl_get"
39 if { $coord_x <= 1 || $coord_y <= 1 } {
40 puts "Error : minimal coordinate is x = 2, y = 2. But we have x = $coord_x y = $coord_y"
45 catch { [set color "[vreadpixel ${coord_x} ${coord_y} rgb]"] }
47 puts "Error : Pixel coordinates (${position_x}; ${position_y}) are out of view"
49 set rd [lindex $color 0]
50 set gr [lindex $color 1]
51 set bl [lindex $color 2]
52 set rd_int [expr int($rd * 1.e+05)]
53 set gr_int [expr int($gr * 1.e+05)]
54 set bl_int [expr int($bl * 1.e+05)]
55 set rd_ch [expr int($rd_get * 1.e+05)]
56 set gr_ch [expr int($gr_get * 1.e+05)]
57 set bl_ch [expr int($bl_get * 1.e+05)]
60 set tol_rd [expr abs($rd_ch - $rd_int)/$rd_ch]
65 set tol_gr [expr abs($gr_ch - $gr_int)/$gr_ch]
70 set tol_bl [expr abs($bl_ch - $bl_int)/$bl_ch]
76 if { $tol_rd > 0.2 } {
77 puts "Warning : RED light of additive color model RGB is invalid"
80 if { $tol_gr > 0.2 } {
81 puts "Warning : GREEN light of additive color model RGB is invalid"
84 if { $tol_bl > 0.2 } {
85 puts "Warning : BLUE light of additive color model RGB is invalid"
90 puts "Warning : Colors of default coordinate are not equal"
94 if { $tol_rd > 0.2 || $tol_gr > 0.2 || $tol_bl > 0.2 } {
95 set info [_checkpoint $coord_x $coord_y $rd_ch $gr_ch $bl_ch]
96 set stat [lindex $info end]
98 puts "Error : Colors are not equal in default coordinate and in the near coordinates too"
101 puts "Point with valid color was found"
109 # Procedure to check color in the point near default coordinate
110 proc _checkpoint {coord_x coord_y rd_ch gr_ch bl_ch} {
111 set x_start [expr ${coord_x} - 2]
112 set y_start [expr ${coord_y} - 2]
115 while { $mistake != 1 && $i <= 5 } {
117 while { $mistake != 1 && $j <= 5 } {
118 set position_x [expr ${x_start} + $j]
119 set position_y [expr ${y_start} + $i]
124 catch { [set color "[vreadpixel ${position_x} ${position_y} rgb]"] }
125 if {"$color" == ""} {
126 puts "Warning : Pixel coordinates (${position_x}; ${position_y}) are out of view"
130 set rd [lindex $color 0]
131 set gr [lindex $color 1]
132 set bl [lindex $color 2]
133 set rd_int [expr int($rd * 1.e+05)]
134 set gr_int [expr int($gr * 1.e+05)]
135 set bl_int [expr int($bl * 1.e+05)]
138 set tol_rd [expr abs($rd_ch - $rd_int)/$rd_ch]
143 set tol_gr [expr abs($gr_ch - $gr_int)/$gr_ch]
148 set tol_bl [expr abs($bl_ch - $bl_int)/$bl_ch]
153 if { $tol_rd > 0.2 || $tol_gr > 0.2 || $tol_bl > 0.2 } {
154 puts "Warning : Point with true color was not found near default coordinates"
166 # auxiliary: check argument
167 proc _check_arg {check_name check_result {get_value 0}} {
168 upvar ${check_result} ${check_result}
172 if { $arg == ${check_name} } {
173 if { ${get_value} == "?" } {
174 set next_arg_index [expr $narg + 1]
175 if { $next_arg_index < [llength $args] && ! [regexp {^-[^0-9]} [lindex $args $next_arg_index]] } {
176 set ${check_result} "[lindex $args $next_arg_index]"
177 set narg ${next_arg_index}
179 set ${check_result} "true"
181 } elseif {${get_value}} {
183 if { $narg < [llength $args] && ! [regexp {^-[^0-9]} [lindex $args $narg]] } {
184 set ${check_result} "[lindex $args $narg]"
186 error "Option ${check_result} requires argument"
189 set ${check_result} "true"
197 Compare number of sub-shapes in "shape" with given reference data
199 Use: checknbshapes shape [options...]
210 -t: compare the number of sub-shapes in "shape" counting
211 the same sub-shapes with different location as different sub-shapes.
212 -m msg: print "msg" in case of error
213 -ref [nbshapes a]: compare the number of sub-shapes in "shape" and in "a".
214 -vertex N, -edge N and other options are stil working.
216 proc checknbshapes {shape args} {
217 puts "checknbshapes ${shape} ${args}"
218 upvar ${shape} ${shape}
231 set count_locations 0
234 for {set narg 0} {$narg < [llength $args]} {incr narg} {
235 set arg [lindex $args $narg]
236 if {[_check_arg "-vertex" nbVERTEX 1] ||
237 [_check_arg "-edge" nbEDGE 1] ||
238 [_check_arg "-wire" nbWIRE 1] ||
239 [_check_arg "-face" nbFACE 1] ||
240 [_check_arg "-shell" nbSHELL 1] ||
241 [_check_arg "-solid" nbSOLID 1] ||
242 [_check_arg "-compsolid" nbCOMPSOLID 1] ||
243 [_check_arg "-compound" nbCOMPOUND 1] ||
244 [_check_arg "-shape" nbSHAPE 1] ||
245 [_check_arg "-t" count_locations] ||
246 [_check_arg "-m" message 1] ||
247 [_check_arg "-ref" ref_info 1]
252 if { [regexp {^-} $arg] } {
253 error "Error: unsupported option \"$arg\""
255 error "Error: cannot interpret argument $narg ($arg)"
258 if { ${count_locations} == 0 } {
259 set nb_info [nbshapes ${shape}]
261 set nb_info [nbshapes ${shape} -t]
264 set EntityList {VERTEX EDGE WIRE FACE SHELL SOLID COMPSOLID COMPOUND SHAPE}
266 foreach Entity ${EntityList} {
267 set expr_string "${Entity} +: +(\[-0-9.+eE\]+)"
269 # get number of elements from ${shape}
270 if { [regexp "${expr_string}" ${nb_info} full nb_entity2] } {
271 lappend to_compare ${nb_entity2}
273 error "Error : command \"nbshapes ${shape}\" gives an empty result"
275 # get number of elements from options -vertex -edge and so on
276 set nb_entity1 [set nb${Entity}]
277 if { ${nb_entity1} != -1 } {
278 lappend to_compare ${nb_entity1}
280 # get number of elements from option -ref
281 if { [regexp "${expr_string}" ${ref_info} full nb_entity_ref] } {
282 lappend to_compare ${nb_entity_ref}
284 # skip comparing if no reference data was given
285 if {[llength $to_compare] == 1} {
288 # compare all values, if they are equal, length of sorted list "to_compare"
289 # (with key -unique) should be equal to 1
290 set to_compare [lsort -dictionary -unique $to_compare]
291 if { [llength $to_compare] != 1 } {
292 puts "Error : ${message} is WRONG because number of ${Entity} entities in shape \"${shape}\" is ${nb_entity2}"
294 puts "OK : ${message} is GOOD because number of ${Entity} entities is equal to number of expected ${Entity} entities"
299 # Procedure to check equality of two reals with tolerance (relative and absolute)
301 Compare value with expected
302 Use: checkreal name value expected tol_abs tol_rel
304 proc checkreal {name value expected tol_abs tol_rel} {
305 if { abs ($value - $expected) > $tol_abs + $tol_rel * abs ($expected) } {
306 puts "Error: $name = $value is not equal to expected $expected"
308 puts "Check of $name OK: value = $value, expected = $expected"
313 help checkfreebounds {
314 Compare number of free edges with ref_value
316 Use: checkfreebounds shape ref_value [options...]
318 -tol N: used tolerance (default -0.01)
319 -type N: used type, possible values are "closed" and "opened" (default "closed")
321 proc checkfreebounds {shape ref_value args} {
322 puts "checkfreebounds ${shape} ${ref_value} ${args}"
323 upvar ${shape} ${shape}
328 for {set narg 0} {$narg < [llength $args]} {incr narg} {
329 set arg [lindex $args $narg]
330 if {[_check_arg "-tol" tol 1] ||
331 [_check_arg "-type" type 1]
336 if { [regexp {^-} $arg] } {
337 error "Error: unsupported option \"$arg\""
339 error "Error: cannot interpret argument $narg ($arg)"
342 if {"$type" != "closed" && "$type" != "opened"} {
343 error "Error : wrong -type key \"${type}\""
346 freebounds ${shape} ${tol}
347 set free_edges [llength [explode ${shape}_[string range $type 0 0] e]]
349 if { ${ref_value} == -1 } {
350 puts "Error : Number of free edges is UNSTABLE"
354 if { ${free_edges} != ${ref_value} } {
355 puts "Error : Number of free edges is not equal to reference data"
357 puts "OK : Number of free edges is ${free_edges}"
362 Compare max tolerance of shape with reference value.
363 Command returns max tolerance of the shape.
365 Use: checkmaxtol shape [options...]
367 -ref: reference value of maximum tolerance.
368 -source: list of shapes to compare with, e.g.: -source {shape1 shape2 shape3}
369 -min_tol: minimum tolerance for comparison.
370 -multi_tol: tolerance multiplier.
373 proc checkmaxtol {shape args} {
374 puts "checkmaxtol ${shape} ${args}"
375 upvar ${shape} ${shape}
383 for {set narg 0} {$narg < [llength $args]} {incr narg} {
384 set arg [lindex $args $narg]
385 if {[_check_arg "-min_tol" min_tol 1] ||
386 [_check_arg "-multi_tol" tol_multiplier 1] ||
387 [_check_arg "-source" source_shapes 1] ||
388 [_check_arg "-ref" ref_value 1]
393 if { [regexp {^-} $arg] } {
394 error "Error: unsupported option \"$arg\""
396 error "Error: cannot interpret argument $narg ($arg)"
399 # get max tol of shape
401 if {[regexp "Tolerance MAX=(\[-0-9.+eE\]+)" [tolerance ${shape}] full maxtol_temp]} {
402 set max_tol ${maxtol_temp}
404 error "Error: cannot get tolerances of shape \"${shape}\""
407 # find max tol of source shapes
408 foreach source_shape ${source_shapes} {
409 upvar ${source_shape} ${source_shape}
410 set _src_max_tol [checkmaxtol ${source_shape}]
411 if { [expr ${_src_max_tol} > ${min_tol} ] } {
412 set min_tol ${_src_max_tol}
415 # apply -multi_tol option
416 if {${tol_multiplier}} {
417 set min_tol [expr ${tol_multiplier} * ${_src_max_tol}]
419 # compare max tol of source shapes with checking tolerance
420 if { ${min_tol} && [expr ${max_tol} > ${min_tol}] } {
421 puts "Error: tolerance of \"${shape}\" (${max_tol}) is greater than checking tolerance (${min_tol})"
423 if { ${ref_value} != "" } {
424 checkreal "Max tolerance" ${max_tol} ${ref_value} 0.0001 0.01
430 Compare faults number of given shapes.
432 Use: checkfaults shape source_shape [ref_value=0]
434 proc checkfaults {shape source_shape {ref_value 0}} {
435 puts "checkfaults ${shape} ${source_shape} ${ref_value}"
437 upvar $source_shape $source_shape
438 set cs_a [checkshape $source_shape]
440 if {[regexp {Faulty shapes in variables faulty_([0-9]*) to faulty_([0-9]*)} $cs_a full nb_a_begin nb_a_end]} {
441 set nb_a [expr $nb_a_end - $nb_a_begin +1]
443 set cs_r [checkshape $shape]
445 if {[regexp {Faulty shapes in variables faulty_([0-9]*) to faulty_([0-9]*)} $cs_r full nb_r_begin nb_r_end]} {
446 set nb_r [expr $nb_r_end - $nb_r_begin +1]
448 puts "Number of faults for the initial shape is $nb_a."
449 puts "Number of faults for the resulting shape is $nb_r."
451 if { ${ref_value} == -1 } {
452 puts "Error : Number of faults is UNSTABLE"
456 if { $nb_r > $nb_a } {
457 puts "Error : Number of faults is $nb_r"
461 # auxiliary: check all arguments
462 proc _check_args { args {options {}} {command_name ""}} {
464 for {set narg 0} {${narg} < [llength ${args}]} {incr narg} {
465 set arg [lindex ${args} ${narg}]
467 foreach option ${options} {
468 set option_name [lindex ${option} 0]
469 set variable_to_save_value [lindex ${option} 1]
470 set get_value [lindex ${option} 2]
472 if { [_check_arg ${option_name} local_value ${get_value}] } {
473 upvar ${variable_to_save_value} ${variable_to_save_value}
474 set ${variable_to_save_value} ${local_value}
478 if {${toContinue}} { continue }
480 if { [regexp {^-} ${arg}] } {
481 error "Error: unsupported option \"${arg}\""
483 error "Error: cannot interpret argument ${narg} (${arg})"
485 foreach option ${options} {
486 set option_name [lindex ${option} 0]
487 set variable_to_save_value [lindex ${option} 1]
488 set should_exist [lindex ${option} 3]
489 if {![info exists ${variable_to_save_value}] && ${should_exist} == 1} {
490 error "Error: wrong using of command '${command_name}', '${option_name}' option is required"
496 Procedure includes commands to compute length, area and volume of input shape.
498 Use: checkprops shapename [options...]
500 -l LENGTH: command lprops, computes the mass properties of all edges in the shape with a linear density of 1
501 -s AREA: command sprops, computes the mass properties of all faces with a surface density of 1
502 -v VOLUME: command vprops, computes the mass properties of all solids with a density of 1
503 -eps EPSILON: the epsilon defines relative precision of computation
504 -equal SHAPE: compare area\volume\length of input shapes. Puts error if its are not equal
505 -notequal SHAPE: compare area\volume\length of input shapes. Puts error if its are equal
506 -skip: count shared shapes only once, skipping repeatitions
507 Options -l, -s and -v are independent and can be used in any order. Tolerance epsilon is the same for all options.
510 proc checkprops {shape args} {
511 puts "checkprops ${shape} ${args}"
512 upvar ${shape} ${shape}
514 if {![isdraw ${shape}] || [regexp "${shape} is a \n" [whatis ${shape}]]} {
515 puts "Error: The command cannot be built"
523 set compared_equal_shape -1
524 set compared_notequal_shape -1
528 set options {{"-eps" epsilon 1}
529 {"-equal" compared_equal_shape 1}
530 {"-notequal" compared_notequal_shape 1}
533 if { [regexp {\-[not]*equal} $args] } {
534 lappend options {"-s" area 0}
535 lappend options {"-l" length 0}
536 lappend options {"-v" volume 0}
539 lappend options {"-s" area 1}
540 lappend options {"-l" length 1}
541 lappend options {"-v" volume 1}
543 _check_args ${args} ${options} "checkprops"
545 if { ${length} != -1 || ${equal_check} == 1 } {
546 set CommandName lprops
551 if { ${area} != -1 || ${equal_check} == 1 } {
552 set CommandName sprops
557 if { ${volume} != -1 || ${equal_check} == 1 } {
558 set CommandName vprops
566 set skip_option "-skip"
570 regexp {Mass +: +([-0-9.+eE]+)} [eval ${CommandName} ${shape} ${epsilon} $skip_option] full m
572 if { ${compared_equal_shape} != -1 } {
573 upvar ${compared_equal_shape} ${compared_equal_shape}
574 regexp {Mass +: +([-0-9.+eE]+)} [eval ${CommandName} ${compared_equal_shape} ${epsilon} $skip_option] full compared_m
575 if { $compared_m != $m } {
576 puts "Error: Shape ${compared_equal_shape} is not equal to shape ${shape}"
580 if { ${compared_notequal_shape} != -1 } {
581 upvar ${compared_notequal_shape} ${compared_notequal_shape}
582 regexp {Mass +: +([-0-9.+eE]+)} [eval ${CommandName} ${compared_notequal_shape} ${epsilon} $skip_option] full compared_m
583 if { $compared_m == $m } {
584 puts "Error: Shape ${compared_notequal_shape} is equal shape to ${shape}"
588 if { ${compared_equal_shape} == -1 && ${compared_notequal_shape} == -1 } {
589 if { [string compare "$mass" "empty"] != 0 } {
591 puts "Error : The command is not valid. The $prop is 0."
594 puts "The expected $prop is $mass"
596 #check of change of area is < 1%
597 if { ($mass != 0 && [expr 1.*abs($mass - $m)/$mass] > 0.01) || ($mass == 0 && $m != 0) } {
598 puts "Error : The $prop of result shape is $m"
602 puts "Error : The command is not valid. The $prop is $m"
609 Procedure includes command to parse output dump and compare it with reference values.
611 Use: checkdump shapename [options...]
613 -name NAME: list of parsing parameters (e.g. Center, Axis, etc)
614 -ref VALUE: list of reference values for each parameter in NAME
615 -eps EPSILON: the epsilon defines relative precision of computation
618 proc checkdump {shape args} {
619 puts "checkdump ${shape} ${args}"
620 upvar ${shape} ${shape}
624 set options {{"-name" params 1}
629 if { ${ddump} == -1 } {
630 set ddump [dump ${shape}]
632 _check_args ${args} ${options} "checkdump"
635 foreach param ${params} {
636 set pattern "${param}\\s*:\\s*"
637 set number_pattern "(\[-0-9.+eE\]+)\\s*"
640 if { [llength ${params}] > 1 } {
641 set local_ref [lindex ${ref} ${index}]
643 foreach item ${local_ref} {
644 if { ![regexp "$pattern$number_pattern" $ddump full res] } {
645 puts "Error: cheked parameter ${param} is not listed in dump"
648 lappend ref_values $res
649 set pattern "${pattern}${res},\\s*"
651 if { ${epsilon} == -1 } {
652 if { ${item} != ${res} } {
653 puts "Error: parameter ${param} - current value (${res}) is not equal to reference value (${item})"
655 puts "OK: parameter ${param} - current value (${res}) is equal to reference value (${item})"
659 set precision 0.0000001
660 if { ( abs($res) > $precision ) || ( abs($item) > $precision ) } {
661 if { ($item != 0 && [expr 1.*abs($item - $res)/$item] > $epsilon) || ($item == 0 && $res != 0) } {
662 puts "Error: The $param of the resulting shape is $res and the expected $param is $item"
664 puts "OK: parameter ${param} - current value (${res}) is equal to reference value (${item})"
674 Procedure includes commands to compute length of input curve.
676 Use: checklength curvename [options...]
678 -l LENGTH: command length, computes the length of input curve with precision of computation
679 -eps EPSILON: the epsilon defines relative precision of computation
680 -equal CURVE: compare length of input curves. Puts error if its are not equal
681 -notequal CURVE: compare length of input curves. Puts error if its are equal
684 proc checklength {shape args} {
685 puts "checklength ${shape} ${args}"
686 upvar ${shape} ${shape}
688 if {![isdraw ${shape}] || [regexp "${shape} is a \n" [whatis ${shape}]]} {
689 puts "Error: The command cannot be built"
695 set compared_equal_shape -1
696 set compared_notequal_shape -1
699 set options {{"-eps" epsilon 1}
700 {"-equal" compared_equal_shape 1}
701 {"-notequal" compared_notequal_shape 1}}
703 if { [regexp {\-[not]*equal} $args] } {
704 lappend options {"-l" length 0}
707 lappend options {"-l" length 1}
709 _check_args ${args} ${options} "checkprops"
711 if { ${length} != -1 || ${equal_check} == 1 } {
712 set CommandName length
718 regexp "The +length+ ${shape} +is +(\[-0-9.+eE\]+)" [${CommandName} ${shape} ${epsilon}] full m
720 if { ${compared_equal_shape} != -1 } {
721 upvar ${compared_equal_shape} ${compared_equal_shape}
722 regexp "The +length+ ${compared_equal_shape} +is +(\[-0-9.+eE\]+)" [${CommandName} ${compared_equal_shape} ${epsilon}] full compared_m
723 if { $compared_m != $m } {
724 puts "Error: length of shape ${compared_equal_shape} is not equal to shape ${shape}"
728 if { ${compared_notequal_shape} != -1 } {
729 upvar ${compared_notequal_shape} ${compared_notequal_shape}
730 regexp "The +length+ ${compared_notequal_shape} +is +(\[-0-9.+eE\]+)" [${CommandName} ${compared_notequal_shape} ${epsilon}] full compared_m
731 if { $compared_m == $m } {
732 puts "Error: length of shape ${compared_notequal_shape} is equal shape to ${shape}"
736 if { ${compared_equal_shape} == -1 && ${compared_notequal_shape} == -1 } {
737 if { [string compare "$mass" "empty"] != 0 } {
739 puts "Error : The command is not valid. The $prop is 0."
742 puts "The expected $prop is $mass"
744 #check of change of area is < 1%
745 if { ($mass != 0 && [expr 1.*abs($mass - $m)/$mass] > 0.01) || ($mass == 0 && $m != 0) } {
746 puts "Error : The $prop of result shape is $m"
750 puts "Error : The command is not valid. The $prop is $m"
757 Display shape in selected viewer.
759 Use: checkview [options...]
761 -display shapename: display shape with name 'shapename'
762 -3d: display shape in 3d viewer
763 -2d [ v2d / smallview ]: display shape in 2d viewer (default viewer is a 'smallview')
764 -path PATH: location of saved screenshot of viewer
765 -vdispmode N: it is possible to set vdispmode for 3d viewer (default value is 1)
766 -screenshot: procedure will try to make screenshot of already created viewer
767 Procedure can check some property of shape (length, area or volume) and compare it with some value N:
771 If current property is equal to value N, shape is marked as valid in procedure.
772 If value N is not given procedure will mark shape as valid if current property is non-zero.
773 -with {a b c}: display shapes 'a' 'b' 'c' together with 'shape' (if shape is valid)
774 -otherwise {d e f}: display shapes 'd' 'e' 'f' instead of 'shape' (if shape is NOT valid)
775 Note that one of two options -2d/-3d is required.
778 proc checkview {args} {
779 puts "checkview ${args}"
787 set check_length false
789 set check_volume false
793 set options {{"-3d" 3dviewer 0}
796 {"-path" PathToSave 1}
797 {"-vdispmode" dispmode 1}
798 {"-screenshot" isScreenshot 0}
799 {"-otherwise" otherwise 1}
801 {"-l" check_length ?}
803 {"-v" check_volume ?}}
806 _check_args ${args} ${options} "checkview"
808 if { ${PathToSave} == "" } {
809 set PathToSave "./photo.png"
812 if { ${3dviewer} == 0 && ${2dviewer} == false } {
813 error "Error: wrong using of command 'checkview', please use -2d or -3d option"
816 if { ${isScreenshot} } {
827 upvar ${shape} ${shape}
828 if {[isdraw ${shape}]} {
830 if { [string is boolean ${check_area}] } {
831 if { ${check_area} } {
832 regexp {Mass +: +([-0-9.+eE]+)} [sprops ${shape}] full mass
835 set mass ${check_area}
838 if { [string is boolean ${check_length}] } {
839 if { ${check_length} } {
840 regexp {Mass +: +([-0-9.+eE]+)} [lprops ${shape}] full mass
843 set mass ${check_length}
846 if { [string is boolean ${check_volume}] } {
847 if { ${check_volume} } {
848 regexp {Mass +: +([-0-9.+eE]+)} [vprops ${shape}] full mass
851 set mass ${check_volume}
859 } elseif { ([string is boolean ${2dviewer}] && ${2dviewer}) || ${2dviewer} == "smallview"} {
862 } elseif { ${2dviewer} == "v2d"} {
866 if {[isdraw ${shape}]} {
867 if { ( ${check_area} == false && ${check_length} == false && ${check_volume} == false ) || ( ${mass} != 0 ) } {
871 lappend with ${shape}
884 if { ${isBAD} && [llength ${otherwise}] } {
885 foreach s ${otherwise} {
889 vdisplay {*}${otherwise}
891 donly {*}${otherwise}
896 vsetdispmode ${dispmode}
900 if { ([string is boolean ${2dviewer}] && ${2dviewer}) || ${2dviewer} == "smallview"} {
902 } elseif { ${2dviewer} == "v2d"} {
911 Compare maximum deflection, number of nodes and triangles in "shape" mesh with given reference data
913 Use: checktrinfo shapename [options...]
915 -tri [N]: compare current number of triangles in "shapename" mesh with given reference data.
916 If reference value N is not given and current number of triangles is equal to 0
917 procedure checktrinfo will print an error.
918 -nod [N]: compare current number of nodes in "shapename" mesh with given reference data.
919 If reference value N is not givenand current number of nodes is equal to 0
920 procedure checktrinfo will print an error.
921 -defl [N]: compare current value of maximum deflection in "shapename" mesh with given reference data
922 If reference value N is not given and current maximum deflection is equal to 0
923 procedure checktrinfo will print an error.
924 -max_defl N: compare current value of maximum deflection in "shapename" mesh with max possible value
925 -tol_abs_tri N: absolute tolerance for comparison of number of triangles (default value 0)
926 -tol_rel_tri N: relative tolerance for comparison of number of triangles (default value 0)
927 -tol_abs_nod N: absolute tolerance for comparison of number of nodes (default value 0)
928 -tol_rel_nod N: relative tolerance for comparison of number of nodes (default value 0)
929 -tol_abs_defl N: absolute tolerance for deflection comparison (default value 0)
930 -tol_rel_defl N: relative tolerance for deflection comparison (default value 0)
931 -ref [trinfo a]: compare deflection, number of triangles and nodes in "shapename" and in "a"
933 proc checktrinfo {shape args} {
934 puts "checktrinfo ${shape} ${args}"
935 upvar ${shape} ${shape}
937 if {![isdraw ${shape}] || [regexp "${shape} is a \n" [whatis ${shape}]]} {
938 puts "Error: The command cannot be built"
942 set ref_nb_triangles false
943 set ref_nb_nodes false
944 set ref_deflection false
954 set options {{"-tri" ref_nb_triangles ?}
955 {"-nod" ref_nb_nodes ?}
956 {"-defl" ref_deflection ?}
957 {"-tol_abs_defl" tol_abs_defl 1}
958 {"-tol_rel_defl" tol_rel_defl 1}
959 {"-tol_abs_tri" tol_abs_tri 1}
960 {"-tol_rel_tri" tol_rel_tri 1}
961 {"-tol_abs_nod" tol_abs_nod 1}
962 {"-tol_rel_nod" tol_rel_nod 1}
963 {"-max_defl" max_defl 1}
966 _check_args ${args} ${options} "checktrinfo"
968 # get current number of triangles and nodes, value of max deflection
969 set tri_info [trinfo ${shape}]
970 set triinfo_pattern "(\[0-9\]+) +triangles.*\[^0-9]\(\[0-9\]+) +nodes.*deflection +(\[-0-9.+eE\]+)"
971 if {![regexp "${triinfo_pattern}" ${tri_info} dump cur_nb_triangles cur_nb_nodes cur_deflection]} {
972 puts "Error: command trinfo prints empty info"
975 # get reference values from -ref option
976 if { "${ref_info}" != ""} {
977 if {![regexp "${triinfo_pattern}" ${ref_info} dump ref_nb_triangles ref_nb_nodes ref_deflection]} {
978 puts "Error: reference information gived by -ref option is wrong"
982 # check number of triangles
983 if { [string is boolean ${ref_nb_triangles}] } {
984 if { ${cur_nb_triangles} <= 0 && ${ref_nb_triangles} } {
985 puts "Error: Number of triangles is equal to 0"
988 if {[regexp {!([-0-9.+eE]+)} $ref_nb_triangles full ref_nb_triangles_value]} {
989 if {${ref_nb_triangles_value} == ${cur_nb_triangles} } {
990 puts "Error: Number of triangles is equal to ${ref_nb_triangles_value} but it should not"
993 checkreal "Number of triangles" ${cur_nb_triangles} ${ref_nb_triangles} ${tol_abs_tri} ${tol_rel_tri}
997 # check number of nodes
998 if { [string is boolean ${ref_nb_nodes}] } {
999 if { ${cur_nb_nodes} <= 0 && ${ref_nb_nodes} } {
1000 puts "Error: Number of nodes is equal to 0"
1003 if {[regexp {!([-0-9.+eE]+)} $ref_nb_nodes full ref_nb_nodes_value]} {
1004 if {${ref_nb_nodes_value} == ${cur_nb_nodes} } {
1005 puts "Error: Number of nodes is equal to ${ref_nb_nodes_value} but it should not"
1008 checkreal "Number of nodes" ${cur_nb_nodes} ${ref_nb_nodes} ${tol_abs_nod} ${tol_rel_nod}
1013 if { [string is boolean ${ref_deflection}] } {
1014 if { ${cur_deflection} <= 0 && ${ref_deflection} } {
1015 puts "Error: Maximal deflection is equal to 0"
1018 checkreal "Maximal deflection" ${cur_deflection} ${ref_deflection} ${tol_abs_defl} ${tol_rel_defl}
1021 if { ${max_defl} != -1 && ${cur_deflection} > ${max_defl} } {
1022 puts "Error: Maximal deflection is too big"