Migrating to vtk6: Is it not necessary to Update() (anymore)? - c++

Migrating some code from VTK 5.10 to 6.1, I have several code pieces like this:
vtkSmartPointer<vtkImageData> img = vtkSmartPointer<vtkImageData>::New();
// ... initialize img somehow, e.g. copy from other image:
img->DeepCopy(otherImg);
img->SetInformation(otherImg->getInformation());
// the problematical statement:
img->Update();
At the call to Update(), the compiler now complains that there isn't such a function (anymore).
The migration site from VTK doesn't really tell me too much about that - I believe this falls into the section Removal of Data Objects’ Dependency on the Pipeline , but as it's no Algorithm which is filling my image, I can't call update on an algorithm.
Similar goes for custom-filled vtkPolyData objects.
My question now is: Is the call to Update not necessary (anymore?), can I just remove it? Or by what would I need to replace it?
I have to say I'm relatively new to vtk, so if there's something fundamentally simple that I'm missing I'd be glad if you could point it out to me!

I think you've been meaning to call Modified() on your image rather than Update().

Apparently they already answered your question on VTK:
http://www.vtk.org/Wiki/VTK/VTK_6_Migration/Removal_of_Update

Related

Alternative of CreateVideoSource() in webrtc

Hi all I had seen one webrtc old source code which has this method called CreateVideoSource() for adding streams after an CreateAudioTrack() call.
rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> video_source =
peer_connection_factory_->CreateVideoSource(std::unique_ptr<cricket::VideoCapturer>(
media_source->GetVideoCapturer()),
NULL);
What's happening is whenever I try to build it gives an error for the above CreateVideoSource() that it is undefined. And the reason behind that is the latest webrtc-checkout has deprecated this.
So my question is, I wanted to know the alternative which they have introduced after deprecating this method. So can anyone tell me what the alternate approach is.
Okay, Finally I was able to come up with an alternative(i.e the current implementation of libwebrtc) after looking into bundle examples and tests.
Line 71 is a good point to start

glBindTexture - returns argument error

