use of org.bimserver.plugins.PluginManager in project BIMserver by opensourceBIM.
the class AddFurniture method main.
public static void main(String[] args) {
try {
PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home"));
DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true);
Deserializer deserializer = deserializerPlugin.createDeserializer(null);
deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1"));
IfcModelInterface model = DeserializerUtils.readFromFile(deserializer, Paths.get("../TestData/data/AC9R1-Haus-G-H-Ver2-2x3.ifc"));
deserializer = deserializerPlugin.createDeserializer(null);
deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1"));
IfcModelInterface furnishingModel = DeserializerUtils.readFromFile(deserializer, Paths.get("test.ifc"));
model.fixOids(new IncrementingOidProvider());
long oid = model.getHighestOid();
IncrementingOidProvider oidProvider = new IncrementingOidProvider(oid + 1);
IfcFurnishingElement picknick = (IfcFurnishingElement) furnishingModel.getByName(Ifc2x3tc1Package.eINSTANCE.getIfcFurnishingElement(), "Picknik Bank");
ModelHelper modelHelper = new ModelHelper(pluginManager.getMetaDataManager(), new HideAllInversesObjectIDM(CollectionUtils.singleSet(Ifc2x3tc1Package.eINSTANCE), pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1")), model);
IfcProductDefinitionShape representation = (IfcProductDefinitionShape) picknick.getRepresentation();
IfcRepresentation surfaceModel = null;
IfcRepresentation boundingBox = null;
for (IfcRepresentation ifcRepresentation : representation.getRepresentations()) {
IfcShapeRepresentation ifcShapeRepresentation = (IfcShapeRepresentation) ifcRepresentation;
if (ifcShapeRepresentation.getRepresentationType().equals("SurfaceModel")) {
surfaceModel = (IfcRepresentation) modelHelper.copy(ifcShapeRepresentation, false);
} else if (ifcShapeRepresentation.getRepresentationType().equals("BoundingBox")) {
boundingBox = (IfcRepresentation) modelHelper.copy(ifcShapeRepresentation, false);
}
}
IfcOwnerHistory ownerHistory = null;
List<IfcOwnerHistory> all = model.getAll(IfcOwnerHistory.class);
if (all.size() > 0) {
ownerHistory = all.get(0);
}
for (IfcBuildingStorey ifcBuildingStorey : model.getAll(IfcBuildingStorey.class)) {
for (IfcRelDecomposes ifcRelDecomposes : ifcBuildingStorey.getIsDecomposedBy()) {
for (IfcObjectDefinition ifcObjectDefinition : ifcRelDecomposes.getRelatedObjects()) {
if (ifcObjectDefinition instanceof IfcSpace) {
IfcSpace ifcSpace = (IfcSpace) ifcObjectDefinition;
// IfcProductDefinitionShape slabRepr = (IfcProductDefinitionShape) ifcSpace.getRepresentation();
// IfcBoundingBox box = null;
// for (IfcRepresentation representation2 : slabRepr.getRepresentations()) {
// IfcShapeRepresentation shapeRepresentation = (IfcShapeRepresentation)representation2;
// if (shapeRepresentation.getRepresentationType().equals("BoundingBox")) {
// for (IfcRepresentationItem i2 : shapeRepresentation.getItems()) {
// box = (IfcBoundingBox)i2;
// }
// }
// }
IfcFurnishingElement newFurnishing = model.create(IfcFurnishingElement.class, oidProvider);
IfcRelContainedInSpatialStructure containedInSpatialStructure2 = model.create(IfcRelContainedInSpatialStructure.class, oidProvider);
containedInSpatialStructure2.setRelatingStructure(ifcBuildingStorey);
containedInSpatialStructure2.getRelatedElements().add(newFurnishing);
newFurnishing.setName("Generated");
newFurnishing.setGlobalId("TEST");
newFurnishing.setOwnerHistory(ownerHistory);
IfcProductDefinitionShape definitionShape = model.create(IfcProductDefinitionShape.class, oidProvider);
newFurnishing.setRepresentation(definitionShape);
definitionShape.getRepresentations().add(boundingBox);
definitionShape.getRepresentations().add(surfaceModel);
IfcLocalPlacement localPlacement = model.create(IfcLocalPlacement.class, oidProvider);
localPlacement.setPlacementRelTo(ifcSpace.getObjectPlacement());
IfcAxis2Placement3D axis2Placement3D = model.create(IfcAxis2Placement3D.class, oidProvider);
localPlacement.setRelativePlacement(axis2Placement3D);
IfcCartesianPoint pos = model.create(IfcCartesianPoint.class, oidProvider);
pos.getCoordinates().add(-3d);
pos.getCoordinates().add(+0.5d);
pos.getCoordinates().add(0d);
axis2Placement3D.setLocation(pos);
newFurnishing.setObjectPlacement(localPlacement);
}
}
}
}
model.resetExpressIds();
SerializerPlugin serializerPlugin = pluginManager.getSerializerPlugin("org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin", true);
Serializer serializer = serializerPlugin.createSerializer(null);
serializer.init(model, null, true);
SerializerUtils.writeToFile(serializer, Paths.get("withfurn.ifc"));
} catch (PluginException e) {
e.printStackTrace();
} catch (DeserializeException e) {
e.printStackTrace();
} catch (IfcModelInterfaceException e) {
e.printStackTrace();
} catch (SerializerException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.bimserver.plugins.PluginManager in project BIMserver by opensourceBIM.
the class Visualise method main.
public static void main(String[] args) {
PluginManager pluginManager;
try {
pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home"));
DeserializerPlugin deserializerPlugin = pluginManager.requireDeserializer("application/ifc");
Deserializer deserializer = deserializerPlugin.createDeserializer(new PluginConfiguration());
deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1"));
IfcModelInterface model1 = DeserializerUtils.readFromFile(deserializer, TestFile.EXPORT3.getFile());
IfcModelInterface model1b = DeserializerUtils.readFromFile(deserializer, TestFile.EXPORT3.getFile());
IfcModelInterface model2 = DeserializerUtils.readFromFile(deserializer, TestFile.EXPORT3.getFile());
IfcModelInterface model2b = DeserializerUtils.readFromFile(deserializer, TestFile.EXPORT3.getFile());
model1.setObjectOids();
model1b.setObjectOids();
model2.setObjectOids();
model2b.setObjectOids();
model1.indexGuids();
model2.indexGuids();
model2.fixOids(new IncrementingOidProvider(model1.getHighestOid() + 1));
IfcModel merged = new RevisionMerger(model1, model2).merge();
SerializerPlugin serializerPlugin = pluginManager.getSerializerPlugin("org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin", true);
Serializer serializer = serializerPlugin.createSerializer(new PluginConfiguration());
serializer.init(merged, null, false);
SerializerUtils.writeToFile(serializer, Paths.get("merged.ifc"));
new Visualise().start(model1b, "Model 1");
new Visualise().start(model2b, "Model 2");
new Visualise().start(merged, "Merged");
} catch (PluginException e1) {
e1.printStackTrace();
} catch (SerializerException e) {
e.printStackTrace();
} catch (DeserializeException e) {
e.printStackTrace();
} catch (IfcModelInterfaceException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.bimserver.plugins.PluginManager in project BIMserver by opensourceBIM.
the class TestManyRevisions method start.
private void start(String[] args) {
try {
Path home = Paths.get("home");
PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(home);
MetaDataManager metaDataManager = new MetaDataManager(home.resolve("tmp"));
pluginManager.setMetaDataManager(metaDataManager);
try (BimServerClientFactory factory = new JsonBimServerClientFactory(metaDataManager, "http://localhost:8080")) {
BimServerClientInterface client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
try {
SProject project = client.getServiceInterface().addProject("lots2", "ifc2x3tc1");
Path[] files = new Path[] { Paths.get("../TestData/data/AC11-Institute-Var-2-IFC.ifc"), Paths.get("../TestData/data/AC11-FZK-Haus-IFC - Alt.ifc") };
SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
int fn = 0;
for (int i = 0; i < 20; i++) {
System.out.println(i + ": " + files[fn].getFileName().toString());
client.checkin(project.getOid(), "comment" + i, deserializer.getOid(), false, Flow.SYNC, files[fn]);
fn = 1 - fn;
}
} catch (ServerException | UserException | PublicInterfaceNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.bimserver.plugins.PluginManager in project BIMserver by opensourceBIM.
the class GuidHighlighterTester method readModel.
public IfcModelInterface readModel(Path file) {
PluginManager pluginManager;
try {
pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home"));
DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true);
Deserializer deserializer = deserializerPlugin.createDeserializer(new PluginConfiguration());
deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1"));
try {
IfcModelInterface model = DeserializerUtils.readFromFile(deserializer, file);
return model;
} catch (Exception e) {
e.printStackTrace();
}
} catch (PluginException e1) {
e1.printStackTrace();
}
return null;
}
use of org.bimserver.plugins.PluginManager in project BIMserver by opensourceBIM.
the class IfcRioleringTest method start.
private void start() {
Path src = TestFile.RIOLERING_TEST.getFile();
PluginManager pluginManager;
try {
pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home"));
DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true);
Deserializer deserializer = deserializerPlugin.createDeserializer(new PluginConfiguration());
deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1"));
try {
model = DeserializerUtils.readFromFile(deserializer, src);
} catch (Exception e) {
e.printStackTrace();
}
step1();
} catch (PluginException e1) {
e1.printStackTrace();
}
}
Aggregations