use of org.bimserver.models.ifc2x3tc1.IfcRelAssociates in project BIMserver by opensourceBIM.
the class IfcUtils method getMaterial.
public static String getMaterial(IfcProduct ifcProduct) {
Set<IfcMaterial> materials = new HashSet<>();
for (IfcRelAssociates ifcRelAssociates : ifcProduct.getHasAssociations()) {
if (ifcRelAssociates instanceof IfcRelAssociatesMaterial) {
IfcRelAssociatesMaterial ifcRelAssociatesMaterial = (IfcRelAssociatesMaterial) ifcRelAssociates;
IfcMaterialSelect relatingMaterial = ifcRelAssociatesMaterial.getRelatingMaterial();
if (relatingMaterial instanceof IfcMaterial) {
materials.add((IfcMaterial) relatingMaterial);
} else if (relatingMaterial instanceof IfcMaterialLayerSetUsage) {
IfcMaterialLayerSetUsage ifcMaterialLayerSetUsage = (IfcMaterialLayerSetUsage) relatingMaterial;
IfcMaterialLayerSet forLayerSet = ifcMaterialLayerSetUsage.getForLayerSet();
for (IfcMaterialLayer ifcMaterialLayer : forLayerSet.getMaterialLayers()) {
IfcMaterial material = ifcMaterialLayer.getMaterial();
materials.add(material);
}
} else if (relatingMaterial instanceof IfcMaterialList) {
materials.addAll(((IfcMaterialList) relatingMaterial).getMaterials());
} else if (relatingMaterial instanceof IfcMaterialLayerSet) {
for (IfcMaterialLayer ifcMaterialLayer : ((IfcMaterialLayerSet) relatingMaterial).getMaterialLayers()) {
materials.add(ifcMaterialLayer.getMaterial());
}
} else {
throw new UnsupportedOperationException(relatingMaterial.toString());
}
}
}
Iterator<IfcMaterial> iterator = materials.iterator();
while (iterator.hasNext()) {
IfcMaterial next = iterator.next();
if (next == null || next.getName() == null) {
iterator.remove();
}
}
return Joiner.on(", ").join(materials.stream().map(new Function<IfcMaterial, String>() {
@Override
public String apply(IfcMaterial input) {
return input.getName();
}
}).iterator());
}
use of org.bimserver.models.ifc2x3tc1.IfcRelAssociates in project BIMserver by opensourceBIM.
the class TestGetMaterials method getMaterials.
public static Set<IfcMaterial> getMaterials(IfcProduct ifcProduct) {
Set<IfcMaterial> materials = new HashSet<>();
for (IfcRelAssociates ifcRelAssociates : ifcProduct.getHasAssociations()) {
if (ifcRelAssociates instanceof IfcRelAssociatesMaterial) {
IfcRelAssociatesMaterial ifcRelAssociatesMaterial = (IfcRelAssociatesMaterial) ifcRelAssociates;
IfcMaterialSelect relatingMaterial = ifcRelAssociatesMaterial.getRelatingMaterial();
// System.out.println(relatingMaterial);
if (relatingMaterial instanceof IfcMaterial) {
materials.add((IfcMaterial) relatingMaterial);
} else if (relatingMaterial instanceof IfcMaterialLayerSetUsage) {
IfcMaterialLayerSetUsage ifcMaterialLayerSetUsage = (IfcMaterialLayerSetUsage) relatingMaterial;
IfcMaterialLayerSet forLayerSet = ifcMaterialLayerSetUsage.getForLayerSet();
if (forLayerSet != null) {
for (IfcMaterialLayer ifcMaterialLayer : forLayerSet.getMaterialLayers()) {
IfcMaterial material = ifcMaterialLayer.getMaterial();
materials.add(material);
}
}
} else if (relatingMaterial instanceof IfcMaterialList) {
materials.addAll(((IfcMaterialList) relatingMaterial).getMaterials());
} else if (relatingMaterial instanceof IfcMaterialLayerSet) {
for (IfcMaterialLayer ifcMaterialLayer : ((IfcMaterialLayerSet) relatingMaterial).getMaterialLayers()) {
materials.add(ifcMaterialLayer.getMaterial());
}
} else {
throw new UnsupportedOperationException(relatingMaterial.toString());
}
}
}
Iterator<IfcMaterial> iterator = materials.iterator();
while (iterator.hasNext()) {
IfcMaterial next = iterator.next();
if (next == null || next.getName() == null) {
System.out.println(next.getOid());
iterator.remove();
}
}
if (materials.size() > 0) {
System.out.println(ifcProduct.eClass().getName() + ": " + Joiner.on(", ").join(materials));
}
return new HashSet<>(materials);
}
Aggregations