Example #1
0
def tile_jobs(Jobs):
  """Take a list of raw Job objects and find best tiling by calling tile_search"""

  # We must take the raw jobs and construct a list of 4-tuples (Xdim,Ydim,job,rjob).
  # This means we must construct a rotated job for each entry. We first sort all
  # jobs from largest to smallest. This should give us the best tilings first so
  # we can interrupt the tiling process and get a decent layout.
  L = []
  #sortJobs = schwartz.schwartz(Jobs, jobs.Job.jobarea)
  sortJobs = schwartz.schwartz(Jobs, jobs.Job.maxdimension)
  sortJobs.reverse()

  for job in sortJobs:
    Xdim = job.width_in()
    Ydim = job.height_in()
    rjob = jobs.rotateJob(job, 90)  ##NOTE: This will only try 90 degree rotations though 180 & 270 are available

    for count in range(job.Repeat):
      L.append( (Xdim,Ydim,job,rjob) )

  PX,PY = config.Config['panelwidth'],config.Config['panelheight']
  if config.AutoSearchType==RANDOM_SEARCH:
    tile = tilesearch2.tile_search2(L, PX, PY)
  else:
    tile = tilesearch1.tile_search1(L, PX, PY)

  if not tile:
    # add metric support (1/1000 mm vs. 1/100,000 inch)
    if config.Config['measurementunits'] == 'inch':
      raise RuntimeError, 'Panel size %.2f"x%.2f" is too small to hold jobs' % (PX,PY)
    else:
      raise RuntimeError, 'Panel size %.2fmmx%.2fmm is too small to hold jobs' % (PX,PY)

  return tile
Example #2
0
def tile_jobs(Jobs):
  """Take a list of raw Job objects and find best tiling by calling tile_search"""

  # We must take the raw jobs and construct a list of 4-tuples (Xdim,Ydim,job,rjob).
  # This means we must construct a rotated job for each entry. We first sort all
  # jobs from largest to smallest. This should give us the best tilings first so
  # we can interrupt the tiling process and get a decent layout.
  L = []
  #sortJobs = schwartz.schwartz(Jobs, jobs.Job.jobarea)
  sortJobs = schwartz.schwartz(Jobs, jobs.Job.maxdimension)
  sortJobs.reverse()

  for job in sortJobs:
    Xdim = job.width_in()
    Ydim = job.height_in()
    rjob = jobs.rotateJob(job, 90)  ##NOTE: This will only try 90 degree rotations though 180 & 270 are available

    for count in range(job.Repeat):
      L.append( (Xdim,Ydim,job,rjob) )

  PX,PY = config.Config['panelwidth'],config.Config['panelheight']
  if config.AutoSearchType==RANDOM_SEARCH:
    tile = tilesearch2.tile_search2(L, PX, PY)
  else:
    tile = tilesearch1.tile_search1(L, PX, PY)

  if not tile:
    # add metric support (1/1000 mm vs. 1/100,000 inch)
    if config.Config['measurementunits'] == 'inch':
      raise RuntimeError, 'Panel size %.2f"x%.2f" is too small to hold jobs' % (PX,PY)
    else:
      raise RuntimeError, 'Panel size %.2fmmx%.2fmm is too small to hold jobs' % (PX,PY)

  return tile
Example #3
0
def tile_jobs(Jobs):
    """Take a list of raw Job objects and find best tiling by calling tile_search"""

    # We must take the raw jobs and construct a list of 4-tuples (Xdim,Ydim,job,rjob).
    # This means we must construct a rotated job for each entry. We first sort all
    # jobs from largest to smallest. This should give us the best tilings first so
    # we can interrupt the tiling process and get a decent layout.
    L = []
    sortJobs = schwartz.schwartz(Jobs, jobs.Job.maxdimension)
    sortJobs.reverse()

    for job in sortJobs:
        Xdim = job.width_in()
        Ydim = job.height_in()
        rjob = jobs.rotateJob(job, 90)  # NOTE: This will only try 90 degree rotations though 180 & 270 are available

        for count in range(job.Repeat):
            L.append((Xdim, Ydim, job, rjob))

    PX, PY = config.Config['panelwidth'], config.Config['panelheight']
    if config.AutoSearchType == RANDOM_SEARCH:
        tile = tile_search_random(L, PX, PY, config.Config['xspacing'], config.Config['yspacing'], config.SearchTimeout, config.RandomSearchExhaustiveJobs)
    else:
        tile = tile_search_exhaustive(L, PX, PY, config.Config['xspacing'], config.Config['yspacing'], config.SearchTimeout)

    if not tile:
        raise RuntimeError('Panel size {:.2f}"x{:.2f}" is too small to hold jobs'.format(PX, PY))

    return tile
Example #4
0
def findJob(jobname, rotated, Jobs=config.Jobs):
    """
    Find a job in config.Jobs, possibly rotating it
    If job not in config.Jobs add it for future reference
    Return found job
  """

    if rotated == 90:
        fullname = jobname + '*rotated90'
    elif rotated == 180:
        fullname = jobname + '*rotated180'
    elif rotated == 270:
        fullname = jobname + '*rotated270'
    else:
        fullname = jobname

    try:
        for existingjob in Jobs.keys():
            if existingjob.lower() == fullname.lower(
            ):  ## job names are case insensitive
                job = Jobs[existingjob]
                return jobs.JobLayout(job)
    except:
        pass

    # Perhaps we just don't have a rotated job yet
    if rotated:
        try:
            for existingjob in Jobs.keys():
                if existingjob.lower() == jobname.lower(
                ):  ## job names are case insensitive
                    job = Jobs[existingjob]
        except:
            raise RuntimeError, "Job name '%s' not found" % jobname
    else:
        raise RuntimeError, "Job name '%s' not found" % jobname

    # Make a rotated job
    job = jobs.rotateJob(job, rotated)
    Jobs[fullname] = job

    return jobs.JobLayout(job)
Example #5
0
def findJob(jobname, rotated, Jobs=config.Jobs):
  """
    Find a job in config.Jobs, possibly rotating it
    If job not in config.Jobs add it for future reference
    Return found job
  """
                                                                                    
  if rotated == 90:
    fullname = jobname + '*rotated90'
  elif rotated == 180:
    fullname = jobname + '*rotated180'
  elif rotated == 270:
    fullname = jobname + '*rotated270'
  else:
    fullname = jobname
                         
  try:
    for existingjob in Jobs.keys():
      if existingjob.lower() == fullname.lower(): ## job names are case insensitive
        job = Jobs[existingjob]                 
        return jobs.JobLayout(job)
  except:
    pass

  # Perhaps we just don't have a rotated job yet
  if rotated:
    try:      
      for existingjob in Jobs.keys():
        if existingjob.lower() == jobname.lower(): ## job names are case insensitive
          job = Jobs[existingjob]
    except:
      raise RuntimeError, "Job name '%s' not found" % jobname
  else:
    raise RuntimeError, "Job name '%s' not found" % jobname

  # Make a rotated job
  job = jobs.rotateJob(job, rotated)
  Jobs[fullname] = job

  return jobs.JobLayout(job)