org.ifcopenshell.IfcOpenShellEngine Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ifcopenshellplugin Show documentation
Show all versions of ifcopenshellplugin Show documentation
BIMserver plugin that uses IfcOpenShell to generate geometry from IFC files
The newest version!
/*******************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
* IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. *
* *
* IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. *
* *
* You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see . *
* *
********************************************************************************/
/*******************************************************************************
* *
* An intermediate between the Plugin implementation and the Model *
* implementation, nothing fancy going on here. *
* *
********************************************************************************/
package org.ifcopenshell;
/******************************************************************************
* Copyright (C) 2009-2019 BIMserver.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see {@literal }.
*****************************************************************************/
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import org.bimserver.plugins.renderengine.Metrics;
import org.bimserver.plugins.renderengine.RenderEngine;
import org.bimserver.plugins.renderengine.RenderEngineException;
import org.bimserver.plugins.renderengine.RenderEngineModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class IfcOpenShellEngine implements RenderEngine {
private static final Logger LOGGER = LoggerFactory.getLogger(IfcOpenShellEngine.class);
private Path executableFilename;
private IfcGeomServerClient client;
private boolean calculateQuantities;
private boolean applyLayerSets;
private boolean disableOpeningSubtractions;
public IfcOpenShellEngine(Path executableFilename, boolean calculateQuantities, boolean applyLayerSets, boolean disableOpeningSubtractions) throws IOException {
this.executableFilename = executableFilename;
this.setCalculateQuantities(calculateQuantities);
this.setApplyLayerSets(applyLayerSets);
this.setDisableOpeningSubtractions(disableOpeningSubtractions);
}
@Override
public void init() throws RenderEngineException {
LOGGER.debug("Initializing IfcOpenShell engine");
client = new IfcGeomServerClient(executableFilename);
client.setCalculateQuantities(isCalculateQuantities());
client.setApplyLayersets(isApplyLayerSets());
client.setDisableOpeningSubtractions(isDisableOpeningSubtractions());
}
@Override
public void close() throws RenderEngineException {
LOGGER.debug("Closing IfcOpenShell engine");
if (client.isRunning()) {
client.close();
}
}
@Override
public RenderEngineModel openModel(InputStream inputStream, long size) throws RenderEngineException {
if (!client.isRunning()) {
client = new IfcGeomServerClient(executableFilename);
}
try {
return new IfcOpenShellModel(client, inputStream, size);
} catch (IOException e) {
throw new RenderEngineException(e);
}
}
@Override
public RenderEngineModel openModel(InputStream inputStream) throws RenderEngineException {
if (!client.isRunning()) {
client = new IfcGeomServerClient(executableFilename);
}
try {
return new IfcOpenShellModel(client, inputStream);
} catch (IOException e) {
throw new RenderEngineException(e);
}
}
public boolean isCalculateQuantities() {
return calculateQuantities;
}
public void setCalculateQuantities(boolean calculateQuantities) {
this.calculateQuantities = calculateQuantities;
}
public boolean isApplyLayerSets() {
return applyLayerSets;
}
public void setApplyLayerSets(boolean applyLayerSets) {
this.applyLayerSets = applyLayerSets;
}
public boolean isDisableOpeningSubtractions(){
return disableOpeningSubtractions;
}
public void setDisableOpeningSubtractions(boolean disableOpeningSubtractions) {
this.disableOpeningSubtractions = disableOpeningSubtractions;
}
@Override
public Metrics getMetrics() {
return null;
}
}