Program: 147082
Project: 147082
Buggy source:
private UUID createJsonForGeometryPath(GeometryPath path,ModelDisplayHints mdh,JSONArray json_geometries,JSONArray json_materials,boolean visible){
  Map<String,Object> mat_json=new LinkedHashMap<String,Object>();
  UUID mat_uuid=UUID.randomUUID();
  mat_json.put("String_Node_Str",mat_uuid.toString());
  populatePathMaterialDefaults(mat_json,path);
  mat_json.put("String_Node_Str",path.getAbsolutePathString() + "String_Node_Str");
  mat_json.put("String_Node_Str",true);
  json_materials.add(mat_json);
  Map<String,Object> pathpt_mat_json=new LinkedHashMap<String,Object>();
  UUID pathpt_mat_uuid=UUID.randomUUID();
  pathpt_mat_json.put("String_Node_Str",pathpt_mat_uuid.toString());
  populatePathMaterialDefaults(pathpt_mat_json,path);
  pathpt_mat_json.put("String_Node_Str",path.getAbsolutePathString() + "String_Node_Str");
  json_materials.add(pathpt_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",actualMuscleDisplayRadius);
  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);
  mapGeometryPathToPathPointMaterialUUID.put(path,pathpt_mat_uuid);
  UUID pathpoint_uuid=addPathPointObjectToParent(firstPoint,pathpt_mat_uuid.toString(),visible);
  pathpoint_jsonArr.add(pathpoint_uuid.toString());
  pathpointActive_jsonArr.add(true);
  addComponentToUUIDMap(firstPoint,pathpoint_uuid);
  int firstIndex=0;
  int numIntermediatePoints=NUM_PATHPOINTS_PER_WRAP_OBJECT * 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)) {
      if (numWrapObjects > 0)       createComputedPathPoints(numIntermediatePoints,firstPoint,secondPoint,pathpoint_jsonArr,pathpointActive_jsonArr);
    }
 else     if (secondIndex == -1) {
      ConditionalPathPoint cpp=ConditionalPathPoint.safeDownCast(secondPoint);
      pathpoint_uuid=addComputedPathPointObjectToParent(ppointSetIndex,pathPointSetNoWrap,pathpt_mat_uuid.toString(),visible);
      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 >= 1) {
            int[] indicesToUse=new int[NUM_PATHPOINTS_PER_WRAP_OBJECT];
            for (int ndx=0; ndx < NUM_PATHPOINTS_PER_WRAP_OBJECT - 1; ndx++)             indicesToUse[ndx]=ndx * (size - 1) / (NUM_PATHPOINTS_PER_WRAP_OBJECT);
            indicesToUse[NUM_PATHPOINTS_PER_WRAP_OBJECT - 1]=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,pathpt_mat_uuid.toString(),false);
              UUID ppt_uuid=UUID.fromString((String)bpptInBodyJson.get("String_Node_Str"));
              children.add(bpptInBodyJson);
              pathpoint_jsonArr.add(ppt_uuid.toString());
              pathpointActive_jsonArr.add(false);
              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,pathpt_mat_uuid.toString(),visible && ppointSetIndex == pathPointSetNoWrap.getSize() - 1);
      pathpoint_jsonArr.add(pathpoint_uuid.toString());
      pathpointActive_jsonArr.add(true);
      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());
  if (!visible) {
    obj_json.put("String_Node_Str",false);
  }
  return mesh_uuid;
}

Fixed version (ground truth):
private UUID createJsonForGeometryPath(GeometryPath path,ModelDisplayHints mdh,JSONArray json_geometries,JSONArray json_materials,boolean visible){
  Map<String,Object> mat_json=new LinkedHashMap<String,Object>();
  UUID mat_uuid=UUID.randomUUID();
  mat_json.put("String_Node_Str",mat_uuid.toString());
  populatePathMaterialDefaults(mat_json,path);
  mat_json.put("String_Node_Str",path.getAbsolutePathString() + "String_Node_Str");
  mat_json.put("String_Node_Str",true);
  json_materials.add(mat_json);
  Map<String,Object> pathpt_mat_json=new LinkedHashMap<String,Object>();
  UUID pathpt_mat_uuid=UUID.randomUUID();
  pathpt_mat_json.put("String_Node_Str",pathpt_mat_uuid.toString());
  populatePathMaterialDefaults(pathpt_mat_json,path);
  pathpt_mat_json.put("String_Node_Str",path.getAbsolutePathString() + "String_Node_Str");
  json_materials.add(pathpt_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",actualMuscleDisplayRadius);
  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);
  mapGeometryPathToPathPointMaterialUUID.put(path,pathpt_mat_uuid);
  UUID pathpoint_uuid=addPathPointObjectToParent(firstPoint,pathpt_mat_uuid.toString(),visible);
  pathpoint_jsonArr.add(pathpoint_uuid.toString());
  pathpointActive_jsonArr.add(true);
  addComponentToUUIDMap(firstPoint,pathpoint_uuid);
  int firstIndex=0;
  int numIntermediatePoints=NUM_PATHPOINTS_PER_WRAP_OBJECT * 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)) {
      if (numWrapObjects > 0)       createComputedPathPoints(numIntermediatePoints,firstPoint,secondPoint,pathpoint_jsonArr,pathpointActive_jsonArr);
    }
 else     if (secondIndex == -1) {
      ConditionalPathPoint cpp=ConditionalPathPoint.safeDownCast(secondPoint);
      pathpoint_uuid=addComputedPathPointObjectToParent(ppointSetIndex,pathPointSetNoWrap,pathpt_mat_uuid.toString(),visible && ppointSetIndex == pathPointSetNoWrap.getSize() - 1);
      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 >= 1) {
            int[] indicesToUse=new int[NUM_PATHPOINTS_PER_WRAP_OBJECT];
            for (int ndx=0; ndx < NUM_PATHPOINTS_PER_WRAP_OBJECT - 1; ndx++)             indicesToUse[ndx]=ndx * (size - 1) / (NUM_PATHPOINTS_PER_WRAP_OBJECT);
            indicesToUse[NUM_PATHPOINTS_PER_WRAP_OBJECT - 1]=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,pathpt_mat_uuid.toString(),false);
              UUID ppt_uuid=UUID.fromString((String)bpptInBodyJson.get("String_Node_Str"));
              children.add(bpptInBodyJson);
              pathpoint_jsonArr.add(ppt_uuid.toString());
              pathpointActive_jsonArr.add(false);
              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,pathpt_mat_uuid.toString(),visible && ppointSetIndex == pathPointSetNoWrap.getSize() - 1);
      pathpoint_jsonArr.add(pathpoint_uuid.toString());
      pathpointActive_jsonArr.add(true);
      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());
  if (!visible) {
    obj_json.put("String_Node_Str",false);
  }
  return mesh_uuid;
}