Program: 160498
Project: 160498
Buggy source:
public void generateGeometry(long uoid,PluginManager pluginManager,DatabaseSession databaseSession,IfcModelInterface model,int pid,int rid,boolean store,GeometryCache geometryCache) throws BimserverDatabaseException, GeometryGeneratingException {
  if (geometryCache != null && !geometryCache.isEmpty()) {
    returnCachedData(model,geometryCache,databaseSession,pid,rid);
    return;
  }
  String pluginName="String_Node_Str";
  if (model.getPackageMetaData().getSchema() == Schema.IFC4) {
    pluginName="String_Node_Str";
  }
 else   if (model.getPackageMetaData().getSchema() == Schema.IFC2X3TC1) {
    pluginName="String_Node_Str";
  }
  SerializerPlugin serializerPlugin=(SerializerPlugin)pluginManager.getPlugin(pluginName,true);
  Serializer serializer=serializerPlugin.createSerializer(new PluginConfiguration());
  try {
    model.generateMinimalExpressIds();
    PackageMetaData packageMetaData=model.getPackageMetaData();
    serializer.init(model,null,pluginManager,null,packageMetaData,false);
    SerializerInputstream serializerInputstream=new SerializerInputstream((EmfSerializer)serializer);
    User user=(User)databaseSession.get(uoid,Query.getDefault());
    UserSettings userSettings=user.getUserSettings();
    RenderEnginePluginConfiguration defaultRenderEngine=userSettings.getDefaultRenderEngine();
    if (defaultRenderEngine == null) {
      throw new UserException("String_Node_Str");
    }
    RenderEnginePlugin renderEnginePlugin=pluginManager.getRenderEngine(defaultRenderEngine.getPluginDescriptor().getPluginClassName(),true);
    if (renderEnginePlugin == null) {
      throw new UserException("String_Node_Str" + defaultRenderEngine.getPluginDescriptor().getPluginClassName());
    }
    try {
      RenderEngine renderEngine=renderEnginePlugin.createRenderEngine(new PluginConfiguration(),packageMetaData.getSchema().getEPackageName());
      renderEngine.init();
      try {
        RenderEngineModel renderEngineModel=renderEngine.openModel(serializerInputstream);
        RenderEngineSettings settings=new RenderEngineSettings();
        settings.setPrecision(Precision.SINGLE);
        settings.setIndexFormat(IndexFormat.AUTO_DETECT);
        settings.setGenerateNormals(true);
        settings.setGenerateTriangles(true);
        settings.setGenerateWireFrame(false);
        renderEngineModel.setSettings(settings);
        try {
          renderEngineModel.generateGeneralGeometry();
          EClass productClass=model.getPackageMetaData().getEClass("String_Node_Str");
          List<IdEObject> products=model.getAllWithSubTypes(productClass);
          EStructuralFeature geometryFeature=productClass.getEStructuralFeature("String_Node_Str");
          EStructuralFeature representationFeature=productClass.getEStructuralFeature("String_Node_Str");
          for (          IdEObject ifcProduct : products) {
            if (ifcProduct.eGet(representationFeature) != null) {
              RenderEngineInstance renderEngineInstance=renderEngineModel.getInstanceFromExpressId(ifcProduct.getExpressId());
              RenderEngineGeometry geometry=renderEngineInstance.generateGeometry();
              if (geometry != null && geometry.getNrIndices() > 0) {
                GeometryInfo geometryInfo=null;
                if (store) {
                  geometryInfo=databaseSession.create(GeometryPackage.eINSTANCE.getGeometryInfo(),pid,rid);
                }
 else {
                  geometryInfo=GeometryFactory.eINSTANCE.createGeometryInfo();
                }
                geometryInfo.setMinBounds(createVector3f(Float.POSITIVE_INFINITY,databaseSession,store,pid,rid));
                geometryInfo.setMaxBounds(createVector3f(Float.NEGATIVE_INFINITY,databaseSession,store,pid,rid));
                GeometryData geometryData=null;
                if (store) {
                  geometryData=databaseSession.create(GeometryPackage.eINSTANCE.getGeometryData(),pid,rid);
                }
 else {
                  geometryData=GeometryFactory.eINSTANCE.createGeometryData();
                }
                geometryData.setIndices(intArrayToByteArray(geometry.getIndices()));
                geometryData.setVertices(floatArrayToByteArray(geometry.getVertices()));
                geometryData.setMaterialIndices(intArrayToByteArray(geometry.getMaterialIndices()));
                geometryData.setNormals(floatArrayToByteArray(geometry.getNormals()));
                if (geometry.getMaterialIndices() != null && geometry.getMaterialIndices().length > 0) {
                  boolean hasMaterial=false;
                  float[] vertex_colors=new float[geometry.getVertices().length / 3 * 4];
                  for (int i=0; i < geometry.getMaterialIndices().length; ++i) {
                    int c=geometry.getMaterialIndices()[i];
                    for (int j=0; j < 3; ++j) {
                      int k=geometry.getIndices()[i * 3 + j];
                      if (c > -1) {
                        hasMaterial=true;
                        for (int l=0; l < 4; ++l) {
                          vertex_colors[4 * k + l]=geometry.getMaterials()[4 * c + l];
                        }
                      }
                    }
                  }
                  if (hasMaterial) {
                    geometryData.setMaterials(floatArrayToByteArray(vertex_colors));
                  }
                }
                float[] tranformationMatrix=new float[16];
                if (renderEngineInstance.getTransformationMatrix() != null) {
                  tranformationMatrix=renderEngineInstance.getTransformationMatrix();
                  tranformationMatrix=Matrix.changeOrientation(tranformationMatrix);
                }
 else {
                  Matrix.setIdentityM(tranformationMatrix,0);
                }
                for (int i=0; i < geometry.getIndices().length; i++) {
                  processExtends(geometryInfo,tranformationMatrix,geometry.getVertices(),geometry.getIndices()[i] * 3);
                }
                geometryInfo.setData(geometryData);
                setTransformationMatrix(geometryInfo,tranformationMatrix);
                if (bimServer.getServerSettingsCache().getServerSettings().isReuseGeometry()) {
                  int hash=hash(geometryData);
                  if (hashes.containsKey(hash)) {
                    databaseSession.removeFromCommit(geometryData);
                    geometryInfo.setData(hashes.get(hash));
                  }
 else {
                    hashes.put(hash,geometryData);
                  }
                }
                ifcProduct.eSet(geometryFeature,geometryInfo);
                if (store) {
                  databaseSession.store(ifcProduct,pid,rid);
                }
              }
            }
          }
        }
  finally {
          renderEngineModel.close();
        }
      }
  finally {
        renderEngine.close();
      }
    }
 catch (    RenderEngineException e) {
      LOGGER.error("String_Node_Str",e);
    }
  }
 catch (  Exception e) {
    LOGGER.error("String_Node_Str",e);
    throw new GeometryGeneratingException(e);
  }
}

