예제 #1
0
 public STLMeasuringTool_MultiThread(STL STL2Measure, List<PointD> P, List<Vector> N, int ThreadNumber, EventHandler OnFinish, STLMeasuringTool objSTLMeasurement)
 {
     this.STL2Measure = STL2Measure;
     this.MeasurePoints = P;
     this.MeasurePointNormals = N;
     this.ThreadNumber = ThreadNumber;
     this.OnFinish += OnFinish;
     this.STLMeasurentReferenceObject = objSTLMeasurement;
 }
예제 #2
0
 public STLMeasuringTool_MultiThread(STL STL2Measure, List <PointD> P, List <Vector> N, int ThreadNumber, EventHandler OnFinish, STLMeasuringTool objSTLMeasurement)
 {
     this.STL2Measure                 = STL2Measure;
     this.MeasurePoints               = P;
     this.MeasurePointNormals         = N;
     this.ThreadNumber                = ThreadNumber;
     this.OnFinish                   += OnFinish;
     this.STLMeasurentReferenceObject = objSTLMeasurement;
 }
예제 #3
0
        /// <summary>
        /// 給定STL,量測點及量測方向
        /// 計算 從量測點出發、延量測方向距離最近 的位置
        /// 若與STL所有三角面都無相交則回傳 null
        /// </summary>
        /// <param name="aSTL">STL</param>
        /// <param name="P">量測點</param>
        /// <param name="N">量測方向</param>
        /// <returns>最近點</returns>
        public override void StartMeasure()
        {
            if (this.IsBusy == false)
            {
                //設定狀態
                this.FinishedThreadNumber = 0;
                this.IsBusy    = true;
                this.StartTime = DateTime.Now;

                //劃分執行緒工作區域
                List <int> sliceIndex = new List <int>();
                for (int i = 0; i <= this.ThreadNumber; i++)
                {
                    sliceIndex.Add((int)((double)i * (double)MeasurePoints.Count / (double)this.ThreadNumber));
                }
                //建立量測物件並指定量測範圍
                STLMeasurent_Objects = new List <STLMeasuringTool>();

                for (int i = 0; i < sliceIndex.Count - 1; i++)
                {
                    PointD[] PartoalPoints = new PointD[sliceIndex[i + 1] - sliceIndex[i]];
                    for (int j = 0; j < sliceIndex[i + 1] - sliceIndex[i]; j++)
                    {
                        PartoalPoints[j] = this.MeasurePoints[j + sliceIndex[i]];
                    }
                    STLMeasuringTool aSTLMeasurementObject = (STLMeasuringTool)Activator.CreateInstance(this.STLMeasurentReferenceObject.GetType());
                    aSTLMeasurementObject.STL2Measure        = this.STL2Measure;
                    aSTLMeasurementObject.MeasurePoints      = PartoalPoints.ToList();
                    aSTLMeasurementObject.PercentageChanged += this.OnThreadPercentageChanged;
                    aSTLMeasurementObject.OnFinish          += this.OnThreadFinished;
                    if (aSTLMeasurementObject is ISTLMeasurement_NeedNormals && this.MeasurePointNormals != null)
                    {
                        Vector[] PartoalNormals = new Vector[sliceIndex[i + 1] - sliceIndex[i]];
                        for (int j = 0; j < sliceIndex[i + 1] - sliceIndex[i]; j++)
                        {
                            PartoalNormals[j] = this.MeasurePointNormals[j + sliceIndex[i]];
                        }
                        (aSTLMeasurementObject as ISTLMeasurement_NeedNormals).MeasurePointNormals = PartoalNormals.ToList();
                    }
                    STLMeasurent_Objects.Add(aSTLMeasurementObject);
                }

                foreach (var aThreadObject in STLMeasurent_Objects)
                {
                    aThreadObject.PercentageChanged += OnThreadPercentageChanged;
                    aThreadObject.StartMeasure();
                }
            }
        }