Program: 57205
Project: 57205
Buggy source:
/** 
 * Filter the parts of an hyperplane belonging to the boundary. <p>The filtering consist in splitting the specified sub-hyperplane into several parts lying in inside and outside cells of the tree. The principle is to call this method twice for each cut sub-hyperplane in the tree, once one the plus node and once on the minus node. The parts that have the same flag (inside/inside or outside/outside) do not belong to the boundary while parts that have different flags (inside/outside or outside/inside) do belong to the boundary.</p>
 * @param node current BSP tree node
 * @param sub sub-hyperplane to characterize
 * @param characterization placeholder where to put the characterized parts
 */
private void characterize(final BSPTree<S> node,final SubHyperplane<S> sub,final SubHyperplane<S>[] characterization){
  if (node.getCut() == null) {
    final boolean inside=(Boolean)node.getAttribute();
    if (inside) {
      if (characterization[1] == null) {
        characterization[1]=sub;
      }
 else {
        characterization[1]=characterization[1].reunite(sub);
      }
    }
 else {
      if (characterization[0] == null) {
        characterization[0]=sub;
      }
 else {
        characterization[0]=characterization[0].reunite(sub);
      }
    }
  }
 else {
    final Hyperplane<S> hyperplane=node.getCut().getHyperplane();
switch (sub.side(hyperplane)) {
case PLUS:
      characterize(node.getPlus(),sub,characterization);
    break;
case MINUS:
  characterize(node.getMinus(),sub,characterization);
break;
case BOTH:
final SubHyperplane.SplitSubHyperplane<S> split=sub.split(hyperplane);
characterize(node.getPlus(),split.getPlus(),characterization);
characterize(node.getMinus(),split.getMinus(),characterization);
break;
default :
throw new MathInternalError();
}
}
}

Fixed version (ground truth):
/** 
 * Filter the parts of an hyperplane belonging to the boundary. <p>The filtering consist in splitting the specified sub-hyperplane into several parts lying in inside and outside cells of the tree. The principle is to call this method twice for each cut sub-hyperplane in the tree, once on the plus node and once on the minus node. The parts that have the same flag (inside/inside or outside/outside) do not belong to the boundary while parts that have different flags (inside/outside or outside/inside) do belong to the boundary.</p>
 * @param node current BSP tree node
 * @param sub sub-hyperplane to characterize
 * @param characterization placeholder where to put the characterized parts
 */
private void characterize(final BSPTree<S> node,final SubHyperplane<S> sub,final SubHyperplane<S>[] characterization){
  if (node.getCut() == null) {
    final boolean inside=(Boolean)node.getAttribute();
    if (inside) {
      if (characterization[1] == null) {
        characterization[1]=sub;
      }
 else {
        characterization[1]=characterization[1].reunite(sub);
      }
    }
 else {
      if (characterization[0] == null) {
        characterization[0]=sub;
      }
 else {
        characterization[0]=characterization[0].reunite(sub);
      }
    }
  }
 else {
    final Hyperplane<S> hyperplane=node.getCut().getHyperplane();
switch (sub.side(hyperplane)) {
case PLUS:
      characterize(node.getPlus(),sub,characterization);
    break;
case MINUS:
  characterize(node.getMinus(),sub,characterization);
break;
case BOTH:
final SubHyperplane.SplitSubHyperplane<S> split=sub.split(hyperplane);
characterize(node.getPlus(),split.getPlus(),characterization);
characterize(node.getMinus(),split.getMinus(),characterization);
break;
default :
throw new MathInternalError();
}
}
}