コード例 #1
0
    void Start()
    {
        string filepath = System.IO.Path.Combine(Application.streamingAssetsPath, "Vtk-Data/Box.vtp");         //Application.dataPath + "/" + "Vtk-Data/Box.vtp";

        //filepath = filepath.Replace("/", "\\");
        Kitware.VTK.vtkXMLPolyDataReader reader = Kitware.VTK.vtkXMLPolyDataReader.New();
        if (reader.CanReadFile(filepath) == 0)
        {
            Debug.Log(filepath + " could not be loaded by Vtk!");
            return;
        }
        reader.SetFileName(filepath);
        reader.Update();

        VtkToUnity vtkToUnity = new VtkToUnity(reader.GetOutputPort(), "Vtk-Data/Box.vtp");

        vtkToUnity.ColorBy("Elevation", VtkToUnity.VtkColorType.POINT_DATA);
        vtkToUnity.SetLut(VtkToUnity.LutPreset.BLUE_RED);
        //vtkToUnity.ColorBy(Color.red);
        vtkToUnity.Update();
        vtkToUnity.go.transform.Translate(-2f, 0f, 0f);

        Kitware.VTK.vtkContourFilter contours = Kitware.VTK.vtkContourFilter.New();
        contours.SetInputConnection(vtkToUnity.triangleFilter.GetOutputPort());
        contours.SetInputArrayToProcess(0, 0, 0, (int)Kitware.VTK.vtkDataObject.FieldAssociations.FIELD_ASSOCIATION_POINTS, "Elevation");
        for (int i = 0; i < 10; ++i)
        {
            contours.SetValue(i, i / 10.0);
        }
        contours.ComputeScalarsOn();
        VtkToUnity vtkToUnityContours = new VtkToUnity(contours.GetOutputPort(), "Contours");

        vtkToUnityContours.ColorBy("Elevation", VtkToUnity.VtkColorType.POINT_DATA);
        vtkToUnityContours.SetLut(VtkToUnity.LutPreset.BLUE_RED);
        //vtkToUnityContours.ColorBy(Color.red);
        vtkToUnityContours.Update();
        vtkToUnityContours.go.transform.Translate(-4f, 0f, 0f);

        // Points
        filepath = System.IO.Path.Combine(Application.streamingAssetsPath, "Vtk-Data/Points.vtp");
        if (reader.CanReadFile(filepath) == 0)
        {
            Debug.Log(filepath + " could not be loaded by Vtk!");
            return;
        }
        reader.SetFileName(filepath);
        reader.Update();

        VtkToUnity vtkToUnityPoints = new VtkToUnity(reader.GetOutputPort(), "Vtk-Data/Points.vtp");

        vtkToUnityPoints.ColorBy("Elevation", VtkToUnity.VtkColorType.POINT_DATA);
        vtkToUnityPoints.SetLut(VtkToUnity.LutPreset.RED_BLUE);
        //vtkToUnityPoints.ColorBy(Color.red);
        vtkToUnityPoints.Update();
        vtkToUnityPoints.go.transform.Translate(2f, 0f, 0f);
    }
コード例 #2
0
        public new vtkContourFilter NewInstance()
        {
            vtkContourFilter result      = null;
            uint             mteStatus   = 0u;
            uint             mteIndex    = 4294967295u;
            uint             rawRefCount = 0u;
            IntPtr           intPtr      = vtkContourFilter.vtkContourFilter_NewInstance_25(base.GetCppThis(), ref mteStatus, ref mteIndex, ref rawRefCount);

            if (IntPtr.Zero != intPtr)
            {
                bool flag;
                result = (vtkContourFilter)Methods.CreateWrappedObject(mteStatus, mteIndex, rawRefCount, intPtr, true, out flag);
            }
            return(result);
        }
コード例 #3
0
        public new static vtkContourFilter SafeDownCast(vtkObjectBase o)
        {
            vtkContourFilter vtkContourFilter = null;
            uint             mteStatus        = 0u;
            uint             mteIndex         = 4294967295u;
            uint             rawRefCount      = 0u;
            IntPtr           intPtr           = vtkContourFilter.vtkContourFilter_SafeDownCast_26((o == null) ? default(HandleRef) : o.GetCppThis(), ref mteStatus, ref mteIndex, ref rawRefCount);

            if (IntPtr.Zero != intPtr)
            {
                bool flag;
                vtkContourFilter = (vtkContourFilter)Methods.CreateWrappedObject(mteStatus, mteIndex, rawRefCount, intPtr, true, out flag);
                if (flag)
                {
                    vtkContourFilter.Register(null);
                }
            }
            return(vtkContourFilter);
        }