private void InitializePathFind()
    {
        search = true;
        PathMarker[] markers = FindObjectsOfType <PathMarker>();
        foreach (PathMarker p in markers)
        {
            Destroy(p.gameObject);
        }
        ArrayList allNodes = graph.returnGraphNodes();

        g1      = allNodes [Random.Range(0, allNodes.Count)] as GameObject;
        v1      = g1.GetComponent <VisualNode> ();
        v2      = v1;
        depth   = 0;
        explore = Random.Range(2, 6);
    }
Esempio n. 2
0
    public void SendQuery()
    {
        ArrayList graphNodes = graph.returnGraphNodes();

        if (filterNodes.Count > 0)
        {
            foreach (VisualNode v in filterNodes)
            {
                graph.removeIgnoreNode(v);
                //v.ColorDef();
                v.gameObject.SetActive(false);
                v.GetComponent <MeshFilter>().mesh = def_mesh;
            }
        }
        filterNodes = new ArrayList();
        foreach (GameObject g in graphNodes)
        {
            VisualNode v          = g.GetComponent <VisualNode>();
            int        queryCount = 0;
            if (ageStrings.Count == 0)
            {
                foreach (string s in queryStrings)
                {
                    if (s.Equals(string.Empty) == false)
                    {
                        print(v.getAttributeInfo().ToLower().Contains(s.ToLower()));
                        if (v.getAttributeInfo().ToLower().Contains(s.ToLower()))
                        {
                            queryCount++;
                        }
                    }
                }
                if (queryCount == queryStrings.Count && Query.Equals(string.Empty) == false)
                {
                    print("Found Node");
                    filterNodes.Add(v);
                    graph.addIgnoreNode(v);
                }
            }
            else
            {
                bool foundAge = false;
                foreach (string s in ageStrings)
                {
                    if (s.Equals(string.Empty) == false)
                    {
                        if (v.getAttributeInfo().ToLower().Contains(s.ToLower()))
                        {
                            foundAge = true;
                            Query   += "found age";
                        }
                    }
                }
                foreach (string s in queryStrings)
                {
                    if (s.Equals(string.Empty) == false)
                    {
                        print(v.getAttributeInfo().ToLower().Contains(s.ToLower()));
                        if (v.getAttributeInfo().ToLower().Contains(s.ToLower()))
                        {
                            queryCount++;
                        }
                    }
                }
                if (queryCount == queryStrings.Count && Query.Equals(string.Empty) == false && foundAge == true)
                {
                    print("Found Node");
                    filterNodes.Add(v);
                    graph.addIgnoreNode(v);
                }
                if (queryStrings.Count == 0 && foundAge)
                {
                    print("Found Node");
                    filterNodes.Add(v);
                    graph.addIgnoreNode(v);
                }
            }
        }

        ArrayList clusters = graph.returnClusterNodes();

        foreach (ClusterBehaviour c in clusters)
        {
            if (Query.Equals(string.Empty))
            {
                c.Brighten();
            }
            else
            {
                c.Dim();
            }
            c.ExitHighlight();
            c.RecreateCluster();
        }
        CreateFilterCluster();
    }
    // Update is called once per frame
    void Update()
    {
        if (graph.graphIsClustered() && !stop)
        {
            int pickNumber = studyAssign.DataArray[0];
            vis_nodes = graph.returnGraphNodes();

            // SimpleFind
            simpleFindAsset = simpleFind[pickNumber];
            string   s     = simpleFindAsset.text.Replace("\r", "\n");
            string[] lines = s.Split("\n"[0]);
            for (int i = 0; i < lines.Length; i++)
            {
                if (lines[i].Equals(string.Empty) == false)
                {
                    simpleFindNodes.Add(search(lines[i]));
                }
            }

            //ComplexFind
            pickNumber       = studyAssign.DataArray[1];
            complexFindAsset = complexFind[pickNumber];
            s     = complexFindAsset.text.Replace("\r", "\n");
            lines = s.Split("\n"[0]);
            for (int i = 0; i < lines.Length; i++)
            {
                if (lines[i].Equals(string.Empty) == false)
                {
                    complexFindNodes.Add(search(lines[i]));
                }
            }

            //CircleCount
            pickNumber       = studyAssign.DataArray[2];
            circleCountAsset = circleCount[pickNumber];
            s     = circleCountAsset.text.Replace("\r", "\n");
            lines = s.Split("\n"[0]);
            for (int i = 0; i < lines.Length; i++)
            {
                if (lines[i].Equals(string.Empty) == false)
                {
                    circleCountNodes.Add(search(lines[i]));
                }
            }

            //AssocCount
            pickNumber      = studyAssign.DataArray[3];
            assocCountAsset = AssocCount[pickNumber];
            s     = assocCountAsset.text.Replace("\r", "\n");
            lines = s.Split("\n"[0]);
            for (int i = 0; i < lines.Length; i++)
            {
                if (lines[i].Equals(string.Empty) == false)
                {
                    AssocCountNodes.Add(search(lines[i]));
                }
            }
            stop = true;
        }
        if (graph.graphIsClustered() && stop == true)
        {
            // set positions for nodes (simple nodes)
            if (studyStage == 1 && simpleStart == false)
            {
                currentTask = "Simple Find";
                for (int i = 0; i < simpleFindNodes.Count; i++)
                {
                    VisualNode v = (VisualNode)simpleFindNodes[i];
                    studyNodes[i].transform.position = v.transform.position;
                    studyNodes[i].setTarget(v);
                    if (i == 0)
                    {
                        currentStudyNode = studyNodes[i];
                        currentStudyNode.gameObject.SetActive(true);
                        closeBtns[0].setStudyNode(currentStudyNode);
                        closeBtns[1].setStudyNode(currentStudyNode);
                    }
                    else
                    {
                        studyNodes[i - 1].setNext(studyNodes[i]);
                        studyNodes[i].gameObject.SetActive(false);
                    }
                }
                simpleStart = true;
            }
            // set positions for nodes (complex nodes)
            if (studyStage == 2 && complexStart == false)
            {
                currentTask = "Complex Find";
                for (int i = 0; i < complexFindNodes.Count; i++)
                {
                    VisualNode v = (VisualNode)complexFindNodes[i];
                    studyNodes[i].transform.position = v.transform.position;
                    studyNodes[i].setTarget(v);
                    if (i == 0)
                    {
                        currentStudyNode = studyNodes[i];
                        currentStudyNode.gameObject.SetActive(true);
                        closeBtns[0].setStudyNode(currentStudyNode);
                        closeBtns[1].setStudyNode(currentStudyNode);
                    }
                    else
                    {
                        studyNodes[i - 1].setNext(studyNodes[i]);
                        studyNodes[i].gameObject.SetActive(false);
                    }
                }
                complexStart = true;
            }
            // set positions for nodes (circle nodes)
            if (studyStage == 3 && circleStart == false)
            {
                currentTask = "Circle Find";
                for (int i = 0; i < circleCountNodes.Count; i++)
                {
                    VisualNode v = (VisualNode)circleCountNodes[i];
                    studyNodes[i].transform.position = v.transform.position;
                    studyNodes[i].setTarget(v);
                    if (i == 0)
                    {
                        currentStudyNode = studyNodes[i];
                        currentStudyNode.gameObject.SetActive(true);
                        closeBtns[0].setStudyNode(currentStudyNode);
                        closeBtns[1].setStudyNode(currentStudyNode);
                    }
                    else
                    {
                        studyNodes[i - 1].setNext(studyNodes[i]);
                        studyNodes[i].gameObject.SetActive(false);
                    }
                }
                circleStart = true;
            }
            // set positions for nodes (circle nodes)
            if (studyStage == 4 && assocStart == false)
            {
                currentTask = "Association Find";
                for (int i = 0; i < AssocCountNodes.Count; i++)
                {
                    VisualNode v = (VisualNode)AssocCountNodes[i];
                    studyNodes[i].transform.position = v.transform.position;
                    studyNodes[i].setTarget(v);
                    if (i == 0)
                    {
                        currentStudyNode = studyNodes[i];
                        currentStudyNode.gameObject.SetActive(true);
                        closeBtns[0].setStudyNode(currentStudyNode);
                        closeBtns[1].setStudyNode(currentStudyNode);
                    }
                    else
                    {
                        studyNodes[i - 1].setNext(studyNodes[i]);
                        studyNodes[i].gameObject.SetActive(false);
                    }
                }
                assocStart = true;
            }
        }
        if (testCSVOutput)
        {
            createCSV();
            testCSVOutput = false;
        }
        if (studyAssign != null)
        {
            splashTime -= Time.deltaTime;
            if (splashTime > 0)
            {
                if (studyAssign.initialLoad > 1)
                {
                    splashText.text = studyAssign.currentNavigation;
                }
                else
                {
                    splashText.text = "INITIAL LOAD TEST";
                }
            }
            else
            {
                splashText.text = "";
            }
            if (studyAssign.currentNavigation.Equals("WM") == false)
            {
                wim.gameObject.SetActive(false);
            }
        }
    }