XbimGeometry icon indicating copy to clipboard operation
XbimGeometry copied to clipboard

How to get face points of any building element.

Open ashvinisawantsofttechengr opened this issue 1 year ago • 1 comments

Can we use folowing function to get all face points of any building elements and how?

public Dictionary<string, List<List<Point>>> GetFacesOfASpace(string spaceGuid)
        {
            Dictionary<string, List<List<Point>>> faces = new Dictionary<string, List<List<Point>>>();
            XbimGeometryEngine engine = new XbimGeometryEngine();
            PointOperator objOp = new PointOperator();
            try
            {
                IfcSpace spc = _mObjModelIFCStore.Instances.Where<IfcSpace>(rel => rel.GlobalId == spaceGuid).FirstOrDefault();
                var representations = spc.Representation.Representations;

                XbimMatrix3D plc = GenerateLocRefMatrixOfObject(spc);//To use in converting local to global coordinates

                foreach (IfcShapeRepresentation shapeRepresentation in representations)
                {
                    IfcShapeRepresentation rep = (IfcShapeRepresentation)shapeRepresentation;
                    IXbimSolid objectSolid = null;
                    if (shapeRepresentation.RepresentationType == "SweptSolid")
                    {
                        List<Point> extPoints = new List<Point>();
                        IfcExtrudedAreaSolid solid = (IfcExtrudedAreaSolid)rep.Items.ElementAt(0);
                        objectSolid = engine.CreateSolid((IfcExtrudedAreaSolid)solid, null);
                        faces = GetExtFacesOfAFaceSet(objectSolid, plc);
                    }
                    else if(shapeRepresentation.RepresentationType == "AdvancedBrep")
                    {
                        IfcAdvancedBrep advancedBRep = (IfcAdvancedBrep)rep.Items.ElementAt(0);
                        objectSolid = engine.CreateSolid((IfcAdvancedBrep)advancedBRep, null);
                        faces = GetExtFacesOfAFaceSet(objectSolid, plc);
                    }

                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
#if DEBUG
                throw;
#endif
            }
            return faces;
        }

Yes you can, but these points will only be defined in local coordinate system and you may miss other possible types of geometry representations.

martin1cerny avatar Jun 12 '24 12:06 martin1cerny