Search in sources :

Example 6 with IfcCartesianPoint

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

the class RichIfcModel method createRectangularExtrusionProductRepresentation.

public IfcProductRepresentation createRectangularExtrusionProductRepresentation(double width, double depth, double height) throws IfcModelInterfaceException {
    IfcPolyline ifcPolyline = create(IfcPolyline.class);
    EList<IfcCartesianPoint> points = ifcPolyline.getPoints();
    points.add(createIfcCartesianPoint(0, 0, 0));
    points.add(createIfcCartesianPoint(width, 0, 0));
    points.add(createIfcCartesianPoint(width, depth, 0));
    points.add(createIfcCartesianPoint(0, depth, 0));
    points.add(createIfcCartesianPoint(0, 0, 0));
    IfcArbitraryClosedProfileDef def = create(IfcArbitraryClosedProfileDef.class);
    def.setProfileType(IfcProfileTypeEnum.AREA);
    def.setOuterCurve(ifcPolyline);
    IfcExtrudedAreaSolid extrudedAreaSolid = create(IfcExtrudedAreaSolid.class);
    extrudedAreaSolid.setDepth(height);
    extrudedAreaSolid.setSweptArea(def);
    extrudedAreaSolid.setPosition(createBasicPosition(0, 0, 0));
    extrudedAreaSolid.setExtrudedDirection(createDirection(0, 0, 1));
    IfcProductRepresentation productRepresentation = create(IfcProductRepresentation.class);
    IfcShapeRepresentation shapeRepresentation = create(IfcShapeRepresentation.class);
    if (defaultRepresentationContext != null) {
        shapeRepresentation.setContextOfItems(defaultRepresentationContext);
    }
    shapeRepresentation.setRepresentationType("SweptSolid");
    shapeRepresentation.setRepresentationIdentifier("Body");
    shapeRepresentation.getItems().add(extrudedAreaSolid);
    productRepresentation.getRepresentations().add(shapeRepresentation);
    return productRepresentation;
}
Also used : IfcArbitraryClosedProfileDef(org.bimserver.models.ifc2x3tc1.IfcArbitraryClosedProfileDef) IfcProductRepresentation(org.bimserver.models.ifc2x3tc1.IfcProductRepresentation) IfcCartesianPoint(org.bimserver.models.ifc2x3tc1.IfcCartesianPoint) IfcShapeRepresentation(org.bimserver.models.ifc2x3tc1.IfcShapeRepresentation) IfcExtrudedAreaSolid(org.bimserver.models.ifc2x3tc1.IfcExtrudedAreaSolid) IfcPolyline(org.bimserver.models.ifc2x3tc1.IfcPolyline)

Example 7 with IfcCartesianPoint

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

the class TestMoveObject method test.

