コード例 #1
0
  private void applyIDMFilter(IfcModelInterface model) {
    try {
      ObjectIDM objectIDM = cobieToolkit.getObjectIDM();
      if (objectIDM != null) {
        ArrayList<IdEObject> removeTheseObjects = new ArrayList<IdEObject>();
        for (long key : model.getObjects().keySet()) {
          IdEObject candidateObject = model.get(key);
          boolean shouldIncludeObject =
              objectIDM.shouldIncludeClass(candidateObject.eClass(), candidateObject.eClass());
          for (EStructuralFeature feature : candidateObject.eClass().getEAllStructuralFeatures()) {
            boolean shouldFollowReference =
                objectIDM.shouldFollowReference(
                    candidateObject.eClass(), candidateObject.eClass(), feature);
            if (!shouldFollowReference) {
              candidateObject.eUnset(feature);
            }
          }
          if (!shouldIncludeObject) {
            removeTheseObjects.add(candidateObject);
          }
        }
        for (IdEObject ideObject : removeTheseObjects) {
          model.remove(ideObject);
        }
      }

    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
コード例 #2
0
 public CompareResult compare(
     IfcModelInterface model1, IfcModelInterface model2, CompareType compareType)
     throws ModelCompareException {
   CompareResult result = StoreFactory.eINSTANCE.createCompareResult();
   try {
     for (EClassifier eClassifier : Ifc2x3tc1Package.eINSTANCE.getEClassifiers()) {
       if (eClassifier instanceof EClass
           && Ifc2x3tc1Package.eINSTANCE.getIfcRoot().isSuperTypeOf((EClass) eClassifier)) {
         EClass eClass = (EClass) eClassifier;
         for (IdEObject i : model1.getValues()) {
           if (i instanceof IfcWindow) {
             IfcWindow window = (IfcWindow) i;
             for (EStructuralFeature feature : window.eClass().getEStructuralFeatures()) {
               window.eGet(feature);
             }
           }
         }
         for (String guid : model1.getGuids(eClass)) {
           IdEObject eObject1 = model1.getByGuid(guid);
           IdEObject eObject2 = model2.getByGuid(guid);
           if (eObject2 == null) {
             if (compareType == CompareType.ALL || compareType == CompareType.DELETE) {
               ObjectRemoved objectRemoved = StoreFactory.eINSTANCE.createObjectRemoved();
               objectRemoved.setDataObject(makeDataObject(eObject1));
               getCompareContainer(eObject1.eClass()).getItems().add(objectRemoved);
             }
           }
         }
         for (String guid : model2.getGuids(eClass)) {
           IdEObject eObject1 = model1.getByGuid(guid);
           IdEObject eObject2 = model2.getByGuid(guid);
           if (eObject1 == null) {
             if (compareType == CompareType.ALL || compareType == CompareType.ADD) {
               ObjectAdded objectAdded = StoreFactory.eINSTANCE.createObjectAdded();
               objectAdded.setDataObject(makeDataObject(eObject2));
               getCompareContainer(eObject2.eClass()).getItems().add(objectAdded);
             }
           } else {
             compareEObjects(eClass, eObject1, eObject2, result, compareType);
           }
         }
       }
     }
   } catch (Exception e) {
     throw new ModelCompareException(e);
   }
   for (CompareContainer compareContainer : getMap().values()) {
     result.getItems().add(compareContainer);
   }
   return result;
 }
コード例 #3
0
 private void write(PrintWriter out, IdEObject object) throws SerializerException {
   EClass eClass = object.eClass();
   if (eClass.getEAnnotation("hidden") != null) {
     return;
   }
   out.print(DASH);
   int convertedKey = getExpressId(object);
   if (convertedKey == -1) {
     throw new SerializerException(
         "Going to serialize an object with id -1 (" + object.eClass().getName() + ")");
   }
   out.print(String.valueOf(convertedKey));
   out.print("= ");
   String upperCase = upperCases.get(eClass);
   if (upperCase == null) {
     throw new SerializerException("Type not found: " + eClass.getName());
   }
   out.print(upperCase);
   out.print(OPEN_PAREN);
   boolean isFirst = true;
   for (EStructuralFeature feature : eClass.getEAllStructuralFeatures()) {
     if (!feature.isDerived() && feature.getEAnnotation("hidden") == null) {
       EClassifier type = feature.getEType();
       if (type instanceof EEnum) {
         if (!isFirst) {
           out.print(COMMA);
         }
         writeEnum(out, object, feature);
         isFirst = false;
       } else if (type instanceof EClass) {
         if (!isInverse(feature)) {
           if (!isFirst) {
             out.print(COMMA);
           }
           writeEClass(out, object, feature);
           isFirst = false;
         }
       } else if (type instanceof EDataType) {
         if (!isFirst) {
           out.print(COMMA);
         }
         writeEDataType(out, object, feature);
         isFirst = false;
       }
     }
   }
   out.println(PAREN_CLOSE_SEMICOLON);
 }
コード例 #4
0
 public BiMap<IdEObject, Long> getMap(IdEObject idEObject) {
   if (idEObject.eClass().getEPackage() == Ifc2x3tc1Package.eINSTANCE) {
     return objectsToCommitFirst;
   } else {
     return objectsToCommitSecond;
   }
 }
コード例 #5
0
ファイル: IfcVisualiser.java プロジェクト: joojump/BIMserver
  private void createSceneGraph() throws PluginException, IfcModelInterfaceException {
    buildingTransformGroup = new TransformGroup();

    Set<Class<? extends IfcRoot>> classesToConvert = new HashSet<Class<? extends IfcRoot>>();
    classesToConvert.add(IfcWall.class);
    classesToConvert.add(IfcWallStandardCase.class);
    classesToConvert.add(IfcWindow.class);
    classesToConvert.add(IfcOpeningElement.class);
    classesToConvert.add(IfcSlab.class);
    classesToConvert.add(IfcRoof.class);
    classesToConvert.add(IfcColumn.class);
    classesToConvert.add(IfcSpace.class);
    classesToConvert.add(IfcDoor.class);
    classesToConvert.add(IfcRailing.class);
    classesToConvert.add(IfcFurnishingElement.class);
    classesToConvert.add(IfcStair.class);
    classesToConvert.add(IfcBeam.class);
    classesToConvert.add(IfcFlowTerminalType.class);
    classesToConvert.add(IfcDistributionFlowElement.class);
    classesToConvert.add(IfcSite.class);
    // classesToConvert.add(IfcProxy.class);

    for (IdEObject idEObject : model.getValues()) {
      if (classesToConvert.contains(idEObject.eClass().getInstanceClass())) {
        setGeometry((IfcRoot) idEObject);
      }
    }
    buildingBranchGroup = new BranchGroup();
    addLights(buildingBranchGroup);
    buildingBranchGroup.addChild(buildingTransformGroup);
    showLoader = false;
    sceneBranchGroup.removeChild(loaderBranchGroup);
    sharedGroup.addChild(buildingBranchGroup);

    // for (int x = 0; x < 5; x++) {
    // for (int y = 0; y < 5; y++) {
    Link link1 = new Link(sharedGroup);
    Transform3D t3d1 = new Transform3D();
    // t3d1.setTranslation(new Vector3f(x * 20, y * 20, 0f));
    BranchGroup x1 = new BranchGroup();
    TransformGroup t1 = new TransformGroup(t3d1);
    x1.addChild(t1);
    t1.addChild(link1);
    sceneBranchGroup.addChild(x1);
    // }
    // }

    reInitView();
  }
コード例 #6
0
 private void writeList(PrintWriter out, EObject object, EStructuralFeature feature)
     throws SerializerException {
   List<?> list = (List<?>) object.eGet(feature);
   List<?> doubleStingList = null;
   if (feature.getEType() == EcorePackage.eINSTANCE.getEDouble() && model.isUseDoubleStrings()) {
     EStructuralFeature doubleStringFeature =
         feature.getEContainingClass().getEStructuralFeature(feature.getName() + "AsString");
     if (doubleStringFeature == null) {
       throw new SerializerException("Field " + feature.getName() + "AsString" + " not found");
     }
     doubleStingList = (List<?>) object.eGet(doubleStringFeature);
   }
   if (list.isEmpty()) {
     if (!feature.isUnsettable()) {
       out.print(OPEN_CLOSE_PAREN);
     } else {
       out.print("$");
     }
   } else {
     out.print(OPEN_PAREN);
     boolean first = true;
     int index = 0;
     for (Object listObject : list) {
       if (!first) {
         out.print(COMMA);
       }
       if ((listObject instanceof IdEObject) && model.contains((IdEObject) listObject)) {
         IdEObject eObject = (IdEObject) listObject;
         out.print(DASH);
         out.print(String.valueOf(getExpressId(eObject)));
       } else {
         if (listObject == null) {
           out.print(DOLLAR);
         } else {
           if (listObject instanceof IdEObject
               && feature.getEType().getEAnnotation("wrapped") != null) {
             IdEObject eObject = (IdEObject) listObject;
             Object realVal = eObject.eGet(eObject.eClass().getEStructuralFeature("wrappedValue"));
             if (realVal instanceof Double) {
               Object stringVal =
                   eObject.eGet(eObject.eClass().getEStructuralFeature("wrappedValueAsString"));
               if (stringVal != null && model.isUseDoubleStrings()) {
                 out.print(stringVal);
               } else {
                 out.print(realVal);
               }
             } else {
               writePrimitive(out, realVal);
             }
           } else if (listObject instanceof EObject) {
             IdEObject eObject = (IdEObject) listObject;
             EClass class1 = eObject.eClass();
             EStructuralFeature structuralFeature = class1.getEStructuralFeature(WRAPPED_VALUE);
             if (structuralFeature != null) {
               Object realVal = eObject.eGet(structuralFeature);
               out.print(upperCases.get(class1));
               out.print(OPEN_PAREN);
               if (realVal instanceof Double) {
                 Object stringVal =
                     eObject.eGet(
                         class1.getEStructuralFeature(structuralFeature.getName() + "AsString"));
                 if (stringVal != null && model.isUseDoubleStrings()) {
                   out.print(stringVal);
                 } else {
                   out.print(realVal);
                 }
               } else {
                 writePrimitive(out, realVal);
               }
               out.print(CLOSE_PAREN);
             } else {
               LOGGER.info(
                   "Unfollowable reference found from "
                       + object
                       + "."
                       + feature.getName()
                       + " to "
                       + eObject);
             }
           } else {
             if (doubleStingList != null) {
               if (index < doubleStingList.size()) {
                 String val = (String) doubleStingList.get(index);
                 if (val == null) {
                   writePrimitive(out, listObject);
                 } else {
                   out.write(val);
                 }
               } else {
                 writePrimitive(out, listObject);
               }
             } else {
               writePrimitive(out, listObject);
             }
           }
         }
       }
       first = false;
       index++;
     }
     out.print(CLOSE_PAREN);
   }
 }
コード例 #7
0
ファイル: ClientEStore.java プロジェクト: GuilleUCM/BIMserver
 @Override
 public Object set(
     InternalEObject eObject, EStructuralFeature eFeature, int index, Object newValue) {
   IdEObject idEObject = (IdEObject) eObject;
   if (index == NO_INDEX) {
     if (clientIfcModel.getModelState() != ModelState.LOADING) {
       try {
         if (newValue != EStructuralFeature.Internal.DynamicValueHolder.NIL) {
           Bimsie1LowLevelInterface lowLevelInterface =
               clientIfcModel.getBimServerClient().getBimsie1LowLevelInterface();
           if (eFeature.getName().equals("wrappedValue")) {
             // Wrapped objects get the same oid as their "parent" object, so we know which object
             // the client wants to update. That's why we can use idEObject.getOid() here
             // We are making this crazy hack ever crazier, let's iterate over our parents
             // features, and see if there is one matching our wrapped type...
             // Seriously, when there are multiple fields of the same type, this fails miserably, a
             // real fix should probably store the parent-oid + feature name in the wrapped object
             // (requires two extra, volatile, fields),
             // or we just don't support this (just create a new wrapped object too), we could even
             // throw some sort of exception. Hack morally okay because it's client-side...
             EReference foundReference = null;
             if (clientIfcModel.contains(idEObject.getOid())) {
               IdEObject parentObject = clientIfcModel.get(idEObject.getOid());
               int found = 0;
               foundReference = null;
               for (EReference testReference : parentObject.eClass().getEAllReferences()) {
                 if (((EClass) testReference.getEType()).isSuperTypeOf(idEObject.eClass())) {
                   foundReference = testReference;
                   found++;
                   if (found > 1) {
                     throw new RuntimeException(
                         "Sorry, crazy hack could not resolve the right field, please let BIMserver developer know (debug info: "
                             + parentObject.eClass().getName()
                             + ", "
                             + idEObject.eClass().getName()
                             + ")");
                   }
                 }
               }
               if (eFeature.getEType() == EcorePackage.eINSTANCE.getEString()) {
                 lowLevelInterface.setWrappedStringAttribute(
                     clientIfcModel.getTransactionId(),
                     idEObject.getOid(),
                     foundReference.getName(),
                     idEObject.eClass().getName(),
                     (String) newValue);
               } else if (eFeature.getEType() == EcorePackage.eINSTANCE.getELong()
                   || eFeature.getEType() == EcorePackage.eINSTANCE.getELongObject()) {
                 lowLevelInterface.setWrappedLongAttribute(
                     clientIfcModel.getTransactionId(),
                     idEObject.getOid(),
                     foundReference.getName(),
                     idEObject.eClass().getName(),
                     (Long) newValue);
               } else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEDouble()
                   || eFeature.getEType() == EcorePackage.eINSTANCE.getEDoubleObject()) {
                 lowLevelInterface.setWrappedDoubleAttribute(
                     clientIfcModel.getTransactionId(),
                     idEObject.getOid(),
                     foundReference.getName(),
                     idEObject.eClass().getName(),
                     (Double) newValue);
               } else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEBoolean()
                   || eFeature.getEType() == EcorePackage.eINSTANCE.getEBooleanObject()) {
                 lowLevelInterface.setWrappedBooleanAttribute(
                     clientIfcModel.getTransactionId(),
                     idEObject.getOid(),
                     foundReference.getName(),
                     idEObject.eClass().getName(),
                     (Boolean) newValue);
               } else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEInt()
                   || eFeature.getEType() == EcorePackage.eINSTANCE.getEIntegerObject()) {
                 lowLevelInterface.setWrappedIntegerAttribute(
                     clientIfcModel.getTransactionId(),
                     idEObject.getOid(),
                     foundReference.getName(),
                     idEObject.eClass().getName(),
                     (Integer) newValue);
               } else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEByteArray()) {
                 throw new RuntimeException(
                     "Unimplemented " + eFeature.getEType().getName() + " " + newValue);
               }
             } else {
               if (eFeature.getEType() == EcorePackage.eINSTANCE.getEString()) {
                 lowLevelInterface.setStringAttribute(
                     clientIfcModel.getTransactionId(),
                     idEObject.getOid(),
                     eFeature.getName(),
                     (String) newValue);
               } else if (eFeature.getEType() == EcorePackage.eINSTANCE.getELong()
                   || eFeature.getEType() == EcorePackage.eINSTANCE.getELongObject()) {
                 lowLevelInterface.setLongAttribute(
                     clientIfcModel.getTransactionId(),
                     idEObject.getOid(),
                     eFeature.getName(),
                     (Long) newValue);
               } else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEDouble()
                   || eFeature.getEType() == EcorePackage.eINSTANCE.getEDoubleObject()) {
                 lowLevelInterface.setDoubleAttribute(
                     clientIfcModel.getTransactionId(),
                     idEObject.getOid(),
                     eFeature.getName(),
                     (Double) newValue);
               } else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEBoolean()
                   || eFeature.getEType() == EcorePackage.eINSTANCE.getEBooleanObject()) {
                 lowLevelInterface.setBooleanAttribute(
                     clientIfcModel.getTransactionId(),
                     idEObject.getOid(),
                     eFeature.getName(),
                     (Boolean) newValue);
               } else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEInt()
                   || eFeature.getEType() == EcorePackage.eINSTANCE.getEIntegerObject()) {
                 lowLevelInterface.setIntegerAttribute(
                     clientIfcModel.getTransactionId(),
                     idEObject.getOid(),
                     eFeature.getName(),
                     (Integer) newValue);
               } else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEByteArray()) {
                 lowLevelInterface.setByteArrayAttribute(
                     clientIfcModel.getTransactionId(),
                     idEObject.getOid(),
                     eFeature.getName(),
                     (Byte[]) newValue);
               } else if (eFeature.getEType() instanceof EEnum) {
                 lowLevelInterface.setEnumAttribute(
                     clientIfcModel.getTransactionId(),
                     idEObject.getOid(),
                     eFeature.getName(),
                     ((Enum<?>) newValue).toString());
               } else if (eFeature instanceof EReference) {
                 if (newValue == null) {
                   lowLevelInterface.setReference(
                       clientIfcModel.getTransactionId(),
                       idEObject.getOid(),
                       eFeature.getName(),
                       -1L);
                 } else {
                   lowLevelInterface.setReference(
                       clientIfcModel.getTransactionId(),
                       idEObject.getOid(),
                       eFeature.getName(),
                       ((IdEObject) newValue).getOid());
                 }
               } else {
                 throw new RuntimeException(
                     "Unimplemented " + eFeature.getEType().getName() + " " + newValue);
               }
             }
           } else {
             if (eFeature.getEType() == EcorePackage.eINSTANCE.getEString()) {
               lowLevelInterface.setStringAttribute(
                   clientIfcModel.getTransactionId(),
                   idEObject.getOid(),
                   eFeature.getName(),
                   (String) newValue);
             } else if (eFeature.getEType() == EcorePackage.eINSTANCE.getELong()
                 || eFeature.getEType() == EcorePackage.eINSTANCE.getELongObject()) {
               lowLevelInterface.setLongAttribute(
                   clientIfcModel.getTransactionId(),
                   idEObject.getOid(),
                   eFeature.getName(),
                   (Long) newValue);
             } else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEDouble()
                 || eFeature.getEType() == EcorePackage.eINSTANCE.getEDoubleObject()) {
               lowLevelInterface.setDoubleAttribute(
                   clientIfcModel.getTransactionId(),
                   idEObject.getOid(),
                   eFeature.getName(),
                   (Double) newValue);
             } else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEBoolean()
                 || eFeature.getEType() == EcorePackage.eINSTANCE.getEBooleanObject()) {
               lowLevelInterface.setBooleanAttribute(
                   clientIfcModel.getTransactionId(),
                   idEObject.getOid(),
                   eFeature.getName(),
                   (Boolean) newValue);
             } else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEInt()
                 || eFeature.getEType() == EcorePackage.eINSTANCE.getEIntegerObject()) {
               lowLevelInterface.setIntegerAttribute(
                   clientIfcModel.getTransactionId(),
                   idEObject.getOid(),
                   eFeature.getName(),
                   (Integer) newValue);
             } else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEByteArray()) {
               lowLevelInterface.setByteArrayAttribute(
                   clientIfcModel.getTransactionId(),
                   idEObject.getOid(),
                   eFeature.getName(),
                   (Byte[]) newValue);
             } else if (eFeature.getEType() instanceof EEnum) {
               lowLevelInterface.setEnumAttribute(
                   clientIfcModel.getTransactionId(),
                   idEObject.getOid(),
                   eFeature.getName(),
                   ((Enum<?>) newValue).toString());
             } else if (eFeature instanceof EReference) {
               if (newValue == null) {
                 lowLevelInterface.setReference(
                     clientIfcModel.getTransactionId(),
                     idEObject.getOid(),
                     eFeature.getName(),
                     -1L);
               } else {
                 lowLevelInterface.setReference(
                     clientIfcModel.getTransactionId(),
                     idEObject.getOid(),
                     eFeature.getName(),
                     ((IdEObject) newValue).getOid());
               }
             } else {
               throw new RuntimeException(
                   "Unimplemented " + eFeature.getEType().getName() + " " + newValue);
             }
           }
         }
       } catch (ServiceException e) {
         LOGGER.error("", e);
       } catch (PublicInterfaceNotFoundException e) {
         LOGGER.error("", e);
       }
     }
   } else {
     if (clientIfcModel.getModelState() != ModelState.LOADING) {
       try {
         Bimsie1LowLevelInterface lowLevelInterface =
             clientIfcModel.getBimServerClient().getBimsie1LowLevelInterface();
         if (newValue instanceof String) {
           lowLevelInterface.setStringAttributeAtIndex(
               clientIfcModel.getTransactionId(),
               idEObject.getOid(),
               eFeature.getName(),
               index,
               (String) newValue);
         } else if (newValue instanceof Double) {
           lowLevelInterface.setDoubleAttributeAtIndex(
               clientIfcModel.getTransactionId(),
               idEObject.getOid(),
               eFeature.getName(),
               index,
               (Double) newValue);
         } else if (newValue instanceof Boolean) {
           lowLevelInterface.setBooleanAttributeAtIndex(
               clientIfcModel.getTransactionId(),
               idEObject.getOid(),
               eFeature.getName(),
               index,
               (Boolean) newValue);
         } else if (newValue instanceof Integer) {
           lowLevelInterface.setIntegerAttributeAtIndex(
               clientIfcModel.getTransactionId(),
               idEObject.getOid(),
               eFeature.getName(),
               index,
               (Integer) newValue);
         } else if (newValue instanceof IdEObject) {
           lowLevelInterface.addReference(
               clientIfcModel.getTransactionId(),
               idEObject.getOid(),
               eFeature.getName(),
               ((IdEObject) newValue).getOid());
         } else {
           throw new RuntimeException(
               "Unimplemented " + eFeature.getEType().getName() + " " + newValue);
         }
       } catch (ServerException e) {
         LOGGER.error("", e);
       } catch (UserException e) {
         LOGGER.error("", e);
       } catch (PublicInterfaceNotFoundException e) {
         LOGGER.error("", e);
       }
     }
   }
   return super.set(eObject, eFeature, index, newValue);
 }
