public String getObjectIdentifier(IfcProduct ifcProduct) { if (ifcProduct == null) { return "No object"; } String name = ifcProduct.getName(); if (name != null && !name.trim().equals("")) { return name; } String guid = ifcProduct.getGlobalId(); if (guid != null && !guid.trim().equals("")) { return guid; } return ifcProduct.eClass().getName() + " " + ifcProduct.getOid(); }
public Set<GeometryData> getMatchingGeometry(IfcProduct ifcProduct, GeometryData geometryData) { Set<GeometryData> result = new HashSet<>(); Map<Integer, Set<GeometryData>> ofType = data.get(ifcProduct.eClass()); if (ofType != null) { Set<GeometryData> set = ofType.get(geometryData.getVertices().getData().length); if (set != null) { for (GeometryData d : set) { if (d != ifcProduct.getGeometry().getData()) { if (matchExactlyTheSame(geometryData, d)) { result.add(d); } else if (matchSameOrder(geometryData, d)) { result.add(d); // } else if (matchTotalDistance(geometryData, d)) { // return d; } } } } } return result; }
public static int getNrOfRelations(IfcProduct product) { return product.getDecomposes().size() + product.getHasAssignments().size() + product.getHasAssociations().size() + product.getIsDecomposedBy().size() + product.getReferencedBy().size() + product.getIsDefinedBy().size(); }
private ObjectNode objectToJson(IdEObject idEObject) { ObjectNode objectNode = OBJECT_MAPPER.createObjectNode(); if (idEObject.getOid() != -1) { objectNode.put("oid", idEObject.getOid()); } if (idEObject instanceof IfcProduct) { IfcProduct ifcProduct = (IfcProduct)idEObject; if (ifcProduct.getName() != null) { objectNode.put("name", ifcProduct.getName()); } if (ifcProduct.getGlobalId() != null) { objectNode.put("guid", ifcProduct.getGlobalId()); } } return objectNode; }
public void setColor(IfcProduct product, double[] color, float transparency) throws IfcModelInterfaceException { if (!productToStyledItem.containsKey(product) || productToStyledItem.get(product).isEmpty()) { System.out.println("No style for " + product + " " + product.getGlobalId()); IfcProductRepresentation productRepresentation = product.getRepresentation(); if (product.getRepresentation() == null) { productRepresentation = model.create(IfcProductRepresentation.class); product.setRepresentation(productRepresentation);
public Area get2D(IfcProduct ifcProduct, double multiplierMillimeters) { IfcObjectPlacement objectPlacement = ifcProduct.getObjectPlacement(); double[] productMatrix = placementToMatrix(objectPlacement); IfcProductRepresentation representation = ifcProduct.getRepresentation(); if (representation == null) { return null; GeometryInfo geometry = ifcProduct.getGeometry(); if (geometry != null) { GeometryData geometryData = geometry.getData();
public ModelColorizer(IfcModelInterface model) { this.model = model; for (IfcProduct product : model.getAllWithSubTypes(IfcProduct.class)) { IfcProductRepresentation productRepresentation = product.getRepresentation(); if (productRepresentation != null) { if (productRepresentation instanceof IfcProductDefinitionShape) {
private void calculateExtents(String id, IfcProduct ifcObject) throws RenderEngineException, SerializerException { if (!geometryExtents.containsKey(id)) { geometryExtents.put(id, new Extends()); } Extends extents = geometryExtents.get(id); GeometryInfo geometryInfo = ifcObject.getGeometry(); if (geometryInfo != null) { extents.integrate(geometryInfo); sceneExtends.addToMinExtents(extents.min); sceneExtends.addToMaxExtents(extents.max); } } }
public static int getNrOfPropertySets(IfcProduct ifcProduct) { int nrPropertySets = 0; for (IfcRelDefines ifcRelDefines : ifcProduct.getIsDefinedBy()) { if (ifcRelDefines instanceof IfcRelDefinesByProperties) { IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines; IfcPropertySetDefinition propertySetDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition(); if (propertySetDefinition instanceof IfcPropertySet) { nrPropertySets++; } } } return nrPropertySets; }
public void add(IfcProduct ifcProduct, GeometryData geometryData) { Map<Integer, Set<GeometryData>> ofType = data.get(ifcProduct.eClass()); if (ofType == null) { ofType = new HashMap<>(); data.put(ifcProduct.eClass(), ofType); } Set<GeometryData> set = ofType.get(geometryData.getVertices().getData().length); if (set == null) { set = new HashSet<GeometryData>(); ofType.put(geometryData.getVertices().getData().length, set); } set.add(geometryData); }
protected void calculateGeometryExtents() throws RenderEngineException, SerializerException { for (IfcProduct ifcProduct : model.getAllWithSubTypes(IfcProduct.class)) { try { calculateExtents(ifcProduct.getGlobalId(), ifcProduct); } catch (Exception e) { LoggerFactory.getLogger(AbstractGeometrySerializer.class).error("", e); } } }
public static IfcBuildingStorey getIfcBuildingStorey(IfcProduct ifcProduct) { if (ifcProduct instanceof IfcBuildingStorey) { return (IfcBuildingStorey) ifcProduct; } for (IfcRelDecomposes ifcRelDecomposes : ifcProduct.getDecomposes()) { IfcObjectDefinition relatingObject = ifcRelDecomposes.getRelatingObject(); if (relatingObject instanceof IfcBuildingStorey) { return (IfcBuildingStorey) relatingObject; } } if (ifcProduct instanceof IfcElement) { IfcElement ifcElement = (IfcElement) ifcProduct; for (IfcRelContainedInSpatialStructure ifcRelContainedInSpatialStructure : ifcElement.getContainedInStructure()) { IfcSpatialStructureElement relatingStructure = ifcRelContainedInSpatialStructure.getRelatingStructure(); if (relatingStructure instanceof IfcBuildingStorey) { return (IfcBuildingStorey) relatingStructure; } else { if (relatingStructure instanceof IfcSpace) { return getIfcBuildingStorey(relatingStructure); } } } } return null; }
public static String getMaterial(IfcProduct ifcProduct) { Set<IfcMaterial> materials = new HashSet<>(); for (IfcRelAssociates ifcRelAssociates : ifcProduct.getHasAssociations()) { if (ifcRelAssociates instanceof IfcRelAssociatesMaterial) { IfcRelAssociatesMaterial ifcRelAssociatesMaterial = (IfcRelAssociatesMaterial) ifcRelAssociates;
Collection<IfcProduct> products = model.getCollection(IfcProduct.class); for(IfcProduct product: products){ List<IfcRepresentation> representations = product.getRepresentation().getRepresentations(); assert ! representations.isEmpty(); assert representations.get(0) instanceof IfcShapeRepresentation: Collection<IfcRepresentationItem> repr = representations.get(0).getItems(); assert !repr.isEmpty(); IfcRepresentationItem representationItem = repr.iterator().next(); assert representationItem instanceof IfcFacetedBrep; for(IfcFace face: ((IfcFacetedBrep)representationItem).getOuter().getCfsFaces()){ for(IfcFaceBound faceBound: face.getBounds()){ IfcLoop loop = faceBound.getBound(); assert loop instanceof IfcPolyLoop; for(IfcCartesianPoint point: ((IfcPolyLoop) loop).getPolygon()){ point.getCoordinates(); } } } }
@Override public Double execute() throws UserException, BimserverDatabaseException, BimserverLockConflictException { Revision revision = getDatabaseSession().get(roid, OldQuery.getDefault()); IfcProduct ifcProduct = getDatabaseSession().get(oid, new OldQuery(bimServer.getMetaDataManager().getPackageMetaData(revision.getProject().getSchema()), revision.getProject().getId(), revision.getId(), revision.getOid())); return ifcProduct.getGeometry().getArea(); } }
public static List<String> listElementQuantities(IfcProduct ifcProduct) { List<String> list = new ArrayList<>(); for (IfcRelDefines ifcRelDefines : ifcProduct.getIsDefinedBy()) { if (ifcRelDefines instanceof IfcRelDefinesByProperties) { IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines; IfcPropertySetDefinition propertySetDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition(); if (propertySetDefinition instanceof IfcElementQuantity) { IfcElementQuantity ifcElementQuantity = (IfcElementQuantity) propertySetDefinition; list.add(ifcElementQuantity.getName()); } } } return list; }
public static IfcProject getIfcProject(IfcProduct ifcProduct) { if (ifcProduct instanceof IfcProject) { return (IfcProject) ifcProduct; } for (IfcRelDecomposes ifcRelDecomposes : ifcProduct.getDecomposes()) { IfcObjectDefinition relatingObject = ifcRelDecomposes.getRelatingObject(); if (relatingObject instanceof IfcProject) { return (IfcProject) relatingObject; } else if (relatingObject instanceof IfcProduct) { return getIfcProject((IfcProduct) relatingObject); } } if (ifcProduct instanceof IfcElement) { IfcElement ifcElement = (IfcElement) ifcProduct; for (IfcRelContainedInSpatialStructure ifcRelContainedInSpatialStructure : ifcElement.getContainedInStructure()) { IfcSpatialStructureElement relatingStructure = ifcRelContainedInSpatialStructure.getRelatingStructure(); if (relatingStructure instanceof IfcProject) { return (IfcProject) relatingStructure; } else if (relatingStructure instanceof IfcBuildingStorey) { return getIfcProject(relatingStructure); } else { if (relatingStructure instanceof IfcSpace) { return getIfcProject(relatingStructure); } } } } return null; }
@Override public Double execute() throws UserException, BimserverDatabaseException, BimserverLockConflictException { Revision revision = getDatabaseSession().get(roid, OldQuery.getDefault()); IfcProduct ifcProduct = getDatabaseSession().get(oid, new OldQuery(bimServer.getMetaDataManager().getPackageMetaData(revision.getProject().getSchema()), revision.getProject().getId(), revision.getId(), revision.getOid())); return ifcProduct.getGeometry().getVolume(); } }
public static int getNrOfProperties(IfcProduct ifcProduct) { int nrProperties = 0; for (IfcRelDefines ifcRelDefines : ifcProduct.getIsDefinedBy()) { if (ifcRelDefines instanceof IfcRelDefinesByProperties) { IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines; IfcPropertySetDefinition propertySetDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition(); if (propertySetDefinition instanceof IfcPropertySet) { IfcPropertySet ifcPropertySet = (IfcPropertySet) propertySetDefinition; nrProperties += ifcPropertySet.getHasProperties().size(); } } } return nrProperties; }
public static Set<String> listPropertyNames(IfcProduct ifcProduct) { Set<String> list = new HashSet<>(); for (IfcRelDefines ifcRelDefines : ifcProduct.getIsDefinedBy()) { if (ifcRelDefines instanceof IfcRelDefinesByProperties) { IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines; IfcPropertySetDefinition propertySetDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition(); if (propertySetDefinition instanceof IfcPropertySet) { IfcPropertySet ifcPropertySet = (IfcPropertySet) propertySetDefinition; for (IfcProperty ifcProperty : ifcPropertySet.getHasProperties()) { list.add(ifcProperty.getName()); } } } } return list; }