@Test
public void test() {
    try {
        // Create a new BimServerClient with authentication
        BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        // Create a new project
        SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
        // Get the appropriate deserializer
        SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid());
        // Checkin the file
        bimServerClient.checkinSync(newProject.getOid(), "test", deserializer.getOid(), false, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/AC11-Institute-Var-2-IFC.ifc"));
        // Refresh project info
        newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
        IfcModelInterface model = bimServerClient.getModel(newProject, newProject.getLastRevisionId(), true, true);
        for (IfcFurnishingElement ifcFurnishingElement : model.getAllWithSubTypes(IfcFurnishingElement.class)) {
            IfcObjectPlacement objectPlacement = ifcFurnishingElement.getObjectPlacement();
            if (objectPlacement != null && objectPlacement instanceof IfcLocalPlacement) {
                IfcLocalPlacement localPlacement = (IfcLocalPlacement) objectPlacement;
                IfcAxis2Placement relativePlacement = localPlacement.getRelativePlacement();
                if (relativePlacement != null) {
                    if (relativePlacement instanceof IfcAxis2Placement3D) {
                        IfcAxis2Placement3D axis2Placement3D = (IfcAxis2Placement3D) relativePlacement;
                        IfcCartesianPoint location = axis2Placement3D.getLocation();
                        double newValue = location.getCoordinates().get(2) + 50;
                        System.out.println("Changing z value of " + ifcFurnishingElement.getName() + " from " + location.getCoordinates().get(2) + " to " + newValue);
                        location.getCoordinates().set(2, newValue);
                    }
                }
            }
        }
        long newRoid = model.commit("Moved all furniture 50 meters up");
        SSerializerPluginConfiguration ifcSerializer = bimServerClient.getServiceInterface().getSerializerByContentType("application/ifc");
        bimServerClient.download(newRoid, ifcSerializer.getOid(), Paths.get("movedf.ifc"));
    } catch (Throwable e) {
        e.printStackTrace();
        if (e instanceof AssertionError) {
            throw (AssertionError) e;
        }
        fail(e.getMessage());
    }
}
Also used : SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) IfcFurnishingElement(org.bimserver.models.ifc2x3tc1.IfcFurnishingElement) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) IfcModelInterface(org.bimserver.emf.IfcModelInterface) SProject(org.bimserver.interfaces.objects.SProject) IfcObjectPlacement(org.bimserver.models.ifc2x3tc1.IfcObjectPlacement) URL(java.net.URL) IfcAxis2Placement3D(org.bimserver.models.ifc2x3tc1.IfcAxis2Placement3D) IfcLocalPlacement(org.bimserver.models.ifc2x3tc1.IfcLocalPlacement) IfcCartesianPoint(org.bimserver.models.ifc2x3tc1.IfcCartesianPoint) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) IfcAxis2Placement(org.bimserver.models.ifc2x3tc1.IfcAxis2Placement) Test(org.junit.Test)

Example 8 with IfcCartesianPoint

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

the class TestIfc4TwoDimensional2 method test.

@Test
public void test() throws Exception {
    try (JsonBimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080")) {
        try (BimServerClient client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"))) {
            SProject project = client.getServiceInterface().addProject(RandomStringUtils.randomAlphanumeric(10), "ifc4");
            SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
            Path path = Paths.get("../../TestFiles/TestData/data/ifc4add2tc1/basin-advanced-brep.ifc");
            SLongCheckinActionState actionState = client.checkinSync(project.getOid(), "test", deserializer.getOid(), path, (title, progress) -> System.out.println(title + ": " + progress));
            ClientIfcModel model = client.getModel(project, actionState.getRoid(), true, false);
            List<IfcBSplineCurveWithKnots> bSplineCurves = model.getAll(IfcBSplineCurveWithKnots.class);
            Assert.assertEquals(4, bSplineCurves.size());
            for (IfcBSplineCurveWithKnots bSplineCurve : bSplineCurves) {
                Assert.assertEquals(7, bSplineCurve.getControlPointsList().size());
                for (org.bimserver.models.ifc4.IfcCartesianPoint point : bSplineCurve.getControlPointsList()) {
                    Assert.assertNotNull(point);
                    Assert.assertTrue(point.getCoordinates().size() == 2 || point.getCoordinates().size() == 3);
                }
            }
            List<IfcBSplineSurfaceWithKnots> bSplineSurfaces = model.getAll(IfcBSplineSurfaceWithKnots.class);
            Assert.assertEquals(2, bSplineSurfaces.size());
            for (IfcBSplineSurfaceWithKnots bSplineSurface : bSplineSurfaces) {
                Assert.assertEquals(4, bSplineSurface.getControlPointsList().size());
                for (ListOfIfcCartesianPoint pointList : bSplineSurface.getControlPointsList()) {
                    // This assertion fails, error seems to be in client.
                    // 1st pointlist is of size 1, 2nd of size 2 and so on
                    // with duplication of the first point's coordinates
                    Assert.assertEquals(7, pointList.getList().size());
                    for (IfcCartesianPoint point : pointList.getList()) {
                        Assert.assertNotNull(point);
                        Assert.assertEquals(3, point.getCoordinates().size());
                    }
                }
            }
        }
        Thread.sleep(500);
    }
}
Also used : Path(java.nio.file.Path) ClientIfcModel(org.bimserver.client.ClientIfcModel) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) IfcBSplineSurfaceWithKnots(org.bimserver.models.ifc4.IfcBSplineSurfaceWithKnots) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) SLongCheckinActionState(org.bimserver.interfaces.objects.SLongCheckinActionState) IfcCartesianPoint(org.bimserver.models.ifc4.IfcCartesianPoint) SProject(org.bimserver.interfaces.objects.SProject) BimServerClient(org.bimserver.client.BimServerClient) ListOfIfcCartesianPoint(org.bimserver.models.ifc4.ListOfIfcCartesianPoint) IfcCartesianPoint(org.bimserver.models.ifc4.IfcCartesianPoint) ListOfIfcCartesianPoint(org.bimserver.models.ifc4.ListOfIfcCartesianPoint) IfcBSplineCurveWithKnots(org.bimserver.models.ifc4.IfcBSplineCurveWithKnots) Test(org.junit.Test)

