<commit_before>/*
 * Copyright (C) 20011-2014 Scalable minds UG (haftungsbeschränkt) & Co. KG. <http://scm.io>
 */
package com.scalableminds.util.geometry

import net.liftweb.common.{Box, Empty, Full}

case class BoundingBox(topLeft: Point3D, width: Int, height: Int, depth: Int) {

  val bottomRight = topLeft.move(width, height, depth)

  def contains(p: Point3D): Boolean = {
    p.x >= topLeft.x && p.y >= topLeft.y && p.z >= topLeft.z &&
      p.x <= bottomRight.x && p.y <= bottomRight.y && p.z <= bottomRight.z
  }

  def intersects(other: BoundingBox): Boolean =
    topLeft.x < other.bottomRight.x && other.topLeft.x < bottomRight.x &&
      topLeft.y < other.bottomRight.y && other.topLeft.y < bottomRight.y &&
      topLeft.z < other.bottomRight.z && other.topLeft.z < bottomRight.z

  def combineWith(other: BoundingBox): BoundingBox = {
    val x = math.min(other.topLeft.x, topLeft.x)
    val y = math.min(other.topLeft.y, topLeft.y)
    val z = math.min(other.topLeft.z, topLeft.z)

    val w = math.max(other.width, width)
    val h = math.max(other.height, height)
    val d = math.max(other.depth, depth)

    BoundingBox(Point3D(x, y, z), w, h, d)
  }

  def isEmpty: Boolean =
    width <= 0 || height <= 0 || depth <= 0

  def center: Point3D =
    topLeft.move(bottomRight).scale(0.5f)
}

object BoundingBox {

  import play.api.libs.json._

  val formRx = "\\s*([0-9]+),\\s*([0-9]+),\\s*([0-9]+)\\s*,\\s*([0-9]+),\\s*([0-9]+),\\s*([0-9]+)\\s*".r

  def toForm(b: BoundingBox): Some[String] =
    Some("%d, %d, %d, %d, %d, %d".format(
                                          b.topLeft.x,<commit_msg>scaling of bounding box check<commit_after>/*
 * Copyright (C) 20011-2014 Scalable minds UG (haftungsbeschränkt) & Co. KG. <http://scm.io>
 */
package com.scalableminds.util.geometry

import net.liftweb.common.{Box, Empty, Full}

case class BoundingBox(topLeft: Point3D, width: Int, height: Int, depth: Int) {

  val bottomRight = topLeft.move(width, height, depth)

  def contains(p: Point3D): Boolean = {
    p.x >= topLeft.x && p.y >= topLeft.y && p.z >= topLeft.z &&
      p.x <= bottomRight.x && p.y <= bottomRight.y && p.z <= bottomRight.z
  }

  def intersects(other: BoundingBox): Boolean =
    topLeft.x < other.bottomRight.x && other.topLeft.x < bottomRight.x &&
      topLeft.y < other.bottomRight.y && other.topLeft.y < bottomRight.y &&
      topLeft.z < other.bottomRight.z && other.topLeft.z < bottomRight.z

  def combineWith(other: BoundingBox): BoundingBox = {
    val x = math.min(other.topLeft.x, topLeft.x)
    val y = math.min(other.topLeft.y, topLeft.y)
    val z = math.min(other.topLeft.z, topLeft.z)

    val w = math.max(other.width, width)
    val h = math.max(other.height, height)
    val d = math.max(other.depth, depth)

    BoundingBox(Point3D(x, y, z), w, h, d)
  }

  def isEmpty: Boolean =
    width <= 0 || height <= 0 || depth <= 0

  def center: Point3D =
    topLeft.move(bottomRight).scale(0.5f)

  def scale(s: Float) =
    BoundingBox(topLeft.scale(s), (width * s).toInt, (height * s).toInt, (depth * s).toInt)
}

object BoundingBox {

  import play.api.libs.json._

  val formRx = "\\s*([0-9]+),\\s*([0-9]+),\\s*([0-9]+)\\s*,\\s*([0-9]+),\\s*([0-9]+),\\s*([0-9]+)\\s*".r

  def toForm(b: BoundingBox): Some[String] =
    Some("%d, %d, %d, %d, %d, %d".format(
                                          b.topLeft.x,
{'fraction_non_alphanumeric': 0.18940514945250073, 'fraction_numerical': 0.017756732761171946, 'mean_word_length': 2.876146788990826, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3834585', 'n_tokens_mistral': 1362, 'n_tokens_neox': 1281, 'n_words': 271}