//this is a simple way to get the polyLoop X product.
        //this is a support function used by the Function TestBuildingStory RHR above
        //This X Product routine is the first attempt to produce a X product from coordinates  Since the coordinates used to define
        //a level plane never create an irregular polygon, this scheme worked.  
        //it will only assuredly work properly for a triangle, square, or rectangle.  Shapes other than these should use subsequent XProduct
        //functions as created below.
        //Created by CHarriman, Senior Product Manager Carmel Software
        //Nov 2012
        public static VectorMath.Vector.CartVect GetPolyLoopXProduct(XmlNodeList PlanarGeometry, string level)
        {
            int cartPtCount = 0;
            VectorMath.Vector.CartVect xProd = new VectorMath.Vector.CartVect();
            //gathers all the cartesian points in a given polyloop
            int nodecount = PlanarGeometry.Count;
            VectorMath.Vector.CartCoord[] vCoords = new VectorMath.Vector.CartCoord[3];
            foreach (XmlNode PolyLoops in PlanarGeometry)
            {
                foreach (XmlNode cartesianPoints in PolyLoops)
                {

                    //test the polyloop RHR convention
                    //count the total number of cartesian coordinates
                    int coordcount = cartesianPoints.ChildNodes.Count;
                    //I may want to test the number of coordinates to make sure it matches, or if it has a minimum number of coords
                    if (coordcount < minPlanePoints)
                    {
                        //result += "Insufficient number of cartesian points to define a plane";
                        return xProd;
                    }
                    else
                    {
                        cartPtCount = 0;
                        //gets a set of XYZ coordinates, one at a time
                        foreach (XmlNode coordinates in cartesianPoints.ChildNodes)
                        {
                            if (cartPtCount < 3)
                            {
                                VectorMath.Vector.CartCoord vC = new VectorMath.Vector.CartCoord();
                                vCoords[cartPtCount] = vC;
                            }
                            else { break; }

                            int crdCount = 1;
                            //gets each coordinate one at a time
                            //filtering through the inner children of the PolyLoop
                            foreach (XmlNode coordinate in coordinates.ChildNodes)
                            {
                                double coord = Convert.ToDouble(coordinate.InnerText);
                                switch (crdCount)
                                {
                                    case 1:
                                        vCoords[cartPtCount].X = coord;
                                        break;
                                    case 2:
                                        vCoords[cartPtCount].Y = coord;
                                        break;
                                    case 3:
                                        vCoords[cartPtCount].Z = coord;
                                        break;
                                    default:
                                        break;
                                }
                                if (vCoords[cartPtCount].Z.ToString() == level) { break; };
                                crdCount++;
                            }

                            cartPtCount++;
                        }

                    }
                }
                if (vCoords[(cartPtCount - 1)].Z.ToString() == level) { break; }
            }
            //Get the Cross Product
            VectorMath.Vector.CartVect v1 = VectorMath.Vector.CreateVector(vCoords[0], vCoords[1]);
            VectorMath.Vector.CartVect v2 = VectorMath.Vector.CreateVector(vCoords[1], vCoords[2]);
            xProd = VectorMath.Vector.CrossProduct(v1, v2);
            xProd = Vector.UnitVector(xProd);
            return xProd;

        }
        //this is a support function used by the GetLevelHeights function above.  It is not directly,
        //iteslf, a test
        private static List<string> GetLevelZs(XmlNodeList PlanarGeometry, List<string> LevelZs)
        {
            string result = "";
            int polyLoopCount = 0;
            try
            {
                int nodecount = PlanarGeometry.Count;
                VectorMath.Vector.CartCoord[] vCoords = new VectorMath.Vector.CartCoord[nodecount];
                foreach (XmlNode PolyLoops in PlanarGeometry)
                {
                    //gathers all the cartesian points in a given polyloop
                    foreach (XmlNode cartesianPoints in PolyLoops)
                    {

                        //test the polyloop RHR convention
                        //count the total number of cartesian coordinates
                        int coordcount = cartesianPoints.ChildNodes.Count;
                        //I may want to test the number of coordinates to make sure it matches
                        //I do want to ensure I have a minimum number of coords
                        if (coordcount < minPlanePoints)
                        {
                            result += "Insufficient number of cartesian points to define a plane";
                            LevelZs.Add(result);
                            return LevelZs;
                        }
                        else
                        {
                            int cartPtCount = 0;
                            //gets a set of XYZ coordinates, one at a time
                            foreach (XmlNode coordinates in cartesianPoints.ChildNodes)
                            {
                                //I will only test one Z-coordinate in each set of coordinates
                                if (cartPtCount < 1)
                                {
                                    VectorMath.Vector.CartCoord vC = new VectorMath.Vector.CartCoord();
                                    vCoords[polyLoopCount] = vC;
                                }
                                else { break; }

                                int crdCount = 1;
                                //gets each coordinate one at a time
                                foreach (XmlNode coordinate in coordinates.ChildNodes)
                                {
                                    double coord = Convert.ToDouble(coordinate.InnerText);
                                    switch (crdCount)
                                    {
                                        case 1:
                                            vCoords[polyLoopCount].X = coord;
                                            break;
                                        case 2:
                                            vCoords[polyLoopCount].Y = coord;
                                            break;
                                        case 3:
                                            vCoords[polyLoopCount].Z = coord;
                                            break;
                                        default:
                                            break;
                                    }
                                    crdCount++;
                                }
                                cartPtCount++;
                            }
                        }

                    }
                    polyLoopCount++;
                }
                //create the List that holds the z-values of each level
                for (int z = 0; z < nodecount; z++)
                {
                    LevelZs.Add(vCoords[z].Z.ToString());
                }

                return LevelZs;
            }

            catch (Exception e)
            {
                result += e.ToString();
                LevelZs.Add(result);
                return LevelZs;
            }
        }