public override bool GetSign(Point3 pos)
        {
            var offsetPos = pos - _offset;

            if (offsetPos.X < 0 || offsetPos.Y < 0 || offsetPos.Z < 0)
            {
                return(a.GetSign(pos));
            }
            return(a.GetSign(pos) || b.GetSign(pos - _offset));
        }
 public override bool GetSign(Point3 pos)
 {
     return(!b.GetSign(pos - offset) && a.GetSign(pos));
 }
        public static HermiteDataGrid CopyGrid(AbstractHermiteGrid grid)
        {
            var    ret         = new HermiteDataGrid();
            Point3 storageSize = grid.Dimensions + new Point3(1, 1, 1);

            ret.cells = new Array3D <Vertex>(storageSize);

            for (int x = 0; x < storageSize.X; x++)
            {
                for (int y = 0; y < storageSize.Y; y++)
                {
                    for (int z = 0; z < storageSize.Z; z++)
                    {
                        var p = new Point3(x, y, z);
                        ret.cells[p] = new Vertex()
                        {
                            Sign     = grid.GetSign(p),
                            Material = grid.GetMaterial(p)

                                       /*EdgeData = ret.dirs.Select(dir =>
                                        *  {
                                        *      var edgeId = grid.GetEdgeId(p, p + dir);
                                        *      return grid.HasEdgeData(p, edgeId) ? grid.getEdgeData(p, edgeId) : new Vector4();
                                        *  }).ToArray()*/
                        };
                    }
                }
            }

            //ret.ForEachGridPoint(p =>
            //    {
            //        ret.cells[p] = new Vertex()
            //            {
            //                Sign = grid.GetSign(p),
            //                /*EdgeData = ret.dirs.Select(dir =>
            //                    {
            //                        var edgeId = grid.GetEdgeId(p, p + dir);
            //                        return grid.HasEdgeData(p, edgeId) ? grid.getEdgeData(p, edgeId) : new Vector4();
            //                    }).ToArray()*/
            //            };
            //    });


            var dirs     = ret.dirs;
            var dirEdges = dirs.Select(i => ret.GetEdgeId(new Point3(), i)).ToArray();

            ret.ForEachGridPoint(p =>
            {
                var gridPointP      = ret.cells.GetFast(p.X, p.Y, p.Z);
                gridPointP.EdgeData = new Vector4[3];
                for (int i = 0; i < 3; i++)
                {
                    var dir    = dirs[i];
                    var edgeId = dirEdges[i];

                    Point3 endPoint = p + dir;
                    // Optimization: direclty read from already constructed data
                    if (!ret.cells.InArray(endPoint))
                    {
                        continue;
                    }
                    if (gridPointP.Sign == ret.cells.GetFast(endPoint.X, endPoint.Y, endPoint.Z).Sign)
                    {
                        continue;
                    }
                    if (!grid.HasEdgeData(p, edgeId))
                    {
                        // This can normally not happen, since we check if there is a sign difference by looking at the already evaluated density points.
                        //  If this would be true there is some problem with the manual determining of the existence of an edge.
                        //throw new InvalidOperationException();
                        continue;
                    }
                    gridPointP.EdgeData[i] = grid.getEdgeData(p, edgeId);
                }

                /*val.EdgeData = ret.dirs.Select( dir =>
                 *  {
                 *
                 *  } ).ToArray();*/

                ret.cells[p] = gridPointP;
            });

            return(ret);
        }