puts "Check History of Boolean operations"

puts "Case with overlapping planar faces"

plane p 0 0 0 0 0 1
mkface f1 p -10 10 -10 10
mkface f2 p 0 20 -10 10

bclearobjects
bcleartools
baddobjects f1
baddtools f2
bfillds

puts "Common operation"
bbop rcom 0

# get history of the operation
savehistory com_hist

# check that both f1 and f2 have not been deleted
if {[string trim [isdeleted com_hist f1]] != "Not deleted."} {
  puts "Error: Incorrect information about Deleted shapes"
}

if {[string trim [isdeleted com_hist f2]] != "Not deleted."} {
  puts "Error: Incorrect information about Deleted shapes"
}

# check that both f1 and f2 have been Modified into the same face
modified rm1 com_hist f1
checknbshapes rm1 -face 1 -m "Information about modification of f1"

modified rm2 com_hist f2
checknbshapes rm2 -face 1 -m "Information about modification of f2"

compound rm1 rm2 cm
checknbshapes cm -face 1 -m "Information about modification of f1 and f2"


# check that none of the f1 and f2 have Generated shapes
if {[string trim [generated rg com_hist f1]] != "No shapes were generated from the shape."} {
  puts "Error: Incorrect information about Generated shapes"
}

if {[string trim [generated rg com_hist f2]] != "No shapes were generated from the shape."} {
  puts "Error: Incorrect information about Generated shapes"
}


puts "Fuse operation"
bbop rfuse 1

# get history of the operation
savehistory fuse_hist

# check that both f1 and f2 have not been deleted
if {[string trim [isdeleted fuse_hist f1]] != "Not deleted."} {
  puts "Error: Incorrect information about Deleted shapes"
}

if {[string trim [isdeleted fuse_hist f2]] != "Not deleted."} {
  puts "Error: Incorrect information about Deleted shapes"
}

# check that both f1 and f2 have been Modified
modified rm fuse_hist f1
checknbshapes rm -face 2 -m "Information about modification of f1"

modified rm fuse_hist f2
checknbshapes rm -face 2 -m "Information about modification of f2"

# check that none of the f1 and f2 have Generated shapes
if {[string trim [generated rg fuse_hist f1]] != "No shapes were generated from the shape."} {
  puts "Error: Incorrect information about Generated shapes"
}

if {[string trim [generated rg fuse_hist f2]] != "No shapes were generated from the shape."} {
  puts "Error: Incorrect information about Generated shapes"
}


puts "CUT operation"
bbop rcut 2

# get history of the operation
savehistory cut_hist

# check that f1 has not been deleted
if {[string trim [isdeleted cut_hist f1]] != "Not deleted."} {
  puts "Error: Incorrect information about Deleted shapes"
}

# check that f2 has been deleted
if {[string trim [isdeleted cut_hist f2]] != "Deleted."} {
  puts "Error: Incorrect information about Deleted shapes"
}

# check that f1 has been modified
modified rm cut_hist f1
checknbshapes rm -face 1 -m "Information about modification of f1"

# check that f2 has not been modified
if {[string trim [modified rm cut_hist f2]] != "The shape has not been modified."} {
  puts "Error: Incorrect information about Modified shapes"
}

# check that none of the f1 and f2 have Generated shapes
if {[string trim [generated rg cut_hist f1]] != "No shapes were generated from the shape."} {
  puts "Error: Incorrect information about Generated shapes"
}

if {[string trim [generated rg cut_hist f2]] != "No shapes were generated from the shape."} {
  puts "Error: Incorrect information about Generated shapes"
}


puts "TUC operation"
bbop rtuc 3

# get history of the operation
savehistory tuc_hist

# check that f1 has been deleted
if {[string trim [isdeleted tuc_hist f1]] != "Deleted."} {
  puts "Error: Incorrect information about Deleted shapes"
}

# check that f2 has not been deleted
if {[string trim [isdeleted tuc_hist f2]] != "Not deleted."} {
  puts "Error: Incorrect information about Deleted shapes"
}

# check that f1 has not been modified
if {[string trim [modified rm tuc_hist f1]] != "The shape has not been modified."} {
  puts "Error: Incorrect information about Modified shapes"
}

# check that f2 has been modified
modified rm tuc_hist f2
checknbshapes rm -face 1 -m "Information about modification of f1"

# check that none of the f1 and f2 have Generated shapes
if {[string trim [generated rg tuc_hist f1]] != "No shapes were generated from the shape."} {
  puts "Error: Incorrect information about Generated shapes"
}

if {[string trim [generated rg tuc_hist f2]] != "No shapes were generated from the shape."} {
  puts "Error: Incorrect information about Generated shapes"
}



puts "SECTION operation"
bbop rsec 4

# get history of the operation
savehistory sec_hist

# check that both f1 and f2 have been deleted
if {[string trim [isdeleted sec_hist f1]] != "Deleted."} {
  puts "Error: Incorrect information about Deleted shapes"
}

if {[string trim [isdeleted sec_hist f2]] != "Deleted."} {
  puts "Error: Incorrect information about Deleted shapes"
}

# check that none of the f1 and f2 have been Modified 
if {[string trim [modified rm sec_hist f1]] != "The shape has not been modified."} {
  puts "Error: Incorrect information about Modified shapes"
}

if {[string trim [modified rm sec_hist f2]] != "The shape has not been modified."} {
  puts "Error: Incorrect information about Modified shapes"
}

# check that none of the f1 and f2 have Generated shapes
if {[string trim [generated rg sec_hist f1]] != "No shapes were generated from the shape."} {
  puts "Error: Incorrect information about Generated shapes"
}

if {[string trim [generated rg sec_hist f2]] != "No shapes were generated from the shape."} {
  puts "Error: Incorrect information about Generated shapes"
}