Example 9 with IfcCartesianPoint

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

the class IfcTools2D method getArea.

private Area getArea(double multiplierMillimeters, double[] productMatrix, IfcRepresentationItem ifcRepresentationItem) {
    if (ifcRepresentationItem instanceof IfcExtrudedAreaSolid) {
        IfcExtrudedAreaSolid ifcExtrudedAreaSolid = (IfcExtrudedAreaSolid) ifcRepresentationItem;
        IfcAxis2Placement3D position = ifcExtrudedAreaSolid.getPosition();
        // 1 0 0 0 <- 3de argument
        // 0 1 0 0 <- cross product van 2 en 3 (levert ortogonale vector op)
        // 0 0 1 0 <- 2st argument
        // 5 0 0 1 <- 1st argument
        double[] matrix = placement3DToMatrix(position);
        if (productMatrix != null) {
            double[] rhs = matrix;
            matrix = Matrix.identity();
            Matrix.multiplyMM(matrix, 0, productMatrix, 0, rhs, 0);
        }
        IfcDirection extrudedDirection = ifcExtrudedAreaSolid.getExtrudedDirection();
        // TODO do something with this
        IfcProfileDef ifcProfileDef = ifcExtrudedAreaSolid.getSweptArea();
        if (ifcProfileDef instanceof IfcArbitraryProfileDefWithVoids) {
            IfcArbitraryProfileDefWithVoids ifcArbitraryProfileDefWithVoids = (IfcArbitraryProfileDefWithVoids) ifcProfileDef;
            IfcCurve outerCurve = ifcArbitraryProfileDefWithVoids.getOuterCurve();
            Path2D outerPath = null;
            if (outerCurve instanceof IfcPolyline) {
                outerPath = curveToPath(matrix, outerCurve, multiplierMillimeters);
            } else {
                storeUnimplemented(outerCurve);
            }
            if (outerPath != null) {
                Area area = new Area(outerPath);
                for (IfcCurve innerCurve : ifcArbitraryProfileDefWithVoids.getInnerCurves()) {
                    Path2D.Float innerPath = curveToPath(matrix, innerCurve, multiplierMillimeters);
                    if (innerPath != null) {
                        area.subtract(new Area(innerPath));
                    }
                }
                return area;
            }
        } else if (ifcProfileDef instanceof IfcArbitraryClosedProfileDef) {
            IfcArbitraryClosedProfileDef ifcArbitraryClosedProfileDef = (IfcArbitraryClosedProfileDef) ifcProfileDef;
            Path2D.Float path2d = new Path2D.Float();
            IfcCurve outerCurve = ifcArbitraryClosedProfileDef.getOuterCurve();
            boolean first = true;
            if (outerCurve instanceof IfcPolyline) {
                IfcPolyline ifcPolyline = (IfcPolyline) outerCurve;
                double[] res = new double[4];
                int i = 0;
                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);
                    if (first) {
                        path2d.moveTo(res[0] * multiplierMillimeters, res[1] * multiplierMillimeters);
                        first = false;
                    } else {
                        if (i > 1) {
                        }
                        path2d.lineTo(res[0] * multiplierMillimeters, res[1] * multiplierMillimeters);
                    }
                    i++;
                }
                path2d.closePath();
                return new Area(path2d);
            } else if (outerCurve instanceof IfcCompositeCurve) {
                IfcCompositeCurve ifcCompositeCurve = (IfcCompositeCurve) outerCurve;
                for (IfcCompositeCurveSegment ifcCompositeCurveSegment : ifcCompositeCurve.getSegments()) {
                    IfcCurve curve = ifcCompositeCurveSegment.getParentCurve();
                    if (curve instanceof IfcPolyline) {
                        IfcPolyline ifcPolyline = (IfcPolyline) curve;
                        double[] res = new double[4];
                        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);
                            if (first) {
                                path2d.moveTo(res[0] * multiplierMillimeters, res[1] * multiplierMillimeters);
                                first = false;
                            } else {
                                path2d.lineTo(res[0] * multiplierMillimeters, res[1] * multiplierMillimeters);
                            }
                        }
                    } else if (curve instanceof IfcTrimmedCurve) {
                        storeUnimplemented(curve);
                    } else {
                        storeUnimplemented(curve);
                    }
                }
                try {
                    path2d.closePath();
                    return new Area(path2d);
                } catch (Exception e) {
                // 
                }
            }
        } else if (ifcProfileDef instanceof IfcRectangleProfileDef) {
            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 };
            Cube cube = new Cube(min, max);
            cube.transform(matrix);
            double[] transformedMin = cube.getMin();
            double[] transformedMax = cube.getMax();
            Path2D.Float path2d = new Path2D.Float();
            path2d.moveTo(transformedMin[0] * multiplierMillimeters, transformedMin[1] * multiplierMillimeters);
            path2d.lineTo(transformedMax[0] * multiplierMillimeters, transformedMin[1] * multiplierMillimeters);
            path2d.lineTo(transformedMax[0] * multiplierMillimeters, transformedMax[1] * multiplierMillimeters);
            path2d.lineTo(transformedMin[0] * multiplierMillimeters, transformedMax[1] * multiplierMillimeters);
            path2d.lineTo(transformedMin[0] * multiplierMillimeters, transformedMin[1] * multiplierMillimeters);
            path2d.closePath();
            return new Area(path2d);
        } else {
            storeUnimplemented(ifcProfileDef);
        }
    } else if (ifcRepresentationItem instanceof IfcPolyline) {
        IfcPolyline ifcPolyline = (IfcPolyline) ifcRepresentationItem;
        double[] res = new double[4];
        Path2D.Float path2d = new Path2D.Float();
        boolean first = true;
        for (IfcCartesianPoint cartesianPoint : ifcPolyline.getPoints()) {
            EList<Double> coords = cartesianPoint.getCoordinates();
            Matrix.multiplyMV(res, 0, productMatrix, 0, new double[] { coords.get(0), coords.get(1), 0, 1 }, 0);
            if (first) {
                path2d.moveTo(res[0] * multiplierMillimeters, res[1] * multiplierMillimeters);
                first = false;
            } else {
                path2d.lineTo(res[0] * multiplierMillimeters, res[1] * multiplierMillimeters);
            }
        }
        path2d.closePath();
        return new Area(path2d);
    } else {
        storeUnimplemented(ifcRepresentationItem);
    }
    return null;
}
Also used : IfcCurve(org.bimserver.models.ifc2x3tc1.IfcCurve) IfcArbitraryClosedProfileDef(org.bimserver.models.ifc2x3tc1.IfcArbitraryClosedProfileDef) IfcRectangleProfileDef(org.bimserver.models.ifc2x3tc1.IfcRectangleProfileDef) IfcArbitraryProfileDefWithVoids(org.bimserver.models.ifc2x3tc1.IfcArbitraryProfileDefWithVoids) Path2D(java.awt.geom.Path2D) IfcTrimmedCurve(org.bimserver.models.ifc2x3tc1.IfcTrimmedCurve) IfcProfileDef(org.bimserver.models.ifc2x3tc1.IfcProfileDef) IfcPolyline(org.bimserver.models.ifc2x3tc1.IfcPolyline) Area(java.awt.geom.Area) EList(org.eclipse.emf.common.util.EList) IfcCompositeCurve(org.bimserver.models.ifc2x3tc1.IfcCompositeCurve) IfcAxis2Placement3D(org.bimserver.models.ifc2x3tc1.IfcAxis2Placement3D) IfcCompositeCurveSegment(org.bimserver.models.ifc2x3tc1.IfcCompositeCurveSegment) IfcCartesianPoint(org.bimserver.models.ifc2x3tc1.IfcCartesianPoint) IfcDirection(org.bimserver.models.ifc2x3tc1.IfcDirection) IfcExtrudedAreaSolid(org.bimserver.models.ifc2x3tc1.IfcExtrudedAreaSolid)

