gpt4 book ai didi

java - 从 IFC 文件中提取几何图形

转载 作者:行者123 更新时间:2023-11-30 07:18:52 24 4
gpt4 key购买 nike

我必须在 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 几何图形。

最佳答案

根据您想对几何体执行的操作、您想深入研究 IFC 标准的程度以及您的解决方案需要什么样的性能,您有两种不同的选择:

  1. 自己提取隐式几何
  2. 使用外部几何引擎

如果您选择第一个选项,则必须研究 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++(IfcopenshellRDF IfcEngine)编写的,因此您必须应对本地库集成。 IFCOpenshell 提供的 jar 包旨在用作 Bimserver 插件。如果没有相应的依赖项,您将无法使用它。但是,您可以从此包中获取 native 二进制文件。为了使用该引擎,您可以从 Bimserver 中汲取一些灵感 plugin source .您将要使用的关键 native 方法是

  • boolean setIfcData(byte[] ifc) 解析ifc数据
  • IfcGeomObject getGeometry() 以连续访问提取的几何体。

关于java - 从 IFC 文件中提取几何图形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15075934/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com