I am working on augmented reality project. So the user should use the Webcam, and to see the captured video with a cube drawn on that frame.
And this is where I get stuck , when I try to use glBindTexture(GL_TEXTURE_2D,texture_background) method, I get error:
(
ArgumentError: argument 2: : wrong type
GLUT Display callback with (),{} failed: returning None argument 2: : wrong type
)
I am completely stuck, have no idea what to do . The project is done in Python 2.7 , am using opencv and PyOpenGl 3.1.0.
You can find code on this link :click here
Thanks in advance.
Interesting error! So I played around with your source code (by the way in the future you should probably just add the code directly to your question instead of as a separate link), and the issue is actually just one of variable scope, not glut or opengl usage. The problem is your texture_background variable does not exist within the scope of the _draw_scene() function. To verify this, simply try calling print texture_background in your _draw_scene() function and you will find it returns None rather than the desired integer texture identifier.
The simple hack-y solution is to just call global texture_background before using it within your _handle_input() function. You will also need to define texture_background = None in the main scope of your program (underneath your ##FOR CUBE FROM OPENGL comment). The same global comment applies for x_axis and z_axis.
That being said, that solution is not really that great. The rigid structure required by GLUT with all of these predefined glut* functions makes it hard to structure code the way you might want to in terms of initializing your app. I would suggest, if you are not forced to use GLUT, to use a more flexible alternative, such as pygame, pysdl2 or pyqt, to create your context instead.

Gtk::ScaleButton: Icons in the constructor

I am trying to use a Gtk::ScaleButton in Gtkmm 3. My problem is the constructor. It needs as last parameter (see here: https://developer.gnome.org/gtkmm/stable/classGtk_1_1ScaleButton.html#a96753b6cb6b8adb0ed3727ba3eb8cfb7 ) a vector of ustrings. I guess (i can't find it in the docs what it means exactly) i have to give it the path to the +/- Images. I want to use the Gtk Stock items for +/-. How can i achieve this?
Currently i give it an empty vector, which results in a glibmm warning:
std::vector<Glib::ustring> icons;
Gtk::ScaleButton * scale = Gtk::manage(new Gtk::ScaleButton(Gtk::ICON_SIZE_SMALL_TOOLBAR, 0.0, 10.0, 1.0, icons));
Warning:
glibmm-WARNING **: Glib::ConstructParams::ConstructParams(): object class "gtkmm__GtkScaleButton" has no property named "min"
How can i avoid the warning and give it stock icons?
You must be one of the first people to ever try using this Gtk::ScaleButton constructor from gtkmm. It seems to have been broken for several years.
I've fixed it in gtkmm: https://git.gnome.org/browse/gtkmm/commit/?id=26f94d231da9481d74acdd94e56168ed6b38609a
But it will be some time until that is widely available via Linux distro packages. In the meantime you can try using
Gtk::ScaleButton* button = Glib::wrap(gtk_scale_button_new(whatever));
See https://developer.gnome.org/gtkmm-tutorial/stable/sec-basics-gobj-and-wrap.html.en
However, I don't know how it's actually meant to behave, so you might encounter other bugs. You might actually want to use the derived Gtk::VolumeButton instead.
andlabs is correct that the GTK+ documentation describes the icons better:
https://developer.gnome.org/gtk3/stable/GtkScaleButton.html#GtkScaleButton--icons
and those should indeed probably be the standard icon names:
http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html

XTK - rendering volume in multiple renderers without .onShowtime()?

I'm wondering if someone can explain to me why I can't render the same volume in a 4 panel setup (3D, X, Y, Z) just like in XTK Tutorial 13, without the .onShowtime function. I tried altering the code to do this, rather than call the .onShowtimes function:
volume = new X.volume();
volume.file = 'http://x.babymri.org/?vol.nrrd';
sliceX.add(volume);
sliceX.render();
sliceY.add(volume);
sliceY.render();
sliceZ.add(volume);
sliceZ.render();
but when I do this, I get the load bars in the 3 display panels, but after loading, only the sliceX panel will display an image, the others remain black. Do I always have to have a main renderer and make the other renderers listen to it, as the tutorial suggests?
Thanks,
Dave
It is because the first call to 'render' is going to trigger the downloading of the data.
Once it has been downloaded 1 time and rendered the first time, we add/render it in the other renderers.
When we call 'render' on the next renderers, it will not try to download the data again since it has already been downloaded once.
If we call renderer as you are doing it right now, it tries to download the volume 3 times and it can mess up the internals of the object.
So long answer short, it is to avoid some race conditions but I agree we should improve that if possible.
Thanks
I have solved it temporaly replacing onShowTime with the JavaScript function setTimeout.You render the first renderer and after that you rend the others inside that function
volume = new X.volume();
volume.file = 'http://x.babymri.org/?vol.nrrd';
slice3D.add(volume);
slice3D.render();
setTimeout(function(){
sliceX.add(volume);
sliceX.render();
sliceY.add(volume);
sliceY.render();
sliceZ.add(volume);
sliceZ.render();
},600);
it worked for me.

Project1.exe Has Stopped Working. I cant seem to find what the heel is wrong with my SDL Code

All right, i apologize right away because the code is actually kind of big. The thing is, i am working with SDL, learning actually. I had managed to create animations, but i decided i wanted to go a little deeper. This is how the Code works
App - Uses: This has the main loop, the Init function, the Render Function and the whole softwares is originated from here.
Animation - Uses: This will contain and declare all of the functions in the Class Animation. It only works when a bool variable called Running is true.
Surface - Uses: This will Load files onto surfaces, Make certain color transparents and Draw images or part of images onto the MainSurface.
Events - Uses: This has all of the Virtual Functions to Events
Object - Uses: This is the big part. It was working perfectly. Before i would have a Surface Called Yoshi on the Main Class, and i would interact with the animation using that Surface. I thought that the method of having the "Character" on the main Class was a little bit confusing and it would cause me problems when having Multiple images on the screen. So therefore i decided to create a class called Object, which would have its own SDL_Surface, its own location on screen, Its own variable decided which frame it is. What i did was that i created an object to This class on the APP Class... Something like
Object MainCharacter;
So then i would be able to manipulate that Character alone, and if i ever needed to have another Object on screen i would just use
Object *SecondCharacter;
etc... So then the OBJECT Class would call the Animation. APP Class would render all of the images, by a function somewhat like this
MySurface::OnDraw(Surf_Display, MainCharacter.Img_Surface, MainCharacter.RetrievePosX(), MainCharacter.RetrievePosY(), MainCharacter.RetrieveFrameByID(0), MainCharacter.RetrieveFrameByID(1), 64, 64);
Well... But the thing is: The code stops working. This is far from a finished code, but i would like to fix this issue right away, so i can finish only after it already has a base.
Here are all of the files: Some of them dont have too many lines. I also wrote some comments to help anyone who may be able to help me.
HEADERS:
Animation.h - http://pastebin.com/v4REcmBd
Object.h - http://pastebin.com/KdeamZTG
Events.h - http://pastebin.com/dpQ7zwpG
CApp.h - http://pastebin.com/5zZYwDjv
Surface.h - http://pastebin.com/S66ChQ3f
SOURCES:
Surface.cpp - http://pastebin.com/KRgAkHpw
Object.cpp - http://pastebin.com/RtDRwVj4
Events.cpp - http://pastebin.com/dpXn8Rh3
OnRender.cpp - http://pastebin.com/AqgMTacb
OnLoop.cpp - http://pastebin.com/UAeAt7y6
OnInit.cpp - http://pastebin.com/1iiZVeyK
OnEvent.cpp - http://pastebin.com/AjRXnKC1
OnCleanUp.cpp - http://pastebin.com/cv0M11nV
CApp.cpp - http://pastebin.com/L0jhfWY8
Animation.cpp - http://pastebin.com/0BZhh6TG
All right those are it. Some of them are really short. Well, if anyone can help me finding where is my mistake i would be glad. And with that aside, i would really like to get an opinion on the structure of the software, do you think what i am doing is practical? What Design do YOU use when creating SDL Software or Games???
Having been told in the comments it happens on line 12 of Source.cpp which says
Res = SDL_DisplayFormat(Temp);
and googled SDL_DisplayFormat for you, I find this manual page
Near the bottom it says:
Newbie hint
You have to call SDL_Init before using the SDL_DisplayFormat function.
If you don't, your program will crash with an access violation.