/// <summary>
 /// Compares two objects for geomtric equality
 /// </summary>
 /// <param name="a"></param>
 /// <param name="b">object to compare with</param>
 /// <returns></returns>
 public static bool GeometricEquals(this IfcManifoldSolidBrep a, IfcRepresentationItem b)
 {
     IfcFacetedBrep fb = b as IfcFacetedBrep;
     if (fb == null) return false; //different types are not the same
     if(a.Equals(fb)) return true;
     return a.Outer.GeometricEquals(fb.Outer);
 }
 /// <summary>
 /// Compares two objects for geomtric equality
 /// </summary>
 /// <param name="a"></param>
 /// <param name="b">object to compare with</param>
 /// <returns></returns>
 public static bool GeometricEquals(this IfcExtrudedAreaSolid a, IfcRepresentationItem b)
 {
     IfcExtrudedAreaSolid eas = b as IfcExtrudedAreaSolid;
     if(eas == null) return false; //different types are not the same
     double precision = a.ModelOf.ModelFactors.Precision;
     return Math.Abs(a.Depth - eas.Depth) <= precision &&
            a.ExtrudedDirection.GeometricEquals(eas.ExtrudedDirection) &&
            a.Position.GeometricEquals(eas.Position) &&
            a.SweptArea.GeometricEquals(eas.SweptArea);
 }
        /// <summary>
        /// Compares two objects for geomtric equality
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b">object to compare with</param>
        /// <returns></returns>
        public static bool GeometricEquals(this  IfcBooleanResult a, IfcRepresentationItem b)
        {
            IfcBooleanResult p = b as IfcBooleanResult;
            if (p == null) return false; //different types are not the same
            if(a.Equals(p)) return true;
            return a.FirstOperand.EntityLabel == p.FirstOperand.EntityLabel &&
                 a.SecondOperand.EntityLabel == p.SecondOperand.EntityLabel &&
                 a.Operator == p.Operator;

        }
 /// <summary>
 /// Compares two objects for geomtric equality
 /// </summary>
 /// <param name="a"></param>
 /// <param name="b">object to compare with</param>
 /// <returns></returns>
 public static bool GeometricEquals(this IfcBoundingBox a, IfcRepresentationItem b)
 {
     var bb = b as IfcBoundingBox;
     if (bb == null) return false; //different types are not the same
     double precision = a.ModelOf.ModelFactors.Precision;
     return Math.Abs(a.XDim - bb.XDim) <= precision &&
         Math.Abs(a.YDim - bb.YDim) <= precision &&
         Math.Abs(a.ZDim - bb.ZDim) <= precision &&
            a.Corner.GeometricEquals(bb.Corner);
 }
