Program: 160480
Project: 160480
Buggy source:
public void generateGeometry(long uoid,final PluginManager pluginManager,final DatabaseSession databaseSession,IfcModelInterface model,final int pid,final int rid,final boolean store,GeometryCache geometryCache) throws BimserverDatabaseException, GeometryGeneratingException {
  if (geometryCache != null && !geometryCache.isEmpty()) {
    returnCachedData(model,geometryCache,databaseSession,pid,rid);
    return;
  }
  long start=System.nanoTime();
  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";
  }
  try {
    final SerializerPlugin ifcSerializerPlugin=(SerializerPlugin)pluginManager.getPlugin(pluginName,true);
    if (ifcSerializerPlugin == null) {
      throw new UserException("String_Node_Str");
    }
    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");
    }
    final RenderEnginePlugin renderEnginePlugin=pluginManager.getRenderEngine(defaultRenderEngine.getPluginDescriptor().getPluginClassName(),true);
    if (renderEnginePlugin == null) {
      throw new UserException("String_Node_Str" + defaultRenderEngine.getPluginDescriptor().getPluginClassName());
    }
    final EClass productClass=model.getPackageMetaData().getEClass("String_Node_Str");
    final EClass productRepresentationClass=model.getPackageMetaData().getEClass("String_Node_Str");
    final EStructuralFeature geometryFeature=productClass.getEStructuralFeature("String_Node_Str");
    final EStructuralFeature representationFeature=productClass.getEStructuralFeature("String_Node_Str");
    final EStructuralFeature representationsFeature=productRepresentationClass.getEStructuralFeature("String_Node_Str");
    Set<EClass> classes=new HashSet<>();
    for (    IfcProduct object : model.getAllWithSubTypes(IfcProduct.class)) {
      IfcProductRepresentation representation=object.getRepresentation();
      if (representation != null && representation.getRepresentations().size() > 0) {
        classes.add(object.eClass());
      }
    }
    if (classes.size() == 0) {
      return;
    }
    final RenderEngineSettings settings=new RenderEngineSettings();
    settings.setPrecision(Precision.SINGLE);
    settings.setIndexFormat(IndexFormat.AUTO_DETECT);
    settings.setGenerateNormals(true);
    settings.setGenerateTriangles(true);
    settings.setGenerateWireFrame(false);
    classes.remove(Ifc2x3tc1Package.eINSTANCE.getIfcAnnotation());
    int maxSimultanousThreads=Math.min(bimServer.getServerSettingsCache().getServerSettings().getRenderEngineProcesses(),Runtime.getRuntime().availableProcessors());
    if (maxSimultanousThreads < 1) {
      maxSimultanousThreads=1;
    }
    LOGGER.debug("String_Node_Str" + maxSimultanousThreads + "String_Node_Str");
    ThreadPoolExecutor executor=new ThreadPoolExecutor(maxSimultanousThreads,maxSimultanousThreads,24,TimeUnit.HOURS,new ArrayBlockingQueue<Runnable>(classes.size()));
    final Map<IdEObject,IdEObject> bigMap=new HashMap<IdEObject,IdEObject>();
    HideAllInversesObjectIDM idm=new HideAllInversesObjectIDM(CollectionUtils.singleSet(Ifc2x3tc1Package.eINSTANCE),pluginManager.getMetaDataManager().getPackageMetaData("String_Node_Str").getSchemaDefinition());
    for (    final EClass eClass : classes) {
      if (eClass.getName().equals("String_Node_Str")) {
        continue;
      }
      final BasicIfcModel targetModel=new BasicIfcModel(pluginManager.getMetaDataManager().getPackageMetaData("String_Node_Str"),null);
      ModelHelper modelHelper=new ModelHelper(targetModel);
      modelHelper.setObjectIDM(idm);
      IfcProject newProject=null;
      for (      IdEObject idEObject : model.getAllWithSubTypes(IfcProject.class)) {
        newProject=(IfcProject)modelHelper.copy(idEObject,false,skipRepresentation);
        bigMap.put(newProject,idEObject);
      }
      for (      IdEObject idEObject : model.getAll(eClass)) {
        IfcProduct ifcProduct=(IfcProduct)idEObject;
        IdEObject newObject=modelHelper.copy(idEObject,false,createObjectIdm(ifcProduct.eClass()));
        copyDecomposes(ifcProduct,modelHelper);
        bigMap.put(newObject,idEObject);
        if (eClass.getName().equals("String_Node_Str")) {
          IfcWallStandardCase ifcWallStandardCase=(IfcWallStandardCase)idEObject;
          for (          IfcRelVoidsElement ifcRelVoidsElement : ifcWallStandardCase.getHasOpenings()) {
            bigMap.put(modelHelper.copy(ifcRelVoidsElement,false),ifcRelVoidsElement);
            IfcFeatureElementSubtraction relatedOpeningElement=ifcRelVoidsElement.getRelatedOpeningElement();
            if (relatedOpeningElement != null) {
              bigMap.put(modelHelper.copy(relatedOpeningElement,false),relatedOpeningElement);
            }
          }
        }
      }
      for (      IdEObject idEObject : model.getAllWithSubTypes(IfcUnit.class)) {
        bigMap.put(modelHelper.copy(idEObject,false,skipRepresentation),idEObject);
      }
      for (      IdEObject idEObject : model.getAllWithSubTypes(IfcUnitAssignment.class)) {
        bigMap.put(modelHelper.copy(idEObject,false,skipRepresentation),idEObject);
      }
      executor.submit(new Runnable(){
        @Override public void run(){
          targetModel.generateMinimalExpressIds();
          Serializer ifcSerializer=ifcSerializerPlugin.createSerializer(new PluginConfiguration());
          RenderEngine renderEngine=null;
          try {
            renderEngine=renderEnginePlugin.createRenderEngine(new PluginConfiguration(),"String_Node_Str");
          }
 catch (          RenderEngineException e2) {
            e2.printStackTrace();
          }
          try {
            renderEngine.init();
            ifcSerializer.init(targetModel,null,pluginManager,null,pluginManager.getMetaDataManager().getPackageMetaData("String_Node_Str"),true);
            RenderEngineModel renderEngineModel=renderEngine.openModel(ifcSerializer.getInputStream());
            try {
              renderEngineModel.setSettings(settings);
              renderEngineModel.generateGeneralGeometry();
              List<IdEObject> allWithSubTypes=targetModel.getAll(eClass);
              for (              IdEObject ifcProduct : allWithSubTypes) {
                IdEObject representation=(IdEObject)ifcProduct.eGet(representationFeature);
                if (representation != null && ((List<?>)representation.eGet(representationsFeature)).size() > 0) {
                  try {
                    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);
                        }
                      }
                      bigMap.get(ifcProduct).eSet(geometryFeature,geometryInfo);
                      ifcProduct.eSet(geometryFeature,geometryInfo);
                      if (store) {
                        databaseSession.store(bigMap.get(ifcProduct),pid,rid);
                      }
                    }
                  }
 catch (                  BimserverDatabaseException|RenderEngineException e) {
                    if (!(ifcProduct instanceof IfcAnnotation)) {
                      LOGGER.info("String_Node_Str" + ifcProduct.eClass().getName() + "String_Node_Str"+ ifcProduct.getExpressId()+ "String_Node_Str"+ ifcProduct.getOid());
                    }
                  }
                }
              }
            }
  finally {
              renderEngineModel.close();
            }
          }
 catch (          SerializerException|RenderEngineException|IOException e) {
            LOGGER.error("String_Node_Str",e);
          }
 finally {
            try {
              renderEngine.close();
            }
 catch (            RenderEngineException e) {
              LOGGER.error("String_Node_Str",e);
            }
          }
        }
      }
);
    }
    executor.shutdown();
    executor.awaitTermination(24,TimeUnit.HOURS);
    long end=System.nanoTime();
    LOGGER.info("String_Node_Str" + ((end - start) / 1000000) + "String_Node_Str");
  }
 catch (  Exception e) {
    LOGGER.error("String_Node_Str",e);
    throw new GeometryGeneratingException(e);
  }
}

