use of org.bimserver.models.ifc2x3tc1.IfcWindow in project BIMserver by opensourceBIM.
the class CommandLine method run.
@Override
public void run() {
reader = new BufferedReader(new InputStreamReader(System.in));
running = true;
try {
while (running) {
try {
String line = reader.readLine();
if (line == null) {
Thread.sleep(50);
continue;
}
if (line.equalsIgnoreCase("exit")) {
bimServer.stop();
return;
} else if (line.startsWith("dumpmodel")) {
try {
long roid = Long.parseLong(line.substring(9).trim());
DatabaseSession databaseSession = bimServer.getDatabase().createSession();
try {
DownloadDatabaseAction downloadDatabaseAction = new DownloadDatabaseAction(bimServer, databaseSession, AccessMethod.INTERNAL, roid, -1, -1, new SystemAuthorization(1, TimeUnit.HOURS), null);
IfcModelInterface model = downloadDatabaseAction.execute();
LOGGER.info("Model size: " + model.size());
List<IfcWall> walls = model.getAll(IfcWall.class);
List<IfcProject> projects = model.getAll(IfcProject.class);
List<IfcSlab> slabs = model.getAll(IfcSlab.class);
List<IfcWindow> windows = model.getAll(IfcWindow.class);
LOGGER.info("Walls: " + walls.size());
LOGGER.info("Windows: " + windows.size());
LOGGER.info("Projects: " + projects.size());
LOGGER.info("Slabs: " + slabs.size());
} catch (UserException e) {
LOGGER.error("", e);
} catch (BimserverLockConflictException e) {
LOGGER.error("", e);
} catch (BimserverDatabaseException e) {
LOGGER.error("", e);
} finally {
databaseSession.close();
}
} catch (Exception e) {
LOGGER.error("", e);
}
} else if (line.equalsIgnoreCase("dump")) {
LOGGER.info("Dumping all thread's track traces...");
LOGGER.info("");
Map<Thread, StackTraceElement[]> allStackTraces = Thread.getAllStackTraces();
for (Thread t : allStackTraces.keySet()) {
LOGGER.info(t.getName());
StackTraceElement[] stackTraceElements = allStackTraces.get(t);
for (StackTraceElement stackTraceElement : stackTraceElements) {
LOGGER.info("\t" + stackTraceElement.getClassName() + ":" + stackTraceElement.getLineNumber() + "." + stackTraceElement.getMethodName());
}
LOGGER.info("");
}
LOGGER.info("Done printing stack traces");
LOGGER.info("");
Thread.sleep(10000);
} else if (line.equals("migrate")) {
try {
bimServer.getDatabase().getMigrator().migrate();
bimServer.getServerInfoManager().update();
} catch (MigrationException e) {
LOGGER.error("", e);
} catch (InconsistentModelsException e) {
LOGGER.error("", e);
}
} else if (line.equals("clearendpoints")) {
bimServer.getEndPointManager().clear();
} else if (line.startsWith("showall")) {
KeyValueStore keyValueStore = ((Database) bimServer.getDatabase()).getKeyValueStore();
Set<String> allTableNames = keyValueStore.getAllTableNames();
long total = 0;
for (String tableName : allTableNames) {
long size = keyValueStore.count(tableName);
total += size;
if (size != 0) {
LOGGER.info(tableName + " " + size);
}
}
LOGGER.info("total: " + total);
} else {
LOGGER.info("Unknown command");
}
} catch (IOException e) {
LOGGER.error("", e);
}
}
} catch (InterruptedException e) {
}
}
use of org.bimserver.models.ifc2x3tc1.IfcWindow in project BIMserver by opensourceBIM.
the class Scaler method scale.
public void scale(float scale) {
if (scale != 1.0f) {
for (long key : ifcModel.keySet()) {
IdEObject idEObject = (IdEObject) ifcModel.get(key);
if (idEObject instanceof IfcAsymmetricIShapeProfileDef) {
setIfcAsymmetricIShapeProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcBlock) {
setIfcBlock(idEObject, scale);
} else if (idEObject instanceof IfcBoundingBox) {
setIfcBoundingBox(idEObject, scale);
} else if (idEObject instanceof IfcBuilding) {
setIfcBuilding(idEObject, scale);
} else if (idEObject instanceof IfcBuildingStorey) {
setIfcBuildingStorey(idEObject, scale);
} else if (idEObject instanceof IfcCartesianPoint) {
setIfcCartesianPoint(idEObject, scale);
} else if (idEObject instanceof IfcCenterLineProfileDef) {
setIfcCenterLineProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcChamferEdgeFeature) {
setIfcChamferEdgeFeature(idEObject, scale);
} else if (idEObject instanceof IfcCircle) {
setIfcCircle(idEObject, scale);
} else if (idEObject instanceof IfcCircleHollowProfileDef) {
setIfcCircleHollowProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcCircleProfileDef) {
setIfcCircleProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcCraneRailAShapeProfileDef) {
setIfcCraneRailAShapeProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcCraneRailFShapeProfileDef) {
setIfcCraneRailFShapeProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcConnectionPointEccentricity) {
setIfcConnectionPointEccentricity(idEObject, scale);
} else if (idEObject instanceof IfcCShapeProfileDef) {
setIfcCShapeProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcCurveStyleFontPattern) {
setIfcCurveStyleFontPattern(idEObject, scale);
} else if (idEObject instanceof IfcDoor) {
setIfcDoor(idEObject, scale);
} else if (idEObject instanceof IfcDoorLiningProperties) {
setIfcDoorLiningProperties(idEObject, scale);
} else if (idEObject instanceof IfcDoorPanelProperties) {
setIfcDoorPanelProperties(idEObject, scale);
} else if (idEObject instanceof IfcEdgeFeature) {
setIfcEdgeFeature(idEObject, scale);
} else if (idEObject instanceof IfcEllipse) {
setIfcEllipse(idEObject, scale);
} else if (idEObject instanceof IfcEllipseProfileDef) {
setIfcEllipseProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcExtrudedAreaSolid) {
setIfcExtrudedAreaSolid(idEObject, scale);
} else if (idEObject instanceof IfcGeneralProfileProperties) {
setIfcGeneralProfileProperties(idEObject, scale);
} else if (idEObject instanceof IfcIShapeProfileDef) {
setIfcIShapeProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcLightSourcePositional) {
setIfcLightSourcePositional(idEObject, scale);
} else if (idEObject instanceof IfcLShapeProfileDef) {
setIfcLShapeProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcMaterialLayer) {
setIfcMaterialLayer(idEObject, scale);
} else if (idEObject instanceof IfcMaterialLayerSetUsage) {
setIfcMaterialLayerSetUsage(idEObject, scale);
} else if (idEObject instanceof IfcMechanicalConcreteMaterialProperties) {
setIfcMechanicalConcreteMaterialProperties(idEObject, scale);
} else if (idEObject instanceof IfcMechanicalFastener) {
setIfcMechanicalFastener(idEObject, scale);
} else if (idEObject instanceof IfcOffsetCurve2D) {
setIfcOffsetCurve2D(idEObject, scale);
} else if (idEObject instanceof IfcOffsetCurve3D) {
setIfcOffsetCurve3D(idEObject, scale);
} else if (idEObject instanceof IfcPermeableCoveringProperties) {
setIfcPermeableCoveringProperties(idEObject, scale);
} else if (idEObject instanceof IfcPlanarExtent) {
setIfcPlanarExtent(idEObject, scale);
} else if (idEObject instanceof IfcQuantityLength) {
setIfcQuantityLength(idEObject, scale);
} else if (idEObject instanceof IfcRectangleHollowProfileDef) {
setIfcRectangleHollowProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcRectangleProfileDef) {
setIfcRectangleProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcRectangularPyramid) {
setIfcRectangularPyramid(idEObject, scale);
} else if (idEObject instanceof IfcReinforcementBarProperties) {
setIfcReinforcementBarProperties(idEObject, scale);
} else if (idEObject instanceof IfcReinforcingBar) {
setIfcReinforcingBar(idEObject, scale);
} else if (idEObject instanceof IfcReinforcingMesh) {
setIfcReinforcingMesh(idEObject, scale);
} else if (idEObject instanceof IfcRelConnectsStructuralMember) {
setIfcRelConnectsStructuralMember(idEObject, scale);
} else if (idEObject instanceof IfcRibPlateProfileProperties) {
setIfcRibPlateProfileProperties(idEObject, scale);
} else if (idEObject instanceof IfcRightCircularCone) {
setIfcRightCircularCone(idEObject, scale);
} else if (idEObject instanceof IfcRightCircularCylinder) {
setIfcRightCircularCylinder(idEObject, scale);
} else if (idEObject instanceof IfcRoundedEdgeFeature) {
setIfcRoundedEdgeFeature(idEObject, scale);
} else if (idEObject instanceof IfcRoundedRectangleProfileDef) {
setIfcRoundedRectangleProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcSectionReinforcementProperties) {
setIfcSectionReinforcementProperties(idEObject, scale);
} else if (idEObject instanceof IfcSite) {
setIfcSite(idEObject, scale);
} else if (idEObject instanceof IfcSlippageConnectionCondition) {
setIfcSlippageConnectionCondition(idEObject, scale);
} else if (idEObject instanceof IfcSpace) {
setIfcSpace(idEObject, scale);
} else if (idEObject instanceof IfcSphere) {
setIfcSphere(idEObject, scale);
} else if (idEObject instanceof IfcStairFlight) {
setIfcStairFlight(idEObject, scale);
} else if (idEObject instanceof IfcStructuralLoadSingleDisplacement) {
setIfcStructuralLoadSingleDisplacement(idEObject, scale);
} else if (idEObject instanceof IfcStructuralProfileProperties) {
setIfcStructuralProfileProperties(idEObject, scale);
} else if (idEObject instanceof IfcStructuralSurfaceMember) {
setIfcStructuralSurfaceMember(idEObject, scale);
} else if (idEObject instanceof IfcStructuralSurfaceMemberVarying) {
setIfcStructuralSurfaceMemberVarying(idEObject, scale);
} else if (idEObject instanceof IfcSurfaceOfLinearExtrusion) {
setIfcSurfaceOfLinearExtrusion(idEObject, scale);
} else if (idEObject instanceof IfcSweptDiskSolid) {
setIfcSweptDiskSolid(idEObject, scale);
} else if (idEObject instanceof IfcTendon) {
setIfcTendon(idEObject, scale);
} else if (idEObject instanceof IfcTextStyleWithBoxCharacteristics) {
setIfcTextStyleWithBoxCharacteristics(idEObject, scale);
} else if (idEObject instanceof IfcTrapeziumProfileDef) {
setIfcTrapeziumProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcTShapeProfileDef) {
setIfcTShapeProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcUShapeProfileDef) {
setIfcUShapeProfileDef(idEObject, scale);
} else if (idEObject instanceof IfcVector) {
setIfcVector(idEObject, scale);
} else if (idEObject instanceof IfcVirtualGridIntersection) {
setIfcVirtualGridIntersection(idEObject, scale);
} else if (idEObject instanceof IfcWindow) {
setIfcWindow(idEObject, scale);
} else if (idEObject instanceof IfcWindowLiningProperties) {
setIfcWindowLiningProperties(idEObject, scale);
} else if (idEObject instanceof IfcWindowPanelProperties) {
setIfcWindowPanelProperties(idEObject, scale);
} else if (idEObject instanceof IfcZShapeProfileDef) {
setIfcZShapeProfileDef(idEObject, scale);
}
setDoubleAsStringValues(idEObject);
}
}
}
use of org.bimserver.models.ifc2x3tc1.IfcWindow in project BIMserver by opensourceBIM.
the class TestCreateProperties method test.
@Test
public void test() {
try {
// New client
BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
// Create a project
SProject project = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
// Look for a deserializer
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
bimServerClient.checkin(project.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
project = bimServerClient.getServiceInterface().getProjectByPoid(project.getOid());
// Load model without lazy loading (complete model at once)
IfcModelInterface model = bimServerClient.getModel(project, project.getLastRevisionId(), true, true);
String propertyName = "BooleanProperty";
int nrWindowsFirst = 0;
// Iterate over all projects, there should be 1
for (IfcWindow window : model.getAllWithSubTypes(IfcWindow.class)) {
nrWindowsFirst++;
createProperty(window, model, propertyName, "Description of property", true);
}
long newRoid = model.commit("Added boolean properties to " + nrWindowsFirst + " windows");
model = bimServerClient.getModel(project, newRoid, true, false);
int foundOke = 0;
int nrWindowsSecond = 0;
Set<Long> counted = new HashSet<Long>();
for (IfcWindow window : model.getAllWithSubTypes(IfcWindow.class)) {
nrWindowsSecond++;
for (IfcRelDefines ifcRelDefines : window.getIsDefinedBy()) {
if (ifcRelDefines instanceof IfcRelDefinesByProperties) {
IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines;
IfcPropertySetDefinition relatingPropertyDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition();
if (relatingPropertyDefinition instanceof IfcPropertySet) {
IfcPropertySet ifcPropertySet = (IfcPropertySet) relatingPropertyDefinition;
for (IfcProperty ifcProperty : ifcPropertySet.getHasProperties()) {
if (ifcProperty instanceof IfcPropertySingleValue) {
IfcPropertySingleValue ifcPropertySingleValue = (IfcPropertySingleValue) ifcProperty;
if (ifcPropertySingleValue.getName().equals(propertyName)) {
IfcValue nominalValue = ifcPropertySingleValue.getNominalValue();
if (nominalValue instanceof IfcBoolean) {
if (((IfcBoolean) nominalValue).getWrappedValue() == Tristate.TRUE) {
if (!counted.contains(ifcPropertySingleValue.getOid())) {
foundOke++;
counted.add(ifcPropertySingleValue.getOid());
}
}
}
}
}
}
}
}
}
}
LOGGER.info("Windows first: " + nrWindowsFirst);
LOGGER.info("Windows second: " + nrWindowsSecond);
LOGGER.info("Found Oke: " + foundOke);
if (foundOke != nrWindowsFirst) {
fail(foundOke + " / " + nrWindowsFirst);
}
} catch (Throwable e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.bimserver.models.ifc2x3tc1.IfcWindow in project BIMserver by opensourceBIM.
the class TestCreateProperties method createProperty.
private void createProperty(IfcWindow window, IfcModelInterface model, String name, String description, Object value) throws IfcModelInterfaceException {
IfcRelDefinesByProperties ifcRelDefinesByProperties = model.create(IfcRelDefinesByProperties.class);
window.getIsDefinedBy().add(ifcRelDefinesByProperties);
IfcPropertySet propertySet = model.create(IfcPropertySet.class);
ifcRelDefinesByProperties.setRelatingPropertyDefinition(propertySet);
IfcPropertySingleValue property = model.create(IfcPropertySingleValue.class);
propertySet.getHasProperties().add(property);
property.setName(name);
property.setDescription(description);
if (value instanceof Boolean) {
IfcBoolean ifcValue = model.create(IfcBoolean.class);
ifcValue.setWrappedValue(((Boolean) value) ? Tristate.TRUE : Tristate.FALSE);
property.setNominalValue(ifcValue);
} else {
// Unimplemented
}
}
use of org.bimserver.models.ifc2x3tc1.IfcWindow in project BIMserver by opensourceBIM.
the class TestLoadCompleteModel method start.
@Test
public void start() {
try {
// New client
BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
// Create a project
SProject project = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
// Look for a deserializer
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
// Checkin file
bimServerClient.checkin(project.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
project = bimServerClient.getServiceInterface().getProjectByPoid(project.getOid());
// Load model without lazy loading (complete model at once)
IfcModelInterface model = bimServerClient.getModel(project, project.getLastRevisionId(), false, true);
// Change the window names
for (IfcWindow window : model.getAllWithSubTypes(IfcWindow.class)) {
window.setName(window.getName() + " Changed");
}
long newRoid = model.commit("Changed window names");
IfcModelInterface newModel = bimServerClient.getModel(project, newRoid, true, false);
List<IfcWindow> windows = newModel.getAllWithSubTypes(Ifc2x3tc1Package.eINSTANCE.getIfcWindow());
for (IfcWindow window : windows) {
assertTrue(window.getName().endsWith(" Changed"));
}
} catch (Exception e) {
fail(e.getMessage());
}
}
Aggregations