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.
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
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:
Its good now. But not sure about magnitude. Do you how i set according to magnitude ? like X,Y,Z like paraview does.