Пример #1
0
        void SupportSupportedIsland(int[] searchmap, SliceIsland si, int[] lbm, int[] lbmz, bool[] lbms, List <SupportLocation> sl)
        {
            int             l = si.maxx - si.minx;
            int             w = si.maxy - si.miny;
            int             x, y, b, p;
            SupportLocation s = null;

            for (x = si.minx; x <= si.maxx; x++)
            {
                for (y = si.miny; y < si.maxy; y++)
                {
                    p = y * si.xres + x;
                    if (lbms[p] || (searchmap[p] != si.islandid)) // skip if area is already supported
                    {
                        continue;
                    }
                    b = lbmz[p];
                    if (b != 0)
                    {
                        continue; // right now we support only base supports, so b must be 0;
                    }
                    // add support to current location, and mark this area as supported
                    s = new SupportLocation(x, y, si.sliceid, b);
                    sl.Add(s);
                    UpdateSupportMap(lbms, x, y, si.xres, si.yres);
                    si.FloodSupport(searchmap, x, y, x, y);
                }
            }
        }
Пример #2
0
        void SupportLooseIsland(int[] searchmap, SliceIsland si, int[] lbm, int[] lbmz, bool[] lbms, List <SupportLocation> sl)
        {
            int             l = si.maxx - si.minx;
            int             w = si.maxy - si.miny;
            int             x, y, t, b, p;
            SupportLocation s = null;

            // /*P*/ = need to use parameters here
            if ((l < m_supportgap) && (w < m_supportgap))
            {
                // Island is small, in this case just put as Single support in the center
                x = (si.minx + si.maxx) / 2;
                y = (si.miny + si.maxy) / 2;
                p = y * si.xres + x;
                t = lbm[p];
                b = lbmz[p];
                if ((t != 0) && (b == 0)) // right now we support only base supports, so b must be 0;
                {
                    s = new SupportLocation(x, y, t, b);
                    sl.Add(s);
                    UpdateSupportMap(lbms, x, y, si.xres, si.yres);
                }
            }
            if (s != null)
            {
                return;
            }

            // island is big or irregular shape, iterate over the island surface and add supports.
            for (x = si.minx; x <= si.maxx; x++)
            {
                for (y = si.miny; y < si.maxy; y++)
                {
                    p = y * si.xres + x;
                    if (searchmap[p] != si.islandid)
                    {
                        continue;
                    }
                    b = lbmz[p]; // &0xFFFFFF;
                    if (b != 0)
                    {
                        continue; // right now we support only base supports, so b must be 0;
                    }
                    // add support to current location, and mark this area as supported
                    s = new SupportLocation(x, y, si.sliceid, b);
                    sl.Add(s);
                    UpdateSupportMap(lbms, x, y, si.xres, si.yres);
                    si.FloodSupport(searchmap, x, y, x, y);
                }
            }
        }
