[vtkusers] Automatically configure scalar range for mappers
Francesco Argese
kekko84 at gmail.com
Thu Jul 17 05:04:01 EDT 2014
Hello all,
I have solved using method one. I was doing an error loping on Size
rather than GetNumberOfTuples() of the array in GetPointData and it
was giving me some errors not so clear: in fact it was not a buffer
overflow but only strange values appearing. Probably I must study in
deep vtkDataArray data structure to understand the reason.
Below a sample code extracted hoping that it could be useful for
others. In the code firstFrame is a vector of actors from
lsDynaReader.
Hello,
Francesco
Here is my code:
for(unsigned int i = 0; i < firstFrame.size(); i++)
{
vtkActor *actor = firstFrame.at(i);
// get polyData from vtkActor
vtkPolyData *polyData = (vtkPolyData *) actor->GetMapper()->GetInput();
if(polyData)
{
if(polyData->GetPointData())
{
int arrayNum = 3; // Acceleration
std::cout <<
polyData->GetPointData()->GetArray(arrayNum)->GetName() << std::endl;
vtkDataArray *scalars =
polyData->GetPointData()->GetArray(arrayNum);
for(unsigned int i = 0; i <
polyData->GetPointData()->GetArray(arrayNum)->GetNumberOfTuples();
i++)
{
double magnitude = 0;
for(unsigned int j = 0; j <
polyData->GetPointData()->GetArray(arrayNum)->GetNumberOfComponents();
j++)
{
double value =
polyData->GetPointData()->GetArray(arrayNum)->GetComponent(i, j);
magnitude += pow(value, 2);
}
magnitude = sqrt(magnitude);
min = std::min(min, magnitude);
max = std::max(max, magnitude);
std::cout << magnitude << std::endl;
}
}
}
}
std::cout << "Min found: " << min << std::endl;
std::cout << "Max found: " << max << std::endl;
2014-07-16 15:08 GMT+02:00 Francesco Argese <kekko84 at gmail.com>:
> Hello,
>
> I'm new to vtk and I'm having a problem already asked on this forum
> but that has never received a response. The previous related posts are
> the folowing:
> - http://www.vtk.org/pipermail/vtkusers/2012-June/074840.html
> - http://public.kitware.com/pipermail/vtkusers/2002-January/009488.html
>
> In my case I have a lsdyna fem analysis loaded correctly through Vtk
> that I like to color selecting a particular property (for example
> velocity or acceleration) specified in it.
>
> At the moment I'm able to show something similar to what ParaView
> display for the model except for the range. If I set statically the
> range that I have found with ParaView on a specified model I see the
> same colours but I don't know how to calculate the range for a generic
> model.
>
> I have tried the following:
> - using actor->GetMapper()->GetInput()->GetPointData()->GetArray(id)
> to retrieve parameters related to a property (I think it could be
> right because GetName on the array give me the right property name): I
> calculated a range but the max is different from that calculated in
> ParaView and colours are not so useful. Could it be possible that the
> array I'm using is wrong? Or is there some other scaling operation on
> those parameters?
> - Getting range through GetRange() function but it also don't do me
> the same results of ParaView.
>
> Considering that in ParaView there is something similar I think it
> could be possible to do so.
>
> Have someone any suggestion to try resolving?
>
> Thanks in advance,
> Francesco Argese
More information about the vtkusers
mailing list