示例#1
0
        //Loads stl,  makes computations ("classify" each facet), then removes the facet data from memory.
        private void process_stl_async(string stl_location, int process_count)
        {
            //Build all threads, start. (This snippet may be worth saving?)
            Thread[] threads = new Thread[process_count];
            thread_signin = new bool[process_count];
            for (int i = 0; i < process_count; i++)
            {
                //Lambda expressions pass by reference. Dereferencing is necessary here.
                int dereference_i = i;

                threads[i] = new Thread(() => process_stl_singleprocess(dereference_i, process_count));
            }
            foreach (Thread t in threads)
            {
                t.Start();
            }
            //Wait for all threads to complete.
            while (!MathTools.CheckAll(thread_signin))
            {
                Thread.Sleep(1);
            }

            //Combine tables and reduce.
            lookup_table = StlClassificationTable.CombineReduce(volatile_tables);
        }
示例#2
0
        public static StlClassificationTable CombineReduce(StlClassificationTable[] tables)
        {
            if (tables.Length == 0)
            {
                throw new Exception("Error: no tables to combine.");
            }
            int n = tables[0].Count;
            StlClassificationTable output = new StlClassificationTable(tables[0].Count);

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    List <int> entry = new List <int>();
                    for (int p = 0; p < tables.Length; p++)
                    {
                        List <int> this_table = (tables[p])[i, j];
                        for (int y = 0; y < this_table.Count; y++)
                        {
                            entry.Add(this_table[y]);
                        }
                    }
                    output[i, j] = entry;
                }
            }
            output.Reduce();
            return(output);
        }
示例#3
0
 public StlClassifier(string _stl_location, int _bin_count)
 {
     //build bounds...
     bin_count       = _bin_count;
     stl_location    = _stl_location;
     temp_facet_data = new STL(_stl_location);
     bounds          = get_bounds();
     classifier      = new GridClassifier(bin_count, bounds);
     lookup_table    = new StlClassificationTable(bin_count);
 }
示例#4
0
        //test function for asynchronous classification.
        //This function is not run by default.
        public void RunClassify(int process_count)
        {
            //Declare and initialize volatile table array.
            volatile_tables = new StlClassificationTable[process_count];
            for (int i = 0; i < process_count; i++)
            {
                volatile_tables[i] = new StlClassificationTable(bin_count);
            }

            //Populates the volatile array
            process_stl_async(stl_location, process_count);
        }