Пример #3
0
        void ProcessSlice(int[] lbm, int[] lbmz, bool[] lbms, int xres, int yres, List <SupportLocation> sl)
        {
            int npix = xres * yres;

            int[] searchmap = new int[npix];
            int   x, y, p;

            for (p = 0; p < npix; p++)
            {
                searchmap[p] = 0;
            }

            int islandid               = 1;
            List <SliceIsland> islands = new List <SliceIsland>();

            // find islands in the slice
            for (x = 0; x < xres; x++)
            {
                for (y = 0; y < yres; y++)
                {
                    p = y * xres + x;
                    int sid = lbm[p];// &0xFFFFFF;
                    if ((searchmap[p] == 0) && (sid != 0))
                    {
                        SliceIsland si = new SliceIsland(islandid, sid, xres, yres);
                        si.supportGap = m_supportgap;
                        si.FloodIsland(searchmap, lbm, lbmz, x, y);
                        islands.Add(si);
                        islandid++;
                    }
                }
            }

            // locate potential supports locations
            foreach (SliceIsland si in islands)
            {
                // case 1: island is not supported at all.
                if (si.supportedCount == 0)
                {
                    SupportLooseIsland(searchmap, si, lbm, lbmz, lbms, sl);
                }
                // case 2: island is partially supported
                else
                {
                    SupportSupportedIsland(searchmap, si, lbm, lbmz, lbms, sl);
                }
            }
        }
        void ProcessSlice(int[] lbm, int[] lbmz, bool[] lbms, int xres, int yres, List<SupportLocation> sl)
        {
            int npix = xres * yres;
            int[] searchmap = new int[npix];
            int x, y, p;
            for (p = 0; p < npix; p++)
                searchmap[p] = 0;

            int islandid = 1;
            List<SliceIsland> islands = new List<SliceIsland>();

            // find islands in the slice
            for (x = 0; x < xres; x++)
                for (y = 0; y < yres; y++)
                {
                    p = y * xres + x;
                    int sid = lbm[p];// &0xFFFFFF;
                    if ((searchmap[p] == 0) && (sid != 0))
                    {
                        SliceIsland si = new SliceIsland(islandid, sid, xres, yres);
                        si.supportGap = m_supportgap;
                        si.FloodIsland(searchmap, lbm, lbmz, x, y);
                        islands.Add(si);
                        islandid++;
                    }
                }

            // locate potential supports locations
            foreach (SliceIsland si in islands)
            {
                // case 1: island is not supported at all.
                if (si.supportedCount == 0)
                {
                    SupportLooseIsland(searchmap, si, lbm, lbmz, lbms, sl);
                }
                // case 2: island is partially supported
                else
                {
                    SupportSupportedIsland(searchmap, si, lbm, lbmz, lbms, sl);
                }
            }
        }
 void SupportSupportedIsland(int[] searchmap, SliceIsland si, int[] lbm, int[] lbmz, bool[] lbms, List<SupportLocation> sl)
 {
     int l = si.maxx - si.minx;
     int w = si.maxy - si.miny;
     int x, y, b, p;
     SupportLocation s = null;
     for (x = si.minx; x <= si.maxx; x++)
     {
         for (y = si.miny; y < si.maxy; y++)
         {
             p = y * si.xres + x;
             if (lbms[p] || (searchmap[p] != si.islandid)) // skip if area is already supported
                 continue;
             b = lbmz[p];
             if (b != 0)
                 continue; // right now we support only base supports, so b must be 0;
             // add support to current location, and mark this area as supported
             s = new SupportLocation(x, y, si.sliceid, b);
             sl.Add(s);
             UpdateSupportMap(lbms, x, y, si.xres, si.yres);
             si.FloodSupport(searchmap, x, y, x, y);
         }
     }
 }
        void SupportLooseIsland(int[] searchmap, SliceIsland si, int[] lbm, int[] lbmz, bool[] lbms, List<SupportLocation> sl)
        {
            int l = si.maxx - si.minx;
            int w = si.maxy - si.miny;
            int x, y, t, b, p;
            SupportLocation s = null;
            // /*P*/ = need to use parameters here
            if ((l < m_supportgap) && (w < m_supportgap))
            {
                // Island is small, in this case just put as Single support in the center
                x = (si.minx + si.maxx) / 2;
                y = (si.miny + si.maxy) / 2;
                p = y * si.xres + x;
                t = lbm[p];
                b = lbmz[p];
                if ((t != 0) && (b == 0)) // right now we support only base supports, so b must be 0;
                {
                    s = new SupportLocation(x, y, t, b);
                    sl.Add(s);
                    UpdateSupportMap(lbms, x, y, si.xres, si.yres);
                }
            }
            if (s != null)
                return;

            // island is big or irregular shape, iterate over the island surface and add supports.
            for (x = si.minx; x <= si.maxx; x++)
            {
                for (y = si.miny; y < si.maxy; y++)
                {
                    p = y * si.xres + x;
                    if (searchmap[p] != si.islandid)
                        continue;
                    b = lbmz[p]; // &0xFFFFFF;
                    if (b != 0)
                        continue; // right now we support only base supports, so b must be 0;
                    // add support to current location, and mark this area as supported
                    s = new SupportLocation(x, y, si.sliceid, b);
                    sl.Add(s);
                    UpdateSupportMap(lbms, x, y, si.xres, si.yres);
                    si.FloodSupport(searchmap, x, y, x, y);
                }
            }
        }
Пример #7
0
 // calculate supports for islands that are at least partially unsupported by underneath layers.
 void SupportSupportedIsland(int[] searchmap, SliceIsland si, int[] lbm, int[] lbmz, int[] lbms, List<SupportLocation> sl)
 {
     int l = si.maxx - si.minx;
     int w = si.maxy - si.miny;
     int x, y, b, p, t;
     SupportLocation s = null;
     for (x = si.minx; x <= si.maxx; x++)
     {
         for (y = si.miny; y < si.maxy; y++)
         {
             p = y * si.xres + x;
             b = lbmz[p];
             t = lbm[p];
             if ((lbms[p] >= b) || (searchmap[p] != si.islandid)) // skip if area is already supported
                 continue;
             if ((b != 0) && (si.sliceid - b < m_asp.minHeight))
                 continue; // disregard supports that are too low
             // add support to current location, and mark this area as supported
             s = new SupportLocation(x, y, si.sliceid, b);
             sl.Add(s);
             UpdateSupportMap(lbms, x, y, si.xres, si.yres, t);
             si.FloodSupport(searchmap, x, y, x, y);
         }
     }
 }