Exemplo n.º 1
0
  public static void main(String[] args) {
    RectangularBox rb = new RectangularBox();

    System.out.println("Created: " + rb);

    Point3f p = new Point3f(95, 18f, 98);

    System.out.println("Moved: " + rb.getTranslatedRegion(new Vector3f(p)));
    System.out.println("Sphere around: " + RectangularBox.getEnclosingSphere(rb));

    SimpleCell cell = new SimpleCell("fff");
    Vector3f origLoc = new Vector3f(cell.getFirstSomaSegment().getStartPointPosition());
    origLoc.scale(-1);
    CellTopologyHelper.translateAllPositions(cell, origLoc);

    System.out.println("Cell: " + CellTopologyHelper.printShortDetails(cell));

    System.out.println("Is point: " + p + " in region: " + rb.isCellWithinRegion(p, cell, true));
  }
  protected Point3f generateNextPosition() throws CellPackingException {
    Point3f proposedPoint = null;

    logger.logComment(
        "----   Generating next position. positionsAlreadyTaken.size() = "
            + getNumPosAlreadyTaken());

    float minXLoc, minYLoc, minZLoc, maxXLoc, maxYLoc, maxZLoc;

    if (mustBeCompletelyInsideRegion()) {
      // limit the extent for possible location of soma centre to box which
      // will preclude soma wall impacting region boundary.

      minXLoc = myRegion.getLowestXValue() - CellTopologyHelper.getMinXExtent(myCell, true, false);
      minYLoc = myRegion.getLowestYValue() - CellTopologyHelper.getMinYExtent(myCell, true, false);
      minZLoc = myRegion.getLowestZValue() - CellTopologyHelper.getMinZExtent(myCell, true, false);

      maxXLoc = myRegion.getHighestXValue() - CellTopologyHelper.getMaxXExtent(myCell, true, false);
      maxYLoc = myRegion.getHighestYValue() - CellTopologyHelper.getMaxYExtent(myCell, true, false);
      maxZLoc = myRegion.getHighestZValue() - CellTopologyHelper.getMaxZExtent(myCell, true, false);
    } else {
      // in this case the soma centre can be anywhere inside the region..

      minXLoc = myRegion.getLowestXValue();
      minYLoc = myRegion.getLowestYValue();
      minZLoc = myRegion.getLowestZValue();

      maxXLoc = myRegion.getHighestXValue();
      maxYLoc = myRegion.getHighestYValue();
      maxZLoc = myRegion.getHighestZValue();
    }

    Point3f startPoint = new Point3f(minXLoc, minYLoc, minZLoc);

    logger.logComment("minXLoc: " + minXLoc + ", maxXLoc: " + maxXLoc);

    if (maxXLoc - minXLoc < 0 || maxYLoc - minYLoc < 0 || maxZLoc - minZLoc < 0) {
      throw new CellPackingException("Diameter of cell is smaller than region");
    }

    if (getNumPosAlreadyTaken() >= getNumberCells()) {
      throw new CellPackingException("All cells successfully placed");
    }

    if (getNumberCells() == 0) {
      throw new CellPackingException("Cell number set to zero!!");
    } else if (getNumberCells() == 1) {
      if (parameterList[DIMENSION_PARAM].value == DIMENSION_PARAM_X) {
        proposedPoint = new Point3f((minXLoc + maxXLoc) / 2, minYLoc, minZLoc);

      } else if (parameterList[DIMENSION_PARAM].value == DIMENSION_PARAM_Y) {
        proposedPoint = new Point3f(minXLoc, (minYLoc + maxYLoc) / 2, minZLoc);

      } else if (parameterList[DIMENSION_PARAM].value == DIMENSION_PARAM_Z) {

        proposedPoint = new Point3f(minXLoc, minYLoc, (minZLoc + maxZLoc) / 2);
      }

    } else {

      // Point3f lastPositionedPoint = getLastPosTaken();

      if (parameterList[DIMENSION_PARAM].value == DIMENSION_PARAM_X) {
        float distanceApart = (maxXLoc - minXLoc) / (getNumberCells() - 1);

        proposedPoint = new Point3f(startPoint);
        proposedPoint.add(new Point3f(distanceApart * numProposedPoints, 0, 0));

        logger.logComment(
            "Placing one of "
                + getNumberCells()
                + " cells in x dim..."
                + distanceApart
                + " apart, new: "
                + proposedPoint
                + ", already proposed: "
                + numProposedPoints);

        if (proposedPoint.x > maxXLoc) throw new CellPackingException("Reached end of x dimension");
      } else if (parameterList[DIMENSION_PARAM].value == DIMENSION_PARAM_Y) {
        logger.logComment("Placing cell in y dim...");
        float distanceApart = (maxYLoc - minYLoc) / (getNumberCells() - 1);
        proposedPoint = new Point3f(startPoint);
        proposedPoint.add(new Point3f(0, distanceApart * numProposedPoints, 0));

        if (proposedPoint.y > maxYLoc) throw new CellPackingException("Reached end of y dimension");
      } else if (parameterList[DIMENSION_PARAM].value == DIMENSION_PARAM_Z) {
        logger.logComment("Placing cell in z dim...");
        float distanceApart = (maxZLoc - minZLoc) / (getNumberCells() - 1);
        proposedPoint = new Point3f(startPoint);
        proposedPoint.add(new Point3f(0, 0, distanceApart * numProposedPoints));
        if (proposedPoint.z > maxZLoc) throw new CellPackingException("Reached end of z dimension");
      }

      if (proposedPoint == null) throw new CellPackingException("Cannot successfully place cell.");
    }
    // lastProposedPoint = new Point3d(proposedPoint);
    numProposedPoints++;

    return new Point3f(proposedPoint);
  }
Exemplo n.º 3
0
 public static void main(String[] args) {
   GolgiCell g = new GolgiCell("Test golgi");
   System.out.println(CellTopologyHelper.printDetails(g, null));
 }