Program: 147086
Project: 147086
Buggy source:
private UUID createJsonForGeometryPath(GeometryPath path,ModelDisplayHints mdh,JSONArray json_geometries,JSONArray json_materials){
  Map<String,Object> mat_json=new LinkedHashMap<String,Object>();
  UUID mat_uuid=UUID.randomUUID();
  mapPathMaterialToUUID.put(path.getAbsolutePathString(),mat_uuid);
  mat_json.put("String_Node_Str",mat_uuid.toString());
  mat_json.put("String_Node_Str",path.getAbsolutePathString() + "String_Node_Str");
  mat_json.put("String_Node_Str","String_Node_Str");
  Vec3 pathColor=path.getDefaultColor();
  String colorString=JSONUtilities.mapColorToRGBA(pathColor);
  mat_json.put("String_Node_Str",colorString);
  mat_json.put("String_Node_Str",2);
  mat_json.put("String_Node_Str",true);
  mat_json.put("String_Node_Str",true);
  json_materials.add(mat_json);
  JSONObject pathGeomJson=new JSONObject();
  UUID uuidForPathGeomGeometry=UUID.randomUUID();
  pathGeomJson.put("String_Node_Str",uuidForPathGeomGeometry.toString());
  pathGeomJson.put("String_Node_Str","String_Node_Str");
  pathGeomJson.put("String_Node_Str",path.getAbsolutePathString() + "String_Node_Str");
  int numWrapObjects=path.getWrapSet().getSize();
  final PathPointSet pathPointSetNoWrap=path.getPathPointSet();
  json_geometries.add(pathGeomJson);
  JSONArray pathpoint_jsonArr=new JSONArray();
  JSONArray pathpointActive_jsonArr=new JSONArray();
  boolean hasWrapping=(numWrapObjects > 0);
  ArrayPathPoint actualPath=path.getCurrentPath(state);
  AbstractPathPoint firstPoint=pathPointSetNoWrap.get(0);
  UUID pathpoint_uuid=addPathPointObjectToParent(firstPoint);
  pathpoint_jsonArr.add(pathpoint_uuid.toString());
  int firstIndex=0;
  int numIntermediatePoints=2 * numWrapObjects;
  for (int ppointSetIndex=1; ppointSetIndex < pathPointSetNoWrap.getSize(); ppointSetIndex++) {
    AbstractPathPoint secondPoint=pathPointSetNoWrap.get(ppointSetIndex);
    int secondIndex=actualPath.findIndex(secondPoint);
    boolean pointAdded=false;
    if (secondIndex == firstIndex + 1 || (firstIndex == -1 && secondIndex != -1)) {
      pathpointActive_jsonArr.add(true);
      if (numWrapObjects > 0)       createComputedPathPoints(numIntermediatePoints,firstPoint,secondPoint,pathpoint_jsonArr);
    }
 else     if (secondIndex == -1) {
      ConditionalPathPoint cpp=ConditionalPathPoint.safeDownCast(secondPoint);
      pathpoint_uuid=addComputedPathPointObjectToParent(ppointSetIndex,pathPointSetNoWrap);
      pointAdded=true;
      ArrayList<UUID> comp_uuids=new ArrayList<UUID>();
      comp_uuids.add(pathpoint_uuid);
      mapComponentToUUID.put(cpp,comp_uuids);
      mapUUIDToComponent.put(pathpoint_uuid,cpp);
      pathpointActive_jsonArr.add(false);
      pathpoint_jsonArr.add(pathpoint_uuid.toString());
      firstIndex=secondIndex;
      firstPoint=secondPoint;
    }
 else {
      for (int wrappointIndex=firstIndex + 1; wrappointIndex < secondIndex; wrappointIndex++) {
        AbstractPathPoint nextPathPoint=actualPath.get(wrappointIndex);
        PathWrapPoint pathWrapPoint=PathWrapPoint.safeDownCast(nextPathPoint);
        if (pathWrapPoint != null) {
          ArrayVec3 pathwrap=pathWrapPoint.getWrapPath();
          PhysicalFrame wrapPtsFrame=pathWrapPoint.getParentFrame();
          int size=pathwrap.size();
          if (size >= 2) {
            int x=0;
            int[] indicesToUse=new int[]{0,size - 1};
            double step=1.0 / (indicesToUse.length + 1.0);
            JSONObject bodyJson=mapBodyIndicesToJson.get(0);
            JSONArray children=(JSONArray)bodyJson.get("String_Node_Str");
            ArrayList<UUID> wrapPointUUIDs=new ArrayList<UUID>();
            for (int j=0; j < indicesToUse.length; j++) {
              Vec3 globalLocation=wrapPtsFrame.findStationLocationInAnotherFrame(state,pathwrap.get(indicesToUse[j]),mapBodyIndicesToFrames.get(0));
              JSONObject bpptInBodyJson=createPathPointObjectJson(null,"String_Node_Str",false,globalLocation);
              UUID ppt_uuid=UUID.fromString((String)bpptInBodyJson.get("String_Node_Str"));
              children.add(bpptInBodyJson);
              pathpoint_jsonArr.add(ppt_uuid.toString());
              wrapPointUUIDs.add(ppt_uuid);
              computedPathPoints.put(ppt_uuid,new ComputedPathPointInfo(firstPoint,secondPoint,step * (j + 1)));
            }
            wrapPathPoints.put(pathWrapPoint,wrapPointUUIDs);
          }
        }
      }
    }
    if (!pointAdded) {
      pathpoint_uuid=addPathPointObjectToParent(secondPoint);
      pathpoint_jsonArr.add(pathpoint_uuid.toString());
      ArrayList<UUID> comp_uuids=new ArrayList<UUID>();
      comp_uuids.add(pathpoint_uuid);
      mapComponentToUUID.put(secondPoint,comp_uuids);
      mapUUIDToComponent.put(pathpoint_uuid,secondPoint);
    }
    if (MovingPathPoint.safeDownCast(secondPoint) != null) {
      movingComponents.put(secondPoint,pathpoint_uuid);
    }
    firstIndex=secondIndex;
    firstPoint=secondPoint;
  }
  if (hasWrapping)   pathsWithWrapping.put(path,pathpoint_jsonArr);
  pathGeomJson.put("String_Node_Str",pathpoint_jsonArr.size() - 1);
  JSONObject gndJson=mapBodyIndicesToJson.get(0);
  if (gndJson.get("String_Node_Str") == null)   gndJson.put("String_Node_Str",new JSONArray());
  JSONArray gndChildren=(JSONArray)gndJson.get("String_Node_Str");
  Map<String,Object> obj_json=new LinkedHashMap<String,Object>();
  UUID mesh_uuid=UUID.randomUUID();
  obj_json.put("String_Node_Str",mesh_uuid.toString());
  obj_json.put("String_Node_Str","String_Node_Str");
  obj_json.put("String_Node_Str",path.getAbsolutePathString());
  obj_json.put("String_Node_Str",pathpoint_jsonArr);
  obj_json.put("String_Node_Str",pathpointActive_jsonArr);
  obj_json.put("String_Node_Str",uuidForPathGeomGeometry.toString());
  obj_json.put("String_Node_Str","String_Node_Str");
  gndChildren.add(obj_json);
  obj_json.put("String_Node_Str",mat_uuid.toString());
  return mesh_uuid;
}

