<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt">I do get a nice black renderwindow, because I set up the callback-observer connection sometime after the first render. But I get your point.<br><br>If I create the pipeline and add the input before the render, everything works fine.<br>The if statement is never true.<br><br>I like my code better (stupid me?) when I add the input later, so it isn't shown automatically, but after a button press... don't understand why I cannot abort the render (even if it were to come from the interactor)...<br><div><span><br></span></div><div style="display: block;" class="yahoo_quoted"> <br> <br> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande,
sans-serif; font-size: 12pt;"> <div dir="ltr"> <font size="2" face="Arial"> On Tuesday, January 14, 2014 5:04:43 PM, David Gobbi <david.gobbi@gmail.com> wrote:<br> </font> </div> <div class="y_msg_container">Like I said a couple emails ago, I think that the best choice is to<br clear="none">not add the actors to the renderer until the data is loaded.<br clear="none"><br clear="none">If you abort the first render, then the window is likely to show<br clear="none">whatever was left over in the GPU's pixel buffer. It might show<br clear="none">black, it might show garbage, or it might show something from a recent<br clear="none">websurfing session. In any case, I advise that you do not abort the<br clear="none">first render. Let the window render a nice, black background like it<br clear="none">should.<br clear="none"><br clear="none"><div class="yqt6258956654" id="yqtfd33548"><br clear="none">On Tue, Jan 14, 2014 at 2:41 PM,
Maarten Beek <<a shape="rect" ymailto="mailto:beekmaarten@yahoo.com" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>> wrote:<br clear="none">> I almost have to thing working!<br clear="none">><br clear="none">> One last question:<br clear="none">> I added the following to the render callback class:<br clear="none">><br clear="none">> virtual void RenderCallBack::Execute(vtkObject* obj, unsigned long<br clear="none">> eventId, void* callData)<br clear="none">> {<br clear="none">> vtkRenderWindow* renderWindow = vtkRenderWindow::SafeDownCast(obj);<br clear="none">> if( eventId == vtkCommand::StartEvent && NULL != renderWindow )<br clear="none">> {<br clear="none">> if( !m_pWidget->m_pDRRGenerator ||<br clear="none">>
!m_pWidget->m_pDRRGenerator->GetInputDataObject(0, 0) )<br clear="none">> {<br clear="none">> // if no input set, abort render<br clear="none">> renderWindow->SetInAbortCheck(1);<br clear="none">> return;<br clear="none">> }<br clear="none">><br clear="none">> <...><br clear="none">> }<br clear="none">> }<br clear="none">><br clear="none">> However, it looks like the renderwindow is rendered anyway...<br clear="none">><br clear="none">> If I call GetRenderWindow()->GetInteractor()->EnableRenderOff(); it seems to<br
clear="none">> be working as desired.<br clear="none">><br clear="none">> But I think I want the interactor to be able to initiate renders, but how do<br clear="none">> I abort a render from the interactor?<br clear="none">><br clear="none">> Thanks so much for your help today - Maarten<br clear="none">><br clear="none">><br clear="none">><br clear="none">> On Tuesday, January 14, 2014 2:12:15 PM, David Gobbi <<a shape="rect" ymailto="mailto:david.gobbi@gmail.com" href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>><br clear="none">> wrote:<br clear="none">> Just make sure you don't add the actor to the renderer in your<br clear="none">> constructor. The actor should only be added after the data is loaded.<br clear="none">> Or, if this isn't possible, you can just make a dummy data set to use<br clear="none">> as the initial input.<br clear="none">><br clear="none">> For the
window/level, probably the best thing is to catch the<br clear="none">> StartEvent from the render window. In the callback, manually call<br clear="none">> Update() on your pipeline and set the window/level.<br clear="none">><br clear="none">> On Tue, Jan 14, 2014 at 11:31 AM, Maarten Beek <<a shape="rect" ymailto="mailto:beekmaarten@yahoo.com" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>><br clear="none">> wrote:<br clear="none">>> Thanks for all your help, David<br clear="none">>><br clear="none">>> I removed RequestDataObject() from the algorithm. Still working fine and<br clear="none">>> no<br clear="none">>> speed difference. I am not surprised this was somewhat "vtk-illegal", a<br clear="none">>> remainder from when the algorithm was inheriting from vtkAlgorithm (now<br clear="none">>> vtkImageAlgorithm).<br clear="none">>><br clear="none">>> I now
have a different question:<br clear="none">>> I have a QVTKWidget that has a pipeline to display the output image of the<br clear="none">>> algorithm. I would like to set up the pipeline in the constructor of the<br clear="none">>> QVTKWidget and make the connection with the algorithm at the start of the<br clear="none">>> pipeline later. Of course, vtk starts complaining about a missing input<br clear="none">>> that's required as soon as the QVTKWidget is displayed (and its<br clear="none">>> renderwindow<br clear="none">>> subsequently rendered). How do I solve this?<br clear="none">>><br clear="none">>> I assume calls to vtkImageActor::GetProperty()->SetColorWindow(window);<br clear="none">>> and<br clear="none">>> similar in the pipeline should be made in a callback (inheriting from<br clear="none">>> vtkCommand) each time the input to my algorithm is changed?<br
clear="none">>><br clear="none">>> The value for window is calculated from the range of an algorithm<br clear="none">>> somewhere<br clear="none">>> halfway the pipeline. The pipeline has several of these constants, just<br clear="none">>> using SetColorWindow as an example.<br clear="none">>><br clear="none">>> Maarten<br clear="none">>><br clear="none">>><br clear="none">>> On Tuesday, January 14, 2014 1:02:51 PM, David Gobbi<br clear="none">>> <<a shape="rect" ymailto="mailto:david.gobbi@gmail.com" href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>><br clear="none">>> wrote:<br clear="none">>> I really don't think you should be using RequestDataObject at all.<br clear="none">>> Since it's an image filter, the fact that the output is a vtkImageData<br clear="none">>> will be set in SetOutputPortInformation(), and the data object will be<br
clear="none">>> created automatically. The data type (e.g. float) and the<br clear="none">>> WHOLE_EXTENT should be set in RequestInformation().<br clear="none">>><br clear="none">>> Does your filter derives from vtkImageAlgorithm? Then the data should<br clear="none">>> definitely be allocated in RequestData(). Calling SetExtent() after<br clear="none">>> the memory has already been allocated makes no sense, because if the<br clear="none">>> new extent is different from the old extent then you end up with an<br clear="none">>> invalid data object. Allocate the data in the same way that<br clear="none">>> vtkImageAccumulate allocates data, like this:<br clear="none">>><br clear="none">>><br clear="none">>><br clear="none">>> outData->SetExtent(outInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()));<br clear="none">>>
outData->AllocateScalars(outInfo);<br clear="none">>><br clear="none">>> Calling AllocateScalars() is efficient because it will only<br clear="none">>> re-allocate the data if the Extent changes, and as shown above, the<br clear="none">>> Extent will always be the WHOLE_EXTENT.<br clear="none">>><br clear="none">>> You can ignore the UPDATE_EXTENT() for the output, it is completely<br clear="none">>> irrelevant to your particular filter and no matter what it is set to,<br clear="none">>> allocating the WHOLE_EXTENT for your output is always safe. But you<br clear="none">>> must still override RequestUpdateExtent() to set your input's update<br clear="none">>> extent to your input's whole extent.<br clear="none">>><br clear="none">>> David<br clear="none">>><br clear="none">>><br clear="none">>><br clear="none">>> On Tue, Jan 14, 2014 at 9:58
AM, Maarten Beek <<a shape="rect" ymailto="mailto:beekmaarten@yahoo.com" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>><br clear="none">>> wrote:<br clear="none">>>> I create data in RequestDataObject() with:<br clear="none">>>><br clear="none">>>> vtkImageData* newoutput = vtkImageData::New();<br clear="none">>>> outinfo->Set(vtkDataObject::DATA_OBJECT(), newoutput);<br clear="none">>>> output->ReleaseData(); // so filters know it's empty<br clear="none">>>> output->Delete();<br clear="none">>>><br clear="none">>>> I've seen other filters do this as well. I've also seen it happen in the<br clear="none">>>> constructor of the filter.<br clear="none">>>><br clear="none">>>> I also allocate the memory for the output in RequestDataObject(). This<br clear="none">>>> might<br clear="none">>>> be a hack
because should happen after setting extent in RequestData(),<br clear="none">>>> but<br clear="none">>>> it improves the speed somewhat. The size of the renderwindow determines<br clear="none">>>> the<br clear="none">>>> size of the output image (class has setter for this).<br clear="none">>>><br clear="none">>>> In RequestData() I do:<br clear="none">>>> this->InternalRenderWindow->Render();<br clear="none">>>> this->InternalRenderWindow->WaitForCompletion();<br clear="none">>>><br clear="none">>>> int* size = this->InternalRenderWindow->GetSize();<br clear="none">>>><br clear="none">>>> vtkInformation* info = outVector->GetInformationObject(0);<br clear="none">>>> vtkImageData* output =<br clear="none">>>> vtkImageData::SafeDownCast(info->Get(vtkDataObject::DATA_OBJECT()));<br
clear="none">>>><br clear="none">>>><br clear="none">>>> output->SetExtent(info->Get(vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT()));<br clear="none">>>><br clear="none">>>> vtkFloatData* data =<br clear="none">>>> vtkFloatData::SafeDownCast(output->GetPointData()->GetScalars());<br clear="none">>>> this->InternalRenderWindow->GetRGBAPixelData(0, 0, size[0]-1, size[1]-1,<br clear="none">>>> data);<br clear="none">>>><br clear="none">>>><br clear="none">>>> On Tuesday, January 14, 2014 11:39:34 AM, David Gobbi<br clear="none">>>> <<a shape="rect" ymailto="mailto:david.gobbi@gmail.com" href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>> wrote:<br clear="none">>>> The order in which requests are processed is:<br clear="none">>>> RequestDataObject()<br clear="none">>>>
RequestInformation()<br clear="none">>>> RequestUpdateExtent()<br clear="none">>>> RequestData()<br clear="none">>>><br clear="none">>>> So I am a bit confused about how you are creating the data before you<br clear="none">>>> Render the window that you get it from.<br clear="none">>>><br clear="none">>>> On Tue, Jan 14, 2014 at 9:20 AM, Maarten Beek <<a shape="rect" ymailto="mailto:beekmaarten@yahoo.com" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>><br clear="none">>>> wrote:<br clear="none">>>>> Yes, it has an internal pipeline. Apologies for not mentioning this,<br clear="none">>>>> thought<br clear="none">>>>> I did, must have been in an earlier email to the mailinglist...<br clear="none">>>>><br clear="none">>>>> I started with the vtkWindowToImageFilter class, but now taking data<br
clear="none">>>>> directly from an internal renderwindow because I want floats instead of<br clear="none">>>>> unsigned chars.<br clear="none">>>>> I don't make a ShallowCopy of the output, instead I create the data in<br clear="none">>>>> RequestDataObject(). I do call Render() on the internal renderwindow in<br clear="none">>>>> RequestData().<br clear="none">>>>><br clear="none">>>>> Basically I am trying to make a nice drr generator algorithm using the<br clear="none">>>>> gpu<br clear="none">>>>> mapper in vtk.<br clear="none">>>>><br clear="none">>>>> Maarten<br clear="none">>>>><br clear="none">>>>><br clear="none">>>>> On Tuesday, January 14, 2014 11:07:21 AM, David Gobbi<br clear="none">>>>> <<a shape="rect" ymailto="mailto:david.gobbi@gmail.com"
href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>> wrote:<br clear="none">>>>> Your filter has an internal pipeline? That would have been worth<br clear="none">>>>> mentioning in your first email.<br clear="none">>>>><br clear="none">>>>> Are you doing a shallow copy to copy the output of the internal<br clear="none">>>>> pipeline to the output of your filter? Does your RequestData() method<br clear="none">>>>> call the Update() method of the internal pipeline?<br clear="none">>>>><br clear="none">>>>> On Tue, Jan 14, 2014 at 8:42 AM, Maarten Beek <<a shape="rect" ymailto="mailto:beekmaarten@yahoo.com" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>><br clear="none">>>>> wrote:<br clear="none">>>>>> Thanks David,<br clear="none">>>>>><br clear="none">>>>>>
Just before reading your email, I already added<br clear="none">>>>>> inInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), inExt);<br clear="none">>>>>> inInfo->Set(vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(), inExt,<br clear="none">>>>>> 6);<br clear="none">>>>>> to the code in RequestUpdateExtent() and that caused the errors to<br clear="none">>>>>> disappear. But it is good to see it seems to work in another filter too<br clear="none">>>>>> ;-)<br clear="none">>>>>><br clear="none">>>>>> Something is still wrong in the algorithm code though, because I need<br clear="none">>>>>> to<br clear="none">>>>>> call Update() to get a sensible output. Without it, the output<br clear="none">>>>>> disappears<br clear="none">>>>>> from the renderwindow after a
new render (although the algorithm's<br clear="none">>>>>> RequestData is called...?)<br clear="none">>>>>><br clear="none">>>>>> Maybe vtkImageHistogram will give me a clue, although I don't see an<br clear="none">>>>>> internal pipeline in it...<br clear="none">>>>>><br clear="none">>>>>> Maarten<br clear="none">>>>>><br clear="none">>>>>><br clear="none">>>>>> On Tuesday, January 14, 2014 9:58:09 AM, David Gobbi<br clear="none">>>>>> <<a shape="rect" ymailto="mailto:david.gobbi@gmail.com" href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>><br clear="none">>>>>> wrote:<br clear="none">>>>>> Hi Maarten,<br clear="none">>>>>><br clear="none">>>>>> In order to set the output extent independent of the input extent,<br
clear="none">>>>>> all you should have to do is override RequestInformation() and<br clear="none">>>>>> RequestUpdateExtent(). It is definitely not necessary to set<br clear="none">>>>>> UNRESTRICTED_UPDATE_EXTENT or EXACT_EXTENT.<br clear="none">>>>>> Take a look at vtkImageHistogram.cxx as an example of a filter<br clear="none">>>>>> that has a 3D input and an independently-sized 2D output.<br clear="none">>>>>><br clear="none">>>>>> David<br clear="none">>>>>><br clear="none">>>>>> On Mon, Jan 13, 2014 at 1:45 PM, Maarten Beek <<a shape="rect" ymailto="mailto:beekmaarten@yahoo.com" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>><br clear="none">>>>>> wrote:<br clear="none">>>>>>> Hi all,<br clear="none">>>>>>><br
clear="none">>>>>>> I am trying to write an (image) algorithm that generates a 2d image<br clear="none">>>>>>> from<br clear="none">>>>>>> a<br clear="none">>>>>>> 3d image.<br clear="none">>>>>>> I would like to be able to set the resolution of the 2d image.<br clear="none">>>>>>> The extents of the input and output are therefore unrelated.<br clear="none">>>>>>><br clear="none">>>>>>> I have the algorithm working when I set the algorithm's input in an<br clear="none">>>>>>> unofficial way (SetNumberOfInputPorts(0), using a custom function<br clear="none">>>>>>> SetInput<br clear="none">>>>>>> instead of SetInputConnection or SetInputData). This way there is no<br clear="none">>>>>>> pipeline created, which I would like to happen.<br
clear="none">>>>>>><br clear="none">>>>>>> I set the whole extent of the algorithm's output to the desired (2d)<br clear="none">>>>>>> extent<br clear="none">>>>>>> in RequestInformation. However, the function<br clear="none">>>>>>> vtkStreamingDemandDrivenPipeline::VerifyOutputInformation() fails<br clear="none">>>>>>> because<br clear="none">>>>>>> this whole extent miraculously gets re-set to whole (3d) extent of the<br clear="none">>>>>>> input.<br clear="none">>>>>>> I have tried to prevent this check using<br clear="none">>>>>>><br clear="none">>>>>>><br clear="none">>>>>>><br clear="none">>>>>>><br clear="none">>>>>>><br clear="none">>>>>>>
outInfo->Set(vtkStreamingDemandDrivenPipeline::UNRESTRICTED_UPDATE_EXTENT(),<br clear="none">>>>>>> 1) and<br clear="none">>>>>>> outInfo->Set(vtkStreamingDemandDrivenPipeline::EXACT_EXTENT(), 0) to<br clear="none">>>>>>> no<br clear="none">>>>>>> avail.<br clear="none">>>>>>><br clear="none">>>>>>> How do I prevent the adjustment of the whole extent after I have set<br clear="none">>>>>>> it<br clear="none">>>>>>> to<br clear="none">>>>>>> the desired value?<br clear="none">>>>>>><br clear="none">>>>>>> Thanks - Maarten<br clear="none">>>>>><br clear="none">>>>>><br clear="none">>>>><br clear="none">>>>><br clear="none">>>><br clear="none">>>><br clear="none">>><br
clear="none">>><br clear="none">><br clear="none">><br clear="none"></div><br><br></div> </div> </div> </div> </div></body></html>