puts "========="
puts "CR24472"
puts "========="
puts ""
###############################
## Wrong section curves
###############################

puts "TODO OCC29501 ALL: Error in ii12_22"

set MaxToler 1.5e-4

restore [locate_data_file bug24472_Pipe_1.brep] b1

explode b1 f
copy b1_2 f1
copy b1_3 f2
copy b1_6 f3
mksurface s1 f1
mksurface s2 f2
mksurface s3 f3

puts ""
puts "First test"
# 1.1 geometry
intersect ii12 s1 s2

foreach c [directory ii12*] {
  bounds $c U1 U2
  
  if {[dval U2-U1] < 1.0e-9} {
    puts "Error: Wrong curve's range!"
  }
  
  # cos(~75.5deg)
  CheckLoops $c 0.25
  
  xdistcs $c s1 U1 U2 10 $MaxToler
  xdistcs $c s2 U1 U2 10 $MaxToler
}

puts ""
puts "Second test"
# 1.2 topology
bsection r12 f1 f2
bopcheck r12
# OK

regexp {Tolerance MAX=([-0-9.+eE]+)} [tolerance r12] full toler
if { $toler > $MaxToler } { puts "Error: Tolerance of the section r12 is too large" }

puts ""
puts "Third test"
# 2.1 geometry
intersect ii13 s1 s3

foreach c [directory ii13*] {
  bounds $c U1 U2
  
  if {[dval U2-U1] < 1.0e-9} {
    puts "Error: Wrong curve's range!"
  }
  
  # cos(~75.5deg)
  CheckLoops $c 0.25

  xdistcs $c s1 U1 U2 10 $MaxToler
  xdistcs $c s2 U1 U2 10 $MaxToler
}

puts ""
puts "Fourth test"
# 2.2 topology
bsection r13 f1 f3
bopcheck r13
# OK

regexp {Tolerance MAX=([-0-9.+eE]+)} [tolerance r13] full toler
if { $toler > $MaxToler } { puts "Error: Tolerance of the section r13 is too large" }
