[vtkusers] using vtkImageBlend to combine two gray image (???)

Jeffery Lewis jlewis at accuray.com
Wed Nov 15 13:24:05 EST 2017


If you are using the default normal blend mode, then setting the opacity on the 0 index input will do nothing. To see both images, you just need to set the second input to its desired opacity, the 0 index input will get the remaining. I would consider using vtkImageBlend::SetInputConnection() (the overload that does not have a port parameter) for the first input, and then calling AddInputConnection() for the second input. This will assure older inputs are cleared out.

Your first code sample seems like it is working. Not sure though why the first image is not in the right position. That could be something not caused by vtkImageBlend. Your second code sample though would expect the first image to not show up because the call to SetOpacity(1, 1) would visualize the opacity of the first image to 0.

If you have more than two images to blend, I would recommend using the blend mode compound. When using the blend mode compound, setting the opacity to the first input does do something. To get what you would typically expect, your opacities for all the inputs should add up to 1.

-----Original Message-----
From: vtkusers [mailto:vtkusers-bounces at vtk.org] On Behalf Of vtkusers-request at vtk.org
Sent: Wednesday, November 15, 2017 9:00 AM
To: vtkusers at vtk.org
Subject: vtkusers Digest, Vol 163, Issue 18

Send vtkusers mailing list submissions to
vtkusers at vtk.org

To subscribe or unsubscribe via the World Wide Web, visit
http://public.kitware.com/mailman/listinfo/vtkusers
or, via email, send a message with subject or body 'help' to
vtkusers-request at vtk.org

You can reach the person managing the list at
vtkusers-owner at vtk.org

When replying, please edit your Subject line so it is more specific than "Re: Contents of vtkusers digest..."


Today's Topics:

   1. Re: vtk and gtk on macOS (Langer, Stephen A. (Fed))
   2. Re: vtk and gtk on macOS (Langer, Stephen A. (Fed))
   3. Ensight Gold Binary Reader (Kurt Sansom)
   4. vtkDICOMImageReader will reverse usingImagePositionPatient ?
      (louiskoo)
   5. Re: TimerEvents not fired while dragging mouse in
      vtkRenderWindow (Kolja Petersen)
   6. using vtkImageBlend to combine two gray image (???)
   7. How to use unsigned char to represent cell types? (landings)
   8. Re: TimerEvents not fired while dragging mouse in
      vtkRenderWindow (David Cole)
   9. Re: TimerEvents not fired while dragging mouse in
      vtkRenderWindow (Kolja Petersen)
  10. Re: TimerEvents not fired while dragging mouse in
      vtkRenderWindow (Ken Martin)


----------------------------------------------------------------------

Message: 1
Date: Tue, 14 Nov 2017 19:05:44 +0000
From: "Langer, Stephen A. (Fed)" <stephen.langer at nist.gov>
To: "vtkusers at vtk.org" <vtkusers at vtk.org>
Subject: Re: [vtkusers] vtk and gtk on macOS
Message-ID: <3CDBE37E-520E-46EB-BA69-30F177FC71EF at nist.gov>
Content-Type: text/plain; charset="utf-8"

Just in case someone else is trying to do the same thing and finds this message, the configure callback below is incorrect because gtk and vtk have different ideas about which direction is up.  The call to render_window->SetPosition should be
  GtkWidget *top = gtk_widget_get_toplevel(drawing_area)
 render_window->SetPosition(top->allocation.height- event->y - event->height);

event->y and drawing_area->allocation.y are interchangeable.

-- Steve

From: vtkusers <vtkusers-bounces at vtk.org> on behalf of "Langer, Stephen A. (Fed)" <stephen.langer at nist.gov>
Date: Friday, November 3, 2017 at 10:11 AM
To: David Gobbi <david.gobbi at gmail.com>
Cc: "vtkusers at vtk.org" <vtkusers at vtk.org>
Subject: Re: [vtkusers] vtk and gtk on macOS


HI David --

Thanks for the suggestions, which got me started on the right track.

What seems to work is this (somewhat simplified to eliminate some infrastructure):

// Create gtk widget and vtk window
GtkWidget *drawing_area = gtk_drawing_area_new(); vtkSmartPointer<vtkCocoaRenderWindow> render_window = vtkSmartPointer<vtkCocoaRenderWindow>::New();
// Connect to gtk signals.
g_signal_connect(drawing_area, "realize", realize_callback, ..) g_signal_connect(drawing_area, "configure_event", configure_callback, ?)

// in realize_callback
gtk_widget_realize(drawing_area);
render_window->SetRootWindow(gtk_widget_get_root_window(drawing_area));
GdkWindow gparent = gtk_widget_get_parent_window(drawing_area);
NSView *pid = gdk_quartz_window_get_nsview(gparent);
render_window->SetParentId((void*) pid);

// in configure_callback
// event is a GdkEventConfigure* that's passed in as an argument // Unlike David's  QWidget example, I do not use the superclass versions of SetSize and SetPosition render_window->SetSize(event->width, event->height); render_window->SetPosition(drawing_area->allocation.x, drawing_area->allocation.y);

I also added an expose event callback which just called render_window->Render(), but it doesn't seem to be necessary.

-- Steve

