Exemple #1
0
 internal void AddSample(Sample_t s)
 {
     int hashX = (int)(s.x * HashCells);
     int hashY = (int)(s.y * HashCells);
     lock (stipplingData) // prevent the collection from being modified while we may be baking a preview
     {
         stipplingData.samples.Add(s);
     }
     sampleHash[hashX, hashY].Add(s);
 }
Exemple #2
0
        internal List<Sample_t> GetConflictSamples(Sample_t s)
        {
            List<Sample_t> conflict = new List<Sample_t>();
            double radius = 0;
            for (int c = 0; c < NumClasses; ++c) radius = Math.Max(radius, MinDistance((int)(s.x * OutputImageWidth), (int)(s.y * OutputImageHeight), s.c, c));
            double cellSize = 1.0 / HashCells;
            int cellSpan = (int)Math.Ceiling(radius / cellSize);
            int hashX = (int)(s.x * HashCells);
            int hashY = (int)(s.y * HashCells);

            for (int j = Math.Max(0, hashY - cellSpan); j <= Math.Min(HashCells - 1, hashY + cellSpan); ++j)
                for (int i = Math.Max(0, hashX - cellSpan); i <= Math.Min(HashCells - 1, hashX + cellSpan); ++i)
                    foreach (Sample_t s_ in sampleHash[i, j])
                    {
                        double dx = s.x - s_.x;
                        double dy = s.y - s_.y;
                        double d = Math.Sqrt(dx * dx + dy * dy);

                        double radiusS = MinDistance((int)(s.x * OutputImageWidth), (int)(s.y * OutputImageHeight), s.c, s_.c);
                        double radiusS_ = MinDistance((int)(s_.x * OutputImageWidth), (int)(s_.y * OutputImageHeight), s_.c, s.c);

                        if (d <= (radiusS + radiusS_) * 0.5) conflict.Add(s_);
                    }
            return conflict;
        }
 private bool Removable(List<Sample_t> conflict, Sample_t s, float[] fillRate)
 {
     int sx = (int)(s.x * imageWidth);
     int sy = (int)(s.y * imageHeight);
     foreach (Sample_t s_ in conflict)
     {
         int sx_ = (int)(s_.x * imageWidth);
         int sy_ = (int)(s_.y * imageHeight);
         if (r[sx_, sy_, s_.c, s_.c] >= r[sx, sy, s.c, s.c] ||
              fillRate[s_.c] < fillRate[s.c]) return false;
     }
     return true;
 }
Exemple #4
0
        private bool AcceptSample(Sample_t s)
        {
            int sx = (int)(s.x * imageWidth);
            int sy = (int)(s.y * imageHeight);
            double radius = MinDistance(sx, sy, s.c, s.c);

            List<Sample_t> nearby = NearbySamples(s.x, s.y, radius);
            return nearby.Count == 0;
        }
        private bool AcceptSample(Sample_t s)
        {
            double radius = 0;
            for (int c = 0; c < numClasses; ++c) radius = Math.Max(radius, r[(int)(s.x * imageWidth), (int)(s.y * imageHeight), s.c, c]);

            int sx = (int)(s.x * imageWidth);
            int sy = (int)(s.y * imageHeight);

            List<Sample_t> nearby = NearbySamples(s.x, s.y, radius);
            foreach (Sample_t s_ in nearby)
            {
                double dx = s_.x - s.x;
                double dy = s_.y - s.y;
                double d = Math.Sqrt(dx * dx + dy * dy);
                if (d <= r[sx, sy, s.c, s_.c]) return false;
            }
            return true;
        }