我必须在JAVA中提取ifc文件的几何图形。我的问题是,我不知道该怎么做。
我试着使用openifctools,但是文档真的很糟糕。目前,我已加载ifc文件,但无法从模型中提取几何图形。
有人有ifc模型加载的经验吗?
提前谢谢。
编辑:这是我到目前为止所做的
try {
IfcModel ifcModel = new IfcModel();
ifcModel.readStepFile(new File("my-project.ifc"));
Collection<IfcClass> ifcObjects = ifcModel.getIfcObjects();
System.out.println(ifcObjects.iterator().next());
} catch (Exception e) {
e.printStackTrace();
}这将正确加载ifc文件。但我不知道如何处理这些信息。
我也尝试使用IfcOpenShell,但提供的jar容器也不起作用。目前,我正在尝试自己构建IfcOpenShell。
我有点绝望,因为一切都是非常没有文档的,我真的需要加载和解析ifc几何图形。
发布于 2013-09-09 20:49:25
根据要对几何图形执行的操作、深入研究IFC标准的深度以及解决方案所需的性能,您有两个不同的选项:
上的隐式几何
如果您选择第一种选择,您将不得不深入研究IFC schema。您只会对IFCProducts感兴趣,因为只有它们才能具有几何体。使用OpenIfcTools,您可以执行以下操作:
Collection<IfcProduct> products = model.getCollection(IfcProduct.class);
for(IfcProduct product: products){
List<IfcRepresentation> representations = product.getRepresentation().getRepresentations();
assert ! representations.isEmpty();
assert representations.get(0) instanceof IfcShapeRepresentation:
Collection<IfcRepresentationItem> repr = representations.get(0).getItems();
assert !repr.isEmpty();
IfcRepresentationItem representationItem = repr.iterator().next();
assert representationItem instanceof IfcFacetedBrep;
for(IfcFace face: ((IfcFacetedBrep)representationItem).getOuter().getCfsFaces()){
for(IfcFaceBound faceBound: face.getBounds()){
IfcLoop loop = faceBound.getBound();
assert loop instanceof IfcPolyLoop;
for(IfcCartesianPoint point: ((IfcPolyLoop) loop).getPolygon()){
point.getCoordinates();
}
}
}
}然而,有很多不同的GeometryRepresentations,你必须覆盖它们,可能是自己做三角测量之类的事情。我已经展示了一个特例,并提出了很多断言。而且你必须摆弄坐标变换,因为它们可能是递归嵌套的。
如果你选择第二种选择,我所知道的几何引擎都是用C/C++ (Ifcopenshell,RDF IfcEngine)编写的,所以你必须处理本地库集成。IFCOpenshell提供的jar包旨在用作Bimserver插件。如果没有相应的依赖关系,就不能使用它。但是,您可以从这个包中获取本机二进制文件。为了使用该引擎,您可以从Bimserver plugin source中获得一些灵感。您将使用的关键本机方法是
解析ifc data
IfcGeomObject getGeometry()以访问提取的几何successively.的
boolean setIfcData(byte[] ifc)https://stackoverflow.com/questions/15075934
复制相似问题