示例#5
0
 public IXbimShapeGeometryData Mesh(IfcRepresentationItem shape)
 {
     var fbm = shape as IfcFaceBasedSurfaceModel;
     if (fbm != null) return Mesh(fbm);
     var sbm = shape as IfcShellBasedSurfaceModel;
     if (sbm != null) return Mesh(sbm);
     var cfs = shape as IfcConnectedFaceSet;
     if (cfs != null) return Mesh(cfs);
     var fbr = shape as IfcFacetedBrep;
     if (fbr != null) return Mesh(fbr);
     throw new ArgumentException("Unsupported representation type for tessellation, " + shape.GetType().Name);
 }
 /// <summary>
 /// Compares two objects for geomtric equality
 /// </summary>
 /// <param name="a"></param>
 /// <param name="b">object to compare with</param>
 /// <returns></returns>
 public static bool GeometricEquals(this IfcSurfaceCurveSweptAreaSolid a, IfcRepresentationItem b)
 {
     IfcSurfaceCurveSweptAreaSolid scsa = b as IfcSurfaceCurveSweptAreaSolid;
     if (scsa == null) return false; //different types are not the same
     double precision = a.ModelOf.ModelFactors.Precision;
     return a.Directrix.GeometricEquals(scsa.Directrix) &&
            a.StartParam == scsa.EndParam &&
            a.EndParam == scsa.EndParam &&
            a.ReferenceSurface.GeometricEquals(scsa.ReferenceSurface) &&
            a.Position.GeometricEquals(scsa.Position) &&
            a.SweptArea.GeometricEquals(scsa.SweptArea);
 }
        /// <summary>
        /// Compares two objects for geomtric equality
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b">object to compare with</param>
        /// <returns></returns>
        public static bool GeometricEquals(this  IfcFaceBasedSurfaceModel a, IfcRepresentationItem b)
        {
            IfcFaceBasedSurfaceModel p = b as IfcFaceBasedSurfaceModel;
            if (p == null) return false; //different type
            List<IfcConnectedFaceSet> fsa = a.FbsmFaces.ToList();
            List<IfcConnectedFaceSet> fsb = p.FbsmFaces.ToList();
            if (fsa.Count != fsb.Count) return false;
            for (int i = 0; i < fsa.Count; i++)
            {
                if (!fsa[i].GeometricEquals(fsb[i])) return false;
            }
            return true;

        }
        /// <summary>
        /// Compares two objects for geomtric equality
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b">object to compare with</param>
        /// <returns></returns>
        public static bool GeometricEquals(this IfcCsgSolid a, IfcRepresentationItem b)
        {
            IfcCsgSolid csg = b as IfcCsgSolid;
            if (csg == null) return false; //different types are not the same

            if (a.TreeRootExpression is IfcBooleanResult && csg.TreeRootExpression is IfcBooleanResult)
                return ((IfcBooleanResult)(a.TreeRootExpression)).GeometricEquals((IfcBooleanResult)(csg.TreeRootExpression));
            else if (a.TreeRootExpression is IfcCsgPrimitive3D)
            {
                throw new XbimGeometryException("Equality of IfcCsgPrimitive3D is not implmeneted yet");
            }
            else
                throw new XbimGeometryException("Equality of unknown Csg Solid is not implmeneted yet");

        }
        /// <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;
        }
 /// <summary>
 /// Compares two objects for geomtric equality
 /// </summary>
 /// <param name="a"></param>
 /// <param name="b">object to compare with</param>
 /// <returns></returns>
 public static bool GeometricEquals(this IfcSolidModel a, IfcRepresentationItem b)
 {
     if (a is IfcExtrudedAreaSolid)
         return ((IfcExtrudedAreaSolid)a).GeometricEquals(b);
     else if (a is IfcFacetedBrep)
         return ((IfcFacetedBrep)a).GeometricEquals(b);
     else if (a is IfcRevolvedAreaSolid)
         return ((IfcRevolvedAreaSolid)a).GeometricEquals(b);
     else if (a is IfcCsgSolid)
         return ((IfcCsgSolid)a).GeometricEquals(b);
     else if (a is IfcSurfaceCurveSweptAreaSolid)
         return ((IfcSurfaceCurveSweptAreaSolid)a).GeometricEquals(b);
     else
     {
         return false;
         throw new XbimGeometryException("Unsupported solid geometry tpype " + a.GetType().Name);
     }
 }
        public override bool Equals(object obj)
        {
            // Check for null
            if (obj == null)
            {
                return(false);
            }

            // Check for type
            if (this.GetType() != obj.GetType())
            {
                return(false);
            }

            // Cast as IfcRoot
            IfcRepresentationItem root = (IfcRepresentationItem)obj;

            return(this == root);
        }
示例#12
0
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     switch (propIndex)
     {
         case 0:
             _item = (IfcRepresentationItem) value.EntityVal;
             break;
         case 1:
             _styles.Add((IfcPresentationStyleAssignment) value.EntityVal);
             break;
         case 2:
             _name = value.StringVal;
             break;
         default:
             this.HandleUnexpectedAttribute(propIndex, value); break;
     }
 }