private void setIfcCartesianPoint(IdEObject idEObject, float scale) { IfcCartesianPoint ifcCartesianPoint = (IfcCartesianPoint) idEObject; EList<Double> coordinates = ifcCartesianPoint.getCoordinates(); for (int index = 0; index < coordinates.size(); index++) { coordinates.set(index, coordinates.get(index) * scale); } }
public IfcCartesianPoint createIfcCartesianPoint(double i, double j, double k) throws IfcModelInterfaceException { IfcCartesianPoint ifcCartesianPoint = create(IfcCartesianPoint.class); EList<Double> coordinates = ifcCartesianPoint.getCoordinates(); coordinates.add(i); coordinates.add(j); coordinates.add(k); return ifcCartesianPoint; }
/** * Not finished, does not take into account the directions * * @param ifcObjectPlacement * @return * @throws PlacementNotImplementedException */ public static double[] getAbsolutePosition(IfcObjectPlacement ifcObjectPlacement) throws PlacementNotImplementedException { if (ifcObjectPlacement instanceof IfcGridPlacement) { throw new PlacementNotImplementedException("IfcGridPlacement has not been implemented"); } else if (ifcObjectPlacement instanceof IfcLocalPlacement) { IfcLocalPlacement ifcLocalPlacement = (IfcLocalPlacement) ifcObjectPlacement; IfcAxis2Placement relativePlacement = ifcLocalPlacement.getRelativePlacement(); if (relativePlacement instanceof IfcAxis2Placement2D) { throw new PlacementNotImplementedException("IfcAxis2Placement2D has not been implemented"); } else if (relativePlacement instanceof IfcAxis2Placement3D) { IfcAxis2Placement3D ifcAxis2Placement3D = (IfcAxis2Placement3D) relativePlacement; IfcObjectPlacement placementRelativeTo = ifcLocalPlacement.getPlacementRelTo(); if (placementRelativeTo == null) { IfcCartesianPoint ifcCartesianPoint = ifcAxis2Placement3D.getLocation(); return new double[] { ifcCartesianPoint.getCoordinates().get(0), ifcCartesianPoint.getCoordinates().get(1), ifcCartesianPoint.getCoordinates().get(2) }; } else { double[] relative = getAbsolutePosition(placementRelativeTo); IfcCartesianPoint ifcCartesianPoint = ifcAxis2Placement3D.getLocation(); return new double[] { relative[0] + ifcCartesianPoint.getCoordinates().get(0), relative[1] + ifcCartesianPoint.getCoordinates().get(1), relative[2] + ifcCartesianPoint.getCoordinates().get(2) }; } } } return new double[] { 0d, 0d, 0d }; }
private static Path2D.Float curveToPath(double[] matrix, IfcCurve outerCurve, double multiplierMillimeters) { Path2D.Float path2d = new Path2D.Float(); if (outerCurve instanceof IfcPolyline) { IfcPolyline ifcPolyline = (IfcPolyline) outerCurve; IfcCartesianPoint first = ifcPolyline.getPoints().get(0); double[] res = new double[4]; Matrix.multiplyMV(res, 0, matrix, 0, new double[]{first.getCoordinates().get(0), first.getCoordinates().get(1), 0, 1}, 0); path2d.moveTo(res[0] * multiplierMillimeters, res[1] * multiplierMillimeters); for (IfcCartesianPoint cartesianPoint : ifcPolyline.getPoints()) { EList<Double> coords = cartesianPoint.getCoordinates(); Matrix.multiplyMV(res, 0, matrix, 0, new double[]{coords.get(0), coords.get(1), 0, 1}, 0); path2d.lineTo(res[0] * multiplierMillimeters, res[1] * multiplierMillimeters); } path2d.closePath(); return path2d; } return null; }
public static double[] placement3DToMatrix(IfcAxis2Placement3D ifcAxis2Placement3D) { if (ifcAxis2Placement3D.getAxis() != null && ifcAxis2Placement3D.getRefDirection() != null) { double[] cross = Vector.crossProduct(new double[]{ifcAxis2Placement3D.getAxis().getDirectionRatios().get(0), ifcAxis2Placement3D.getAxis().getDirectionRatios().get(1), ifcAxis2Placement3D.getAxis().getDirectionRatios().get(2), 1}, new double[]{ifcAxis2Placement3D.getRefDirection().getDirectionRatios().get(0), ifcAxis2Placement3D.getRefDirection().getDirectionRatios().get(1), ifcAxis2Placement3D.getRefDirection().getDirectionRatios().get(2), 1}); return new double[]{ ifcAxis2Placement3D.getRefDirection().getDirectionRatios().get(0), ifcAxis2Placement3D.getRefDirection().getDirectionRatios().get(1), ifcAxis2Placement3D.getRefDirection().getDirectionRatios().get(2), 0, cross[0], cross[1], cross[2], 0, ifcAxis2Placement3D.getAxis().getDirectionRatios().get(0), ifcAxis2Placement3D.getAxis().getDirectionRatios().get(1), ifcAxis2Placement3D.getAxis().getDirectionRatios().get(2), 0, ifcAxis2Placement3D.getLocation().getCoordinates().get(0), ifcAxis2Placement3D.getLocation().getCoordinates().get(1), ifcAxis2Placement3D.getLocation().getCoordinates().get(2), 1 }; } else if (ifcAxis2Placement3D.getLocation() != null) { return new double[]{ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, ifcAxis2Placement3D.getLocation().getCoordinates().get(0), ifcAxis2Placement3D.getLocation().getCoordinates().get(1), ifcAxis2Placement3D.getLocation().getCoordinates().get(2), 1 }; } return Matrix.identity(); }
EList<Double> coords = cartesianPoint.getCoordinates(); double[] res = new double[4]; for (IfcCartesianPoint cartesianPoint : ifcPolyline.getPoints()) { EList<Double> coords = cartesianPoint.getCoordinates(); IfcRectangleProfileDef ifcRectangleProfileDef = (IfcRectangleProfileDef) ifcProfileDef; double[] min = new double[]{ifcRectangleProfileDef.getPosition().getLocation().getCoordinates().get(0) - ifcRectangleProfileDef.getXDim() / 2, ifcRectangleProfileDef.getPosition().getLocation().getCoordinates().get(1) - ifcRectangleProfileDef.getYDim() / 2, 0, 1}; double[] max = new double[]{ifcRectangleProfileDef.getPosition().getLocation().getCoordinates().get(0) + ifcRectangleProfileDef.getXDim() / 2, ifcRectangleProfileDef.getPosition().getLocation().getCoordinates().get(1) + ifcRectangleProfileDef.getYDim() / 2, 0, 1}; EList<Double> coords = cartesianPoint.getCoordinates(); Matrix.multiplyMV(res, 0, productMatrix, 0, new double[]{coords.get(0), coords.get(1), 0, 1}, 0);
Matrix.translateM(tranformationMatrix, 0, ifcBoundingBox.getCorner().getCoordinates().get(0), ifcBoundingBox.getCorner().getCoordinates().get(1), ifcBoundingBox.getCorner().getCoordinates().get(2));
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(); } } } }