Package org.openpixi.pixi.physics.util

Examples of org.openpixi.pixi.physics.util.IntBox


  /**
   * In this mode the iterator does also calculate the extra cells.
   */
  public void setExtraCellsMode(int numCellsX, int numCellsY) {
    dimensions = new IntBox(
        -Grid.EXTRA_CELLS_BEFORE_GRID,
        numCellsX + Grid.EXTRA_CELLS_AFTER_GRID - 1,
        -Grid.EXTRA_CELLS_BEFORE_GRID,
        numCellsY + Grid.EXTRA_CELLS_AFTER_GRID - 1);
  }
View Full Code Here


      throw new RuntimeException(
          "Number of partitions must be less or equal to the number of cells!");
    }

    List<IntBox> partitions = new ArrayList<IntBox>();
    partitions.add(new IntBox(0, numCellsX - 1, 0, numCellsY - 1));

    while (partitions.size() < numPartitions) {
      partitions = splitBoxes(partitions);
    }
View Full Code Here

  private Point getNeighborDirection(int neighbor) {
    if (neighbor == NO_NEIGHBOR) {
      return null;
    }

    IntBox myPart = partitions[thisWorkerID];
    IntBox neighborPart = partitions[neighbor];

    int xdirec = 0;
    int ydirec = 0;

    if (myPart.xmax() < neighborPart.xmin()) {
      xdirec = +1;
    }
    else if (neighborPart.xmax() < myPart.xmin()) {
      xdirec = -1;
    }

    if (myPart.ymax() < neighborPart.ymin()) {
      ydirec = +1;
    }
    else if (neighborPart.ymax() < myPart.ymin()) {
      ydirec = -1;
    }

    return new Point(xdirec, ydirec);
  }
View Full Code Here

    List<IntBox> newPartitions = new ArrayList<IntBox>();
    for (IntBox b: partitions) {
      if (b.xsize() > b.ysize()) {
        // Split along x axis
        int xmid = (b.xmin() + b.xsize() / 2);
        newPartitions.add(new IntBox(b.xmin(), xmid - 1, b.ymin(), b.ymax()));
        newPartitions.add(new IntBox(xmid, b.xmax(), b.ymin(), b.ymax()));
      }
      else {
        // Split along y axis
        int ymid = (b.ymin() + b.ysize() / 2);
        newPartitions.add(new IntBox(b.xmin(), b.xmax(), b.ymin(), ymid - 1));
        newPartitions.add(new IntBox(b.xmin(), b.xmax(), ymid, b.ymax()));
      }
    }
    return newPartitions;
  }
View Full Code Here


  @Override
  public String toString() {
    StringBuilder retval = new StringBuilder();
    IntBox first = findFirst();
    IntBox nextY = first;
    while (nextY != null) {
      IntBox nextX = nextY;
      while (nextX != null) {
        int index = getIndex(nextX);
        retval.append(index + " ");
        nextX = findNextX(nextX);
      }
View Full Code Here

    int smallestXmin = Integer.MAX_VALUE;
    int largestYmax = Integer.MIN_VALUE;
    int smallestYmin = Integer.MAX_VALUE;

    for (int i = 0; i < partitions.length; ++i) {
      IntBox b = partitions[i];

      if (isMalformed(b)) {
        Assert.fail("Malformed partition! " + b);
      }

      if (b.xmax() > largestXmax) {
        largestXmax = b.xmax();
      }
      if (b.ymax() > largestYmax) {
        largestYmax = b.ymax();
      }
      if (b.xmin() < smallestXmin) {
        smallestXmin = b.xmin();
      }
      if (b.ymin() < smallestYmin) {
        smallestYmin = b.ymin();
      }

      for (int j = i + 1; j < partitions.length; ++j) {
        IntBox b2 = partitions[j];
        if (areEqual(b, b2)) {
          Assert.fail("Equal partitions: " + b + " " + b2);
        }
        if (interleave(b, b2)) {
          Assert.fail("Interleaving partitions: " + b + " " + b2);
View Full Code Here

TOP

Related Classes of org.openpixi.pixi.physics.util.IntBox

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.