Program: 160672
Project: 160672
Buggy source:
private JSONObject writeGeometry(IfcObjectDefinition ifcObject,String id) throws IfcEngineException, JSONException, SerializerException {
  float[] modelOffset=new float[]{-(sceneExtents.min[0] + sceneExtents.max[0]) * 0.5f,-(sceneExtents.min[1] + sceneExtents.max[1]) * 0.5f,-(sceneExtents.min[2] + sceneExtents.max[2]) * 0.5f};
  JSONObject jsonObj=new JSONObject();
  IfcModelInterface ifcModel=new IfcModel();
  convertToSubset(ifcObject.eClass(),ifcObject,ifcModel,new HashMap<EObject,EObject>());
  EmfSerializer serializer=getPluginManager().requireIfcStepSerializer();
  serializer.init(ifcModel,getProjectInfo(),getPluginManager());
  try {
    IfcEngineModel model=ifcEngine.openModel(serializer.getBytes());
    try {
      model.setPostProcessing(true);
      IfcEngineGeometry geometry=model.finalizeModelling(model.initializeModelling());
      if (geometry != null) {
        JSONArray verticesArray=new JSONArray();
        jsonObj.put("String_Node_Str","String_Node_Str").put("String_Node_Str",ifcObject.getGlobalId().getWrappedValue()).put("String_Node_Str","String_Node_Str").put("String_Node_Str",verticesArray);
        for (int i=0; i < geometry.getNrVertices(); i+=3) {
          verticesArray.put(geometry.getVertex(i + 0) + modelOffset[0]).put(geometry.getVertex(i + 1) + modelOffset[1]).put(geometry.getVertex(i + 2) + modelOffset[2]);
        }
        JSONArray normalsArray=new JSONArray();
        jsonObj.put("String_Node_Str",normalsArray);
        for (int i=0; i < geometry.getNrNormals(); i++) {
          normalsArray.put(geometry.getNormal(i));
        }
        List<? extends IfcEngineInstance> instances=model.getInstances(ifcObject.eClass().getName().toUpperCase());
        if (instances.size() > 1) {
          LOGGER.error("String_Node_Str");
        }
        for (        IfcEngineInstance instance : instances) {
          IfcEngineInstanceVisualisationProperties instanceInModelling=instance.getVisualisationProperties();
          JSONArray indicesArray=new JSONArray();
          jsonObj.put("String_Node_Str",indicesArray);
          int endIndex=instanceInModelling.getPrimitiveCount() * 3 + instanceInModelling.getStartIndex();
          for (int i=instanceInModelling.getStartIndex(); i < endIndex; i+=3) {
            indicesArray.put(geometry.getIndex(i)).put(geometry.getIndex(i + 2)).put(geometry.getIndex(i + 1));
          }
        }
      }
    }
  finally {
      model.close();
    }
  }
 catch (  IfcEngineException e) {
    throw e;
  }
catch (  Exception e) {
    LOGGER.error("String_Node_Str",e);
  }
  return jsonObj;
}

Fixed version (ground truth):
private JSONObject writeGeometry(IfcObjectDefinition ifcObject,String id) throws IfcEngineException, JSONException, SerializerException {
  float[] modelOffset=new float[]{-(sceneExtents.min[0] + sceneExtents.max[0]) * 0.5f,-(sceneExtents.min[1] + sceneExtents.max[1]) * 0.5f,-(sceneExtents.min[2] + sceneExtents.max[2]) * 0.5f};
  modelOffset[0]=Float.isInfinite(modelOffset[0]) || Float.isNaN(modelOffset[0]) ? 0.0f : modelOffset[0];
  modelOffset[1]=Float.isInfinite(modelOffset[1]) || Float.isNaN(modelOffset[1]) ? 0.0f : modelOffset[1];
  modelOffset[2]=Float.isInfinite(modelOffset[2]) || Float.isNaN(modelOffset[2]) ? 0.0f : modelOffset[2];
  JSONObject jsonObj=new JSONObject();
  IfcModelInterface ifcModel=new IfcModel();
  convertToSubset(ifcObject.eClass(),ifcObject,ifcModel,new HashMap<EObject,EObject>());
  EmfSerializer serializer=getPluginManager().requireIfcStepSerializer();
  serializer.init(ifcModel,getProjectInfo(),getPluginManager());
  try {
    IfcEngineModel model=ifcEngine.openModel(serializer.getBytes());
    try {
      model.setPostProcessing(true);
      IfcEngineGeometry geometry=model.finalizeModelling(model.initializeModelling());
      if (geometry != null) {
        JSONArray verticesArray=new JSONArray();
        jsonObj.put("String_Node_Str","String_Node_Str").put("String_Node_Str",ifcObject.getGlobalId().getWrappedValue()).put("String_Node_Str","String_Node_Str").put("String_Node_Str",verticesArray);
        for (int i=0; i < geometry.getNrVertices(); i+=3) {
          float[] v={geometry.getVertex(i + 0),geometry.getVertex(i + 1),geometry.getVertex(i + 2)};
          verticesArray.put((Float.isInfinite(v[0]) || Float.isNaN(v[0]) ? 0.0f : v[0]) + modelOffset[0]).put((Float.isInfinite(v[1]) || Float.isNaN(v[1]) ? 0.0f : v[1]) + modelOffset[1]).put((Float.isInfinite(v[2]) || Float.isNaN(v[2]) ? 0.0f : v[2]) + modelOffset[2]);
        }
        JSONArray normalsArray=new JSONArray();
        jsonObj.put("String_Node_Str",normalsArray);
        for (int i=0; i < geometry.getNrNormals(); i++) {
          normalsArray.put(geometry.getNormal(i));
        }
        List<? extends IfcEngineInstance> instances=model.getInstances(ifcObject.eClass().getName().toUpperCase());
        if (instances.size() > 1) {
          LOGGER.error("String_Node_Str");
        }
        for (        IfcEngineInstance instance : instances) {
          IfcEngineInstanceVisualisationProperties instanceInModelling=instance.getVisualisationProperties();
          JSONArray indicesArray=new JSONArray();
          jsonObj.put("String_Node_Str",indicesArray);
          int endIndex=instanceInModelling.getPrimitiveCount() * 3 + instanceInModelling.getStartIndex();
          for (int i=instanceInModelling.getStartIndex(); i < endIndex; i+=3) {
            indicesArray.put(geometry.getIndex(i)).put(geometry.getIndex(i + 2)).put(geometry.getIndex(i + 1));
          }
        }
      }
    }
  finally {
      model.close();
    }
  }
 catch (  IfcEngineException e) {
    throw e;
  }
catch (  Exception e) {
    LOGGER.error("String_Node_Str",e);
  }
  return jsonObj;
}