示例#1
0
    public CleanSceneData.ImportDataStructure CosmosDBStructure_TO_ImportDataStructure(GraphsonToGremlin.CosmosDbStructure data)
    {
        CleanSceneData.ImportDataStructure newStructure = new CleanSceneData.ImportDataStructure();

        newStructure.vertices = new List <CleanSceneData.Vertex>();
        newStructure.edges    = new List <CleanSceneData.Edge>();

        if (data.vertices != null && data.vertices.Any())
        {
            foreach (GraphsonToGremlin.Vertex v in data.vertices)
            {
                CleanSceneData.Vertex newV = BridgeToGraphson.ConvertGraphVertexToSceneNode(v);
                newStructure.vertices.Add(newV);
            }
        }

        if (data.edges != null && data.edges.Any())
        {
            foreach (GraphsonToGremlin.Edge e in data.edges)
            {
                CleanSceneData.Edge newE = BridgeToGraphson.ConvertGraphEdgeToSceneEdge(e);

                newStructure.edges.Add(newE);
            }
        }
        return(newStructure);
    }
示例#2
0
    public static CleanSceneData.Edge ConvertGraphEdgeToSceneEdge(GraphsonToGremlin.Edge graphE)
    {
        CleanSceneData.Edge newE = new CleanSceneData.Edge();
        newE.label = graphE.label;
        newE.type  = graphE.type;

        newE.instanceID     = graphE.id;
        newE.fromInstanceID = graphE.outV;
        newE.toInstanceID   = graphE.inV;

        newE.properties = new Dictionary <string, string>();
        if (graphE.properties != null)
        {
            foreach (KeyValuePair <string, string> p in graphE.properties)
            {
                if (p.Key != null && p.Value != null)
                {
                    newE.properties.Add(p.Key, p.Value);
                }
            }
        }
        return(newE);
    }
示例#3
0
    public void GenerateScene(CleanSceneData.ImportDataStructure data)
    {
        if (data == null)
        {
            return;
        }

        Dictionary <string, GameObject> nodesToInstanceID = new Dictionary <string, GameObject>();

        if (data.vertices.Any())
        {
            // Iterate through all vertices
            for (int i = 0; i < data.vertices.Count; i++)
            {
                CleanSceneData.Vertex v = data.vertices[i];

                GameObject nodeObj = em.CreateNode(new Vector2(v.x, v.y));
                Node       n       = nodeObj.GetComponent <Node>();

                n.label          = v.label;
                n.propertiesDict = v.properties;
                n.x     = v.x;
                n.y     = v.y;
                n.color = v.color;

                n.SetVisualLabel();
                n.ShowDialogBubble();

                n.ShowNodeColor();

                bool status = int.TryParse(v.instanceID, out n.instanceID);
                nodesToInstanceID.Add(v.instanceID, nodeObj);
            }
        }

        if (data.edges.Any())
        {
            // Iterate through all edges
            for (int i = 0; i < data.edges.Count; i++)
            {
                CleanSceneData.Edge e = data.edges[i];

                if (nodesToInstanceID.ContainsKey(e.fromInstanceID) && nodesToInstanceID.ContainsKey(e.toInstanceID))
                {
                    GameObject nodeFrom = nodesToInstanceID[e.fromInstanceID];
                    GameObject nodeTo   = nodesToInstanceID[e.toInstanceID];

                    LineRenderer line     = em.CreateEdge(nodeFrom, nodeTo);
                    Connect      lineData = line.GetComponent <Connect>();
                    lineData.from           = nodeFrom;
                    lineData.to             = nodeTo;
                    lineData.label          = e.label;
                    lineData.propertiesDict = e.properties;

                    em.UpdateNewEdge(line, nodeFrom, nodeTo);
                }
                else
                {
                    print("Could not find instance id for the objects connected to this edge");
                }
            }
        }
    }