Exemplo n.º 1
0
        private void PopulateVoxel(object voxel_notifier_resolution)
        {
            List <object>            param    = (List <object>)voxel_notifier_resolution;
            OrderedVoxel <SeedPoint> voxel    = (OrderedVoxel <SeedPoint>)param[0];
            ManualResetEvent         notifier = (ManualResetEvent)param[1];
            int    resolution = (int)param[2];
            double diameter   = voxel.GetVoxelDimension();
            float  step       = (float)(diameter / resolution);

            for (int x = 0; x < resolution; x++)
            {
                for (int y = 0; y < resolution; y++)
                {
                    semaphore.WaitOne();
                    for (int z = 0; z < resolution; z++)
                    {
                        Vector3 pos = new Vector3((x * step) + voxel.vertices[3].X,
                                                  (y * step) + voxel.vertices[3].Y,
                                                  (z * step) + voxel.vertices[3].Z);
                        SeedPoint sp = Interpolator <SeedPoint> .IWDInterpolatePoint(pos, bulkList, diameter);

                        if (sp == null)
                        {
                            sp = Interpolator <SeedPoint> .NNInterpolatePoint(pos, bulkList);
                        }
                        voxel.AddPoint(sp);
                        voxel.AddPointAt(sp, x, y, z);
                    }
                    semaphore.Release();
                }
            }
            notifier.Set();
        }
Exemplo n.º 2
0
        private void AnalyzeLine(object SteamLine_notifier)
        {
            List <object>    param    = (List <object>)SteamLine_notifier;
            StreamLine       sl       = (StreamLine)param[0];
            ManualResetEvent notifier = (ManualResetEvent)param[1];

            double maxFTLE = double.NegativeInfinity;

            semaphore.WaitOne();
            foreach (SeedPoint sp in sl.Points)
            {
                if (sp.FTLE > maxFTLE)
                {
                    maxFTLE = sp.FTLE;
                }
            }
            foreach (SeedPoint sp in sl.Points)
            {
                SeedPoint newSp = new SeedPoint(sp, maxFTLE);
                lock (bulkListLock)
                {
                    bulkList.Add(newSp);
                }
            }
            semaphore.Release();
            notifier.Set();
        }
Exemplo n.º 3
0
        public void Polygonize(ImplicitField2d field)
        {
            m_field = field;

            ResetCells();              // reset bTouched flags

            m_cellStack.Clear();

            // iterate over seed points
            for (int i = 0; i < m_seedPoints.Count; ++i)
            {
                SeedPoint p  = (SeedPoint)m_seedPoints[i];
                int       xi = (int)(p.x / m_fCellSize);
                int       yi = (int)(p.y / m_fCellSize);

                bool bFoundSurface = false;
                while (!bFoundSurface && yi > 0 && yi < m_cells.Length - 1 && xi > 0 && xi < m_cells[0].Length - 1)
                {
                    if (m_cells[yi][xi].bTouched == false)
                    {
                        bool bResult = ProcessCell(xi, yi);
                        if (bResult == true)
                        {
                            bFoundSurface = true;
                        }
                    }
                    else
                    {
                        bFoundSurface = true;
                    }
                    xi--;
                }

                while (m_cellStack.Count != 0)
                {
                    Cell cell = (Cell)m_cellStack[m_cellStack.Count - 1];
                    m_cellStack.RemoveAt(m_cellStack.Count - 1);

                    if (m_cells[(int)cell.y][(int)cell.x].bTouched == false)
                    {
                        bool bResult = ProcessCell((int)cell.x, (int)cell.y);
                        if (bResult == false)
                        {
                            bResult = true;
                        }
                    }
                }
            }
        }