From: David Gobbi <david.gobbi at gmail.com>
Date: Tuesday, October 24, 2017 at 2:56 PM
To: "Langer, Stephen A. (Fed)" <stephen.langer at nist.gov>
Cc: "vtkusers at vtk.org" <vtkusers at vtk.org>
Subject: Re: [vtkusers] vtk and gtk on macOS

Hi Steve,

Here is some code that I use to bind a VTK window to a QWidget.  My guess is that something similar should work with GTK.  I have been using this on OS X with vtkCocoaRenderWindow.

void BindRenderWindow(vtkRenderWindow *window, QWidget *widget) {
  // Unmap the window if it is already mapped somewhere else.
  if (window->GetMapped()) {
    window->Finalize();
  }
  // Create the connection
  window->SetWindowId(reinterpret_cast<void *>(widget->winId()));
  // Note that we must call the superclass SetSize()/SetPosition()
  // (we just want to set the member variables, with no side-effects)
  window->vtkRenderWindow::SetSize(widget->width(), widget->height());
  window->vtkRenderWindow::SetPosition(widget->x(), widget->y());
  // Prepare for rendering
  if (widget->isVisible()) {
    window->Start();
  }
  // Call SetSize() again, to synchronize the window to the widget
  window->SetSize(widget->width(), widget->height()); }

