use of org.bimserver.models.ifc2x3tc1.IfcProject 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.IfcProject in project BIMserver by opensourceBIM.
the class TestReadProperties 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());
// 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(), true, false);
// Iterate over all projects, there should be 1
for (IfcProject ifcProject : model.getAllWithSubTypes(IfcProject.class)) {
for (IfcRelDefines ifcRelDefines : ifcProject.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;
IfcValue nominalValue = ifcPropertySingleValue.getNominalValue();
String stringValue = "";
if (nominalValue instanceof IfcLabel) {
stringValue = ((IfcLabel) nominalValue).getWrappedValue();
} else if (nominalValue instanceof IfcIdentifier) {
stringValue = ((IfcIdentifier) nominalValue).getWrappedValue();
} else if (nominalValue instanceof IfcAreaMeasure) {
stringValue = "" + ((IfcAreaMeasure) nominalValue).getWrappedValue();
}
if (ifcPropertySingleValue.getName().equals("ConstructionMode")) {
if (!stringValue.equals("Massivbau")) {
fail("Massivbau expected");
}
} else if (ifcPropertySingleValue.getName().equals("BuildingPermitId")) {
if (!stringValue.equals("4711")) {
fail("4711 expected");
}
} else if (ifcPropertySingleValue.getName().equals("GrossAreaPlanned")) {
if (stringValue == null || !stringValue.equals("1000.0")) {
fail("1000. expected");
}
}
System.out.println(ifcPropertySingleValue.getName() + ": " + stringValue);
}
}
}
}
}
}
} catch (Throwable e) {
if (!(e instanceof AssertionError)) {
fail(e.getMessage());
}
}
}
use of org.bimserver.models.ifc2x3tc1.IfcProject in project BIMserver by opensourceBIM.
the class RevisionMerger method merge.
public IfcModel merge() throws IfcModelInterfaceException {
for (IdEObject idEObject : oldModel.getValues()) {
copy(resultModel, idEObject, false);
}
resultModel.indexGuids();
newModel.fixOids(new IncrementingOidProvider(resultModel.getHighestOid() + 1));
copyAttributesGuidObjectsAndAddNewObjects();
updateReferences();
fixExplicitNullReferences();
fixNonGuidObjects();
TracingGarbageCollector tracingGarbageCollector = new TracingGarbageCollector(resultModel);
Set<IdEObject> rootObjects = new HashSet<IdEObject>();
for (IdEObject idEObject : resultModel.getValues()) {
if (idEObject instanceof IfcProject) {
rootObjects.add(idEObject);
}
}
tracingGarbageCollector.mark(rootObjects);
tracingGarbageCollector.sweep();
return resultModel;
}
use of org.bimserver.models.ifc2x3tc1.IfcProject in project BIMserver by opensourceBIM.
the class IfcUtils method getLengthUnitPrefix.
public static float getLengthUnitPrefix(IfcModelInterface model) {
float lengthUnitPrefix = 1.0f;
boolean prefixFound = false;
for (IfcProject ifcProject : model.getAll(IfcProject.class)) {
IfcUnitAssignment unitsInContext = ifcProject.getUnitsInContext();
if (unitsInContext != null) {
EList<IfcUnit> units = unitsInContext.getUnits();
for (IfcUnit unit : units) {
if (unit instanceof IfcSIUnit) {
IfcSIUnit ifcSIUnit = (IfcSIUnit) unit;
IfcUnitEnum unitType = ifcSIUnit.getUnitType();
if (unitType == IfcUnitEnum.LENGTHUNIT) {
IfcSIPrefix prefix = ifcSIUnit.getPrefix();
if (prefix != null) {
prefixFound = true;
switch(prefix) {
case EXA:
lengthUnitPrefix = 1.0e18f;
break;
case PETA:
lengthUnitPrefix = 1.0e15f;
break;
case TERA:
lengthUnitPrefix = 1.0e12f;
break;
case GIGA:
lengthUnitPrefix = 1.0e9f;
break;
case MEGA:
lengthUnitPrefix = 1.0e6f;
break;
case KILO:
lengthUnitPrefix = 1.0e3f;
break;
case HECTO:
lengthUnitPrefix = 1.0e2f;
break;
case DECA:
lengthUnitPrefix = 1.0e1f;
break;
case DECI:
lengthUnitPrefix = 1.0e-1f;
break;
case CENTI:
lengthUnitPrefix = 1.0e-2f;
break;
case MILLI:
lengthUnitPrefix = 1.0e-3f;
break;
case MICRO:
lengthUnitPrefix = 1.0e-6f;
break;
case NANO:
lengthUnitPrefix = 1.0e-9f;
break;
case PICO:
lengthUnitPrefix = 1.0e-12f;
break;
case FEMTO:
lengthUnitPrefix = 1.0e-15f;
break;
case ATTO:
lengthUnitPrefix = 1.0e-18f;
break;
case NULL:
break;
}
break;
}
}
}
}
}
if (prefixFound)
break;
}
return lengthUnitPrefix;
}
use of org.bimserver.models.ifc2x3tc1.IfcProject in project BIMserver by opensourceBIM.
the class RichIfcModel method createDefaultProjectStructure.
public IfcBuilding createDefaultProjectStructure() throws IfcModelInterfaceException {
IfcPerson person = create(IfcPerson.class);
IfcOrganization organization = create(IfcOrganization.class);
organization.setName("Required");
IfcPersonAndOrganization owningUser = create(IfcPersonAndOrganization.class);
owningUser.setTheOrganization(organization);
owningUser.setThePerson(person);
IfcOrganization developer = create(IfcOrganization.class);
developer.setName("Required");
IfcApplication application = create(IfcApplication.class);
application.setApplicationDeveloper(developer);
application.setApplicationFullName("Required");
application.setApplicationIdentifier("Required");
application.setVersion("1.0");
IfcOwnerHistory ownerHistory = create(IfcOwnerHistory.class);
ownerHistory.setChangeAction(IfcChangeActionEnum.ADDED);
ownerHistory.setCreationDate(System.currentTimeMillis() / 1000);
ownerHistory.setOwningApplication(application);
ownerHistory.setOwningUser(owningUser);
setDefaultOwnerHistory(ownerHistory);
IfcAxis2Placement3D contextAxisPlacement = create(IfcAxis2Placement3D.class);
contextAxisPlacement.setLocation(createIfcCartesianPoint(0, 0, 0));
IfcGeometricRepresentationContext representationContext = create(IfcGeometricRepresentationContext.class);
representationContext.setCoordinateSpaceDimension(3);
representationContext.setPrecision(0.00001);
representationContext.setWorldCoordinateSystem(contextAxisPlacement);
representationContext.setContextType("Model");
setDefaultRepresentationContext(representationContext);
IfcUnitAssignment ifcUnitAssigment = create(IfcUnitAssignment.class);
ifcUnitAssigment.getUnits().add(createIfcSiUnit(IfcUnitEnum.LENGTHUNIT, IfcSIPrefix.MILLI, IfcSIUnitName.METRE));
ifcUnitAssigment.getUnits().add(createIfcSiUnit(IfcUnitEnum.VOLUMEUNIT, IfcSIPrefix.NULL, IfcSIUnitName.CUBIC_METRE));
ifcUnitAssigment.getUnits().add(createIfcSiUnit(IfcUnitEnum.PLANEANGLEUNIT, IfcSIPrefix.NULL, IfcSIUnitName.RADIAN));
ifcUnitAssigment.getUnits().add(createIfcSiUnit(IfcUnitEnum.SOLIDANGLEUNIT, IfcSIPrefix.NULL, IfcSIUnitName.STERADIAN));
ifcUnitAssigment.getUnits().add(createIfcSiUnit(IfcUnitEnum.MASSUNIT, IfcSIPrefix.NULL, IfcSIUnitName.GRAM));
ifcUnitAssigment.getUnits().add(createIfcSiUnit(IfcUnitEnum.TIMEUNIT, IfcSIPrefix.NULL, IfcSIUnitName.SECOND));
ifcUnitAssigment.getUnits().add(createIfcSiUnit(IfcUnitEnum.THERMODYNAMICTEMPERATUREUNIT, IfcSIPrefix.NULL, IfcSIUnitName.DEGREE_CELSIUS));
ifcUnitAssigment.getUnits().add(createIfcSiUnit(IfcUnitEnum.LUMINOUSINTENSITYUNIT, IfcSIPrefix.NULL, IfcSIUnitName.LUMEN));
IfcProject ifcProject = create(IfcProject.class);
ifcProject.getRepresentationContexts().add(representationContext);
ifcProject.setUnitsInContext(ifcUnitAssigment);
ifcProject.setName("Demo Project");
IfcSite ifcSite = create(IfcSite.class);
ifcSite.setCompositionType(IfcElementCompositionEnum.ELEMENT);
ifcSite.setName("Default site");
IfcBuilding ifcBuilding = create(IfcBuilding.class);
ifcBuilding.setCompositionType(IfcElementCompositionEnum.ELEMENT);
ifcBuilding.setName("Default building");
addDecomposes(ifcProject, ifcSite);
addDecomposes(ifcSite, ifcBuilding);
return ifcBuilding;
}
Aggregations