<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt"><div><span>Thanks for all your help, David<br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span>I removed </span>RequestDataObject() from the algorithm. Still working fine and no speed difference. I am not surprised this was somewhat "vtk-illegal", a remainder from when the algorithm was inheriting from vtkAlgorithm (now vtkImageAlgorithm).</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica
Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;">I now have a different question:</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;">I have a QVTKWidget that has a pipeline to display the output image of the algorithm. I would like to set up the pipeline in the constructor of the QVTKWidget and make the connection with the algorithm at the start of the pipeline later. Of course, vtk starts complaining about a missing input that's required as soon as the QVTKWidget is displayed (and its renderwindow subsequently rendered). How do I solve this? <br></div><div style="color:
rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;">I assume calls to vtkImageActor::GetProperty()->SetColorWindow(window); and similar in the pipeline should be made in a callback (inheriting from vtkCommand) each time the input to my algorithm is changed?</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;">The
value for window is calculated from the range of an algorithm somewhere halfway the pipeline. The pipeline has several of these constants, just using SetColorWindow as an example.<br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;">Maarten<br></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
1:02:51 PM, David Gobbi <david.gobbi@gmail.com> wrote:<br> </font> </div> <div class="y_msg_container">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"> 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"><div class="yqt8853216787" id="yqtfd71044"><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>> 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 might<br clear="none">> be a hack because should happen after setting
extent in RequestData(), but<br clear="none">> it improves the speed somewhat. The size of the renderwindow determines 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">> 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>> 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 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 to<br clear="none">>>> call Update() to get a sensible output. Without
it, the output 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 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">>>>> outInfo->Set(vtkStreamingDemandDrivenPipeline::UNRESTRICTED_UPDATE_EXTENT(),<br clear="none">>>>> 1) and<br clear="none">>>>> outInfo->Set(vtkStreamingDemandDrivenPipeline::EXACT_EXTENT(), 0) to 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 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"></div><br><br></div> </div> </div> </div> </div></body></html>