Some further notes:
1) I disable Qt's paint engine, so that Qt itself doesn't draw in the window.  GTK may be similar.
2) You probably will not need GtkGLExt (for Qt, I didn't have to use QGLWidget).

 - David



On Tue, Oct 24, 2017 at 12:12 PM, Langer, Stephen A. (Fed) <stephen.langer at nist.gov<mailto:stephen.langer at nist.gov>> wrote:
Hi --

Is there a simple way to get vtk to work inside a gtk+2 program on macOS?   If there isn't a simple way, is there a difficult one?

I'm trying to get a program that uses gtk+2 and vtk to work with a modern version of vtk -- I'm upgrading from 5.10.1 to 7.1.1 or 8.0.1.    On Linux, the following code creates a vtk render window and a gtk widget containing it:
    vtkRenderWindow *render_win = vtkRenderWindow::New();
    GtkWidget *drawing_area = gtk_drawing_area_new();
    Display *disp = GDK_DISPLAY();
    render_win->SetDisplayId(disp);
followed eventually by
     XID wid = GDK_WINDOW_XID(drawing_area->window);
     render_win->SetWindowId(wid);
after receiving the gtk "realize" signal on the drawing_area.

On macOS, I'd like to use the Cocoa version of gtk+2 and vtkCocoaRenderWindow, but I can't figure out how to embed the render window into a gtk widget.    All the examples I've found on-line aren't really applicable.

GtkGLExt might be applicable, but it doesn't look like it's being maintained.

An alternative would be to use X11, but native Mac OpenGL doesn't understand X11, so I tried installing mesa from macports , rebuilding vtk with VTK_USE_X instead of VTK_USE_COCOA, and linking to /opt/local/lib instead of /System/Library/Frameworks/OpenGL.framework.  Then I can use the same code as on Linux, but vtk complains about the context not supporting OpenGL 3.2, and then crashes:
  ERROR: In /Users/langer/UTIL/VTK/VTK-7.1.1/Rendering/OpenGL2/vtkTextureObject.cxx, line 440
  vtkTextureObject (0x7f9eafdb1690): failed at glGenTextures 1 OpenGL errors detected
    0 : (1280) Invalid enum

Thanks,
     Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171114/4e09501f/attachment-0001.html>

------------------------------

Message: 2
Date: Tue, 14 Nov 2017 19:59:19 +0000
From: "Langer, Stephen A. (Fed)" <stephen.langer at nist.gov>
To: "vtkusers at vtk.org" <vtkusers at vtk.org>
Subject: Re: [vtkusers] vtk and gtk on macOS
Message-ID: <A0CD0716-BE99-45E8-BC48-618DBC31AA39 at nist.gov>
Content-Type: text/plain; charset="utf-8"

Responding to my own message again?

Is it possible that the vtk or gtk+2 coordinate systems are different on different platforms?
On a Mac, using vtk 7.1.1 and Cocoa, the configure callback for the vtk render window inside a gtk widget looks like this:

gboolean OOFCanvas3D::configure(GdkEventConfigure *event) {
   render_window->SetSize(event->width, event->height);
  GtkWidget *topwindow = gtk_widget_get_toplevel(drawing_area);
  assert(topwindow != nullptr);
  int top_height = topwindow->allocation.height;
  render_window->SetPosition(event->x, top_height - event->y - event->height);
  return true;
}

but that doesn't work on Linux (Ubuntu inside VirtualBox, using vtk 7.1.1 and X11), where it has to be this:

gboolean OOFCanvas3D::configure(GdkEventConfigure *event) {
   render_window->SetSize(event->width, event->height);
  render_window->SetPosition(event->x, event->y);
  return true;
}

Both of these do what they should do (on their respective platforms) when the space allocated for the vtk render window is changed.  But it looks like on the Mac the position of the vtk widget is measured from the bottom of the enclosing window while on Linux it's measured from the top!  Can this be true?  What am I missing?

Thanks.

-- Steve


From: vtkusers <vtkusers-bounces at vtk.org> on behalf of "Langer, Stephen A. (Fed)" <stephen.langer at nist.gov>
Date: Tuesday, November 14, 2017 at 2:06 PM
To: "vtkusers at vtk.org" <vtkusers at vtk.org>
Subject: Re: [vtkusers] vtk and gtk on macOS

Just in case someone else is trying to do the same thing and finds this message, the configure callback below is incorrect because gtk and vtk have different ideas about which direction is up.  The call to render_window->SetPosition should be
  GtkWidget *top = gtk_widget_get_toplevel(drawing_area)
 render_window->SetPosition(top->allocation.height- event->y - event->height);

event->y and drawing_area->allocation.y are interchangeable.

-- Steve

From: vtkusers <vtkusers-bounces at vtk.org> on behalf of "Langer, Stephen A. (Fed)" <stephen.langer at nist.gov>
Date: Friday, November 3, 2017 at 10:11 AM
To: David Gobbi <david.gobbi at gmail.com>
Cc: "vtkusers at vtk.org" <vtkusers at vtk.org>
Subject: Re: [vtkusers] vtk and gtk on macOS


HI David --

Thanks for the suggestions, which got me started on the right track.

What seems to work is this (somewhat simplified to eliminate some infrastructure):

// Create gtk widget and vtk window
GtkWidget *drawing_area = gtk_drawing_area_new(); vtkSmartPointer<vtkCocoaRenderWindow> render_window = vtkSmartPointer<vtkCocoaRenderWindow>::New();
// Connect to gtk signals.
g_signal_connect(drawing_area, "realize", realize_callback, ..) g_signal_connect(drawing_area, "configure_event", configure_callback, ?)

// in realize_callback
gtk_widget_realize(drawing_area);
render_window->SetRootWindow(gtk_widget_get_root_window(drawing_area));
GdkWindow gparent = gtk_widget_get_parent_window(drawing_area);
NSView *pid = gdk_quartz_window_get_nsview(gparent);
render_window->SetParentId((void*) pid);

// in configure_callback
// event is a GdkEventConfigure* that's passed in as an argument // Unlike David's  QWidget example, I do not use the superclass versions of SetSize and SetPosition render_window->SetSize(event->width, event->height); render_window->SetPosition(drawing_area->allocation.x, drawing_area->allocation.y);

I also added an expose event callback which just called render_window->Render(), but it doesn't seem to be necessary.

-- Steve

From: David Gobbi <david.gobbi at gmail.com>
Date: Tuesday, October 24, 2017 at 2:56 PM
To: "Langer, Stephen A. (Fed)" <stephen.langer at nist.gov>
Cc: "vtkusers at vtk.org" <vtkusers at vtk.org>
Subject: Re: [vtkusers] vtk and gtk on macOS

Hi Steve,

Here is some code that I use to bind a VTK window to a QWidget.  My guess is that something similar should work with GTK.  I have been using this on OS X with vtkCocoaRenderWindow.

void BindRenderWindow(vtkRenderWindow *window, QWidget *widget) {
  // Unmap the window if it is already mapped somewhere else.
  if (window->GetMapped()) {
    window->Finalize();
  }
  // Create the connection
  window->SetWindowId(reinterpret_cast<void *>(widget->winId()));
  // Note that we must call the superclass SetSize()/SetPosition()
  // (we just want to set the member variables, with no side-effects)
  window->vtkRenderWindow::SetSize(widget->width(), widget->height());
  window->vtkRenderWindow::SetPosition(widget->x(), widget->y());
  // Prepare for rendering
  if (widget->isVisible()) {
    window->Start();
  }
  // Call SetSize() again, to synchronize the window to the widget
  window->SetSize(widget->width(), widget->height()); }

Some further notes:
1) I disable Qt's paint engine, so that Qt itself doesn't draw in the window.  GTK may be similar.
2) You probably will not need GtkGLExt (for Qt, I didn't have to use QGLWidget).

 - David



On Tue, Oct 24, 2017 at 12:12 PM, Langer, Stephen A. (Fed) <stephen.langer at nist.gov<mailto:stephen.langer at nist.gov>> wrote:
Hi --

Is there a simple way to get vtk to work inside a gtk+2 program on macOS?   If there isn't a simple way, is there a difficult one?

I'm trying to get a program that uses gtk+2 and vtk to work with a modern version of vtk -- I'm upgrading from 5.10.1 to 7.1.1 or 8.0.1.    On Linux, the following code creates a vtk render window and a gtk widget containing it:
    vtkRenderWindow *render_win = vtkRenderWindow::New();
    GtkWidget *drawing_area = gtk_drawing_area_new();
    Display *disp = GDK_DISPLAY();
    render_win->SetDisplayId(disp);
followed eventually by
     XID wid = GDK_WINDOW_XID(drawing_area->window);
     render_win->SetWindowId(wid);
after receiving the gtk "realize" signal on the drawing_area.

On macOS, I'd like to use the Cocoa version of gtk+2 and vtkCocoaRenderWindow, but I can't figure out how to embed the render window into a gtk widget.    All the examples I've found on-line aren't really applicable.

GtkGLExt might be applicable, but it doesn't look like it's being maintained.

An alternative would be to use X11, but native Mac OpenGL doesn't understand X11, so I tried installing mesa from macports , rebuilding vtk with VTK_USE_X instead of VTK_USE_COCOA, and linking to /opt/local/lib instead of /System/Library/Frameworks/OpenGL.framework.  Then I can use the same code as on Linux, but vtk complains about the context not supporting OpenGL 3.2, and then crashes:
  ERROR: In /Users/langer/UTIL/VTK/VTK-7.1.1/Rendering/OpenGL2/vtkTextureObject.cxx, line 440
  vtkTextureObject (0x7f9eafdb1690): failed at glGenTextures 1 OpenGL errors detected
    0 : (1280) Invalid enum

Thanks,
     Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171114/711037db/attachment-0001.html>

------------------------------

Message: 3
Date: Tue, 14 Nov 2017 17:30:57 -0800
From: Kurt Sansom <kayarre at gmail.com>
To: vtk <vtkusers at vtk.org>
Subject: [vtkusers] Ensight Gold Binary Reader
Message-ID:
<CAHyF3ohbp0wfvxN9NCEhx_+yoNGpo33t+YXrypmTWAUqDHRYqg at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi,
  I am exporting fluent files to the ensight gold format, but I have determined that either the ensight Gold format only supports floats or that the vtk reader only supports reading into float arrays (single precision).

I  could not find information about ensight gold format (I did see ensight
6 and 5 mentioned not supporting double precision, bu no comment on ensight
gold)

I would like to know if I can create an vtkEnSightGoldBinaryDoubleReader that will read in double precision arrays, or if the ensight gold format doesn't support double precision.

Many thanks,
  VTK is so awesome. (especially the python bindings)

~Kurt

--
Kurt Sansom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171114/1ced0e33/attachment-0001.html>

------------------------------

Message: 4
Date: Tue, 14 Nov 2017 23:58:50 -0700 (MST)
From: louiskoo <419655660 at qq.com>
To: vtkusers at vtk.org
Subject: [vtkusers] vtkDICOMImageReader will reverse using
ImagePositionPatient ?
Message-ID: <1510729130030-0.post at n5.nabble.com>
Content-Type: text/plain; charset=us-ascii

 vtkDICOMImageReader dicom_reader = vtkDICOMImageReader.New();
                dicom_reader.SetDirectoryName(dicom_folder);
                dicom_reader.Update();



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html


------------------------------

Message: 5
Date: Wed, 15 Nov 2017 11:26:11 +0100
From: Kolja Petersen <petersenkolja at gmail.com>
To: Ken Martin <ken.martin at kitware.com>
Cc: vtk <vtkusers at vtk.org>
Subject: Re: [vtkusers] TimerEvents not fired while dragging mouse in
vtkRenderWindow
Message-ID:
<CAPN39MXrHX2g6aA+Uob8+rA6kkLz6yOr9Na72YeeVtWiDvm5Kg at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

I replaced the line "iren.AddObserver(vtk.vtkCommand.TimerEvent,observer)"
with
iren.AddObserver(vtk.vtkCommand.TimerEvent,observer,100000.) (also tried
10.0 instead of 100000.)

Still no TimerEvents are reported as long as the mouse button is pressed.

How are events consumed? My understanding is that AddObserver(...) adds just another listener, and that all listeners registered for a specific event are invoked one after the other. Which function would "consume"
events in an interactor style? Is it possible to circumvent the consuming of events, or to re-emit the event after it has been consumed?
Thank you
Kolja


On Tue, Nov 14, 2017 at 5:53 PM, Ken Martin <ken.martin at kitware.com> wrote:

> I suspect timer events are fired but something else is consuming them.
> Probably in the interactor style. Try adding your timer events with a
> higher priority like 10.0 (third argument).
>
> On Mon, Nov 13, 2017 at 3:21 PM, Kolja Petersen
> <petersenkolja at gmail.com>
> wrote:
>
>> Heya,
>> I paste some code below, which displays an empty vtkRenderWindow with
>> an interactor. The interactor fires a TimerEvent every 100ms as
>> printed by the Observer.
>> The problem: as long as I press a mouse button in the
>> vtkRenderWindow, the TimerEvents stop to be reported, although I need
>> to process data periodically in my application as a reaction to those TimerEvents.
>>
>> Why are no TimerEvents fired while a button is pressed, and how can I
>> change this behaviour?
>> Thank you
>> Kolja
>>
>> import vtk
>>
>> class Observer(object):
>>   def __init__(self):
>>     self.cnt=0
>>   def __call__(self,caller,evt):
>>     self.cnt+=1
>>     print "count %d %s" % (self.cnt,evt)
>>
>> ren1 = vtk.vtkRenderer()
>> ren1.SetBackground(0.1, 0.2, 0.4)
>>
>> renWin = vtk.vtkRenderWindow()
>> renWin.AddRenderer(ren1)
>> renWin.SetSize(300, 300)
>>
>> iren = vtk.vtkRenderWindowInteractor()
>> iren.SetRenderWindow(renWin)
>>
>> style = vtk.vtkInteractorStyleTrackballCamera()
>> iren.SetInteractorStyle(style)
>>
>> iren.Initialize()
>> observer=Observer()
>> iren.AddObserver(vtk.vtkCommand.TimerEvent,observer)
>> iren.AddObserver(vtk.vtkCommand.MouseMoveEvent,observer)
>> iren.AddObserver(vtk.vtkCommand.InteractionEvent,observer)
>> iren.CreateRepeatingTimer(100)
>> iren.Start()
>>
>>
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Virenfrei.
>> www.avast.com
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm
>> _campaign=sig-email&utm_content=webmail>
>> <#m_-5995428116567439952_m_5020402281578617109_DAB4FAD8-2DD7-40BB-A1B
>> 8-4E2AA1F9FDF2>
>>
>> _______________________________________________
>> 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 PhD
> Distinguished Engineer
> Kitware Inc.
> 28 Corporate Drive
> <https://maps.google.com/?q=28+Corporate+Drive+Clifton+Park+NY+12065&e
> ntry=gmail&source=g>
> Clifton Park NY 12065
> <https://maps.google.com/?q=28+Corporate+Drive+Clifton+Park+NY+12065&e
> ntry=gmail&source=g>
>
> 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.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171115/c36def42/attachment-0001.html>

------------------------------

Message: 6
Date: Wed, 15 Nov 2017 19:17:11 +0800 (CST)
From: ??? <pengfeijia11 at sjtu.edu.cn>
To: vtkusers at vtk.org
Subject: [vtkusers] using vtkImageBlend to combine two gray image
Message-ID:
<928007308.11523911.1510744631970.JavaMail.zimbra at sjtu.edu.cn>
Content-Type: text/plain; charset=utf-8

Hi All:

? I have two gray images (vtkimagedata version),? they have the same size. I want to combine them together using vtkimageblend.

1st? the following are some codes:

?vtkSmartPointer<vtkImageBlend> imgBlender = vtkSmartPointer<vtkImageBlend>::New();
?imgBlender->SetOpacity( 0, 0.5);
?imgBlender->SetOpacity( 1, 0.5);
?imgBlender->AddInput(AP);
?imgBlender->AddInput( APdrr );

It seems that the result is wrong! the second is in the window, while the first seems not in the proper position, only part of it.

2nd?Then I adjust the opacity?
vtkSmartPointer<vtkImageBlend> imgBlender = vtkSmartPointer<vtkImageBlend>::New();
?imgBlender->SetOpacity( 0, 1);
?imgBlender->SetOpacity( 1, 1);
?imgBlender->AddInput(AP);
?imgBlender->AddInput( APdrr );

then the result only shows the second image, there is not the first image!

can someone give me some suggestions, thanks in advance!


------------------------------

Message: 7
Date: Wed, 15 Nov 2017 06:49:42 -0700 (MST)
From: landings <landinghere at 163.com>
To: vtkusers at vtk.org
Subject: [vtkusers] How to use unsigned char to represent cell types?
Message-ID: <1510753782836-0.post at n5.nabble.com>
Content-Type: text/plain; charset=us-ascii

I am using vtkUnstructuredGrid::SetCells() and I don't know what to fill into the cellTypes array.

By the way, do parameters *types and *cellTypes contain similar values?

-------------------------------------
void vtkUnstructuredGrid::SetCells ( int type, vtkCellArray * cells ) void vtkUnstructuredGrid::SetCells ( int * types, vtkCellArray * cells ) void vtkUnstructuredGrid::SetCells ( vtkUnsignedCharArray * cellTypes, vtkIdTypeArray * cellLocations, vtkCellArray * cells ) void vtkUnstructuredGrid::SetCells ( vtkUnsignedCharArray * cellTypes, vtkIdTypeArray * cellLocations, vtkCellArray * cells, vtkIdTypeArray * faceLocations, vtkIdTypeArray * faces )

Description:
-------------------------------------
Most cells require just arrays of cellTypes, cellLocations and cellConnectivities which implicitly define the set of points in each cell and their ordering. In those cases the cellConnectivities are of the format (numFace0Pts, id1, id2, id3, numFace1Pts, id1, id2, id3...). However, some cells like vtkPolyhedron require points plus a list of faces. To handle vtkPolyhedron, SetCells() support a special input cellConnectivities format (numCellFaces, numFace0Pts, id1, id2, id3, numFace1Pts,id1, id2, id3, ...) The functions use vtkPolyhedron::DecomposeAPolyhedronCell() to convert polyhedron cells into standard format.
-------------------------------------



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html


------------------------------

Message: 8
Date: Wed, 15 Nov 2017 11:25:07 -0500
From: David Cole <DLRdave at aol.com>
To: Kolja Petersen <petersenkolja at gmail.com>
Cc: vtk <vtkusers at vtk.org>
Subject: Re: [vtkusers] TimerEvents not fired while dragging mouse in
vtkRenderWindow
Message-ID: <C27C3C2E-0457-46BD-894B-017AC0A77A81 at aol.com>
Content-Type: text/plain; charset="us-ascii"

Is this on Windows? WM_TIMER events are notorious for not firing frequently when lots of other user events are also happening. If the mouse is captured, they may not fire at all. This is not something unique to VTK, it happens with just any Windows program.

You may need to consider redesigning a bit of your app if you must have code being executed regularly even during user interactions.


David

> On Nov 15, 2017, at 5:26 AM, Kolja Petersen <petersenkolja at gmail.com> wrote:
>
> I replaced the line
> "iren.AddObserver(vtk.vtkCommand.TimerEvent,observer)" with
> iren.AddObserver(vtk.vtkCommand.TimerEvent,observer,100000.) (also
> tried 10.0 instead of 100000.)
>
> Still no TimerEvents are reported as long as the mouse button is pressed.
>
> How are events consumed? My understanding is that AddObserver(...) adds just another listener, and that all listeners registered for a specific event are invoked one after the other. Which function would "consume" events in an interactor style? Is it possible to circumvent the consuming of events, or to re-emit the event after it has been consumed?
> Thank you
> Kolja
>
>
>> On Tue, Nov 14, 2017 at 5:53 PM, Ken Martin <ken.martin at kitware.com> wrote:
>> I suspect timer events are fired but something else is consuming them. Probably in the interactor style. Try adding your timer events with a higher priority like 10.0 (third argument).
>>
>>> On Mon, Nov 13, 2017 at 3:21 PM, Kolja Petersen <petersenkolja at gmail.com> wrote:
>>> Heya,
>>> I paste some code below, which displays an empty vtkRenderWindow with an interactor. The interactor fires a TimerEvent every 100ms as printed by the Observer.
>>> The problem: as long as I press a mouse button in the vtkRenderWindow, the TimerEvents stop to be reported, although I need to process data periodically in my application as a reaction to those TimerEvents.
>>>
>>> Why are no TimerEvents fired while a button is pressed, and how can I change this behaviour?
>>> Thank you
>>> Kolja
>>>
>>> import vtk
>>>
>>> class Observer(object):
>>>   def __init__(self):
>>>     self.cnt=0
>>>   def __call__(self,caller,evt):
>>>     self.cnt+=1
>>>     print "count %d %s" % (self.cnt,evt)
>>>
>>> ren1 = vtk.vtkRenderer()
>>> ren1.SetBackground(0.1, 0.2, 0.4)
>>>
>>> renWin = vtk.vtkRenderWindow()
>>> renWin.AddRenderer(ren1)
>>> renWin.SetSize(300, 300)
>>>
>>> iren = vtk.vtkRenderWindowInteractor()
>>> iren.SetRenderWindow(renWin)
>>>
>>> style = vtk.vtkInteractorStyleTrackballCamera()
>>> iren.SetInteractorStyle(style)
>>>
>>> iren.Initialize()
>>> observer=Observer()
>>> iren.AddObserver(vtk.vtkCommand.TimerEvent,observer)
>>> iren.AddObserver(vtk.vtkCommand.MouseMoveEvent,observer)
>>> iren.AddObserver(vtk.vtkCommand.InteractionEvent,observer)
>>> iren.CreateRepeatingTimer(100)
>>> iren.Start()
>>>
>>> Virenfrei. www.avast.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 PhD
>> Distinguished Engineer
>> Kitware Inc.
>> 28 Corporate Drive
>> Clifton Park NY 12065
>>
>> 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.
>
> _______________________________________________
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171115/a03fa8ec/attachment-0001.html>

------------------------------

Message: 9
Date: Wed, 15 Nov 2017 17:42:55 +0100
From: Kolja Petersen <petersenkolja at gmail.com>
To: David Cole <DLRdave at aol.com>
Cc: vtk <vtkusers at vtk.org>
Subject: Re: [vtkusers] TimerEvents not fired while dragging mouse in
vtkRenderWindow
Message-ID:
<CAPN39MWeJN6j9yY84kObvFLGGUEEez=XU7k7RvLEyVJv7+cVZg at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

No, this is on Linux. Maybe you can try the code snippet yourself to see what I am talking about? The problem is not, that the TimerEvents are slowed down during mouse interaction, they are dropped completely.

How can the app be redesigned?
First, I need the standard behaviour of vtkRenderWindowInteractor to allow rotating, zooming, panning.
Second I need to update and redraw the scene repeatedly in constant intervals. Of course, I could trigger these events independent from VTK using a second thread. But these events need to operate on VTK objects from the main thread. Because VTK is not thread safe (which I have experienced by a number of segmentation faults when modifying VTK objects from different threads), I see absolutely no way to correctly process both 1) timer events and 2) user interaction events that block the timer events.
Kolja

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virenfrei.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Wed, Nov 15, 2017 at 5:25 PM, David Cole <DLRdave at aol.com> wrote:

