簡體   English   中英

從IFC文件中提取幾何

[英]Extracting Geometry from IFC File

我必須在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模式 您只會對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插件。 那些沒有相應依賴項就無法使用的人。 但是,您可以從此軟件包中獲取本機二進制文件。 為了使用引擎,您可以從Bimserver 插件源中獲得一些啟發。 您將使用的關鍵本機方法是

  • boolean setIfcData(byte[] ifc)解析ifc數據
  • IfcGeomObject getGeometry()依次訪問提取的幾何。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM