[vtkusers] C# ActiViz.NET 5.8.0 mapper issue
Michel Delanaye - Geonx
michel.delanaye at geonx.com
Thu Feb 28 16:01:10 EST 2013
Dear vtk users,
I am using a vtkUnsignedCharArray to define the color of triangles belonging
to a VtkUnstructuredGrid (code snippet 1). Everything works well for
rendering and the mesh is correctly displayed. However, if I change the
color of some of the triangles after rendering, which can be done by
modifying the Tuple for the specific triangles in the colors array, the view
does not get updated and colors are not changed. I have tried many functions
of the mapper, but nothing seems to work except allocating a new mapper and
linking it to the VtkUnstructuredGrid object (see code snippet 2) . I think
this is a strange behavior.
If anyone faced a similar behavior, I would be interested to get in touch.
Best regards,
-Michel Delanaye
geonX SA
//Code snippet 1
vtkUnsignedCharArray colors = vtkUnsignedCharArray.New();
colors.Allocate(Model.VtkUNS.GetNumberOfCells(),1000);
colors.SetNumberOfComponents(3);
colors.SetName("Colors");
Model.VtkUNS.GetCellData().SetScalars(colors);
for (int j = 0; j < Model.VtkUNS.GetNumberOfCells(); j++)
{
colors.InsertNextTupleValue(p_default_color);
}
Marshal.FreeHGlobal(p_default_color);
vtkDataSetMapper mapper = vtkDataSetMapper.New();
_visualization_triangulation.SetMapper(mapper);
mapper.ImmediateModeRenderingOn();
mapper.SetInput(Model.VtkUNS);
mapper.ImmediateModeRenderingOn();
mapper.ScalarVisibilityOn();
. do rendering etc
// Code snippet 2
vtkUnsignedCharArray colors = (vtkUnsignedCharArray)
Model.VtkUNS.GetCellData().GetArray("Colors", ref index);
foreach (long i in f.VtkTriangleIdList)
{
colors.SetTupleValue((long)i, p_picking_color);
}
vtkDataSetMapper mapper = vtkDataSetMapper.New();
_visualization_triangulation.SetMapper(mapper);
mapper.SetInput(Model.VtkUNS);
mapper.ImmediateModeRenderingOn();
mapper.ScalarVisibilityOn();
.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130228/8c17789c/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Dr Michel Delanaye.vcf
Type: text/x-vcard
Size: 1812 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130228/8c17789c/attachment.vcf>
More information about the vtkusers
mailing list