/// <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 IfcPolyLoop a, IfcPolyLoop b)
 {
     if (a.Equals(b)) return true;
     if (a.Polygon.Count != b.Polygon.Count) return false;
     for (int i = 0; i < a.Polygon.Count; i++)
         if (!a.Polygon[i].GeometricEquals(b.Polygon[i])) return false;
     return true;
 }
Example #2
0
        internal IVector3D Normal()
        {
            IfcPolyLoop polyLoop = Bound as IfcPolyLoop;

            if (polyLoop != null)
            {
                int numPts = polyLoop.Polygon.Count;
                for (int i = 1; i < polyLoop.Polygon.Count; i++)
                {
                    XbimPoint3D  c     = polyLoop.Polygon[i].XbimPoint3D();
                    XbimPoint3D  p     = polyLoop.Polygon[i - 1].XbimPoint3D();
                    XbimPoint3D  n     = polyLoop.Polygon[(i + 1 == numPts) ? 0 : i + 1].XbimPoint3D();
                    XbimVector3D left  = c - p;
                    XbimVector3D right = n - c;
                    XbimVector3D cp    = XbimVector3D.CrossProduct(left, right);
                    cp.Normalize();
                    if (!double.IsNaN(cp.X)) //happens if the three points are in a straigh line
                    {
                        if (!Orientation)
                        {
                            cp.Negate();
                        }
                        return(new IfcDirection(cp));
                    }
                    else if (i == polyLoop.Polygon.Count - 1)
                    {
                        // if its the last round of for look then just return the last cp
                        return(new IfcDirection(cp));
                    }
                }
                //srl removed the exception to stop invalid faces from causing a crash, an invalid normal is returned which can be checked for
                return(new IfcDirection(0, 0, 0)); //return an invalid normal as the face is either a line or a point
                //throw new Exception("IfcFaceBound:Normal has an Invalid face");
            }
            else
            {
                //srl removed the exception to stop invalid faces from causing a crash, an invalid normal is returned which can be checked for
                return(new IfcDirection(0, 0, 0)); //return an invalid normal as the face is either a line or a point
            }
            // throw new Exception("IfcFaceBound:Normal has an undefined bound");
        }
 public IXbimFace CreateFace(IfcPolyLoop loop)
 {
     return _engine.CreateFace(loop);
 }