Fixed version (ground truth):
private UUID createJsonForGeometryPath(GeometryPath path,ModelDisplayHints mdh,JSONArray json_geometries,JSONArray json_materials){
  Map<String,Object> mat_json=new LinkedHashMap<String,Object>();
  UUID mat_uuid=UUID.randomUUID();
  mapPathMaterialToUUID.put(path.getAbsolutePathString(),mat_uuid);
  mat_json.put("String_Node_Str",mat_uuid.toString());
  mat_json.put("String_Node_Str",path.getAbsolutePathString() + "String_Node_Str");
  mat_json.put("String_Node_Str","String_Node_Str");
  Vec3 pathColor=path.getDefaultColor();
  String colorString=JSONUtilities.mapColorToRGBA(pathColor);
  mat_json.put("String_Node_Str",colorString);
  mat_json.put("String_Node_Str",2);
  mat_json.put("String_Node_Str",true);
  mat_json.put("String_Node_Str",true);
  json_materials.add(mat_json);
  JSONObject pathGeomJson=new JSONObject();
  UUID uuidForPathGeomGeometry=UUID.randomUUID();
  pathGeomJson.put("String_Node_Str",uuidForPathGeomGeometry.toString());
  pathGeomJson.put("String_Node_Str","String_Node_Str");
  pathGeomJson.put("String_Node_Str",path.getAbsolutePathString() + "String_Node_Str");
  int numWrapObjects=path.getWrapSet().getSize();
  final PathPointSet pathPointSetNoWrap=path.getPathPointSet();
  json_geometries.add(pathGeomJson);
  JSONArray pathpoint_jsonArr=new JSONArray();
  JSONArray pathpointActive_jsonArr=new JSONArray();
  boolean hasWrapping=(numWrapObjects > 0);
  ArrayPathPoint actualPath=path.getCurrentPath(state);
  AbstractPathPoint firstPoint=pathPointSetNoWrap.get(0);
  UUID pathpoint_uuid=addPathPointObjectToParent(firstPoint);
  pathpoint_jsonArr.add(pathpoint_uuid.toString());
  addComponentToUUIDMap(firstPoint,pathpoint_uuid);
  int firstIndex=0;
  int numIntermediatePoints=2 * numWrapObjects;
  for (int ppointSetIndex=1; ppointSetIndex < pathPointSetNoWrap.getSize(); ppointSetIndex++) {
    AbstractPathPoint secondPoint=pathPointSetNoWrap.get(ppointSetIndex);
    int secondIndex=actualPath.findIndex(secondPoint);
    boolean pointAdded=false;
    if (secondIndex == firstIndex + 1 || (firstIndex == -1 && secondIndex != -1)) {
      pathpointActive_jsonArr.add(true);
      if (numWrapObjects > 0)       createComputedPathPoints(numIntermediatePoints,firstPoint,secondPoint,pathpoint_jsonArr);
    }
 else     if (secondIndex == -1) {
      ConditionalPathPoint cpp=ConditionalPathPoint.safeDownCast(secondPoint);
      pathpoint_uuid=addComputedPathPointObjectToParent(ppointSetIndex,pathPointSetNoWrap);
      pointAdded=true;
      ArrayList<UUID> comp_uuids=new ArrayList<UUID>();
      comp_uuids.add(pathpoint_uuid);
      mapComponentToUUID.put(cpp,comp_uuids);
      mapUUIDToComponent.put(pathpoint_uuid,cpp);
      pathpointActive_jsonArr.add(false);
      pathpoint_jsonArr.add(pathpoint_uuid.toString());
      firstIndex=secondIndex;
      firstPoint=secondPoint;
    }
 else {
      for (int wrappointIndex=firstIndex + 1; wrappointIndex < secondIndex; wrappointIndex++) {
        AbstractPathPoint nextPathPoint=actualPath.get(wrappointIndex);
        PathWrapPoint pathWrapPoint=PathWrapPoint.safeDownCast(nextPathPoint);
        if (pathWrapPoint != null) {
          ArrayVec3 pathwrap=pathWrapPoint.getWrapPath();
          PhysicalFrame wrapPtsFrame=pathWrapPoint.getParentFrame();
          int size=pathwrap.size();
          if (size >= 2) {
            int x=0;
            int[] indicesToUse=new int[]{0,size - 1};
            double step=1.0 / (indicesToUse.length + 1.0);
            JSONObject bodyJson=mapBodyIndicesToJson.get(0);
            JSONArray children=(JSONArray)bodyJson.get("String_Node_Str");
            ArrayList<UUID> wrapPointUUIDs=new ArrayList<UUID>();
            for (int j=0; j < indicesToUse.length; j++) {
              Vec3 globalLocation=wrapPtsFrame.findStationLocationInAnotherFrame(state,pathwrap.get(indicesToUse[j]),mapBodyIndicesToFrames.get(0));
              JSONObject bpptInBodyJson=createPathPointObjectJson(null,"String_Node_Str",false,globalLocation);
              UUID ppt_uuid=UUID.fromString((String)bpptInBodyJson.get("String_Node_Str"));
              children.add(bpptInBodyJson);
              pathpoint_jsonArr.add(ppt_uuid.toString());
              wrapPointUUIDs.add(ppt_uuid);
              computedPathPoints.put(ppt_uuid,new ComputedPathPointInfo(firstPoint,secondPoint,step * (j + 1)));
            }
            wrapPathPoints.put(pathWrapPoint,wrapPointUUIDs);
          }
        }
      }
    }
    if (!pointAdded) {
      pathpoint_uuid=addPathPointObjectToParent(secondPoint);
      pathpoint_jsonArr.add(pathpoint_uuid.toString());
      addComponentToUUIDMap(secondPoint,pathpoint_uuid);
    }
    if (MovingPathPoint.safeDownCast(secondPoint) != null) {
      movingComponents.put(secondPoint,pathpoint_uuid);
    }
    firstIndex=secondIndex;
    firstPoint=secondPoint;
  }
  if (hasWrapping)   pathsWithWrapping.put(path,pathpoint_jsonArr);
  pathGeomJson.put("String_Node_Str",pathpoint_jsonArr.size() - 1);
  JSONObject gndJson=mapBodyIndicesToJson.get(0);
  if (gndJson.get("String_Node_Str") == null)   gndJson.put("String_Node_Str",new JSONArray());
  JSONArray gndChildren=(JSONArray)gndJson.get("String_Node_Str");
  Map<String,Object> obj_json=new LinkedHashMap<String,Object>();
  UUID mesh_uuid=UUID.randomUUID();
  obj_json.put("String_Node_Str",mesh_uuid.toString());
  obj_json.put("String_Node_Str","String_Node_Str");
  obj_json.put("String_Node_Str",path.getAbsolutePathString());
  obj_json.put("String_Node_Str",pathpoint_jsonArr);
  obj_json.put("String_Node_Str",pathpointActive_jsonArr);
  obj_json.put("String_Node_Str",uuidForPathGeomGeometry.toString());
  obj_json.put("String_Node_Str","String_Node_Str");
  gndChildren.add(obj_json);
  obj_json.put("String_Node_Str",mat_uuid.toString());
  return mesh_uuid;
}