private void modelReloadNewFile(int oldCount, int NewCount) { //指定 单帧 int newIndex = NewCount % GlobalVariableBackground.Instance.modelCacheCount; if (vtkAllFrame.listFrame[newIndex].selfFrameIndex == NewCount) { return; } DirectoryInfo folder = new DirectoryInfo(vtkAllFrame.loadFile.FileDir); FileInfo[] fileinfoArray; fileinfoArray = folder.GetFiles("*.qf"); Array.Sort(fileinfoArray, new FileNameSort()); vtkAllFrame.listFrame[newIndex].selfFrameIndex = NewCount; Others.ThreadLoadFilePack pack = new Others.ThreadLoadFilePack(); //填充 线程数据包-》单帧 pack.vtkAllFrame = vtkAllFrame; pack.vtkFrame = vtkAllFrame.listFrame[newIndex]; pack.vtkFrame.isAllFinish = false; //填充 线程数据包-》单一文件 pack.fileAddres = fileinfoArray[NewCount]; // pack.vtkFrame.timeStartLession = System.DateTime.Now; VTKCManager m = new VTKCManager(); //m.DisposeData(pack); //ThreadPool.QueueUserWorkItem(new WaitCallback(m.DisposeData), pack as object); if (vtkAllFrame.loadFile.dataType == Enums.DataType.Water && vtkAllFrame.modelState.isSmooth) { Others.ThreadSmoothModePack packsm = new Others.ThreadSmoothModePack(); packsm.fileAddres = pack.fileAddres; packsm.smoothCount = 20; packsm.vtkAllFrame = pack.vtkAllFrame; packsm.vtkFrame = pack.vtkFrame; Thread t = new Thread(m.SmoothDispose); t.IsBackground = true; t.Start(packsm); } else { Thread t = new Thread(m.DisposeData); t.IsBackground = true; t.Start(pack); } }
public void SmoothDispose(object pack) { Others.ThreadSmoothModePack package = pack as Others.ThreadSmoothModePack; package.vtkFrame.timeLoadStart = DateTime.Now; int index = package.fileAddres.FullName.LastIndexOf('\\'); string strDir = package.fileAddres.FullName.Substring(0, index) + @"\SmoothModel\"; string str = strDir + package.fileAddres.Name; if (!Directory.Exists(strDir)) { Directory.CreateDirectory(strDir); } CLoadTest.smoothModel(package.fileAddres.FullName, str, package.smoothCount); loadQFFile(str, package.vtkFrame); package.vtkFrame.timeLoadQFEnd = DateTime.Now; package.vtkFrame.isLoadFinish = true; pack = null; }
private void modelInitReloadAllFrameByIndex(int indexFrame) { int min, max = 0; int half = GlobalVariableBackground.Instance.modelCacheCount / 2; if (indexFrame - half < 0) { min = 0; max = GlobalVariableBackground.Instance.modelCacheCount - 1; } else if (indexFrame + half > vtkAllFrame.FileCount) { min = vtkAllFrame.FileCount - 1 - GlobalVariableBackground.Instance.modelCacheCount; max = vtkAllFrame.FileCount - 1; } else { min = indexFrame - half; max = indexFrame + half; } for (int i = min; i <= max; i++) { int childIndex = i % GlobalVariableBackground.Instance.modelCacheCount; modelFrameManager modelFrameManager = transform.GetChild(childIndex).GetComponent <modelFrameManager>(); if (modelFrameManager == null) { transform.GetChild(childIndex).gameObject.AddComponent <modelFrameManager>(); modelFrameManager.vtkframe = new VTK_Frame(); modelFrameManager.isCollider = vtkAllFrame.loadFile.dataType == Enums.DataType.Default; } else { if (modelFrameManager.isCutModelGO) { //transform.GetChild(i) 里面含有切割生成的对象 continue; } } VTK_Frame vtkframe = modelFrameManager.vtkframe; vtkframe.go = transform.GetChild(childIndex).gameObject; Others.ThreadLoadFilePack pack = new Others.ThreadLoadFilePack(); pack.vtkFrame = vtkframe; pack.vtkAllFrame = vtkAllFrame; DirectoryInfo folder = new DirectoryInfo(vtkAllFrame.loadFile.FileDir); FileInfo[] fileinfoArray; fileinfoArray = folder.GetFiles("*.qf"); Array.Sort(fileinfoArray, new FileNameSort()); //填充 线程数据包-》单一文件 pack.fileAddres = fileinfoArray[i]; vtkframe.selfFrameIndex = i; VTKCManager m = new VTKCManager(); vtkframe.timeStartLession = DateTime.Now; if (vtkAllFrame.modelState.isSmooth && vtkAllFrame.loadFile.dataType == Enums.DataType.Water) { Others.ThreadSmoothModePack packsm = new Others.ThreadSmoothModePack(); packsm.fileAddres = pack.fileAddres; packsm.smoothCount = 20; packsm.vtkAllFrame = pack.vtkAllFrame; packsm.vtkFrame = pack.vtkFrame; m.SmoothDispose(packsm); //ThreadPool.QueueUserWorkItem(new WaitCallback(m.SmoothDispose), packsm as object); //Thread t = new Thread(m.SmoothDispose); //t.IsBackground = true; //t.Start(packsm); } else { ThreadPool.QueueUserWorkItem(new WaitCallback(m.DisposeData), pack as object); } } }