Пример #1
0
        /// <summary>
        /// Adds stroke to the pairwise feature sketch
        /// </summary>
        /// <param name="stroke"></param>
        public void AddStroke(Substroke stroke)
        {
            if (m_Strokes.Contains(stroke))
            {
                return;
            }

            if (m_Stroke2Pairs.ContainsKey(stroke))
            {
                return;
            }

            m_Stroke2Pairs.Add(stroke, new List <Future <FeatureStrokePair> >());

            foreach (Substroke s in m_Strokes)
            {
                StrokePair strokePair           = new StrokePair(s, stroke);
                Future <FeatureStrokePair> pair = createFeatureStrokePair(strokePair);
                m_Stroke2Pairs[stroke].Add(pair);
                m_Pair2FeaturePair.Add(strokePair, pair);
                m_AllFeaturePairs.Add(pair);
                m_Stroke2Pairs[s].Add(pair);
            }

            m_Strokes.Add(stroke);
        }
Пример #2
0
 private Future <FeatureStrokePair> createFeatureStrokePair(StrokePair strokePair)
 {
     return(new Future <FeatureStrokePair>(delegate()
     {
         FeatureStrokePair pair = new FeatureStrokePair(strokePair, m_FeaturesToUse);
         return pair;
     }));
 }
Пример #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="pair">the pair of strokes to use</param>
        /// <param name="featureList">the list of enabled features</param>
        public FeatureStrokePair(StrokePair pair, Dictionary <string, bool> featureList)
            : base(pair.A, pair.B)
        {
            m_Distances = new SubstrokeDistance(A, B);
            m_Overlaps  = new SubstrokeOverlap(A, B);

            m_FeaturesToUse = featureList;
            m_Features      = new Dictionary <string, Feature>();

            AssignFeatureValues();
        }
Пример #4
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="sketch"></param>
        /// <param name="FeaturesToUse"></param>
        public PairwiseFeatureSketch(Sketch.Sketch sketch, Dictionary <string, bool> FeaturesToUse)
        {
            m_Sketch           = sketch;
            m_FeaturesToUse    = FeaturesToUse;
            m_Strokes          = new List <Substroke>();
            m_Stroke2Pairs     = new Dictionary <Substroke, List <Future <FeatureStrokePair> > >();
            m_Pair2FeaturePair = new Dictionary <StrokePair, Future <FeatureStrokePair> >();
            m_AllFeaturePairs  = new List <Future <FeatureStrokePair> >();

            foreach (Substroke stroke in m_Sketch.Substrokes)
            {
                if (!m_Strokes.Contains(stroke))
                {
                    m_Strokes.Add(stroke);
                }

                List <Future <FeatureStrokePair> > pairs = new List <Future <FeatureStrokePair> >(m_Strokes.Count);
                foreach (Substroke s in m_Strokes)
                {
                    if (stroke != s)
                    {
                        StrokePair strokePair           = new StrokePair(s, stroke);
                        Future <FeatureStrokePair> pair = createFeatureStrokePair(strokePair);
                        pairs.Add(pair);

                        if (!m_Pair2FeaturePair.ContainsKey(strokePair))
                        {
                            m_Pair2FeaturePair.Add(strokePair, pair);
                        }

                        m_AllFeaturePairs.Add(pair);

                        if (m_Stroke2Pairs.ContainsKey(s))
                        {
                            m_Stroke2Pairs[s].Add(pair);
                        }
                    }
                }

                if (!m_Stroke2Pairs.ContainsKey(stroke))
                {
                    m_Stroke2Pairs.Add(stroke, pairs);
                }
            }
        }
Пример #5
0
        private void FindPairInfo(List <Substroke> strokes, int indexOfStroke)
        {
            if (indexOfStroke >= strokes.Count)
            {
                return;
            }

            Substroke stroke = strokes[indexOfStroke];

            lock (stroke)
            {
                int size = Math.Max(1, indexOfStroke - 1);
                List <Future <FeatureStrokePair> > pairs = new List <Future <FeatureStrokePair> >(size);
                for (int i = 0; i < indexOfStroke; i++)
                {
                    Substroke s = strokes[i];
                    lock (s)
                    {
                        try
                        {
                            StrokePair strokePair           = new StrokePair(s, stroke);
                            Future <FeatureStrokePair> pair = createFeatureStrokePair(strokePair);
                            pairs.Add(pair);

                            lock (m_Pair2FeaturePair)
                            {
                                if (!m_Pair2FeaturePair.ContainsKey(strokePair))
                                {
                                    m_Pair2FeaturePair.Add(strokePair, pair);
                                }
                            }
                            lock (m_AllFeaturePairs)
                            {
                                m_AllFeaturePairs.Add(pair);
                            }
                            lock (m_Stroke2Pairs)
                            {
                                if (m_Stroke2Pairs.ContainsKey(s))
                                {
                                    m_Stroke2Pairs[s].Add(pair);
                                }
                            }
                        }
                        catch (Exception exc)
                        {
                            Console.WriteLine("PairwiseSketch FindInfo: " + exc.Message);
                            //throw exc;
                        }
                    }
                }

                if (!m_Strokes.Contains(stroke))
                {
                    m_Strokes.Add(stroke);
                }

                if (!m_Stroke2Pairs.ContainsKey(stroke))
                {
                    m_Stroke2Pairs.Add(stroke, pairs);
                }
            }
        }