首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从IFC文件中提取几何图形

从IFC文件中提取几何图形
EN

Stack Overflow用户
提问于 2013-02-26 04:32:27
回答 1查看 4.1K关注 0票数 3

我必须在JAVA中提取ifc文件的几何图形。我的问题是,我不知道该怎么做。

我试着使用openifctools,但是文档真的很糟糕。目前,我已加载ifc文件,但无法从模型中提取几何图形。

有人有ifc模型加载的经验吗?

提前谢谢。

编辑:这是我到目前为止所做的

代码语言:javascript
复制
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几何图形。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-09 20:49:25

根据要对几何图形执行的操作、深入研究IFC标准的深度以及解决方案所需的性能,您有两个不同的选项:

  1. 使用外部几何引擎
  2. 提取您自己的

上的隐式几何

如果您选择第一种选择,您将不得不深入研究IFC schema。您只会对IFCProducts感兴趣,因为只有它们才能具有几何体。使用OpenIfcTools,您可以执行以下操作:

代码语言:javascript
复制
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插件。如果没有相应的依赖关系,就不能使用它。但是,您可以从这个包中获取本机二进制文件。为了使用该引擎,您可以从Bimserver plugin source中获得一些灵感。您将使用的关键本机方法是

解析ifc data

  • IfcGeomObject getGeometry()以访问提取的几何successively.

  • boolean setIfcData(byte[] ifc)
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15075934

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档