コード例 #8
0
  @SuppressWarnings("unchecked")
  @Override
  public Set<T> execute()
      throws UserException, BimserverLockConflictException, BimserverDatabaseException {
    Map<Long, Revision> oidToRoidMap = new HashMap<Long, Revision>();

    // Look in the cache
    Set<EidClash> clashDetections =
        bimServer.getClashDetectionCache().getClashDetection(clashDetectionSettings);
    if (clashDetections != null) {
      return (Set<T>) clashDetections;
    }

    Project project = null;
    IfcModelSet ifcModelSet = new IfcModelSet();
    for (Revision revision : clashDetectionSettings.getRevisions()) {
      project = revision.getProject();
      for (ConcreteRevision concreteRevision : revision.getConcreteRevisions()) {
        IfcModel source = new IfcModel();
        getDatabaseSession()
            .getMap(
                source,
                concreteRevision.getProject().getId(),
                concreteRevision.getId(),
                true,
                null);
        source.setDate(concreteRevision.getDate());
        ifcModelSet.add(source);
        for (Long oid : source.keySet()) {
          oidToRoidMap.put(oid, revision);
        }
      }
    }
    IfcModelInterface ifcModel =
        bimServer.getMergerFactory().createMerger().merge(project, ifcModelSet, false);
    IfcModel newModel = new IfcModel();
    Map<IdEObject, IdEObject> converted = new HashMap<IdEObject, IdEObject>();
    for (IdEObject idEObject : ifcModel.getValues()) {
      if (!clashDetectionSettings.getIgnoredClasses().contains(idEObject.eClass().getName())) {
        cleanupModel(idEObject.eClass(), idEObject, newModel, ifcModel, converted);
      }
    }
    Collection<SerializerPlugin> allSerializerPlugins =
        bimServer.getPluginManager().getAllSerializerPlugins("application/ifc", true);
    if (!allSerializerPlugins.isEmpty()) {
      SerializerPlugin serializerPlugin = allSerializerPlugins.iterator().next();
      EmfSerializer ifcSerializer = serializerPlugin.createSerializer();
      try {
        try {
          ifcSerializer.init(
              newModel,
              null,
              bimServer.getPluginManager(),
              bimServer.getPluginManager().requireIfcEngine().createIfcEngine());
          byte[] bytes = ifcSerializer.getBytes();
          Plugin plugin =
              bimServer
                  .getPluginManager()
                  .getPlugin("org.bimserver.ifcengine.TNOIfcEnginePlugin", true);
          if (plugin != null && plugin instanceof IfcEnginePlugin) {
            IfcEnginePlugin ifcEnginePlugin = (IfcEnginePlugin) plugin;
            IfcEngine ifcEngine = ifcEnginePlugin.createIfcEngine();
            ifcEngine.init();
            IfcEngineModel ifcEngineModel = ifcEngine.openModel(bytes);
            try {
              Set<IfcEngineClash> clashes =
                  ifcEngineModel.findClashesWithEids(clashDetectionSettings.getMargin());

              Set<EidClash> eidClashes = new HashSet<EidClash>();
              for (IfcEngineClash clash : clashes) {
                EidClash eidClash = StoreFactory.eINSTANCE.createEidClash();
                eidClash.setEid1(clash.getEid1());
                eidClash.setEid2(clash.getEid2());
                eidClash.setName1(clash.getName1());
                eidClash.setName2(clash.getName2());
                eidClash.setType1(clash.getType1());
                eidClash.setType2(clash.getType2());
                eidClashes.add(eidClash);
              }

              // Store in cache
              bimServer
                  .getClashDetectionCache()
                  .storeClashDetection(clashDetectionSettings, eidClashes);

              for (EidClash clash : eidClashes) {
                IfcRoot object1 = (IfcRoot) newModel.get(clash.getEid1());
                clash.setName1(object1.getName());
                clash.setType1(object1.eClass().getName());
                clash.setRevision1(oidToRoidMap.get(clash.getEid1()));
                IfcRoot object2 = (IfcRoot) newModel.get(clash.getEid2());
                clash.setName2(object2.getName());
                clash.setType2(object2.eClass().getName());
                clash.setRevision2(oidToRoidMap.get(clash.getEid2()));
              }
              return (Set<T>) eidClashes;
            } finally {
              ifcEngineModel.close();
              ifcEngine.close();
            }
          }
        } catch (PluginException e) {
          LOGGER.error("", e);
        }
      } catch (SerializerException e) {
        LOGGER.error("", e);
      }
    }
    return null;
  }