> Is this on Windows? WM_TIMER events are notorious for not firing
> frequently when lots of other user events are also happening. If the
> mouse is captured, they may not fire at all. This is not something
> unique to VTK, it happens with just any Windows program.
>
> You may need to consider redesigning a bit of your app if you must
> have code being executed regularly even during user interactions.
>
>
> David
>
> On Nov 15, 2017, at 5:26 AM, Kolja Petersen <petersenkolja at gmail.com>
> wrote:
>
> I replaced the line "iren.AddObserver(vtk.vtkCommand.TimerEvent,observer)"
> with
> iren.AddObserver(vtk.vtkCommand.TimerEvent,observer,100000.) (also
> tried
> 10.0 instead of 100000.)
>
> Still no TimerEvents are reported as long as the mouse button is pressed.
>
> How are events consumed? My understanding is that AddObserver(...)
> adds just another listener, and that all listeners registered for a
> specific event are invoked one after the other. Which function would "consume"
> events in an interactor style? Is it possible to circumvent the
> consuming of events, or to re-emit the event after it has been consumed?
> Thank you
> Kolja
>
>
> On Tue, Nov 14, 2017 at 5:53 PM, Ken Martin <ken.martin at kitware.com>
> wrote:
>
>> I suspect timer events are fired but something else is consuming them.
>> Probably in the interactor style. Try adding your timer events with a
>> higher priority like 10.0 (third argument).
>>
>> On Mon, Nov 13, 2017 at 3:21 PM, Kolja Petersen
>> <petersenkolja at gmail.com>
>> wrote:
>>
>>> Heya,
>>> I paste some code below, which displays an empty vtkRenderWindow
>>> with an interactor. The interactor fires a TimerEvent every 100ms as
>>> printed by the Observer.
>>> The problem: as long as I press a mouse button in the
>>> vtkRenderWindow, the TimerEvents stop to be reported, although I
>>> need to process data periodically in my application as a reaction to those TimerEvents.
>>>
>>> Why are no TimerEvents fired while a button is pressed, and how can
>>> I change this behaviour?
>>> Thank you
>>> Kolja
>>>
>>> import vtk
>>>
>>> class Observer(object):
>>>   def __init__(self):
>>>     self.cnt=0
>>>   def __call__(self,caller,evt):
>>>     self.cnt+=1
>>>     print "count %d %s" % (self.cnt,evt)
>>>
>>> ren1 = vtk.vtkRenderer()
>>> ren1.SetBackground(0.1, 0.2, 0.4)
>>>
>>> renWin = vtk.vtkRenderWindow()
>>> renWin.AddRenderer(ren1)
>>> renWin.SetSize(300, 300)
>>>
>>> iren = vtk.vtkRenderWindowInteractor()
>>> iren.SetRenderWindow(renWin)
>>>
>>> style = vtk.vtkInteractorStyleTrackballCamera()
>>> iren.SetInteractorStyle(style)
>>>
>>> iren.Initialize()
>>> observer=Observer()
>>> iren.AddObserver(vtk.vtkCommand.TimerEvent,observer)
>>> iren.AddObserver(vtk.vtkCommand.MouseMoveEvent,observer)
>>> iren.AddObserver(vtk.vtkCommand.InteractionEvent,observer)
>>> iren.CreateRepeatingTimer(100)
>>> iren.Start()
>>>
>>>
>>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Virenfrei.
>>> www.avast.com
>>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&ut
>>> m_campaign=sig-email&utm_content=webmail>
>>> <#m_-7045443072964375499_m_-5995428116567439952_m_502040228157861710
>>> 9_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>>
>>> _______________________________________________
>>> 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 PhD
>> Distinguished Engineer
>> Kitware Inc.
>> 28 Corporate Drive
>> <https://maps.google.com/?q=28+Corporate+Drive+Clifton+Park+NY+12065&
>> entry=gmail&source=g>
>> Clifton Park NY 12065
>> <https://maps.google.com/?q=28+Corporate+Drive+Clifton+Park+NY+12065&
>> entry=gmail&source=g>
>>
>> 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.
>>
>
> _______________________________________________
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171115/361d4ad9/attachment-0001.html>

