File: begin

package info (click to toggle)
opencascade 7.9.2%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 301,924 kB
  • sloc: cpp: 1,523,264; tcl: 10,159; cs: 5,173; java: 1,554; sh: 1,342; ansic: 827; xml: 699; makefile: 30; javascript: 22
file content (105 lines) | stat: -rwxr-xr-x 3,248 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File : begin

if { [array get Draw_Groups "TOPOLOGY Check commands"] == "" } {
    pload TOPTEST
    pload VISUALIZATION
}

# to prevent loops limit to 16 minutes
cpulimit 1000

set rel_tol 0
set max_rel_tol_diff 0

if { [info exists imagedir] == 0 } {
   set imagedir .
}
if { [info exists test_image] == 0 } {
   set test_image photo
}

# Procedure to check equality of two reals with tolerance (relative and absolute)
help checkarea {shape area_expected tol_abs tol_rel}
proc checkarea {shape area_expected tol_abs tol_rel} {
    # compute area with half of the relative tolerance
    # to be used in comparison; 0.001 is added to avoid zero value
    set prop [uplevel sprops $shape [expr 0.5 * abs($tol_rel) + 0.001]]

    # get the value
    if { ! [regexp {Mass\s*:\s*([0-9.e+-]+)} $prop res area] } {
        puts "Error: cannot get area of the shape $shape"
        return
    }

    # compare with expected value
    checkreal "area of $shape" $area $area_expected $tol_abs $tol_rel
}

# Check if area of triangles is valid
proc CheckTriArea {shape {eps 0}} {
  upvar #0 $shape result
  set area [triarea result $eps]
  set t_area [lindex $area 0]
  set g_area [expr abs([lindex $area 1])]
  puts "area by triangles: $t_area"
  puts "area by geometry:  $g_area"
  expr ($t_area - $g_area) / $g_area * 100
}

# Check expected time
proc checktime {value expected tol_rel message} {
   set t1 [expr ${value} - ${expected}]
   set t2 [expr ${expected} * abs (${tol_rel})]

   if { abs (${t1}) <= ${t2} } {                                         
      puts "OK. ${message}, ${value} seconds, is equal to expected time - ${expected} seconds"
   } elseif {${t1} > ${t2}} {
      puts "Error. ${message}, ${value} seconds, is more than expected time - ${expected} seconds"
   } else {
      puts "Improvement. ${message}, ${value} seconds, is less than expected time - ${expected} seconds"
   }
}

# Reads resource file, returns options from file as key-value dict
proc parse_resource_file {theFileName} {
    # Creating empty dictionary
    set aDict [dict create];
    # Check for resource file
    if { [info exists theFileName] == 0 } {
       puts "Error: resource file \"${theFileName}\" isn't found"
       return $aDict
   }
   # Open a resource file
   set aFD [open "${theFileName}" "rb"]
   set aLineNo 0
   # Read line by line
   while {[gets $aFD aLine] !=-1 } {
       incr aLineNo
       # Clear the line from comment
       if {[regexp {(^[^!]+)} $aLine match aClearLine]} {
          # remove spaces
          set aClearLine [string trim $aClearLine]
          if {[string length $aClearLine] != 0} {
             if {[regexp {(\S+)\s*:\s*(\S*)} $aClearLine match aKey aValue]} {
                 dict set aDict $aKey $aValue
             } else {
                puts "Error: syntax error in resource file at line: ${aLineNo}"
             }
          }   
       }
   }
   close $aFD
   return $aDict
}

# Creates new resource file with options as key-value dict
proc create_resource_file {theFileName theOptions} {
   # Open a resource file
   set aFD [open "${theFileName}" "wb"]
   set aLineNo 0
   # Write line by line
   dict for {aKey aValue} $theOptions {
       puts $aFD "${aKey} : ${aValue}"
   }
   close $aFD
}