Exemple #1
0
        /// <summary>
        /// Compares two objects for geometric equality
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b">object to compare with</param>
        /// <returns></returns>
        public static bool GeometricEquals(this IfcConnectedFaceSet a, IfcRepresentationItem b)
        {
            if (a.Equals(b))
            {
                return(true);
            }
            IfcConnectedFaceSet p = b as IfcConnectedFaceSet;

            if (p == null)
            {
                return(false);
            }
            if (a.CfsFaces.Count != p.CfsFaces.Count)
            {
                return(false);
            }
            List <IfcFace> aFaces = a.CfsFaces.ToList();
            List <IfcFace> bFaces = p.CfsFaces.ToList();

            for (int i = 0; i < aFaces.Count; i++)
            {
                if (!(aFaces[i].GeometricEquals(bFaces[i])))
                {
                    return(false);
                }
            }
            return(true);
        }
        public IXbimShapeGeometryData Mesh(IfcConnectedFaceSet connectedFaceSet)
        {
            var faces = new List <IEnumerable <IfcFace> >();

            faces.Add(connectedFaceSet.CfsFaces);
            return(Mesh(faces, connectedFaceSet.EntityLabel, (float)connectedFaceSet.ModelOf.ModelFactors.Precision));
        }
Exemple #3
0
 /// <summary>
 /// returns a Hash for the geometric behaviour of this object
 /// </summary>
 /// <param name="solid"></param>
 /// <returns></returns>
 public static int GetGeometryHashCode(this IfcConnectedFaceSet cfs)
 {
     int hash = cfs.CfsFaces.Count;
     if (hash > 30) return hash ^ cfs.GetType().Name.GetHashCode(); //probably enough for a uniquish hash
     foreach (var face in cfs.CfsFaces)
         hash ^= face.GetGeometryHashCode();
     return hash;
 }
Exemple #4
0
 /// <summary>
 /// Calculates the maximum number of points in this object, does not remove geometric duplicates
 /// </summary>
 /// <param name="sbsm"></param>
 /// <returns></returns>
 public static int NumberOfPointsMax(this IfcConnectedFaceSet cfs)
 {
     int pointCount = 0;
     foreach (IfcFace face in cfs.CfsFaces)
     {
         pointCount += face.NumberOfPointsMax();
     }
     return pointCount;
 }
        public static void Bounds(this IfcConnectedFaceSet fSet,
                                  out double Xmin, out double Ymin, out double Zmin, out double Xmax, out double Ymax, out double Zmax)
        {
            double xmin = 0; double ymin = 0; double zmin = 0; double xmax = 0; double ymax = 0; double zmax = 0;
            bool   first = true;
            IModel model = fSet.ModelOf;

            model.ForEach <IfcFace>(fSet.CfsFaces, face =>
            {
                IfcFaceBound outer = face.Bounds.OfType <IfcFaceOuterBound>().FirstOrDefault();
                if (outer == null)
                {
                    outer = face.Bounds.FirstOrDefault();
                }
                if (outer == null)
                {
                    return;
                }
                IfcPolyLoop loop = outer.Bound as IfcPolyLoop;
                if (loop != null)
                {
                    foreach (var pt in loop.Polygon)
                    {
                        if (first)
                        {
                            xmin  = pt.X;
                            ymin  = pt.Y;
                            zmin  = pt.Z;
                            xmax  = pt.X;
                            ymax  = pt.Y;
                            zmax  = pt.Z;
                            first = false;
                        }
                        else
                        {
                            xmin = Math.Min(xmin, pt.X);
                            ymin = Math.Min(ymin, pt.Y);
                            zmin = Math.Min(zmin, pt.Z);
                            xmax = Math.Max(xmax, pt.X);
                            ymax = Math.Max(ymax, pt.Y);
                            zmax = Math.Max(zmax, pt.Z);
                        }
                    }
                }
            });
            Xmin = xmin; Ymin = ymin; Zmin = zmin; Xmax = xmax; Ymax = ymax; Zmax = zmax;
        }
 public IXbimShell CreateShell(IfcConnectedFaceSet shell)
 {
     return(_engine.CreateShell(shell));
 }