Exemple #1
0
        private void ImportFlowColors()
        {
            // Kitware.VTK.dll automatically scales colours to 0-255 range.
            Scalars = new double[numberOfVertices][];
            vtkDataArray colors = vtkModel.GetCellData().GetScalars("Colors");

            for (int i = 0; i < numberOfVertices; i++)
            {
                Scalars[i] = TranslateColorAsFraction(colors.GetTuple3(i));
            }
        }
        private void ImportVectors()
        {
            Vectors = new double[numberOfPoints][];

            vtkDataArray vtkVectors = vtkModel.GetPointData().GetVectors("fn");

            for (int i = 0; i < numberOfPoints; i++)
            {
                Vectors[i]    = vtkVectors.GetTuple3(i);
                Vectors[i][2] = -Vectors[i][2];
            }
        }
Exemple #3
0
        public bool hasCorrectIDMapping(string idType, int[] idList)
        {
            VTKgetNameSpecificVTKDataArray vtkSpecificDataArray = new VTKgetNameSpecificVTKDataArray();
            vtkDataArray idData = null;

            if (idType == "BeamIDs" || idType == "ShellIDs")
            {
                idData = vtkSpecificDataArray.getNameSpecificDataArrayFieldData(m_UnstructuredGrid, idType);
            }
            else if (idType == "NodeIDs")
            {
                idData = vtkSpecificDataArray.getNameSpecificDataArrayPointData(m_UnstructuredGrid, idType);
            }

            if (idData == null || idList == null)
            {
                return(false);
            }

            var hasCorrectIDMapping = true;

            int[] dataArray = new int[idData.GetNumberOfTuples()];
            if (idData.GetNumberOfTuples() != idList.Length)
            {
                return(false);
            }

            for (int i = 0; i < idData.GetNumberOfTuples(); i++)
            {
                if (idList[i] != (idData.GetTuple1(i) - 1))
                {
                    hasCorrectIDMapping = false;
                }

                dataArray[i] = (int)(idData.GetTuple1(i) - 1);
            }
            if (!hasCorrectIDMapping && idType == "BeamIDs")
            {
                BeamIDsNonContiniusAcending = dataArray;
            }
            else if (!hasCorrectIDMapping && idType == "ShellIDs")
            {
                ShellIDsNonContiniusAcending = dataArray;
            }
            else if (!hasCorrectIDMapping && idType == "NodeIDs")
            {
                NodeIDsNonContiniusAcending = dataArray;
            }

            return(hasCorrectIDMapping);
        }
        private void ImportAngles()
        {
            Scalars = new double[numberOfPoints][];
            vtkPointData pointData    = vtkModel.GetPointData();
            int          arrayNumbers = pointData.GetNumberOfArrays();
            vtkDataArray alphaAngles  = pointData.GetScalars("alpha");
            vtkDataArray betaAngles   = pointData.GetScalars("beta");

            for (int i = 0; i < numberOfPoints; i++)
            {
                double[] currentScalars = { alphaAngles.GetTuple1(i), betaAngles.GetTuple1(i), 0.0 };
                Scalars[i] = currentScalars;
            }
        }
Exemple #5
0
        public vtkDataArray getNameSpecificDataArrayCellData(vtkUnstructuredGrid unstructuredGrid, string arrayName)
        {
            vtkDataArray dataArray = null;
            var          cellData  = unstructuredGrid.GetCellData();

            for (int i = 0; i < cellData.GetNumberOfArrays(); i++)
            {
                if (cellData.GetArrayName(i) != arrayName)
                {
                    continue;
                }

                dataArray = cellData.GetArray(i);
            }
            return(dataArray);
        }
