Program: 57219
Project: 57219
Buggy source:
/** 
 * Add he contribution of a boundary facet.
 * @param facet boundary facet
 * @param reversed if true, the facet has the inside on its plus side
 */
private void addContribution(final SubHyperplane<Euclidean3D> facet,final boolean reversed){
  @SuppressWarnings("String_Node_Str") final AbstractSubHyperplane<Euclidean3D,Euclidean2D> absFacet=(AbstractSubHyperplane<Euclidean3D,Euclidean2D>)facet;
  final Plane plane=(Plane)facet.getHyperplane();
  final double scal=plane.getNormal().dotProduct(w);
  if (FastMath.abs(scal) > 1.0e-3) {
    Vector2D[][] vertices=((PolygonsSet)absFacet.getRemainingRegion()).getVertices();
    if ((scal < 0) ^ reversed) {
      final Vector2D[][] newVertices=new Vector2D[vertices.length][];
      for (int i=0; i < vertices.length; ++i) {
        final Vector2D[] loop=vertices[i];
        final Vector2D[] newLoop=new Vector2D[loop.length];
        if (loop[0] == null) {
          newLoop[0]=null;
          for (int j=1; j < loop.length; ++j) {
            newLoop[j]=loop[loop.length - j];
          }
        }
 else {
          for (int j=0; j < loop.length; ++j) {
            newLoop[j]=loop[loop.length - (j + 1)];
          }
        }
        newVertices[i]=newLoop;
      }
      vertices=newVertices;
    }
    final ArrayList<SubHyperplane<Euclidean2D>> edges=new ArrayList<SubHyperplane<Euclidean2D>>();
    for (    Vector2D[] loop : vertices) {
      final boolean closed=loop[0] != null;
      int previous=closed ? (loop.length - 1) : 1;
      Vector3D previous3D=plane.toSpace(loop[previous]);
      int current=(previous + 1) % loop.length;
      Vector2D pPoint=new Vector2D(previous3D.dotProduct(u),previous3D.dotProduct(v));
      while (current < loop.length) {
        final Vector3D current3D=plane.toSpace(loop[current]);
        final Vector2D cPoint=new Vector2D(current3D.dotProduct(u),current3D.dotProduct(v));
        final org.apache.commons.math3.geometry.euclidean.twod.Line line=new org.apache.commons.math3.geometry.euclidean.twod.Line(pPoint,cPoint);
        SubHyperplane<Euclidean2D> edge=line.wholeHyperplane();
        if (closed || (previous != 1)) {
          final double angle=line.getAngle() + 0.5 * FastMath.PI;
          final org.apache.commons.math3.geometry.euclidean.twod.Line l=new org.apache.commons.math3.geometry.euclidean.twod.Line(pPoint,angle);
          edge=edge.split(l).getPlus();
        }
        if (closed || (current != (loop.length - 1))) {
          final double angle=line.getAngle() + 0.5 * FastMath.PI;
          final org.apache.commons.math3.geometry.euclidean.twod.Line l=new org.apache.commons.math3.geometry.euclidean.twod.Line(cPoint,angle);
          edge=edge.split(l).getMinus();
        }
        edges.add(edge);
        previous=current++;
        previous3D=current3D;
        pPoint=cPoint;
      }
    }
    final PolygonsSet projectedFacet=new PolygonsSet(edges);
    projected=(PolygonsSet)new RegionFactory<Euclidean2D>().union(projected,projectedFacet);
  }
}

Fixed version (ground truth):
/** 
 * Add he contribution of a boundary facet.
 * @param facet boundary facet
 * @param reversed if true, the facet has the inside on its plus side
 */
private void addContribution(final SubHyperplane<Euclidean3D> facet,final boolean reversed){
  @SuppressWarnings("String_Node_Str") final AbstractSubHyperplane<Euclidean3D,Euclidean2D> absFacet=(AbstractSubHyperplane<Euclidean3D,Euclidean2D>)facet;
  final Plane plane=(Plane)facet.getHyperplane();
  final double scal=plane.getNormal().dotProduct(w);
  if (FastMath.abs(scal) > 1.0e-3) {
    Vector2D[][] vertices=((PolygonsSet)absFacet.getRemainingRegion()).getVertices();
    if ((scal < 0) ^ reversed) {
      final Vector2D[][] newVertices=new Vector2D[vertices.length][];
      for (int i=0; i < vertices.length; ++i) {
        final Vector2D[] loop=vertices[i];
        final Vector2D[] newLoop=new Vector2D[loop.length];
        if (loop[0] == null) {
          newLoop[0]=null;
          for (int j=1; j < loop.length; ++j) {
            newLoop[j]=loop[loop.length - j];
          }
        }
 else {
          for (int j=0; j < loop.length; ++j) {
            newLoop[j]=loop[loop.length - (j + 1)];
          }
        }
        newVertices[i]=newLoop;
      }
      vertices=newVertices;
    }
    final ArrayList<SubHyperplane<Euclidean2D>> edges=new ArrayList<SubHyperplane<Euclidean2D>>();
    for (    Vector2D[] loop : vertices) {
      final boolean closed=loop[0] != null;
      int previous=closed ? (loop.length - 1) : 1;
      Vector3D previous3D=plane.toSpace((Point<Euclidean2D>)loop[previous]);
      int current=(previous + 1) % loop.length;
      Vector2D pPoint=new Vector2D(previous3D.dotProduct(u),previous3D.dotProduct(v));
      while (current < loop.length) {
        final Vector3D current3D=plane.toSpace((Point<Euclidean2D>)loop[current]);
        final Vector2D cPoint=new Vector2D(current3D.dotProduct(u),current3D.dotProduct(v));
        final org.apache.commons.math3.geometry.euclidean.twod.Line line=new org.apache.commons.math3.geometry.euclidean.twod.Line(pPoint,cPoint);
        SubHyperplane<Euclidean2D> edge=line.wholeHyperplane();
        if (closed || (previous != 1)) {
          final double angle=line.getAngle() + 0.5 * FastMath.PI;
          final org.apache.commons.math3.geometry.euclidean.twod.Line l=new org.apache.commons.math3.geometry.euclidean.twod.Line(pPoint,angle);
          edge=edge.split(l).getPlus();
        }
        if (closed || (current != (loop.length - 1))) {
          final double angle=line.getAngle() + 0.5 * FastMath.PI;
          final org.apache.commons.math3.geometry.euclidean.twod.Line l=new org.apache.commons.math3.geometry.euclidean.twod.Line(cPoint,angle);
          edge=edge.split(l).getMinus();
        }
        edges.add(edge);
        previous=current++;
        previous3D=current3D;
        pPoint=cPoint;
      }
    }
    final PolygonsSet projectedFacet=new PolygonsSet(edges);
    projected=(PolygonsSet)new RegionFactory<Euclidean2D>().union(projected,projectedFacet);
  }
}