Fixed version (ground truth):
public void generateGeometry(long uoid,final PluginManager pluginManager,final DatabaseSession databaseSession,IfcModelInterface model,final int pid,final int rid,final boolean store,GeometryCache geometryCache) throws BimserverDatabaseException, GeometryGeneratingException {
  if (geometryCache != null && !geometryCache.isEmpty()) {
    returnCachedData(model,geometryCache,databaseSession,pid,rid);
    return;
  }
  long start=System.nanoTime();
  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";
  }
  try {
    final SerializerPlugin ifcSerializerPlugin=(SerializerPlugin)pluginManager.getPlugin(pluginName,true);
    if (ifcSerializerPlugin == null) {
      throw new UserException("String_Node_Str");
    }
    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");
    }
    final RenderEnginePlugin renderEnginePlugin=pluginManager.getRenderEngine(defaultRenderEngine.getPluginDescriptor().getPluginClassName(),true);
    if (renderEnginePlugin == null) {
      throw new UserException("String_Node_Str" + defaultRenderEngine.getPluginDescriptor().getPluginClassName());
    }
    final EClass productClass=model.getPackageMetaData().getEClass("String_Node_Str");
    final EClass productRepresentationClass=model.getPackageMetaData().getEClass("String_Node_Str");
    final EStructuralFeature geometryFeature=productClass.getEStructuralFeature("String_Node_Str");
    final EStructuralFeature representationFeature=productClass.getEStructuralFeature("String_Node_Str");
    final EStructuralFeature representationsFeature=productRepresentationClass.getEStructuralFeature("String_Node_Str");
    Set<EClass> classes=new HashSet<>();
    for (    IfcProduct object : model.getAllWithSubTypes(IfcProduct.class)) {
      IfcProductRepresentation representation=object.getRepresentation();
      if (representation != null && representation.getRepresentations().size() > 0) {
        classes.add(object.eClass());
      }
    }
    if (classes.size() == 0) {
      return;
    }
    final RenderEngineSettings settings=new RenderEngineSettings();
    settings.setPrecision(Precision.SINGLE);
    settings.setIndexFormat(IndexFormat.AUTO_DETECT);
    settings.setGenerateNormals(true);
    settings.setGenerateTriangles(true);
    settings.setGenerateWireFrame(false);
    classes.remove(Ifc2x3tc1Package.eINSTANCE.getIfcAnnotation());
    int maxSimultanousThreads=Math.min(bimServer.getServerSettingsCache().getServerSettings().getRenderEngineProcesses(),Runtime.getRuntime().availableProcessors());
    if (maxSimultanousThreads < 1) {
      maxSimultanousThreads=1;
    }
    LOGGER.debug("String_Node_Str" + maxSimultanousThreads + "String_Node_Str");
    ThreadPoolExecutor executor=new ThreadPoolExecutor(maxSimultanousThreads,maxSimultanousThreads,24,TimeUnit.HOURS,new ArrayBlockingQueue<Runnable>(classes.size()));
    oidCounter=model.getHighestOid() + 1;
    final Map<IdEObject,IdEObject> bigMap=new HashMap<IdEObject,IdEObject>();
    HideAllInversesObjectIDM idm=new HideAllInversesObjectIDM(CollectionUtils.singleSet(Ifc2x3tc1Package.eINSTANCE),pluginManager.getMetaDataManager().getPackageMetaData("String_Node_Str").getSchemaDefinition());
    for (    final EClass eClass : classes) {
      if (eClass.getName().equals("String_Node_Str")) {
        continue;
      }
      final BasicIfcModel targetModel=new BasicIfcModel(pluginManager.getMetaDataManager().getPackageMetaData("String_Node_Str"),null);
      ModelHelper modelHelper=new ModelHelper(targetModel);
      modelHelper.setObjectIDM(idm);
      IfcProject newProject=null;
      for (      IdEObject idEObject : model.getAllWithSubTypes(IfcProject.class)) {
        newProject=(IfcProject)modelHelper.copy(idEObject,false,skipRepresentation);
        bigMap.put(newProject,idEObject);
      }
      for (      IdEObject idEObject : model.getAll(eClass)) {
        IfcProduct ifcProduct=(IfcProduct)idEObject;
        IdEObject newObject=modelHelper.copy(idEObject,false,createObjectIdm(ifcProduct.eClass()));
        copyDecomposes(ifcProduct,modelHelper);
        bigMap.put(newObject,idEObject);
        if (eClass.getName().equals("String_Node_Str")) {
          IfcWallStandardCase ifcWallStandardCase=(IfcWallStandardCase)idEObject;
          for (          IfcRelVoidsElement ifcRelVoidsElement : ifcWallStandardCase.getHasOpenings()) {
            bigMap.put(modelHelper.copy(ifcRelVoidsElement,false),ifcRelVoidsElement);
            IfcFeatureElementSubtraction relatedOpeningElement=ifcRelVoidsElement.getRelatedOpeningElement();
            if (relatedOpeningElement != null) {
              bigMap.put(modelHelper.copy(relatedOpeningElement,false),relatedOpeningElement);
            }
          }
        }
      }
      for (      IdEObject idEObject : model.getAllWithSubTypes(IfcUnit.class)) {
        bigMap.put(modelHelper.copy(idEObject,false,skipRepresentation),idEObject);
      }
      for (      IdEObject idEObject : model.getAllWithSubTypes(IfcUnitAssignment.class)) {
        bigMap.put(modelHelper.copy(idEObject,false,skipRepresentation),idEObject);
      }
      executor.submit(new Runnable(){
        @Override public void run(){
          targetModel.generateMinimalExpressIds();
          Serializer ifcSerializer=ifcSerializerPlugin.createSerializer(new PluginConfiguration());
          RenderEngine renderEngine=null;
          try {
            renderEngine=renderEnginePlugin.createRenderEngine(new PluginConfiguration(),"String_Node_Str");
          }
 catch (          RenderEngineException e2) {
            e2.printStackTrace();
          }
          try {
            renderEngine.init();
            ifcSerializer.init(targetModel,null,pluginManager,null,pluginManager.getMetaDataManager().getPackageMetaData("String_Node_Str"),true);
            RenderEngineModel renderEngineModel=renderEngine.openModel(ifcSerializer.getInputStream());
            try {
              renderEngineModel.setSettings(settings);
              renderEngineModel.generateGeneralGeometry();
              List<IdEObject> allWithSubTypes=targetModel.getAll(eClass);
              for (              IdEObject ifcProduct : allWithSubTypes) {
                IdEObject representation=(IdEObject)ifcProduct.eGet(representationFeature);
                if (representation != null && ((List<?>)representation.eGet(representationsFeature)).size() > 0) {
                  try {
                    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);
                        }
                      }
                      bigMap.get(ifcProduct).eSet(geometryFeature,geometryInfo);
                      ifcProduct.eSet(geometryFeature,geometryInfo);
                      if (store) {
                        databaseSession.store(bigMap.get(ifcProduct),pid,rid);
                      }
                    }
                  }
 catch (                  BimserverDatabaseException|RenderEngineException e) {
                    if (!(ifcProduct instanceof IfcAnnotation)) {
                      LOGGER.info("String_Node_Str" + ifcProduct.eClass().getName() + "String_Node_Str"+ ifcProduct.getExpressId()+ "String_Node_Str"+ ifcProduct.getOid());
                    }
                  }
                }
              }
            }
  finally {
              renderEngineModel.close();
            }
          }
 catch (          SerializerException|RenderEngineException|IOException e) {
            LOGGER.error("String_Node_Str",e);
          }
 finally {
            try {
              renderEngine.close();
            }
 catch (            RenderEngineException e) {
              LOGGER.error("String_Node_Str",e);
            }
          }
        }
      }
);
    }
    executor.shutdown();
    executor.awaitTermination(24,TimeUnit.HOURS);
    long end=System.nanoTime();
    LOGGER.info("String_Node_Str" + ((end - start) / 1000000) + "String_Node_Str");
  }
 catch (  Exception e) {
    LOGGER.error("String_Node_Str",e);
    throw new GeometryGeneratingException(e);
  }
}