#! /usr/bin/python3
# Last edited on 2021-10-03 17:50:45 by stolfi

import contact_hp
import contact
import contact_example
import path
import block
import block_example
import move
import move_parms
import hacks
import job_parms

import sys

parms = job_parms.typical_js()
parms['solid_raster_width'] = 1.00
parms['contour_trace_width'] = 0.50

mp_jump = move_parms.make_for_jumps(parms)
mp_cont = move_parms.make_for_contours(parms)
mp_fill = move_parms.make_for_fillings(parms)

wdf = move_parms.width(mp_fill)
wdc = move_parms.width(mp_cont)

def test_heuristic_fields():
  sys.stderr.write("--- testing {side_block,set_side_block} ---\n")

  BCS, OPHS, TRS, JMS = block_example.misc_B(mp_fill, mp_jump)
  block.show_list(sys.stderr, BCS, True, 2)
  path.show_list(sys.stderr, OPHS, True, 2)
  move.show_list(sys.stderr, TRS, 2)
  
  # CTS, OPHS, TRS = contact_example.misc_B(mp_fill, mp_jump)
  
  Pd = OPHS[3]; assert path.get_name(Pd) == "Pd"
  Pe = OPHS[4]; assert path.get_name(Pe) == "Pe"
  
  szmin = 0.1
  rszmin = 0.02
  tclim = 17.0
  CTS = contact.from_paths(Pd,Pe, szmin, rszmin, tclim)
  assert CTS != None and len(CTS) == 2
  contact.show_list(sys.stderr, CTS, 2)
  
  ct = CTS[0]
  
  # The {Move} objects that are sides of the contact:
  mv0 = TRS[7]; assert move.get_name(mv0) == "Td0"
  mv1 = TRS[9]; assert move.get_name(mv1) == "Te0"
  
  assert contact.side_move(ct, 0) == mv0
  assert contact.side_move(ct, 1) == mv1
  
  # Some paths that contain the sides of the contact:
  assert path.find_move(Pd, mv0) == 0
  assert path.find_move(Pe, mv1) == 0

  return
  # ----------------------------------------------------------------------

test_heuristic_fields()
