0

我正在寻找一种从 IfcWall 获取绝对顶点的方法。大多数解析器只给出相对位置。如何消除与其他元素的关系并使坐标成为绝对坐标?BimServer API 提供转换矩阵,但输出在某些值上接近 0 或接近无穷大。

是否有一个解析器提供了一种简单的方法来获取墙壁或任何其他具有几何形状的 Ifc 元素的坐标。还是我的方法错了?

我的方法:GeometryGymIfc & apstex ifcopentools

        IfcProject project = db.Project;
        IfcSpatialElement rootElement = project.RootElement;
        List<IfcWall> elements = project.Extract<IfcWall>();
        List<Wall> walls = new List<Wall>();
        List<IfcFacetedBrep> breps = new List<IfcFacetedBrep>();
        foreach (IfcWall element in elements)
        {
            IfcProductRepresentation representation = element.Representation;
            if (representation is null)
            {
                continue;
            }
            foreach (IfcRepresentation rep in representation.Representations)
            {
                IfcShapeRepresentation sr = rep as IfcShapeRepresentation;
                if (sr is null)
                {
                    continue;
                }
                foreach (IfcRepresentationItem item in sr.Items)
                {
                    IfcFacetedBrep fb = item as IfcFacetedBrep;
                    if (fb is null)
                    {
                        continue;
                    }
                    foreach (IfcFace face in fb.Outer.CfsFaces)
                    {
                        foreach (IfcFaceBound facebound in face.Bounds)
                        {
                            IfcLoop loop = facebound.Bound;
                            if (loop is IfcPolyloop == false)
                            {
                                continue;
                            }
                            foreach (IfcCartesianPoint point in ((IfcPolyloop)loop).Polygon)
                            {
                                walls.Add(new Wall(point.Coordinates.Item1, point.Coordinates.Item2, point.Coordinates.Item3));
                            }
                        }
                    }
                }
            }
        }

BIM服务器:

        List<IfcWall> products = model.getAll(IfcWall.class);
        wall = new Wall[products.size()];
        for (IfcWall product : products) {
            if (product.getGeometry() != null) {
                //  Transformation Matrix
                double[] transformationMatrix = new double[product.getGeometry().getTransformation().length / 8];
                ByteBuffer tbuffer = ByteBuffer.wrap(product.getGeometry().getTransformation());
                tbuffer.order(ByteOrder.LITTLE_ENDIAN);
                DoubleBuffer dtbuffer = tbuffer.asDoubleBuffer();
                dtbuffer.get(transformationMatrix);
                for (int i = 0; i < 16; i++) {
                    System.out.println("transformationMatrix " + dtbuffer.get(i));
                }

                //  Coordinate matrix
                double[] coordinateMatrix = new double[product.getGeometry().getData().getVertices().length / 8];
                ByteBuffer cbuffer = ByteBuffer.wrap(product.getGeometry().getData().getVertices());
                cbuffer.order(ByteOrder.LITTLE_ENDIAN);
                DoubleBuffer dcbuffer = cbuffer.asDoubleBuffer();
                dcbuffer.get(coordinateMatrix);
                for (int i = 0; i < 16; i++) {
                    System.out.println("coordinateMatrix " + dcbuffer.get(i));
                }
                //Transformation
                transformationMatrix = Matrix.changeOrientation(transformationMatrix);
                Transform3D transform = new Transform3D(transformationMatrix);
                int count = 0;
                List<double[]> plist = new ArrayList<>();
                for (int i = 2; i < coordinateMatrix.length; i = i + 3) {
                    Point3d p = new Point3d(coordinateMatrix[i - 2], coordinateMatrix[i - 1], coordinateMatrix[i]);
                    transform.transform(p);
                    double[] parray = {p.x, p.y, p.z};
                    plist.add(parray);
                    count++;
                    if (count == 12) count = 0;
                }

                wall[wallcount] = new Wall(GuidCompressor.uncompressGuidString(product.getGlobalId()), product.getGlobalId(), product.getName(), plist);
                wallcount++;
            }
        }
4

0 回答 0