private Vector3D getNormal(FaceIndices face)
        {
            Vector3D v10    = Point3D.Subtract(this.meshVertices[face.Indices[0]], this.meshVertices[face.Indices[1]]);
            Vector3D v12    = Point3D.Subtract(this.meshVertices[face.Indices[2]], this.meshVertices[face.Indices[1]]);
            var      normal = Vector3D.CrossProduct(v12, v10);

            normal.Normalize();
            return(normal);
        }
 //triangulate a cell
 private FaceIndices[] CellToFaces(Cell cell)
 {
     try
     {
         Index index = this._host.cellularFloor.FindIndex(cell);
         int   k     = 0;
         Cell  nextI = this._host.cellularFloor.RelativeIndex(index, new Index(1, 0));
         if (nextI != null)
         {
             if (this.cellToValue.ContainsKey(nextI))
             {
                 k++;
             }
             else
             {
                 nextI = null;
             }
         }
         Cell nextJ = this._host.cellularFloor.RelativeIndex(index, new Index(0, 1));
         if (nextJ != null)
         {
             if (this.cellToValue.ContainsKey(nextJ))
             {
                 k++;
             }
             else
             {
                 nextJ = null;
             }
         }
         Cell nextIJ = this._host.cellularFloor.RelativeIndex(index, new Index(1, 1));
         if (nextIJ != null)
         {
             if (this.cellToValue.ContainsKey(nextIJ))
             {
                 k++;
             }
             else
             {
                 nextIJ = null;
             }
         }
         if (k < 2)//there are only two points
         {
             return(null);
         }
         if (k == 2)//there are three points
         {
             Point3D[] pnts = new Point3D[3];
             pnts[0] = this.point3DAndCell.Find(cell);
             int i = 1;
             if (nextI != null)
             {
                 pnts[i] = this.point3DAndCell.Find(nextI);
                 i++;
             }
             if (nextJ != null)
             {
                 pnts[i] = this.point3DAndCell.Find(nextJ);
                 i++;
             }
             if (nextIJ != null)
             {
                 pnts[i] = this.point3DAndCell.Find(nextIJ);
                 i++;
             }
             int           v0   = this.Point3DAndIndex.Find(pnts[0]);
             int           v1   = this.Point3DAndIndex.Find(pnts[1]);
             int           v2   = this.Point3DAndIndex.Find(pnts[2]);
             FaceIndices[] face = new FaceIndices[1];
             face[0] = new FaceIndices(v0, v1, v2);
             Vector3D vec10  = Point3D.Subtract(pnts[0], pnts[1]);
             Vector3D vec12  = Point3D.Subtract(pnts[2], pnts[1]);
             var      normal = Vector3D.CrossProduct(vec12, vec10);
             if (normal.Z < 0)
             {
                 face[0].Flip();
             }
             return(face);
         }
         //there are four points
         FaceIndices[] faces = new FaceIndices[2];
         Point3D       v00   = this.point3DAndCell.Find(cell);
         int           I00   = this.Point3DAndIndex.Find(v00);
         Point3D       v10   = this.point3DAndCell.Find(nextI);
         int           I10   = this.Point3DAndIndex.Find(v10);
         Point3D       v11   = this.point3DAndCell.Find(nextIJ);
         int           I11   = this.Point3DAndIndex.Find(v11);
         Point3D       v01   = this.point3DAndCell.Find(nextJ);
         int           I01   = this.Point3DAndIndex.Find(v01);
         faces[0] = new FaceIndices(I00, I10, I11);
         faces[1] = new FaceIndices(I00, I11, I01);
         return(faces);
     }
     catch (Exception error)
     {
         MessageBox.Show(error.Message);
     }
     return(null);
 }