예제 #1
0
        /// Start
        void Start()
        {
            /// Read in grid files from ActiveCell folder
            string[] cellFiles = GetCellFiles(hhCellFolder, activeCellFolder);
            Grid     grid1d    = new Grid(new Mesh(), "1D cell");

            grid1d.Attach(new DiameterAttachment());
            VertexAttachementAccessor <DiameterData> diams = new VertexAttachementAccessor <DiameterData> (grid1d);

            UGXReader.Validate = false;
            UGXReader.ReadUGX(cellFiles[1], ref grid1d);
            Grid grid2d = new Grid(new Mesh(), "2D cell");

            UGXReader.Validate = false;
            UGXReader.ReadUGX(cellFiles[2], ref grid2d);

            /// Add visual components
            go = new GameObject(grid1d.Mesh.name);
            go.AddComponent <MeshFilter>();
            go.AddComponent <MeshRenderer>();
            Vector3[] vertices   = grid1d.Mesh.vertices;
            Vector3[] vertices2d = grid2d.Mesh.vertices;

            /// 1D within 3D cell test
            if (isModelGeometryVisible)
            {
                foreach (var edge in grid1d.Edges)
                {
                    int from = edge.From.Id;
                    int to   = edge.To.Id;
                    UnityEngine.Debug.Log("Draw line");
                    ///  DrawLine(vertices[from], vertices[to], Color.red, Color.red);
                }
            }

            go.GetComponent <MeshRenderer>().material = new Material(Shader.Find("Particles/Standard Surface"));
            if (isMappingChecked)
            {
                MappingInfo mapping = MapUtils.BuildMap(cellFiles[1], cellFiles[0], false, cellFiles[2]);
                foreach (var item in mapping.Data)
                {
                    if (Vector3.Distance(vertices2d[item.Key], vertices[item.Value.Item1]) > (thresh * diams[item.Key].Diameter))
                    {
                        UnityEngine.Debug.LogError("Above threhsold");
                    }
                }
            }

            /// Check winding order
            if (CheckWindingOrderConsistency(grid2d.Mesh))
            {
                UnityEngine.Debug.LogError("Inconsistent winding order");
            }

            /// Check read-in normals from ug4 with calculated from Unity
            if (!CheckNormalsConsistency(grid2d))
            {
                UnityEngine.Debug.LogError("inconsistent normals read-in vs. computed normals from Unity");
            }
        }
예제 #2
0
        // Start is called before the first frame update
        void Start()
        {
            Grid grid1d = new Grid(new Mesh(), "1D cell");

            UGXReader.Validate = false;
            UGXReader.ReadUGX(Application.dataPath + "/StreamingAssets/HHSolver/ActiveCell/12_a/10-dkvm2.CNG_1d_2nd_ref.ugx", ref grid1d);
            grid1d.Type = OrderType.DFS;
            Algebra.ReorderMatrix(grid1d, "test13.csv");
        }