Example 10 with IfcCartesianPoint

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

the class IfcUtils method getBoundingBox3D.

public static AxisAlignedBoundingBox3D getBoundingBox3D(List<IfcCartesianPoint> points) throws GeometryException {
    AxisAlignedBoundingBox3D box3d = new AxisAlignedBoundingBox3D();
    for (IfcCartesianPoint ifcCartesianPoint : points) {
        EList<Double> coordinates = ifcCartesianPoint.getCoordinates();
        if (coordinates.size() < 2) {
            throw new GeometryException("Not enough dimensions (" + coordinates.size() + ") for 3D boundingbox");
        }
        box3d.process(coordinates);
    }
    return box3d;
}
Also used : AxisAlignedBoundingBox3D(org.bimserver.geometry.AxisAlignedBoundingBox3D) IfcCartesianPoint(org.bimserver.models.ifc2x3tc1.IfcCartesianPoint)

Aggregations

IfcCartesianPoint (org.bimserver.models.ifc2x3tc1.IfcCartesianPoint)11 IfcAxis2Placement3D (org.bimserver.models.ifc2x3tc1.IfcAxis2Placement3D)4 IfcExtrudedAreaSolid (org.bimserver.models.ifc2x3tc1.IfcExtrudedAreaSolid)3 IfcLocalPlacement (org.bimserver.models.ifc2x3tc1.IfcLocalPlacement)3 Path2D (java.awt.geom.Path2D)2 IfcModelInterface (org.bimserver.emf.IfcModelInterface)2 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)2 SProject (org.bimserver.interfaces.objects.SProject)2 IfcArbitraryClosedProfileDef (org.bimserver.models.ifc2x3tc1.IfcArbitraryClosedProfileDef)2 IfcAxis2Placement (org.bimserver.models.ifc2x3tc1.IfcAxis2Placement)2 IfcBuildingStorey (org.bimserver.models.ifc2x3tc1.IfcBuildingStorey)2 IfcFurnishingElement (org.bimserver.models.ifc2x3tc1.IfcFurnishingElement)2 IfcObjectPlacement (org.bimserver.models.ifc2x3tc1.IfcObjectPlacement)2 IfcPolyline (org.bimserver.models.ifc2x3tc1.IfcPolyline)2 IfcSpace (org.bimserver.models.ifc2x3tc1.IfcSpace)2 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)2 Test (org.junit.Test)2 Area (java.awt.geom.Area)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1