Пример #1
0
        public static Dictionary <TessellatedSolid, double> PotentialFastener = new Dictionary <TessellatedSolid, double>(); // value is its certainty

        internal static HashSet <TessellatedSolid> Run(
            Dictionary <TessellatedSolid, List <PrimitiveSurface> > solidPrimitive,
            Dictionary <TessellatedSolid, List <TessellatedSolid> > multipleRefs,
            int threaded,
            bool regenerateTrainingData = false)
        {
            var s = Stopwatch.StartNew();

            s.Start();
            Console.WriteLine();
            Console.WriteLine("\nDetecting Fasteners ....\n");
            Fasteners.Clear();
            Nuts.Clear();
            Washers.Clear();
            PotentialFastener.Clear();
            if (threaded != 0) // either all of them or some of them are threaded
            {
                FastenerPerceptronLearner.RunPerecptronLearner(regenerateTrainingData);
                FastenerGaussianNaiveBayes.RunGaussianNaiveBayes();
                // after training data is generated (or exists), now I should check and see
                // if the csv containing weights and votes exists or not.
                // Even if the trainingData csv doesnt exist but the csv of w and votes exist,
                // we can run the classifier.
                // In TrainingDataGenerator, if user says dont regenerate the training data,
                // now check and see if the WeightsAndVotes.csv exists or not.
            }
            var fastener = new HashSet <TessellatedSolid>();

            if (multipleRefs.Count == 1)
            {
                return(fastener);
            }
            if (threaded == 0) // non of them are threaded
            {
                AutoNonthreadedFastenerDetection.Run(solidPrimitive, multipleRefs);
            }
            else
            {
                if (threaded == 1) // all of them are threaded
                {
                    AutoThreadedFastenerDetection.Run(solidPrimitive, multipleRefs);
                }
                else // some are threaded, some not
                {
                    AutoSemiThreadedFastenerDetection.Run(solidPrimitive, multipleRefs);
                }
            }
            RemoveDetectedFastenersFromPotentialFasteners();
            return(fastener);
        }