コード例 #9
0
 @SuppressWarnings("unchecked")
 private IdEObject cleanupModel(
     EClass originalEClass,
     IdEObject original,
     IfcModelInterface newModel,
     IfcModelInterface ifcModel,
     Map<IdEObject, IdEObject> converted)
     throws UserException {
   if (converted.containsKey(original)) {
     return converted.get(original);
   }
   IdEObject newObject =
       (IdEObject) original.eClass().getEPackage().getEFactoryInstance().create(original.eClass());
   ((IdEObjectImpl) newObject).setOid(original.getOid());
   converted.put(original, newObject);
   if (!(newObject instanceof WrappedValue) && !(newObject instanceof IfcGloballyUniqueId)) {
     newModel.add(newObject.getOid(), newObject);
   }
   ObjectIDM objectIDM;
   try {
     objectIDM = bimServer.getPluginManager().requireObjectIDM();
   } catch (ObjectIDMException e) {
     throw new UserException(e);
   }
   for (EStructuralFeature eStructuralFeature : original.eClass().getEAllStructuralFeatures()) {
     if (objectIDM.shouldFollowReference(originalEClass, original.eClass(), eStructuralFeature)) {
       Object get = original.eGet(eStructuralFeature);
       if (eStructuralFeature instanceof EAttribute) {
         if (get instanceof Double) {
           EStructuralFeature doubleStringFeature =
               original.eClass().getEStructuralFeature("wrappedValueAsString");
           if (doubleStringFeature != null) {
             Object doubleString = original.eGet(doubleStringFeature);
             newObject.eSet(doubleStringFeature, doubleString);
           } else {
             newObject.eSet(eStructuralFeature, get);
           }
         } else {
           newObject.eSet(eStructuralFeature, get);
         }
       } else if (eStructuralFeature instanceof EReference) {
         if (get == null) {
         } else {
           if (eStructuralFeature.isMany()) {
             BasicEList<EObject> list = (BasicEList<EObject>) get;
             BasicEList<EObject> toList = (BasicEList<EObject>) newObject.eGet(eStructuralFeature);
             for (Object o : list) {
               if (converted.containsKey(o)) {
                 toList.addUnique(converted.get(o));
               } else {
                 IdEObject result =
                     cleanupModel(originalEClass, (IdEObject) o, newModel, ifcModel, converted);
                 if (result != null) {
                   toList.addUnique(result);
                 }
               }
             }
           } else {
             if (converted.containsKey(get)) {
               newObject.eSet(eStructuralFeature, converted.get(get));
             } else {
               newObject.eSet(
                   eStructuralFeature,
                   cleanupModel(originalEClass, (IdEObject) get, newModel, ifcModel, converted));
             }
           }
         }
       }
     }
   }
   return newObject;
 }