xBimTeam / XbimGeometry

XbimGeometry contains the CLR interop libraries and the c++ engine used to compute the 3D geometry of models.
https://xbimteam.github.io/
Other
254 stars 128 forks source link

How to get face points of any building element. #482

Open ashvinisawantsofttechengr opened 3 months ago

ashvinisawantsofttechengr commented 3 months ago

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;
        }
martin1cerny commented 3 months ago

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