[vtkusers] SetActiveVectors when there are many pipelines that use different arrays
Fernando Nellmeldin
f.nellmeldin at open-engineering.com
Wed Nov 9 03:26:10 EST 2016
Hello. Sorry for the delay.
I couldn't find the source of the problem. It seemed like when I did the
mirroring, one time the data was mirrored and the next time no. As I saw in
the source code of vtkReflectionFilter, only the ActiveVectors are mirrored
using reflection filter, and that is a limitation for what I would like to
do (because I want to reflect all the vectorial data).
Finally, the solution I found was to do the trick of mirroring graphically.
This means that I mirror (duplicate and scale (1,-1,1)) the actors of my
scene. This works like a charm, and it is faster than doing the reflection
on the mesh..
Anyway, problem solved!
Thank you very much!
On 27 October 2016 at 15:56, Dan Lipsa <dan.lipsa at kitware.com> wrote:
> Hi Fernando,
> I am not sure what is going on.
> I would save VTK datasets at points in your pipeline to narrow down where
> the problem is. For instance, save the datasets after the passarray filter.
> Also save the datasets before and after your append filter that produces
> the wrong result.
> You can load those datasets in paraview and to see exactly what you get
> after each filter.
>
> I use the following function in Python. You'll need to convert this to C++.
>
> def debugWriteGrid(grid, name):
> writer = vtk.vtkXMLDataSetWriter()
> gridType = grid.GetDataObjectType()
> if (gridType == vtk.VTK_STRUCTURED_GRID):
> ext = ".vts"
> elif (gridType == vtk.VTK_UNSTRUCTURED_GRID):
> ext = ".vtu"
> elif (gridType == vtk.VTK_POLY_DATA):
> ext = ".vtp"
> else:
> print "Unknown grid type: %d" % gridType
> ext = ".vtk"
> writer.SetFileName(name + ext)
> writer.SetInputData(grid)
> writer.Write()
>
>
>
> On Thu, Oct 27, 2016 at 4:38 AM, Fernando Nellmeldin <f.nellmeldin at open-
> engineering.com> wrote:
>
>> Hello, I am still having problems....
>> I added the casting as you suggested:
>>
>> -----
>> // given that model is first an UnstructuredGrid1 and then
>> UnstructuredGridFull
>> vtkSmartPointer<vtkPassArrays> passArrays = vtkSmartPointer<vtkPassArrays>
>> ::New();
>> passArrays->SetInput(model);
>> passArrays->UseFieldTypesOn(); // restrict to only pass what I say
>> passArrays->AddFieldType(vtkDataObject::POINT);
>> passArrays->AddArray(fieldType, "nameOfArray");
>> passArrays->Update();
>>
>> // modelForFilter is a vtkUnstructuredGrid
>> modelForFilter = vtkUnstructuredGrid::SafeDow
>> nCast(passArrays->GetOutput()); // cast to UnstructuredGrid
>> modelForFilter->GetPointData()->SetActiveVectors("nameOfArray"); // set
>> the active vectors in the new data
>> modelForFilter->Update();
>>
>> //warping vector is a vtkWarpVector
>> warpingVector->SetInputConnection(modelForFilter->GetProducerPort());
>> warpingVector->SetInputArrayToProcess(0, 0,
>> 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, "nameOfArray");
>> // the rest of the pipeline is the same...
>> -----
>> The result is the same. I put some modelForFilter->Print(std::cout) and
>> I can see that the selected array is indeed the active vectors...
>>
>> Other thing I tried:
>> modelForFilter->DeepCopy(model); // full copy the model to the new
>> modelForFilter->GetPointData()->SetActiveVectors("nameOfArray"); // set
>> the active in the new
>> modelForFilter->Update();
>> Still, same result.
>>
>> The only thing that works is:
>> modelForFilter = model;
>> But of course, here I only copy the vtkSmartPointer and not the data, so
>> this is the thing I want to avoid.
>>
>> Any ideas?
>> Thank you!
>>
>> On 26 October 2016 at 16:54, Dan Lipsa <dan.lipsa at kitware.com> wrote:
>>
>>> Can you cast the data object to an unstructured grid and then set the
>>> active vector on it? Make sure you call update before you do that.
>>>
>>> Dan
>>>
>>>
>>> On Wed, Oct 26, 2016 at 10:44 AM, Fernando Nellmeldin <
>>> f.nellmeldin at open-engineering.com> wrote:
>>>
>>>> Hello and thank you for your reply!
>>>>
>>>> After your suggestion, I tried using vtkPassArray, but I can't find how
>>>> to set the Active Vectors. The output is a vtkDataObject*, which of course
>>>> doesn't have the PointsData and therefore no setActiveVectors.
>>>> The result is the same as before, when I change the input to Full, I
>>>> see the wrong deformed mesh.
>>>>
>>>> This is my modified code:
>>>>
>>>> // given that model is first an UnstructuredGrid1 and then
>>>> UnstructuredGridFull
>>>> vtkSmartPointer<vtkPassArrays> passArrays =
>>>> vtkSmartPointer<vtkPassArrays>::New();
>>>> passArrays->SetInput(model);
>>>> passArrays->UseFieldTypesOn(); // restrict to only pass what I say
>>>> passArrays->AddFieldType(vtkDataObject::POINT);
>>>> passArrays->AddArray(fieldType, "nameOfArray");
>>>> passArrays->Update();
>>>>
>>>> //warping vector is a vtkWarpVector
>>>> warpingVector->SetInputConnection(passArrays->GetProducerPort());
>>>> warpingVector->SetInputArrayToProcess(0, 0,
>>>> 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, "nameOfArray"); // I don't
>>>> know why this line is needed to see something
>>>> // the rest of the pipeline is the same...
>>>>
>>>> Am I missing something?
>>>>
>>>> Thank you.
>>>>
>>>>
>>>>
>>>> On 26 October 2016 at 15:40, Dan Lipsa <dan.lipsa at kitware.com> wrote:
>>>>
>>>>> Fernando,
>>>>> Can you try vtkPassArray to pass the proper vector array to each of
>>>>> your pipelines? Then you can set the active vector on the output of this
>>>>> algorithm.
>>>>>
>>>>> Dan
>>>>>
>>>>>
>>>>> On Wed, Oct 26, 2016 at 6:23 AM, Fernando Nellmeldin <
>>>>> f.nellmeldin at open-engineering.com> wrote:
>>>>>
>>>>>> Hello.
>>>>>> I would like to show the deformed mesh of a model based on the values
>>>>>> of a point data array of dimension 3 (vectorial data).
>>>>>>
>>>>>> I have the following pipeline:
>>>>>> UnstructuredGrid1 -> WarpVector -> GeometryFilter -> ExtractEdges ->
>>>>>> PolyDataMapper -> Actor
>>>>>> In the WarpVector, I call to say which array to use
>>>>>> WarpVector->SetInputArrayToProcess(0,0,0,
>>>>>> FIELD_ASSOCIATION_POINTS,"nameOfArray");
>>>>>>
>>>>>> The first time I load the actor in screen, everything is OK.
>>>>>>
>>>>>> Later, I would like to mirror the input UnstructuredGrid1 because it
>>>>>> represents half the model. So I do the following:
>>>>>> UnstructuredGrid1 -> ReflectionFilter -> UnstructuredGrid2
>>>>>> {UnstructuredGrid1, UnstructuredGrid2} -> AppendFilter ->
>>>>>> UnstructuredGridFull
>>>>>>
>>>>>> Then, I replace the input of WarpVector by UnstructuredGridFull, and
>>>>>> I reload the actor.
>>>>>> However, what I see on screen is the same deformed mesh than before,
>>>>>> plus another deformed mesh that is not its mirror, it's something different
>>>>>> and not correct, of course.
>>>>>>
>>>>>> If, however, I call:
>>>>>> At the beginning: UnstructuredGrid1->GetPointDat
>>>>>> a()->SetActiveVectors("nameOfArray");
>>>>>> After I did the mirroring: UnstructuredGridFull->GetPoint
>>>>>> Data()->SetActiveVectors("nameOfArray");
>>>>>> I don't have the problem and everything works OK.
>>>>>>
>>>>>> Problem is, I don't want to call setActiveVectors because I can have
>>>>>> more than one pipeline that makes uses of the same UnstructuredGrid with
>>>>>> different vectorial data, and I noticed that each call to setActive* will
>>>>>> modify all the pipelines that makes use of the Scalars/Vectors/Tensors. So
>>>>>> this doesn't seem an option.
>>>>>>
>>>>>> What is the alternative to use here to solve the problem?
>>>>>>
>>>>>> I tried with vtkAssignAttributes but didn't work.
>>>>>> vtkSmartPointer<vtkAssignAttribute> aa =
>>>>>> vtkSmartPointer<vtkAssignAttribute>::New();
>>>>>> aa->SetInput(UnstructuredGridFull);
>>>>>> aa->Assign("nameOfArray", vtkDataSetAttributes::VECTORS,
>>>>>> vtkAssignAttribute::POINT_DATA);
>>>>>> aa->Update();
>>>>>>
>>>>>> And then:
>>>>>> AssignAttribute -> WarpVector instead of UnstructuredGridFull ->
>>>>>> WarpVector.
>>>>>> but same result...
>>>>>>
>>>>>> Thank you.
>>>>>>
>>>>>> --
>>>>>> *Fernando NELLMELDIN*
>>>>>> Software Engineer
>>>>>> *_______________________________________________________________*
>>>>>>
>>>>>> *Open Engineering s.a.*
>>>>>>
>>>>>> Rue Bois Saint-Jean 15/1
>>>>>> B-4102 Seraing (Belgium)
>>>>>> Tel: +32.4.353.30.34
>>>>>>
>>>>>> http://www.open-engineering.com
>>>>>> https://www.linkedin.com/company/open-engineering?trk=biz-co
>>>>>> mpanies-cym
>>>>>>
>>>>>>
>>>>>> *_________________________________________________________________________*
>>>>>>
>>>>>> _______________________________________________
>>>>>> Powered by www.kitware.com
>>>>>>
>>>>>> Visit other Kitware open-source projects at
>>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>>
>>>>>> Please keep messages on-topic and check the VTK FAQ at:
>>>>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>>>>
>>>>>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>>>>>
>>>>>> Follow this link to subscribe/unsubscribe:
>>>>>> http://public.kitware.com/mailman/listinfo/vtkusers
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> *Fernando NELLMELDIN*
>>>> Software Engineer
>>>> *_______________________________________________________________*
>>>>
>>>> *Open Engineering s.a.*
>>>>
>>>> Rue Bois Saint-Jean 15/1
>>>> B-4102 Seraing (Belgium)
>>>> Tel: +32.4.353.30.34
>>>>
>>>> http://www.open-engineering.com
>>>> https://www.linkedin.com/company/open-engineering?trk=biz-companies-cym
>>>>
>>>>
>>>> *_________________________________________________________________________*
>>>>
>>>
>>>
>>
>>
>> --
>> *Fernando NELLMELDIN*
>> Software Engineer
>> *_______________________________________________________________*
>>
>> *Open Engineering s.a.*
>>
>> Rue Bois Saint-Jean 15/1
>> B-4102 Seraing (Belgium)
>> Tel: +32.4.353.30.34
>>
>> http://www.open-engineering.com
>> https://www.linkedin.com/company/open-engineering?trk=biz-companies-cym
>>
>>
>> *_________________________________________________________________________*
>>
>
>
--
*Fernando NELLMELDIN*
Software Engineer
*_______________________________________________________________*
*Open Engineering s.a.*
Rue Bois Saint-Jean 15/1
B-4102 Seraing (Belgium)
Tel: +32.4.353.30.34
http://www.open-engineering.com
https://www.linkedin.com/company/open-engineering?trk=biz-companies-cym
*_________________________________________________________________________*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161109/ab98474f/attachment.html>
More information about the vtkusers
mailing list