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(); }
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 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; }