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