use of org.bimserver.models.ifc2x3tc1.IfcAxis2Placement 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.IfcAxis2Placement 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.ifc2x3tc1.IfcAxis2Placement 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.checkin(newProject.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, 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());
}
}
Aggregations