use of org.bimserver.models.ifc2x3tc1.IfcLocalPlacement in project BIMserver by opensourceBIM.
the class IfcTools2D method placementToMatrix.
public static double[] placementToMatrix(IfcObjectPlacement objectPlacement) {
double[] matrix = Matrix.identity();
if (objectPlacement instanceof IfcLocalPlacement) {
IfcLocalPlacement ifcLocalPlacement = (IfcLocalPlacement) objectPlacement;
IfcAxis2Placement relativePlacement = ifcLocalPlacement.getRelativePlacement();
if (relativePlacement instanceof IfcAxis2Placement3D) {
IfcAxis2Placement3D ifcAxis2Placement3D = (IfcAxis2Placement3D) relativePlacement;
matrix = placement3DToMatrix(ifcAxis2Placement3D);
}
IfcObjectPlacement relativeTo = ifcLocalPlacement.getPlacementRelTo();
if (relativeTo != null) {
double[] baseMatrix = placementToMatrix(relativeTo);
double[] rhs = matrix;
matrix = Matrix.identity();
Matrix.multiplyMM(matrix, 0, baseMatrix, 0, rhs, 0);
}
}
return matrix;
}
use of org.bimserver.models.ifc2x3tc1.IfcLocalPlacement in project BIMserver by opensourceBIM.
the class TestBigModelEmfRemote method test.
@Test
public void test() {
boolean doreuse = true;
boolean useLowLevelCalls = false;
try (BimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080")) {
BimServerClientInterface bimServerClient = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
IfcModelInterface model = null;
if (useLowLevelCalls) {
model = bimServerClient.newModel(newProject, true);
} else {
model = new BasicIfcModel(bimServerClient.getMetaDataManager().getPackageMetaData("ifc2x3tc1"), null);
}
RichIfcModel richIfcModel = new RichIfcModel(model, !useLowLevelCalls);
IfcBuilding ifcBuilding = richIfcModel.createDefaultProjectStructure(0, 0, 0);
IfcRelAggregates buildingAggregation = richIfcModel.create(IfcRelAggregates.class);
buildingAggregation.setRelatingObject(ifcBuilding);
for (int i = 1; i <= 200; i++) {
IfcBuildingStorey ifcBuildingStorey = richIfcModel.create(IfcBuildingStorey.class);
ifcBuildingStorey.setName("Storey " + i);
ifcBuildingStorey.setCompositionType(IfcElementCompositionEnum.ELEMENT);
ifcBuildingStorey.setElevation(3000 * i);
IfcLocalPlacement storeyPlacement = richIfcModel.create(IfcLocalPlacement.class);
storeyPlacement.setRelativePlacement(richIfcModel.createBasicPosition(0, 0, i * 3000));
ifcBuildingStorey.setObjectPlacement(storeyPlacement);
buildingAggregation.getRelatedObjects().add(ifcBuildingStorey);
IfcRelAggregates storeyAggregation = richIfcModel.create(IfcRelAggregates.class);
storeyAggregation.setRelatingObject(ifcBuildingStorey);
for (int x = 1; x <= 40; x++) {
for (int y = 1; y <= 40; y++) {
createSpace(richIfcModel, richIfcModel.getDefaultRepresentationContext(), storeyPlacement, storeyAggregation, x, y, doreuse);
}
}
}
long roid = -1;
if (useLowLevelCalls) {
roid = model.commit("Initial model");
} else {
Serializer serializer = new Ifc2x3tc1StepSerializer(null);
serializer.init(model, null, true);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
serializer.writeToOutputStream(baos, null);
java.nio.file.Files.write(Paths.get("tmp.ifc"), baos.toByteArray());
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid());
SLongCheckinActionState checkinSync = bimServerClient.checkinSync(newProject.getOid(), "New", deserializer.getOid(), false, baos.size(), "newfile", new ByteArrayInputStream(baos.toByteArray()));
roid = checkinSync.getRoid();
}
SSerializerPluginConfiguration serializerByContentType = bimServerClient.getServiceInterface().getSerializerByName("Ifc2x3tc1 (Streaming)");
bimServerClient.download(roid, serializerByContentType.getOid(), new FileOutputStream(new File("created.ifc")));
} catch (Throwable e) {
e.printStackTrace();
if (e instanceof AssertionError) {
throw (AssertionError) e;
}
fail(e.getMessage());
}
}
use of org.bimserver.models.ifc2x3tc1.IfcLocalPlacement in project BIMserver by opensourceBIM.
the class TestBigModelEmfRemote method createFurnishing.
private void createFurnishing(RichIfcModel richIfcModel, IfcRepresentationContext representationContext, int number, IfcSpace ifcSpace, IfcLocalPlacement spacePlacement, boolean doreuse) throws IfcModelInterfaceException {
IfcFurnishingElement furnishing = richIfcModel.create(IfcFurnishingElement.class);
furnishing.setName("Furnishing " + number);
IfcLocalPlacement furnishingPlacement = richIfcModel.create(IfcLocalPlacement.class);
furnishingPlacement.setPlacementRelTo(spacePlacement);
IfcAxis2Placement3D furnitureAxisPlacement = richIfcModel.create(IfcAxis2Placement3D.class);
furnitureAxisPlacement.setLocation(richIfcModel.createIfcCartesianPoint(500, 500, 2));
furnishingPlacement.setRelativePlacement(furnitureAxisPlacement);
furnishing.setObjectPlacement(furnishingPlacement);
IfcProductRepresentation rep = null;
if (doreuse) {
if (this.furnishingRep == null) {
this.furnishingRep = richIfcModel.createRectangularExtrusionProductRepresentation(4000, 4000, 1200);
}
rep = this.furnishingRep;
} else {
rep = richIfcModel.createRectangularExtrusionProductRepresentation(4000, 4000, 1200);
}
furnishing.setRepresentation(rep);
richIfcModel.addContains(ifcSpace, furnishing);
}
use of org.bimserver.models.ifc2x3tc1.IfcLocalPlacement in project BIMserver by opensourceBIM.
the class TestBigModelEmf method createFurnishing.
private void createFurnishing(RichIfcModel richIfcModel, IfcRepresentationContext representationContext, int number, IfcSpace ifcSpace, IfcLocalPlacement spacePlacement) throws IfcModelInterfaceException {
IfcFurnishingElement furnishing = richIfcModel.create(IfcFurnishingElement.class);
furnishing.setName("Furnishing " + number);
IfcLocalPlacement furnishingPlacement = richIfcModel.create(IfcLocalPlacement.class);
furnishingPlacement.setPlacementRelTo(spacePlacement);
IfcAxis2Placement3D furnitureAxisPlacement = richIfcModel.create(IfcAxis2Placement3D.class);
furnitureAxisPlacement.setLocation(richIfcModel.createIfcCartesianPoint(500, 500, 2));
furnishingPlacement.setRelativePlacement(furnitureAxisPlacement);
furnishing.setObjectPlacement(furnishingPlacement);
furnishing.setRepresentation(richIfcModel.createRectangularExtrusionProductRepresentation(4000, 4000, 1200));
richIfcModel.addContains(ifcSpace, furnishing);
}
use of org.bimserver.models.ifc2x3tc1.IfcLocalPlacement in project BIMserver by opensourceBIM.
the class TestBigModelEmf method test.
@Test
public void test() {
try {
BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
IfcModelInterface model = bimServerClient.newModel(newProject, true);
RichIfcModel richIfcModel = new RichIfcModel(model, false);
IfcBuilding ifcBuilding = richIfcModel.createDefaultProjectStructure(100000, 0, 0);
double offsetX = 100000;
IfcRelAggregates buildingAggregation = richIfcModel.create(IfcRelAggregates.class);
buildingAggregation.setRelatingObject(ifcBuilding);
for (int i = 1; i <= 20; i++) {
IfcBuildingStorey ifcBuildingStorey = richIfcModel.create(IfcBuildingStorey.class);
ifcBuildingStorey.setName("Storey " + i);
ifcBuildingStorey.setCompositionType(IfcElementCompositionEnum.ELEMENT);
ifcBuildingStorey.setElevation(3000 * i);
IfcLocalPlacement storeyPlacement = richIfcModel.create(IfcLocalPlacement.class);
storeyPlacement.setRelativePlacement(richIfcModel.createBasicPosition(offsetX, 0D, i * 3000D));
ifcBuildingStorey.setObjectPlacement(storeyPlacement);
buildingAggregation.getRelatedObjects().add(ifcBuildingStorey);
IfcRelAggregates storeyAggregation = richIfcModel.create(IfcRelAggregates.class);
storeyAggregation.setRelatingObject(ifcBuildingStorey);
for (int x = 1; x <= 10; x++) {
for (int y = 1; y <= 10; y++) {
createSpace(richIfcModel, richIfcModel.getDefaultRepresentationContext(), storeyPlacement, storeyAggregation, x, y);
}
}
}
long roid = model.commit("Initial model");
SSerializerPluginConfiguration serializerByContentType = bimServerClient.getServiceInterface().getSerializerByName("Ifc2x3tc1 (Streaming)");
bimServerClient.download(roid, serializerByContentType.getOid(), new FileOutputStream(new File("created.ifc")));
} catch (Throwable e) {
e.printStackTrace();
if (e instanceof AssertionError) {
throw (AssertionError) e;
}
fail(e.getMessage());
}
}
Aggregations