Fixed version (ground truth):
public void generateGeometry(long uoid,PluginManager pluginManager,DatabaseSession databaseSession,IfcModelInterface model,int pid,int rid,boolean store,GeometryCache geometryCache) throws BimserverDatabaseException, GeometryGeneratingException {
  if (geometryCache != null && !geometryCache.isEmpty()) {
    returnCachedData(model,geometryCache,databaseSession,pid,rid);
    return;
  }
  String pluginName="String_Node_Str";
  if (model.getPackageMetaData().getSchema() == Schema.IFC4) {
    pluginName="String_Node_Str";
  }
 else   if (model.getPackageMetaData().getSchema() == Schema.IFC2X3TC1) {
    pluginName="String_Node_Str";
  }
  SerializerPlugin serializerPlugin=(SerializerPlugin)pluginManager.getPlugin(pluginName,true);
  Serializer serializer=serializerPlugin.createSerializer(new PluginConfiguration());
  try {
    model.generateMinimalExpressIds();
    PackageMetaData packageMetaData=model.getPackageMetaData();
    serializer.init(model,null,pluginManager,null,packageMetaData,false);
    User user=(User)databaseSession.get(uoid,Query.getDefault());
    UserSettings userSettings=user.getUserSettings();
    RenderEnginePluginConfiguration defaultRenderEngine=userSettings.getDefaultRenderEngine();
    if (defaultRenderEngine == null) {
      throw new UserException("String_Node_Str");
    }
    RenderEnginePlugin renderEnginePlugin=pluginManager.getRenderEngine(defaultRenderEngine.getPluginDescriptor().getPluginClassName(),true);
    if (renderEnginePlugin == null) {
      throw new UserException("String_Node_Str" + defaultRenderEngine.getPluginDescriptor().getPluginClassName());
    }
    SerializerInputstream serializerInputstream=new SerializerInputstream((EmfSerializer)serializer);
    try {
      RenderEngine renderEngine=renderEnginePlugin.createRenderEngine(new PluginConfiguration(),packageMetaData.getSchema().getEPackageName());
      renderEngine.init();
      try {
        RenderEngineModel renderEngineModel=renderEngine.openModel(serializerInputstream);
        RenderEngineSettings settings=new RenderEngineSettings();
        settings.setPrecision(Precision.SINGLE);
        settings.setIndexFormat(IndexFormat.AUTO_DETECT);
        settings.setGenerateNormals(true);
        settings.setGenerateTriangles(true);
        settings.setGenerateWireFrame(false);
        renderEngineModel.setSettings(settings);
        try {
          renderEngineModel.generateGeneralGeometry();
          EClass productClass=model.getPackageMetaData().getEClass("String_Node_Str");
          List<IdEObject> products=model.getAllWithSubTypes(productClass);
          EStructuralFeature geometryFeature=productClass.getEStructuralFeature("String_Node_Str");
          EStructuralFeature representationFeature=productClass.getEStructuralFeature("String_Node_Str");
          for (          IdEObject ifcProduct : products) {
            if (ifcProduct.eGet(representationFeature) != null) {
              RenderEngineInstance renderEngineInstance=renderEngineModel.getInstanceFromExpressId(ifcProduct.getExpressId());
              RenderEngineGeometry geometry=renderEngineInstance.generateGeometry();
              if (geometry != null && geometry.getNrIndices() > 0) {
                GeometryInfo geometryInfo=null;
                if (store) {
                  geometryInfo=databaseSession.create(GeometryPackage.eINSTANCE.getGeometryInfo(),pid,rid);
                }
 else {
                  geometryInfo=GeometryFactory.eINSTANCE.createGeometryInfo();
                }
                geometryInfo.setMinBounds(createVector3f(Float.POSITIVE_INFINITY,databaseSession,store,pid,rid));
                geometryInfo.setMaxBounds(createVector3f(Float.NEGATIVE_INFINITY,databaseSession,store,pid,rid));
                GeometryData geometryData=null;
                if (store) {
                  geometryData=databaseSession.create(GeometryPackage.eINSTANCE.getGeometryData(),pid,rid);
                }
 else {
                  geometryData=GeometryFactory.eINSTANCE.createGeometryData();
                }
                geometryData.setIndices(intArrayToByteArray(geometry.getIndices()));
                geometryData.setVertices(floatArrayToByteArray(geometry.getVertices()));
                geometryData.setMaterialIndices(intArrayToByteArray(geometry.getMaterialIndices()));
                geometryData.setNormals(floatArrayToByteArray(geometry.getNormals()));
                if (geometry.getMaterialIndices() != null && geometry.getMaterialIndices().length > 0) {
                  boolean hasMaterial=false;
                  float[] vertex_colors=new float[geometry.getVertices().length / 3 * 4];
                  for (int i=0; i < geometry.getMaterialIndices().length; ++i) {
                    int c=geometry.getMaterialIndices()[i];
                    for (int j=0; j < 3; ++j) {
                      int k=geometry.getIndices()[i * 3 + j];
                      if (c > -1) {
                        hasMaterial=true;
                        for (int l=0; l < 4; ++l) {
                          vertex_colors[4 * k + l]=geometry.getMaterials()[4 * c + l];
                        }
                      }
                    }
                  }
                  if (hasMaterial) {
                    geometryData.setMaterials(floatArrayToByteArray(vertex_colors));
                  }
                }
                float[] tranformationMatrix=new float[16];
                if (renderEngineInstance.getTransformationMatrix() != null) {
                  tranformationMatrix=renderEngineInstance.getTransformationMatrix();
                  tranformationMatrix=Matrix.changeOrientation(tranformationMatrix);
                }
 else {
                  Matrix.setIdentityM(tranformationMatrix,0);
                }
                for (int i=0; i < geometry.getIndices().length; i++) {
                  processExtends(geometryInfo,tranformationMatrix,geometry.getVertices(),geometry.getIndices()[i] * 3);
                }
                geometryInfo.setData(geometryData);
                setTransformationMatrix(geometryInfo,tranformationMatrix);
                if (bimServer.getServerSettingsCache().getServerSettings().isReuseGeometry()) {
                  int hash=hash(geometryData);
                  if (hashes.containsKey(hash)) {
                    databaseSession.removeFromCommit(geometryData);
                    geometryInfo.setData(hashes.get(hash));
                  }
 else {
                    hashes.put(hash,geometryData);
                  }
                }
                ifcProduct.eSet(geometryFeature,geometryInfo);
                if (store) {
                  databaseSession.store(ifcProduct,pid,rid);
                }
              }
            }
          }
        }
  finally {
          renderEngineModel.close();
        }
      }
  finally {
        renderEngine.close();
      }
    }
 catch (    RenderEngineException e) {
      LOGGER.error("String_Node_Str",e);
    }
  }
 catch (  Exception e) {
    LOGGER.error("String_Node_Str",e);
    throw new GeometryGeneratingException(e);
  }
}