Search in sources :

Example 6 with IfcProduct

use of org.bimserver.models.ifc2x3tc1.IfcProduct in project BIMserver by opensourceBIM.

the class GetVolumeDatabaseAction method execute.

@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();
}
Also used : Revision(org.bimserver.models.store.Revision) IfcProduct(org.bimserver.models.ifc2x3tc1.IfcProduct) OldQuery(org.bimserver.database.OldQuery)

Example 7 with IfcProduct

use of org.bimserver.models.ifc2x3tc1.IfcProduct in project BIMserver by opensourceBIM.

the class IfcTools2D method get2D.

public Area get2D(IfcProduct ifcProduct, double multiplierMillimeters) {
    IfcObjectPlacement objectPlacement = ifcProduct.getObjectPlacement();
    double[] productMatrix = placementToMatrix(objectPlacement);
    // Matrix.dump(productMatrix);
    IfcProductRepresentation representation = ifcProduct.getRepresentation();
    if (representation == null) {
        return null;
    }
    for (IfcRepresentation ifcRepresentation : representation.getRepresentations()) {
        if ("Curve2D".equals(ifcRepresentation.getRepresentationType())) {
        // Skip
        } else {
            if (ifcRepresentation instanceof IfcShapeRepresentation) {
                IfcShapeRepresentation ifcShapeRepresentation = (IfcShapeRepresentation) ifcRepresentation;
                for (IfcRepresentationItem ifcRepresentationItem : ifcShapeRepresentation.getItems()) {
                    Area area = getArea(multiplierMillimeters, productMatrix, ifcRepresentationItem);
                    if (area != null && area.getPathIterator(null).isDone()) {
                        return area;
                    }
                }
            }
        }
    }
    // Fall back to 3D geometry projected from the top
    GeometryInfo geometry = ifcProduct.getGeometry();
    if (geometry != null) {
        GeometryData geometryData = geometry.getData();
        if (geometryData != null) {
            int[] indices = GeometryUtils.toIntegerArray(geometryData.getIndices());
            float[] vertices = GeometryUtils.toFloatArray(geometryData.getVertices());
            float[] matrix = GeometryUtils.toFloatArray(GeometryUtils.toDoubleArray(geometry.getTransformation()));
            Area area = new Area();
            for (int i = 0; i < indices.length; i += 3) {
                int index1 = indices[i + 0];
                int index2 = indices[i + 1];
                int index3 = indices[i + 2];
                float[] a = new float[] { vertices[index1 * 3], vertices[index1 * 3 + 1], vertices[index1 * 3 + 2] };
                float[] b = new float[] { vertices[index2 * 3], vertices[index2 * 3 + 1], vertices[index2 * 3 + 2] };
                float[] c = new float[] { vertices[index3 * 3], vertices[index3 * 3 + 1], vertices[index3 * 3 + 2] };
                float[][] points = new float[][] { a, b, c };
                // if (similar(a[2], b[2], c[2])) {
                boolean first = true;
                Path2D.Float path = new Path2D.Float();
                for (int j = 0; j < 3; j++) {
                    float[] point = points[j];
                    float[] res = new float[4];
                    Matrix.multiplyMV(res, 0, matrix, 0, new float[] { point[0], point[1], point[2], 1 }, 0);
                    // * multiplierMillimeters
                    float x = (float) (res[0]);
                    // * multiplierMillimeters
                    float y = (float) (res[1]);
                    if (first) {
                        path.moveTo(x, y);
                        first = false;
                    } else {
                        path.lineTo(x, y);
                    }
                }
                path.closePath();
                area.add(new Area(path));
            // }
            }
            return area;
        }
    } else {
        LOGGER.info("No geometry generated for " + ifcProduct);
    }
    return null;
}
Also used : IfcRepresentationItem(org.bimserver.models.ifc2x3tc1.IfcRepresentationItem) Path2D(java.awt.geom.Path2D) GeometryData(org.bimserver.models.geometry.GeometryData) IfcObjectPlacement(org.bimserver.models.ifc2x3tc1.IfcObjectPlacement) IfcCartesianPoint(org.bimserver.models.ifc2x3tc1.IfcCartesianPoint) Area(java.awt.geom.Area) IfcProductRepresentation(org.bimserver.models.ifc2x3tc1.IfcProductRepresentation) GeometryInfo(org.bimserver.models.geometry.GeometryInfo) IfcShapeRepresentation(org.bimserver.models.ifc2x3tc1.IfcShapeRepresentation) IfcRepresentation(org.bimserver.models.ifc2x3tc1.IfcRepresentation)

Example 8 with IfcProduct

use of org.bimserver.models.ifc2x3tc1.IfcProduct in project BIMserver by opensourceBIM.

