public void Read() { string relPath = Path.Combine(dirpath, filename); Debug.Log(System.Reflection.MethodBase.GetCurrentMethod().Name); Clear(); Base.Mesh m = Scimesh.Third.Activiz.To.Base.rXmlUGridToMesh(relPath); Base.MeshFilter mf = Base.To.Base.boundaryFacesMeshFilter2(m); Base.MeshPointFieldNullable mpf; if (fieldType == FieldType.Point) { mpf = Scimesh.Third.Activiz.To.Base.rXmlUGridPDArrayToMPFNullableNoMesh(relPath, arrayIndex, m); } else { Base.MeshCellFieldNullable mcf = Scimesh.Third.Activiz.To.Base.rXmlUGridCDArrayToMCFNullableNoMesh(relPath, arrayIndex, m); mpf = Base.To.Base.cellFieldToPointFieldNullable(mcf); } int[][] maps = Base.To.Unity.UMsVerticesToMPointsMaps(m, mf); Mesh[] ums = Base.To.Unity.MeshToUMeshesByMaps(m, maps); SetMeshes(ums); float[][] meshesNormedValues = Base.To.Unity.MPFNullableToUMsNValuesByMaps(mpf, maps); times = new List <float>(); times.Add(0); times.Add(1); fields = new List <string>(); fields.Add(mpf.Name); fields.Add(mpf.Name); List <float[][]> timesMeshesNormedValues = new List <float[][]>(); timesMeshesNormedValues.Add(meshesNormedValues); timesMeshesNormedValues.Add(meshesNormedValues); SetNormedValues(timesMeshesNormedValues); // Workaround of a serialization problem }
public void ReadXmlUGridCArrayToUnity() { UnityEngine.Debug.Log(System.Reflection.MethodBase.GetCurrentMethod().Name); Clear(); // Read XML file Stopwatch stopwatch = Stopwatch.StartNew(); Base.MeshCellFieldNullable mcf = Scimesh.Third.Activiz.To.Base.rXmlUGridCDArrayToMCField(path, index); stopwatch.Stop(); UnityEngine.Debug.Log(string.Format("Reading time: {0} ms, {1} ticks", stopwatch.ElapsedMilliseconds, stopwatch.ElapsedTicks)); //UnityEngine.Debug.Log(mcf); // Convert Cell Field to Point Field stopwatch = Stopwatch.StartNew(); Base.MeshPointFieldNullable mpf = Scimesh.Base.To.Base.cellFieldToPointFieldNullable(mcf); stopwatch.Stop(); UnityEngine.Debug.Log(string.Format("MeshCellField to MeshPointField converting time: {0} ms, {1} ticks", stopwatch.ElapsedMilliseconds, stopwatch.ElapsedTicks)); //UnityEngine.Debug.Log(mpf); // Create MeshFilter stopwatch = Stopwatch.StartNew(); Scimesh.Base.MeshFilter mf = Scimesh.Base.To.Base.boundaryFacesMeshFilter2(mpf.Mesh); stopwatch.Stop(); UnityEngine.Debug.Log(string.Format("MeshFilter creating time: {0} ms, {1} ticks", stopwatch.ElapsedMilliseconds, stopwatch.ElapsedTicks)); // Scimesh Mesh to Unity Mesh stopwatch = Stopwatch.StartNew(); Mesh[] ums = Base.To.Unity.MeshPointFieldToUnityMesh(mpf, mf, Color.Colormap.Get(Color.Colormap.Name.Rainbow)); stopwatch.Stop(); UnityEngine.Debug.Log(string.Format("Scimesh to UnityMesh time: {0} ms, {1} ticks", stopwatch.ElapsedMilliseconds, stopwatch.ElapsedTicks)); // Unity stopwatch = Stopwatch.StartNew(); for (int i = 0; i < ums.Length; i++) { GameObject childMesh = new GameObject(); childMesh.transform.parent = gameObject.transform; MeshFilter meshFilter = childMesh.AddComponent <MeshFilter>(); meshFilter.sharedMesh = ums[i]; MeshRenderer meshRenderer = childMesh.AddComponent <MeshRenderer>(); meshRenderer.material = mat; meshes.Add(childMesh); } stopwatch.Stop(); UnityEngine.Debug.Log(string.Format("Unity time: {0} ms, {1} ticks", stopwatch.ElapsedMilliseconds, stopwatch.ElapsedTicks)); }