------------------------------

Message: 10
Date: Wed, 15 Nov 2017 11:48:24 -0500
From: Ken Martin <ken.martin at kitware.com>
To: Kolja Petersen <petersenkolja at gmail.com>
Cc: vtk <vtkusers at vtk.org>
Subject: Re: [vtkusers] TimerEvents not fired while dragging mouse in
vtkRenderWindow
Message-ID:
<CANXz0SZUXyqffmwG4TM3sJw+vuwuARL14mR+TXfkMcciXrjW8g at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

The interactor style may be doing a grab focus (which grabs all events until the motion is done). Try putting some  printfs/breaks in the code that generates the timerevent in vtk. Then maybe you can follow the event and see who is consuming it etc,.

Or try commenting out all the GrabFocus() calls in the style you are using.

On Wed, Nov 15, 2017 at 11:42 AM, Kolja Petersen <petersenkolja at gmail.com>
wrote:

> No, this is on Linux. Maybe you can try the code snippet yourself to
> see what I am talking about? The problem is not, that the TimerEvents
> are slowed down during mouse interaction, they are dropped completely.
>
> How can the app be redesigned?
> First, I need the standard behaviour of vtkRenderWindowInteractor to
> allow rotating, zooming, panning.
> Second I need to update and redraw the scene repeatedly in constant
> intervals. Of course, I could trigger these events independent from
> VTK using a second thread. But these events need to operate on VTK
> objects from the main thread. Because VTK is not thread safe (which I
> have experienced by a number of segmentation faults when modifying VTK
> objects from different threads), I see absolutely no way to correctly
> process both 1) timer events and 2) user interaction events that block the timer events.
> Kolja
>
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Virenfrei.
> www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_
> campaign=sig-email&utm_content=webmail>
> <#m_869865242780024731_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> On Wed, Nov 15, 2017 at 5:25 PM, David Cole <DLRdave at aol.com> wrote:
>
>> Is this on Windows? WM_TIMER events are notorious for not firing
>> frequently when lots of other user events are also happening. If the
>> mouse is captured, they may not fire at all. This is not something
>> unique to VTK, it happens with just any Windows program.
>>
>> You may need to consider redesigning a bit of your app if you must
>> have code being executed regularly even during user interactions.
>>
>>
>> David
>>
>> On Nov 15, 2017, at 5:26 AM, Kolja Petersen <petersenkolja at gmail.com>
>> wrote:
>>
>> I replaced the line "iren.AddObserver(vtk.vtkCommand.TimerEvent,observer)"
>> with
>> iren.AddObserver(vtk.vtkCommand.TimerEvent,observer,100000.) (also
>> tried
>> 10.0 instead of 100000.)
>>
>> Still no TimerEvents are reported as long as the mouse button is pressed.
>>
>> How are events consumed? My understanding is that AddObserver(...)
>> adds just another listener, and that all listeners registered for a
>> specific event are invoked one after the other. Which function would "consume"
>> events in an interactor style? Is it possible to circumvent the
>> consuming of events, or to re-emit the event after it has been consumed?
>> Thank you
>> Kolja
>>
>>
>> On Tue, Nov 14, 2017 at 5:53 PM, Ken Martin <ken.martin at kitware.com>
>> wrote:
>>
>>> I suspect timer events are fired but something else is consuming them.
>>> Probably in the interactor style. Try adding your timer events with
>>> a higher priority like 10.0 (third argument).
>>>
>>> On Mon, Nov 13, 2017 at 3:21 PM, Kolja Petersen
>>> <petersenkolja at gmail.com
>>> > wrote:
>>>
>>>> Heya,
>>>> I paste some code below, which displays an empty vtkRenderWindow
>>>> with an interactor. The interactor fires a TimerEvent every 100ms
>>>> as printed by the Observer.
>>>> The problem: as long as I press a mouse button in the
>>>> vtkRenderWindow, the TimerEvents stop to be reported, although I
>>>> need to process data periodically in my application as a reaction to those TimerEvents.
>>>>
>>>> Why are no TimerEvents fired while a button is pressed, and how can
>>>> I change this behaviour?
>>>> Thank you
>>>> Kolja
>>>>
>>>> import vtk
>>>>
>>>> class Observer(object):
>>>>   def __init__(self):
>>>>     self.cnt=0
>>>>   def __call__(self,caller,evt):
>>>>     self.cnt+=1
>>>>     print "count %d %s" % (self.cnt,evt)
>>>>
>>>> ren1 = vtk.vtkRenderer()
>>>> ren1.SetBackground(0.1, 0.2, 0.4)
>>>>
>>>> renWin = vtk.vtkRenderWindow()
>>>> renWin.AddRenderer(ren1)
>>>> renWin.SetSize(300, 300)
>>>>
>>>> iren = vtk.vtkRenderWindowInteractor()
>>>> iren.SetRenderWindow(renWin)
>>>>
>>>> style = vtk.vtkInteractorStyleTrackballCamera()
>>>> iren.SetInteractorStyle(style)
>>>>
>>>> iren.Initialize()
>>>> observer=Observer()
>>>> iren.AddObserver(vtk.vtkCommand.TimerEvent,observer)
>>>> iren.AddObserver(vtk.vtkCommand.MouseMoveEvent,observer)
>>>> iren.AddObserver(vtk.vtkCommand.InteractionEvent,observer)
>>>> iren.CreateRepeatingTimer(100)
>>>> iren.Start()
>>>>
>>>>
>>>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Virenfrei.
>>>> www.avast.com
>>>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&u
>>>> tm_campaign=sig-email&utm_content=webmail>
>>>> <#m_869865242780024731_m_-7045443072964375499_m_-599542811656743995
>>>> 2_m_5020402281578617109_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>>>
>>>> _______________________________________________
>>>> 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 PhD
>>> Distinguished Engineer
>>> Kitware Inc.
>>> 28 Corporate Drive
>>> <https://maps.google.com/?q=28+Corporate+Drive+Clifton+Park+NY+12065
>>> &entry=gmail&source=g>
>>> Clifton Park NY 12065
>>> <https://maps.google.com/?q=28+Corporate+Drive+Clifton+Park+NY+12065
>>> &entry=gmail&source=g>
>>>
>>> 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.
>>>
>>
>> _______________________________________________
>> 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 PhD
Distinguished Engineer
Kitware Inc.
28 Corporate Drive
Clifton Park NY 12065

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171115/8350395c/attachment-0001.html>

------------------------------

Subject: Digest Footer

_______________________________________________
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

------------------------------

End of vtkusers Digest, Vol 163, Issue 18
*****************************************
-- WARNING - CONFIDENTIAL INFORMATION: The information contained in the e-mail may contain confidential and privileged information and is intended solely for the use of the intended recipient(s). Access for any review, re-transmission, dissemination or other use of, or taking of any action in regard and reliance upon this e-mail by persons or entities other than the intended recipient(s) is unauthorized and prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message and any attachments.


More information about the vtkusers mailing list