How to color 3D model according to magnitude of specific column ?

The paraview has ability to get no. of columns in file and then can color each column according to magnitude we specify.
The color range is what we specify in scale. Please see screenshots:


I want to do this C# using activiz.net. But I see all bindings have same api usage. So any code be acceptable. Or even any advice that I can put in my code.

I tried many examples but looking beyond my needs or unworking.Currently my code is simple, just outputing 3d model on GUI.

public static void stl(string filePath, RenderWindowControl renderWindowControl1)
{
    vtkSTLReader reader = vtkSTLReader.New();
    reader.SetFileName(filePath);
    reader.Update();

    vtkPolyDataMapper mapper = vtkPolyDataMapper.New();

    vtkActor actor = vtkActor.New();
    actor.SetMapper(mapper);

    vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow;
    vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer();
    renderer.AddActor(actor);
}

I also upload some sample files:
Domain.stl (3.0 MB)
Drillholes.7z (3.6 MB)

Thanks so much

I think you would need to create a scalar array maybe. So you assign the result of the dot product of each cellnormal with your desired direction.

For calculating the normal vectors use vtkNormalsFilter.

I think for the coloring you would need to set a colortable somewhere, I’m not sure if in the mapper or on the actor and set it to read the scalar values

Hope it is helpful

Thanks so much sir.
With your help I was able to make it color according to values.
I have list of vtkactors. And I specify which actor to set properties from.

This code which gets all column names from actor index:

        public static List<string> getColumns(int actorIndex)
        {
            List<string> colums = new List<string>();
            vtkActor actor = actors[actorIndex];
            var output = actor.GetMapper().GetInputAsDataSet();
            var cell = output.GetCellData();
            for (int i = 0; i < cell.GetNumberOfArrays(); i++)
            {
                var colm = cell.GetArrayName(i);
                if (colm != null) colums.Add(colm);

            }
            return colums;
         }

This code colors the model of specific column.

        public static void setColors(int actorIndex, string column)
        {
            List<string> colums = new List<string>();
            vtkActor actor = actors[actorIndex];
            var output = actor.GetMapper().GetInputAsDataSet();
            var colors = vtkUnsignedCharArray.New();
            colors.SetNumberOfComponents(3);
            colors.SetName("Colors");

            var cell = output.GetCellData();
            for (int i = 0; i < cell.GetNumberOfArrays(); i++)
            {
                var cells = cell.GetArray(i);
                if (cells == null) continue;
                if (column != cell.GetArrayName(i)) continue;
                for (int j = 0; j < cells.GetNumberOfTuples(); j++)
                {
                    var c = color_range((cells.GetComponent(i, j) / cell.GetArray(i).GetRange()[1]) * 100);
                    var R = c.R;
                    var G = c.G;
                    var B = c.B;
                    colors.InsertNextTuple3((double)R, (double)G, (double)B);
                    colors.InsertNextTuple3((double)R, (double)G, (double)B);
                }

            }
            output.GetPointData().SetScalars(colors);
        }

This code gets range of values from specific column.

        public static double[] getRange(int actorIndex, string column)
        {
            List<string> colums = new List<string>();
            vtkActor actor = actors[actorIndex];
            var output = actor.GetMapper().GetInputAsDataSet();
            var cell = output.GetCellData();
            for (int i = 0; i < cell.GetNumberOfArrays(); i++)
            {
                var colm = cell.GetArrayName(i);
                var arr = cell.GetArray(i);
                if (column == colm)
                {
                    if (arr == null) return null;
                    return arr.GetRange();
                }
            }
            return null;
        }

Result looks like this:
Screenshot 2022-05-29 213601

Its good now. But not sure about magnitude. Do you how i set according to magnitude ? like X,Y,Z like paraview does.

Hi again. I didn’t check your code but it appears to work.

Please search examples of vtkMath::Dot…
You need it to get the component of each cell’s normal vector in reference to the default vectors: x, y, z

For example to get the component Nx of vector N, you need to do Dot(N,x), then save the result on the scalar array you will be mapping.