Esempio n. 1
0
  @Override
  public void updateComponents() {
    // TODO Write recursive validation method and call it here.
    // Then take out the error checking in all the other methods.
    components = new ArrayList<ComponentInterface>();

    if (borePoint != null && !borePoint.isEmpty()) {
      SortedPositionList<BorePoint> borePointList = makePositionList(borePoint);
      // Add the mouthpiece reference position to the map.
      // I don't believe the optimization routines should care that this
      // offset
      // is not subtracted, since the calculations are performed on the
      // components, which are offset agnostic.
      // borePointMap.put(mouthpieceOrigin.getBorePosition(),

      processMouthpiece(borePointList);
      components.add(mouthpiece);

      processTermination(borePointList);

      SortedPositionList<Hole> holeList = makePositionList(hole);

      // TODO Deal with the Mouthpiece and the start of the bore:

      // Process the holes, making sections as needed to include the hole
      // on the right
      if (holeList.size() > 0) {
        for (Hole currentHole : holeList) {
          double rightPosition = currentHole.getBorePosition();
          makeSections(borePointList, rightPosition);
          processPosition(borePointList, currentHole);

          components.add(currentHole);
        }
      }

      // Process the rest of the sections. There must be at least one
      double lastPosition = borePointList.getLast().getBorePosition() + 1.;
      makeSections(borePointList, lastPosition);
    }
  }