Example #1
0
    public void UpdateFilter()
    {
        if (isRoot)
        {
            return;
        }

        //Update this filter
        filter.UpdateInput();

        //UpdateChildren
        if (hasChildren)
        {
            foreach (VTKNode child in children)
            {
                child.UpdateFilter();
            }
        }

        //Update gameobject
        VtkToUnity vtu;
        VTKRoot    root           = filter.gameObject.GetComponent <VTKRoot>();
        string     gameObjectName = VTK.GetGameObjectName(this);

        if (root.gameObjects.TryGetValue(gameObjectName, out vtu))
        {
            /*
             * vtu.triangleFilter.SetInputConnection(filter.vtkFilter.GetOutputPort());
             * vtu.Update();
             */
            UpdateProperties();
        }
    }
Example #2
0
    public void Read()
    {
        VTKRoot root = gameObject.GetComponent <VTKRoot> ();

        VTK.DataType dataType = root.dataType;

        vtkXMLPolyDataReader polyDataReader;

        vtkXMLUnstructuredGridReader unstructuredGridReader;

        if (dataType == VTK.DataType.PolyData)
        {
            polyDataReader = root.polyDataReader;

            dataArrays = new string[polyDataReader.GetNumberOfPointArrays()
                                    + polyDataReader.GetNumberOfCellArrays()];

            //Cell data
            for (int i = 0; i < polyDataReader.GetNumberOfCellArrays(); i++)
            {
                dataArrays[i] = polyDataReader.GetCellArrayName(i) + " [C]";
            }

            //Point data
            for (int i = 0; i < polyDataReader.GetNumberOfPointArrays(); i++)
            {
                dataArrays[polyDataReader.GetNumberOfCellArrays() + i] =
                    polyDataReader.GetPointArrayName(i) + " [P]";
            }
        }

        if (dataType == VTK.DataType.UnstructuredGrid)
        {
            unstructuredGridReader = root.unstructuredGridReader;

            dataArrays = new string[unstructuredGridReader.GetNumberOfPointArrays()
                                    + unstructuredGridReader.GetNumberOfCellArrays()];

            //Cell data
            for (int i = 0; i < unstructuredGridReader.GetNumberOfCellArrays(); i++)
            {
                dataArrays[i] = unstructuredGridReader.GetCellArrayName(i) + " [C]";
            }

            //Point data
            for (int i = 0; i < unstructuredGridReader.GetNumberOfPointArrays(); i++)
            {
                dataArrays[unstructuredGridReader.GetNumberOfCellArrays() + i] =
                    unstructuredGridReader.GetPointArrayName(i) + " [P]";
            }
        }
    }
Example #3
0
    public void Initialize()
    {
        this.flyStick = GameObject.Find("FlyStick");
        this.root     = gameObject.transform.parent.gameObject.GetComponent <VTKRoot> ();

        this.filter     = node.filter;
        this.properties = node.properties;

        activeMode        = mode.None;
        activeMenu        = menu.None;
        activeParameter   = 0;
        activeIndex       = 0;
        playmodeParameter = null;
    }
Example #4
0
    public override void OnInspectorGUI()
    {
        treeNodeStyle = new GUIStyle(EditorStyles.label);

        script = (VTKRoot)target;

        DrawDefaultInspector();

        SelectFileMenu();

        EditorGUILayout.Separator();

        if (script.selectedFileIsValid)
        {
            FilterMenu();
        }

        EditorUtility.SetDirty(target);
    }
Example #5
0
    public override void OnInspectorGUI()
    {
        treeNodeStyle = new GUIStyle(EditorStyles.label);

        script = (VTKRoot)target;

        DrawDefaultInspector ();

        SelectFileMenu ();

        EditorGUILayout.Separator ();

        if (script.selectedFileIsValid)
        {
            FilterMenu();
        }

        EditorUtility.SetDirty (target);
    }
Example #6
0
    public void UpdateProperties()
    {
        Debug.Log("Update properties: " + VTK.GetGameObjectName(this));

        VtkToUnity vtkToUnity;
        VTKRoot    root = filter.gameObject.GetComponent <VTKRoot>();

        root.gameObjects.TryGetValue(VTK.GetGameObjectName(this), out vtkToUnity);

        vtkToUnity.triangleFilter.SetInputConnection(filter.vtkFilter.GetOutputPort());

        //Properties
        if (properties.selectedColorType == 0)         //solid color
        {
            vtkToUnity.ColorBy(Color.magenta);
        }
        else
        {
            if (properties.selectedColorType == 1)             //data
            {
                string data     = properties.dataArrays[properties.selectedDataArray];
                string dataName = data.Remove(data.IndexOf("[") - 1);

                if (data.EndsWith("[C]"))
                {
                    vtkToUnity.ColorBy(dataName, VtkToUnity.VtkColorType.CELL_DATA);
                }

                if (data.EndsWith("[P]"))
                {
                    vtkToUnity.ColorBy(dataName, VtkToUnity.VtkColorType.POINT_DATA);
                }
            }

            vtkToUnity.SetLut((VtkToUnity.LutPreset)properties.selectedLut);
        }

        vtkToUnity.Update();
    }
    public void Initialize()
    {
        this.flyStick = GameObject.Find ("FlyStick");
        this.root = gameObject.transform.parent.gameObject.GetComponent<VTKRoot> ();

        this.filter = node.filter;
        this.properties = node.properties;

        activeMode = mode.None;
        activeMenu = menu.None;
        activeParameter = 0;
        activeIndex = 0;
        playmodeParameter = null;
    }