Exemple #6
0
 public void SetColors(Mesh mesh, vtkDataArray colorArray, vtkLookupTable lut)
 {
     var numVertices = mesh.vertexCount;
     if (numVertices <= 0 || colorArray == null)
         return;
     var colors = new Color32[numVertices];
     for (var i = 0; i < numVertices; ++i)
     {
         var scalar = colorArray.GetTuple1(i);
         var dcolor = lut.GetColor(scalar);
         var color = new byte[3];
         for (uint j = 0; j < 3; j++)
             color[j] = (byte)(255 * dcolor[j]);
         colors[i] = new Color32(color[0], color[1], color[2], 255);
     }
     mesh.colors32 = colors;
 }
 public FastImageDataFetcherShort(vtkImageData imageData)
 {
     _vtkDataArray1  = imageData.GetPointData().GetScalars();
     this._imageData = imageData;
 }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestCutMaterial(String [] argv)
    {
        //Prefix Content is: ""

          // Lets create a data set.[]
          data = new vtkImageData();
          data.SetExtent((int)0,(int)31,(int)0,(int)31,(int)0,(int)31);
          data.SetScalarTypeToFloat();
          // First the data array:[]
          gauss = new vtkImageGaussianSource();
          gauss.SetWholeExtent((int)0,(int)30,(int)0,(int)30,(int)0,(int)30);
          gauss.SetCenter((double)18,(double)12,(double)20);
          gauss.SetMaximum((double)1.0);
          gauss.SetStandardDeviation((double)10.0);
          gauss.Update();
          a = gauss.GetOutput().GetPointData().GetScalars();
          a.SetName((string)"Gauss");
          data.GetCellData().SetScalars((vtkDataArray)a);
          //skipping Delete gauss
          // Now the material array:[]
          ellipse = new vtkImageEllipsoidSource();
          ellipse.SetWholeExtent((int)0,(int)30,(int)0,(int)30,(int)0,(int)30);
          ellipse.SetCenter((double)11,(double)12,(double)13);
          ellipse.SetRadius((double)5,(double)9,(double)13);
          ellipse.SetInValue((double)1);
          ellipse.SetOutValue((double)0);
          ellipse.SetOutputScalarTypeToInt();
          ellipse.Update();
          m = ellipse.GetOutput().GetPointData().GetScalars();
          m.SetName((string)"Material");
          data.GetCellData().AddArray((vtkAbstractArray)m);
          //skipping Delete ellipse
          cut = new vtkCutMaterial();
          cut.SetInput((vtkDataObject)data);
          cut.SetMaterialArrayName((string)"Material");
          cut.SetMaterial((int)1);
          cut.SetArrayName((string)"Gauss");
          cut.SetUpVector((double)1,(double)0,(double)0);
          cut.Update();
          mapper2 = vtkPolyDataMapper.New();
          mapper2.SetInputConnection((vtkAlgorithmOutput)cut.GetOutputPort());
          mapper2.SetScalarRange((double)0,(double)1);
          //apper2 SetScalarModeToUseCellFieldData[]
          //apper2 SetColorModeToMapScalars []
          //apper2 ColorByArrayComponent "vtkGhostLevels" 0[]
          actor2 = new vtkActor();
          actor2.SetMapper((vtkMapper)mapper2);
          actor2.SetPosition((double)1.5,(double)0,(double)0);
          ren = vtkRenderer.New();
          ren.AddActor((vtkProp)actor2);
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren);
          p = cut.GetCenterPoint();
          n = cut.GetNormal();
          cam = ren.GetActiveCamera();
          cam.SetFocalPoint(p[0],p[1],p[2]);
          cam.SetViewUp(cut.GetUpVector()[0], cut.GetUpVector()[1], cut.GetUpVector()[2]);
          cam.SetPosition(
          (double)(lindex(n,0))+(double)(lindex(p,0)),
          (double)(lindex(n,1))+(double)(lindex(p,1)),
          (double)(lindex(n,2))+(double)(lindex(p,2)));
          ren.ResetCamera();
          iren = vtkRenderWindowInteractor.New();
          iren.SetRenderWindow(renWin);
          iren.Initialize();

        //deleteAllVTKObjects();
    }
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setm(vtkDataArray toSet)
 {
     m = toSet;
 }
 ///<summary> A Set Method for Static Variables </summary>
 public static void Seta(vtkDataArray toSet)
 {
     a = toSet;
 }
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setm(vtkDataArray toSet)
 {
     m = toSet;
 }
 ///<summary> A Set Method for Static Variables </summary>
 public static void Seta(vtkDataArray toSet)
 {
     a = toSet;
 }