the class IfcUtils method listPropertyNames.

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;
}
Also used : IfcProperty(org.bimserver.models.ifc2x3tc1.IfcProperty) IfcRelDefinesByProperties(org.bimserver.models.ifc2x3tc1.IfcRelDefinesByProperties) IfcPropertySet(org.bimserver.models.ifc2x3tc1.IfcPropertySet) IfcPropertySetDefinition(org.bimserver.models.ifc2x3tc1.IfcPropertySetDefinition) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) IfcRelDefines(org.bimserver.models.ifc2x3tc1.IfcRelDefines)

Example 9 with IfcProduct

use of org.bimserver.models.ifc2x3tc1.IfcProduct in project BIMserver by opensourceBIM.

the class IfcUtils method getIfcQuantityVolume.

public static Double getIfcQuantityVolume(IfcProduct ifcProduct, String name) {
    for (IfcRelDefines ifcRelDefines : ifcProduct.getIsDefinedBy()) {
        if (ifcRelDefines instanceof IfcRelDefinesByProperties) {
            IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines;
            IfcPropertySetDefinition propertySetDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition();
            if (propertySetDefinition instanceof IfcElementQuantity) {
                if (propertySetDefinition.getName().equals("BaseQuantities")) {
                    IfcElementQuantity ifcElementQuantity = (IfcElementQuantity) propertySetDefinition;
                    for (IfcPhysicalQuantity ifcPhysicalQuantity : ifcElementQuantity.getQuantities()) {
                        if (ifcPhysicalQuantity instanceof IfcQuantityVolume) {
                            return ((IfcQuantityVolume) ifcPhysicalQuantity).getVolumeValue();
                        }
                    }
                }
            }
        }
    }
    return null;
}
Also used : IfcQuantityVolume(org.bimserver.models.ifc2x3tc1.IfcQuantityVolume) IfcElementQuantity(org.bimserver.models.ifc2x3tc1.IfcElementQuantity) IfcPhysicalQuantity(org.bimserver.models.ifc2x3tc1.IfcPhysicalQuantity) IfcRelDefinesByProperties(org.bimserver.models.ifc2x3tc1.IfcRelDefinesByProperties) IfcPropertySetDefinition(org.bimserver.models.ifc2x3tc1.IfcPropertySetDefinition) IfcRelDefines(org.bimserver.models.ifc2x3tc1.IfcRelDefines)

Example 10 with IfcProduct

use of org.bimserver.models.ifc2x3tc1.IfcProduct in project BIMserver by opensourceBIM.

the class RichIfcModel method addContains.

public void addContains(IfcSpatialStructureElement parent, IfcProduct... children) throws IfcModelInterfaceException {
    IfcRelContainedInSpatialStructure rel = this.create(IfcRelContainedInSpatialStructure.class);
    rel.setRelatingStructure(parent);
    for (IfcProduct child : children) {
        rel.getRelatedElements().add(child);
    }
}
Also used : IfcRelContainedInSpatialStructure(org.bimserver.models.ifc2x3tc1.IfcRelContainedInSpatialStructure) IfcProduct(org.bimserver.models.ifc2x3tc1.IfcProduct)

Aggregations

IfcProduct (org.bimserver.models.ifc2x3tc1.IfcProduct)8 GeometryInfo (org.bimserver.models.geometry.GeometryInfo)4 HashSet (java.util.HashSet)3 GeometryData (org.bimserver.models.geometry.GeometryData)3 IfcProductRepresentation (org.bimserver.models.ifc2x3tc1.IfcProductRepresentation)3 IfcPropertySetDefinition (org.bimserver.models.ifc2x3tc1.IfcPropertySetDefinition)3 IfcRelDefines (org.bimserver.models.ifc2x3tc1.IfcRelDefines)3 IfcRelDefinesByProperties (org.bimserver.models.ifc2x3tc1.IfcRelDefinesByProperties)3 IfcRepresentation (org.bimserver.models.ifc2x3tc1.IfcRepresentation)3 IfcRepresentationItem (org.bimserver.models.ifc2x3tc1.IfcRepresentationItem)3 SerializerException (org.bimserver.plugins.serializers.SerializerException)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 ByteBuffer (java.nio.ByteBuffer)2 DoubleBuffer (java.nio.DoubleBuffer)2 FloatBuffer (java.nio.FloatBuffer)2 IntBuffer (java.nio.IntBuffer)2 OldQuery (org.bimserver.database.OldQuery)2 IfcElementQuantity (org.bimserver.models.ifc2x3tc1.IfcElementQuantity)2 IfcStyledItem (org.bimserver.models.ifc2x3tc1.IfcStyledItem)2