Discussion:
[vtkusers] VTK7.1: render points as spheres does not work when coloring by cell data
lp
2016-11-09 19:20:40 UTC
Permalink
Hello,

I am playing around with the new feature in vtk7.1 to render edges and
vertices as tubes and spheres (as described in
https://blog.kitware.com/rendering-tubes-and-spheres-in-vtk/).

This is a very nice feature, but I have found one issue: When the mapper is
set to color by cellData (mapper->SetScalarModeToUseCellData()), only the
edges are shown as tubes but the spheres at the vertices are not rendered.
For SetScalarModeToUsePointData it works as expected (both, tubes and
spheres are rendered).

So my question: Is it possible to show the vertex spheres, when coloring by
cellData?

Example code (based on VTK Sphere example) attached.

Regards,
Lukas

CMakeLists.txt
<http://vtk.1045678.n5.nabble.com/file/n5741121/CMakeLists.txt>
Sphere.cxx <http://vtk.1045678.n5.nabble.com/file/n5741121/Sphere.cxx>



--
View this message in context: http://vtk.1045678.n5.nabble.com/VTK7-1-render-points-as-spheres-does-not-work-when-coloring-by-cell-data-tp5741121.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
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
Ken Martin
2016-11-10 13:30:39 UTC
Permalink
Yes you can render the vertices using cell coloring but it is a bit odd.
Let me jump back a bit.

The sphere source produces triangles as cells. So the cell data will be one
color per triangle. The sphere source does not produce any cells that are
verts. The triangles have vertices which we can render but in VTKs
terminology they are not cells. The EdgeVisibility and VertexVisibility
makes the edges and vertices of cells visible but they themselves are not
cells, so no cell coloring.

Another way to see the issue is that a triangle consists of three
vertices. Those vertices in turn are shared by typically 6 triangles each
with their own cell color. So there is no clear mapping of triangle cell
color to shared vertices, we have to use a cell to point filter or
something like that.

So how would you get cell data showing up on vertices? Well you need to
create verts as cells. SphereSource produces cells that are triangles. But
you can use the GlyphFilter on any dataset with points to convert those
points into verts as follows.

sphereSource ss

// optionally if you have cell data on the triangles you can do a
CellToPoint filter
// to convert that to point data suitable for the next glyph filter.

glyph3dFilter glyph
glyphSource2d gs
gs->SetGlyphTypeToVertex()
glyph->SetInputConnection(ss->GetOutputPort())
glyph->SetSource(gs->GetOutputPort());

// add cell data in here for the verts, one entry per vert

mapper->SetInputConnection(glyph->GetOutputPort());
mapper->RenderPointsAsSpheres()
// Keep vertex visibility off

If you want the surface and the verts then add another mapper for the
surface
ala

mapper2->SetInputConnection(ss->GetOutputPort());

Hope that helps!
Thanks
Ken
Post by lp
Hello,
I am playing around with the new feature in vtk7.1 to render edges and
vertices as tubes and spheres (as described in
https://blog.kitware.com/rendering-tubes-and-spheres-in-vtk/).
This is a very nice feature, but I have found one issue: When the mapper is
set to color by cellData (mapper->SetScalarModeToUseCellData()), only the
edges are shown as tubes but the spheres at the vertices are not rendered.
For SetScalarModeToUsePointData it works as expected (both, tubes and
spheres are rendered).
So my question: Is it possible to show the vertex spheres, when coloring by
cellData?
Example code (based on VTK Sphere example) attached.
Regards,
Lukas
CMakeLists.txt
<http://vtk.1045678.n5.nabble.com/file/n5741121/CMakeLists.txt>
Sphere.cxx <http://vtk.1045678.n5.nabble.com/file/n5741121/Sphere.cxx>
--
View this message in context: http://vtk.1045678.n5.nabble.
com/VTK7-1-render-points-as-spheres-does-not-work-when-
coloring-by-cell-data-tp5741121.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at http://www.kitware.com/
opensource/opensource.html
http://www.vtk.org/Wiki/VTK_FAQ
Search the list archives at: http://markmail.org/search/?q=vtkusers
http://public.kitware.com/mailman/listinfo/vtkusers
--
Ken Martin PhD
Chairman & CFO
Kitware Inc.
28 Corporate Drive
Clifton Park NY 12065
518 371 3971

This communication, including all attachments, contains confidential and
legally privileged information, and it is intended only for the use of the
addressee. Access to this email by anyone else is unauthorized. If you are
not the intended recipient, any disclosure, copying, distribution or any
action taken in reliance on it is prohibited and may be unlawful. If you
received this communication in error please notify us immediately and
destroy the original message. Thank you.
lp
2016-11-10 20:10:40 UTC
Permalink
Hello Ken,

Thank you for your swift reply. Let me apologize for not being clear enough
in my initial post. I will try to clarify.

I do not want to color the vertices by cell data. I just want to turn on the
tubes for the cell edges and the spheres for the vertices, while the cells
are colored by values in a cell data array. Both cell edges and vertex
spheres should just be colored by the constant color set with SetEdgeColor
and SetVertexColor on the actor property.

In the example that I send before, the sphere has a double array added to
the cell data and set as the active scalar. The mapper is set to
ScalarModeToUseCellData. On the property of the actor both
RenderLinesAsTubesOn and RenderPointsAsSpheresOn are set. However, only the
tubes are shown, the spheres for the vertices are not.

If I comment out line 36

sphereSource->GetOutput()->GetCellData()->SetActiveScalars("doubleValues");

then both tubes and vertex spheres are shown, but of course the cells are
not colored by their data array.

So, I wonder why is the rendering of the vertex spheres linked to the active
scalar on the cell data? Is this expected behavior?

The example was build with VTK7.1rc2.

Regards,
Lukas



--
View this message in context: http://vtk.1045678.n5.nabble.com/VTK7-1-render-points-as-spheres-does-not-work-when-coloring-by-cell-data-tp5741121p5741133.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
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
Ken Martin
2016-11-10 20:38:55 UTC
Permalink
Ahh OK I got it, that should definitely work. I'll take a look at it.
Thanks! - Ken
Post by lp
Hello Ken,
Thank you for your swift reply. Let me apologize for not being clear enough
in my initial post. I will try to clarify.
I do not want to color the vertices by cell data. I just want to turn on the
tubes for the cell edges and the spheres for the vertices, while the cells
are colored by values in a cell data array. Both cell edges and vertex
spheres should just be colored by the constant color set with SetEdgeColor
and SetVertexColor on the actor property.
In the example that I send before, the sphere has a double array added to
the cell data and set as the active scalar. The mapper is set to
ScalarModeToUseCellData. On the property of the actor both
RenderLinesAsTubesOn and RenderPointsAsSpheresOn are set. However, only the
tubes are shown, the spheres for the vertices are not.
If I comment out line 36
sphereSource->GetOutput()->GetCellData()->SetActiveScalars("
doubleValues");
then both tubes and vertex spheres are shown, but of course the cells are
not colored by their data array.
So, I wonder why is the rendering of the vertex spheres linked to the active
scalar on the cell data? Is this expected behavior?
The example was build with VTK7.1rc2.
Regards,
Lukas
--
View this message in context: http://vtk.1045678.n5.nabble.
com/VTK7-1-render-points-as-spheres-does-not-work-when-
coloring-by-cell-data-tp5741121p5741133.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at http://www.kitware.com/
opensource/opensource.html
http://www.vtk.org/Wiki/VTK_FAQ
Search the list archives at: http://markmail.org/search/?q=vtkusers
http://public.kitware.com/mailman/listinfo/vtkusers
--
Ken Martin PhD
Chairman & CFO
Kitware Inc.
28 Corporate Drive
Clifton Park NY 12065
518 371 3971

This communication, including all attachments, contains confidential and
legally privileged information, and it is intended only for the use of the
addressee. Access to this email by anyone else is unauthorized. If you are
not the intended recipient, any disclosure, copying, distribution or any
action taken in reliance on it is prohibited and may be unlawful. If you
received this communication in error please notify us immediately and
destroy the original message. Thank you.
Ken Martin
2016-11-16 11:10:24 UTC
Permalink
Thanks, this should be fixed in VTK master now.

Thanks again!
Ken
Post by lp
Hello Ken,
Thank you for your swift reply. Let me apologize for not being clear enough
in my initial post. I will try to clarify.
I do not want to color the vertices by cell data. I just want to turn on the
tubes for the cell edges and the spheres for the vertices, while the cells
are colored by values in a cell data array. Both cell edges and vertex
spheres should just be colored by the constant color set with SetEdgeColor
and SetVertexColor on the actor property.
In the example that I send before, the sphere has a double array added to
the cell data and set as the active scalar. The mapper is set to
ScalarModeToUseCellData. On the property of the actor both
RenderLinesAsTubesOn and RenderPointsAsSpheresOn are set. However, only the
tubes are shown, the spheres for the vertices are not.
If I comment out line 36
sphereSource->GetOutput()->GetCellData()->SetActiveScalars("
doubleValues");
then both tubes and vertex spheres are shown, but of course the cells are
not colored by their data array.
So, I wonder why is the rendering of the vertex spheres linked to the active
scalar on the cell data? Is this expected behavior?
The example was build with VTK7.1rc2.
Regards,
Lukas
--
View this message in context: http://vtk.1045678.n5.nabble.
com/VTK7-1-render-points-as-spheres-does-not-work-when-
coloring-by-cell-data-tp5741121p5741133.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at http://www.kitware.com/
opensource/opensource.html
http://www.vtk.org/Wiki/VTK_FAQ
Search the list archives at: http://markmail.org/search/?q=vtkusers
http://public.kitware.com/mailman/listinfo/vtkusers
--
Ken Martin PhD
Chairman & CFO
Kitware Inc.
28 Corporate Drive
Clifton Park NY 12065
518 371 3971

This communication, including all attachments, contains confidential and
legally privileged information, and it is intended only for the use of the
addressee. Access to this email by anyone else is unauthorized. If you are
not the intended recipient, any disclosure, copying, distribution or any
action taken in reliance on it is prohibited and may be unlawful. If you
received this communication in error please notify us immediately and
destroy the original message. Thank you.
lp
2016-11-16 18:19:31 UTC
Permalink
Indeed, now I get vertex spheres when the mapper is set to color cells by
cell data. Thank you for the fix!

One other difference between before and after your change that I want to
mention in case you are not aware:
The coloring of the vertex spheres when having the mapper set to
SetScalarModeToUsePointData is now different. Before, the spheres get the
color matching the active scalar value in the point. Now, they get the
uniform color as set with SetVertexColor on the actor property.

Regards,
Lukas



--
View this message in context: http://vtk.1045678.n5.nabble.com/VTK7-1-render-points-as-spheres-does-not-work-when-coloring-by-cell-data-tp5741121p5741204.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
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

Loading...