use of org.bimserver.models.ifc4.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;
}
use of org.bimserver.models.ifc4.IfcCartesianPoint in project BIMserver by opensourceBIM.
the class IfcUtils method getAbsolutePosition.
/**
* 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 };
}
use of org.bimserver.models.ifc4.IfcCartesianPoint in project BIMserver by opensourceBIM.
the class IfcUtils method getBoundingBox2D.
public static AxisAlignedBoundingBox2D getBoundingBox2D(List<IfcCartesianPoint> points) throws GeometryException {
AxisAlignedBoundingBox2D box2d = new AxisAlignedBoundingBox2D();
for (IfcCartesianPoint ifcCartesianPoint : points) {
EList<Double> coordinates = ifcCartesianPoint.getCoordinates();
if (coordinates.size() > 2) {
throw new GeometryException("Too many dimensions (" + coordinates.size() + ") for 2D boundingbox");
}
box2d.process(coordinates);
}
return box2d;
}
use of org.bimserver.models.ifc4.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;
}
use of org.bimserver.models.ifc4.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);
}
}
Aggregations