puts "================"
puts "OCC26525"
puts "================"
puts ""
#######################################################################
# Wrong result obtained by curve / surface intersection algorithm.
#######################################################################

pload QAcommands

restore [locate_data_file bug26525_a.brep] b1
restore [locate_data_file bug26525_b.brep] b2

mksurface sb1 b1
trimv sb1t sb1 -30000 30000
mkface b1t sb1t

explode b2 e

# Case 1. The curve is from the edge b2_3 
# 1.1 The face b1 is based on untrimmed surface

set log [OCC26525 p b2_3 b1]

regexp {([-0-9]+)} $log full Number

if { $Number == 2} {
   set tol_abs 0.0001
   set tol_rel 0.01

   regexp {point p_1 +([-0-9.+eE]+) +([-0-9.+eE]+) +([-0-9.+eE]+)} $log full x1 y1 z1

   set expected_x1 48.4205
   set expected_y1 -22.5336
   set expected_z1 82.7431

   checkreal "x1" ${x1} ${expected_x1} ${tol_abs} ${tol_rel}
   checkreal "y1" ${y1} ${expected_y1} ${tol_abs} ${tol_rel}
   checkreal "z1" ${z1} ${expected_z1} ${tol_abs} ${tol_rel}

   regexp {point p_2 +([-0-9.+eE]+) +([-0-9.+eE]+) +([-0-9.+eE]+)} $log full x2 y2 z2

   set expected_x2 32.5621
   set expected_y2 -5.89907
   set expected_z2 82.7431

   checkreal "x2" ${x2} ${expected_x2} ${tol_abs} ${tol_rel}
   checkreal "y2" ${y2} ${expected_y2} ${tol_abs} ${tol_rel}
   checkreal "z2" ${z2} ${expected_z2} ${tol_abs} ${tol_rel}
} else {
   puts "Error: Bad Number of intersection points"
}
