puts "============"
puts "OCC9490"
puts "============"
puts ""
#######################################################################
# Increasing of tolerance in loop test for IGES
#######################################################################

set BugNumber OCC9490

set IsOk 1
set filepath [locate_data_file support_bobine.igs]
if {[catch {igesread $filepath OCC9490a *}]} {
   puts "Faulty ${BugNumber} : here is reading problem"
   set IsOk 0
}

file delete ${imagedir}/OCC9490tmp.igs

if {[catch {brepiges OCC9490a ${imagedir}/OCC9490tmp.igs}]} {
    puts "Faulty ${BugNumber} : here is conversation to brep problem"
    set IsOk 0
}
catch {exec chmod 777 ${imagedir}/OCC9490tmp.igs}

if {[catch {igesread ${imagedir}/OCC9490tmp.igs OCC9490b *}]} {
   puts "Faulty ${BugNumber} : here is 2nd reading problem"
   set IsOk 0
}

if { ${IsOk} == 1} {
   set aTokList {= }
   set Tol1 [lindex [split [tolerance OCC9490a] ${aTokList}] 2]
   set Tol2 [lindex [split [tolerance OCC9490b] ${aTokList}] 2]
   set percent_max 0.1
   set Tolerance_percent [GetPercent ${Tol1} ${Tol2}]
   puts "Tolerance_percent = ${Tolerance_percent} %"
   if { ${Tolerance_percent}  > ${percent_max} } {
      set IsOk 0
   }

   set good_square 36259
   set good_vertex 1770
   set good_edge 1237
   set good_wire 140
   set good_face 123
   set good_shell 0
   set good_solid 0
   set good_compsolid 0
   set good_compound 1
   set good_shape 3271

   set nb_info [nbshapes OCC9490a]
   regexp {Mass +: +([-0-9.+eE]+)} [sprops OCC9490a] full sq1
   regexp {VERTEX +: +([-0-9.+eE]+)} $nb_info full nb_v1
   regexp {EDGE +: +([-0-9.+eE]+)} $nb_info full nb_e1
   regexp {WIRE +: +([-0-9.+eE]+)} $nb_info full nb_w1
   regexp {FACE +: +([-0-9.+eE]+)} $nb_info full nb_f1
   regexp {SHELL +: +([-0-9.+eE]+)} $nb_info full nb_sh1
   regexp {SOLID +: +([-0-9.+eE]+)} $nb_info full nb_sol1
   regexp {COMPSOLID +: +([-0-9.+eE]+)} $nb_info full nb_compsol1
   regexp {COMPOUND +: +([-0-9.+eE]+)} $nb_info full nb_compound1
   regexp {SHAPE +: +([-0-9.+eE]+)} $nb_info full nb_shape1
   if {$sq1 != $good_square
      || $nb_v1 != $good_vertex
      || $nb_e1 != $good_edge
      || $nb_w1 != $good_wire
      || $nb_f1 != $good_face
      || $nb_sh1 != $good_shell
      || $nb_sol1 != $good_solid
      || $nb_compsol1 != $good_compsolid
      || $nb_compound1 != $good_compound
      || $nb_shape1 != $good_shape } {
      	 set IsOk 0
   }	

   set nb_info [nbshapes OCC9490b]
   regexp {Mass +: +([-0-9.+eE]+)} [sprops OCC9490b] full sq2
   regexp {VERTEX +: +([-0-9.+eE]+)} $nb_info full nb_v2
   regexp {EDGE +: +([-0-9.+eE]+)} $nb_info full nb_e2
   regexp {WIRE +: +([-0-9.+eE]+)} $nb_info full nb_w2
   regexp {FACE +: +([-0-9.+eE]+)} $nb_info full nb_f2
   regexp {SHELL +: +([-0-9.+eE]+)} $nb_info full nb_sh2
   regexp {SOLID +: +([-0-9.+eE]+)} $nb_info full nb_sol2
   regexp {COMPSOLID +: +([-0-9.+eE]+)} $nb_info full nb_compsol2
   regexp {COMPOUND +: +([-0-9.+eE]+)} $nb_info full nb_compound2
   regexp {SHAPE +: +([-0-9.+eE]+)} $nb_info full nb_shape2
   if {$sq2 != $good_square
      || $nb_v2 != $good_vertex
      || $nb_e2 != $good_edge
      || $nb_w2 != $good_wire
      || $nb_f2 != $good_face
      || $nb_sh2 != $good_shell
      || $nb_sol2 != $good_solid
      || $nb_compsol2 != $good_compsolid
      || $nb_compound2 != $good_compound
      || $nb_shape2 != $good_shape } {
      	 set IsOk 0
   }	

   if { ${IsOk}  == 0 } {
      puts "${BugNumber}: Faulty"
   } else {
      puts "${BugNumber}: OK"
   }
}

renamevar OCC9490b result
set 2dviewer 0
