protected void processMouthpiece(SortedPositionList<BorePoint> borePointList) { double mouthpiecePosition = mouthpiece.getBorePosition(); // Make the bore sections above mouthpiece makeSections(borePointList, mouthpiecePosition); // Make bore section that ends with mouthpiece // Set mouthpiece boreDiameter processPosition(borePointList, mouthpiece); List<BoreSection> headspace = new ArrayList<BoreSection>(); for (Iterator<ComponentInterface> it = components.iterator(); it.hasNext(); ) { ComponentInterface component = it.next(); if (component instanceof BoreSection) { BoreSection section = (BoreSection) component; if (section.getRightBorePosition() <= mouthpiecePosition) { headspace.add((BoreSection) component); it.remove(); } } } mouthpiece.setHeadspace(headspace); // Move the first borepoint to top of TSH // BorePoint firstPoint = borePointList.getFirst(); // double newPosition = firstPoint.getBorePosition() - // mouthpiece.getFipple().getWindowLength(); // firstPoint.setBorePosition(newPosition); }
@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); } }