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"); }