You are missing that part in RequestData<div><br></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"> // Create an ITK reader and connect it to a Connector to get VTK output</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"> // ------------------------------</span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">------------------------------</span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">--------</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"> this->reader->SetFileName(</span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">FileName);</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"> this->connector->SetInput(</span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">reader->GetOutput());</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"> this->connector->Update();</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"> vtkImageData *imageData = this->connector->GetOutput();</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"> // ------------------------------</span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">------------------------------</span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">--------</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br><div class="gmail_quote">On Fri, Sep 7, 2012 at 4:31 PM, Joe Ping-Lin Hsiao <span dir="ltr"><<a href="mailto:phsiao@cs.unc.edu" target="_blank">phsiao@cs.unc.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">I am not sure how to check the first file's name.<br>
My reader code is not very long, so I paste it below:<br>
<br>
BioFormatsReader::BioFormatsReader()<br>
{<br>
this->FileName = NULL;<br>
this->SetNumberOfInputPorts(0);<br>
this->SetNumberOfOutputPorts(1);<br>
<br>
this->reader = ReaderType::New();<br>
this->connector = ConnectorType::New();<br>
<br>
}<br>
<br>
BioFormatsReader::~BioFormatsReader()<br>
{<br>
if( this->reader )<br>
this->reader = NULL;<br>
<br>
if( this->connector )<br>
this->connector = NULL;<br>
}<br>
<br>
int BioFormatsReader::RequestInformation(<br>
vtkInformation *vtkNotUsed(request),<br>
vtkInformationVector **vtkNotUsed(inputVector),<br>
vtkInformationVector *outputVector)<br>
{<br>
if (!this->FileName)<br>
{<br>
vtkErrorMacro(<< "A FileName must be specified.");<br>
return 0;<br>
}<br>
<br>
// Create an ITK reader and connect it to a Connector to get VTK output<br>
// --------------------------------------------------------------------<br>
this->reader->SetFileName(FileName);<br>
<br>
this->connector->SetInput(reader->GetOutput());<br>
this->connector->Update();<br>
<br>
vtkImageData *imageData = this->connector->GetOutput();<br>
// --------------------------------------------------------------------<br>
<br>
double spacing[3], origin[3];<br>
int extent[6];<br>
<br>
imageData->GetExtent(extent);<br>
imageData->GetOrigin(origin);<br>
imageData->GetSpacing(spacing);<br>
<br>
// get the info object<br>
vtkInformation *outInfo = outputVector->GetInformationObject(0);<br>
<br>
outInfo->Set(vtkDataObject::ORIGIN(),origin,3);<br>
outInfo->Set(vtkDataObject::SPACING(),spacing,3);<br>
outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),extent,6);<br>
<br>
this->GetOutput()->SetNumberOfScalarComponents(1);<br>
this->GetOutput()->SetScalarType(VTK_FLOAT);<br>
<br>
return 1;<br>
}<br>
int BioFormatsReader::RequestData(<br>
vtkInformation *vtkNotUsed(request),<br>
vtkInformationVector **vtkNotUsed(inputVector),<br>
vtkInformationVector *outputVector)<br>
{<br>
<br>
vtkInformation *outInfo = outputVector->GetInformationObject(0);<br>
vtkImageData *output = vtkImageData::SafeDownCast(<br>
(outInfo->Get(vtkDataObject::DATA_OBJECT())));<br>
<br>
if (!output)<br>
{<br>
vtkErrorMacro("Output is not of type vtkImageData");<br>
return 0;<br>
}<br>
<br>
/*<br>
if (output->GetScalarType() != VTK_FLOAT)<br>
{<br>
vtkErrorMacro("Execute: This source only outputs floats.");<br>
return 1;<br>
}<br>
*/<br>
<br>
output->ShallowCopy(this->connector->GetOutput());<br>
<br>
return 1;<br>
}<br>
<br>
void BioFormatsReader::PrintSelf(ostream& os, vtkIndent indent)<br>
{<br>
this->Superclass::PrintSelf(os,indent);<br>
<br>
os << indent << "File Name: "<br>
<< (this->FileName ? this->FileName : "(none)") << "\n";<br>
}<br>
<br>
On Fri, Sep 7, 2012 at 1:19 PM, Sebastien Jourdain<br>
<<a href="mailto:sebastien.jourdain@kitware.com">sebastien.jourdain@kitware.com</a>> wrote:<br>
</div></div><div class="HOEnZb"><div class="h5">> Did you check in your reader that you get properly the file name of the<br>
> first file ? When you switch back to the first time ?<br>
><br>
> Seb<br>
><br>
> On Fri, Sep 7, 2012 at 1:04 PM, Joe Ping-Lin Hsiao <<a href="mailto:phsiao@cs.unc.edu">phsiao@cs.unc.edu</a>><br>
> wrote:<br>
>><br>
>> Besides the capital letters, another error is my gui xml has a<br>
>> mismatched source name. (Later I figure out that I don't need a gui<br>
>> xml for the reader to run.) Now I can load data without crash.<br>
>><br>
>> But the problem remains. The animation plays fine at the first time.<br>
>> After it plays to the end, I click the 'Go back to the first frame'<br>
>> button, but the rendering still stays at the last frame even though in<br>
>> the information tab it says it's at frame 0. Am I missing something?<br>
>><br>
>> Joe<br>
>><br>
>> On Mon, Sep 3, 2012 at 10:12 AM, Sebastien Jourdain<br>
>> <<a href="mailto:sebastien.jourdain@kitware.com">sebastien.jourdain@kitware.com</a>> wrote:<br>
>> > I've just fixed the wiki example to match the current ParaView version.<br>
>> ><br>
>> > The issue in your XML is due to the usage of capital letters in<br>
>> > attributes<br>
>> > here:<br>
>> ><br>
>> > <SubProxy><br>
>> > <Proxy name="Reader"<br>
>> > ProxyGroup="internal_sources"<br>
>> > ProxyName="bioformatsreadercore"><br>
>> > </Proxy><br>
>> > </SubProxy><br>
>> ><br>
>> > === Should be ===<br>
>> ><br>
>> > <SubProxy><br>
>> > <Proxy name="Reader"<br>
>> > proxygroup="internal_sources"<br>
>> > proxyname="bioformatsreadercore"><br>
>> > </Proxy><br>
>> > </SubProxy><br>
>> ><br>
>> > Seb<br>
>> ><br>
>> > On Fri, Aug 31, 2012 at 12:58 PM, Joe Ping-Lin Hsiao <<a href="mailto:phsiao@cs.unc.edu">phsiao@cs.unc.edu</a>><br>
>> > wrote:<br>
>> >><br>
>> >> It's me again.<br>
>> >><br>
>> >> Turns out that my animation plugin is buggy. The symptom is after I<br>
>> >> play the animation once, it doesn't go back to the first animation<br>
>> >> position even I click rewind in ParaView. The frame number in the<br>
>> >> Information tab doesn't match what is currently rendered.<br>
>> >><br>
>> >> When I go back to check my xml, I found I was overwriting the .vtk<br>
>> >> file series reader cause I just copied the whole SourceProxy section<br>
>> >> over and didn't change the name field. (I confirm this because<br>
>> >> ParaView doesn't recognize .vtk files anymore in the open file dialog<br>
>> >> if I load my reader.)<br>
>> >><br>
>> >> But after I assign this file series reader proxy a new name, ParaView<br>
>> >> would just crash after I load files in and click 'Apply'. Also, the<br>
>> >> messages in my core reader are not printed out. It looks like ParaView<br>
>> >> is not using my core reader at all.<br>
>> >><br>
>> >> I have attached my xml code below.<br>
>> >><br>
>> >> <ServerManagerConfiguration><br>
>> >> <ProxyGroup name="internal_sources"><br>
>> >> <SourceProxy name="bioformatsreadercore"<br>
>> >> class="BioFormatsReader"<br>
>> >> label="BioFormats Reader"><br>
>> >> <Documentation<br>
>> >> long_help="Read Bio-Formats files."<br>
>> >> short_help="Read Bio-Formats files."><br>
>> >> </Documentation><br>
>> >> <StringVectorProperty<br>
>> >> name="FileName"<br>
>> >> animateable="0"<br>
>> >> command="SetFileName"<br>
>> >> number_of_elements="1"><br>
>> >> <FileListDomain name="files"/><br>
>> >> <Documentation><br>
>> >> This property specifies the input file name.<br>
>> >> </Documentation><br>
>> >> </StringVectorProperty><br>
>> >><br>
>> >> </SourceProxy><br>
>> >> </ProxyGroup><br>
>> >><br>
>> >> <ProxyGroup name="sources"><br>
>> >> <SourceProxy name="BioFormatsFileReader"<br>
>> >> class="vtkFileSeriesReader"<br>
>> >> label="Legacy VTK Reader"<br>
>> >> si_class="vtkSIFileSeriesReaderProxy"<br>
>> >> file_name_method="SetFileName"><br>
>> >> <Documentation<br>
>> >> short_help="Read legacy VTK files."<br>
>> >> long_help="Reads files stored in VTK's legacy file format."><br>
>> >> The Legacy VTK reader loads files stored in VTK's legacy file<br>
>> >> format (before VTK 4.2, although still supported). The expected file<br>
>> >> extension is .vtk. The type of the dataset may be structured grid,<br>
>> >> uniform rectilinear grid (image/volume), non-uniform rectiinear grid,<br>
>> >> unstructured grid, or polygonal. This reader also supports file<br>
>> >> series.<br>
>> >> </Documentation><br>
>> >> <SubProxy><br>
>> >> <Proxy name="Reader"<br>
>> >> ProxyGroup="internal_sources"<br>
>> >> ProxyName="bioformatsreadercore"><br>
>> >> </Proxy><br>
>> >> </SubProxy><br>
>> >><br>
>> >> <StringVectorProperty name="FileNameInfo"<br>
>> >> command="GetCurrentFileName"<br>
>> >> information_only="1" ><br>
>> >> <SimpleStringInformationHelper /><br>
>> >> </StringVectorProperty><br>
>> >><br>
>> >> <StringVectorProperty<br>
>> >> name="FileNames"<br>
>> >> clean_command="RemoveAllFileNames"<br>
>> >> command="AddFileName"<br>
>> >> animateable="0"<br>
>> >> number_of_elements="1"<br>
>> >> repeat_command="1"<br>
>> >> information_property="FileNameInfo" ><br>
>> >> <FileListDomain name="files"/><br>
>> >> <Documentation><br>
>> >> The list of files to be read by the reader. If more than one<br>
>> >> file is specified, the reader will switch to file series mode in which<br>
>> >> it will pretend that it can support time and provide one file per time<br>
>> >> step.<br>
>> >> </Documentation><br>
>> >> </StringVectorProperty><br>
>> >><br>
>> >> <DoubleVectorProperty<br>
>> >> name="TimestepValues"<br>
>> >> repeatable="1"<br>
>> >> information_only="1"><br>
>> >> <TimeStepsInformationHelper/><br>
>> >> <Documentation><br>
>> >> Available timestep values.<br>
>> >> </Documentation><br>
>> >> </DoubleVectorProperty><br>
>> >><br>
>> >> <Hints><br>
>> >> <ReaderFactory extensions="tif"<br>
>> >> file_description="Legacy VTK files" /><br>
>> >> </Hints><br>
>> >> <!-- End LegacyVTKFileReader --><br>
>> >> </SourceProxy><br>
>> >> </ProxyGroup><br>
>> >><br>
>> >> </ServerManagerConfiguration><br>
>> >><br>
>> >><br>
>> >> On Fri, Aug 24, 2012 at 3:15 PM, Moreland, Kenneth <<a href="mailto:kmorel@sandia.gov">kmorel@sandia.gov</a>><br>
>> >> wrote:<br>
>> >> > In that case, someone should definitely update the wiki page.<br>
>> >> ><br>
>> >> > I see a note added by Jourdain on another page<br>
>> >> > (<a href="http://paraview.org/Wiki/ServerManager_XML_Hints#TimeSeries_readers" target="_blank">http://paraview.org/Wiki/ServerManager_XML_Hints#TimeSeries_readers</a>)<br>
>> >> > that<br>
>> >> > suggests a change in 3.12. Perhaps he can update the example.<br>
>> >> ><br>
>> >> > -Ken<br>
>> >> ><br>
>> >> > Sent from my iPad so blame autocorrect.<br>
>> >> ><br>
>> >> > On Aug 24, 2012, at 11:27 AM, "Joe Ping-Lin Hsiao"<br>
>> >> > <<a href="mailto:phsiao@cs.unc.edu">phsiao@cs.unc.edu</a>><br>
>> >> > wrote:<br>
>> >> ><br>
>> >> >> It's working!<br>
>> >> >> I just followed the VTK reader code in readers.xml at<br>
>> >> >> ParaView3.14.1\ParaViewCore\ServerImplementation\Resources.<br>
>> >> >><br>
>> >> >> Ken,<br>
>> >> >> I first tried the xml code from the wiki, but I couldn't even read<br>
>> >> >> a<br>
>> >> >> file. I guess the xml scheme had changed in ParaView 3.14, and<br>
>> >> >> what's<br>
>> >> >> on the wiki is for older versions of ParaView.<br>
>> >> >><br>
>> >> >> Thanks,<br>
>> >> >> Joe<br>
>> >> >><br>
>> >> >> On Thu, Aug 23, 2012 at 6:43 PM, Moreland, Kenneth<br>
>> >> >> <<a href="mailto:kmorel@sandia.gov">kmorel@sandia.gov</a>><br>
>> >> >> wrote:<br>
>> >> >>> It looks like there is a Wiki page describing how to use the<br>
>> >> >>> vtkFileSeriesReader to convert a reader to understand file series.<br>
>> >> >>><br>
>> >> >>> <a href="http://www.paraview.org/Wiki/Animating_legacy_VTK_file_series" target="_blank">http://www.paraview.org/Wiki/Animating_legacy_VTK_file_series</a><br>
>> >> >>><br>
>> >> >>> -Ken<br>
>> >> >>><br>
>> >> >>><br>
>> >> >>><br>
>> >> >>> On 8/23/12 3:35 PM, "David E DeMarle" <<a href="mailto:dave.demarle@kitware.com">dave.demarle@kitware.com</a>><br>
>> >> >>> wrote:<br>
>> >> >>><br>
>> >> >>>> To make uniformly increasing time denoted in numbered file<br>
>> >> >>>> sequences,<br>
>> >> >>>> encapsulate your reader in a sub proxy of a vtkFileSeriesReader.<br>
>> >> >>>> See<br>
>> >> >>>> readers.xml for numerous examples of that.<br>
>> >> >>>><br>
>> >> >>>> If you need nonuniform temporal spacing or need to improve upon<br>
>> >> >>>> the<br>
>> >> >>>> file series reader's IO performance, make your reader supply<br>
>> >> >>>> temporal<br>
>> >> >>>> information and respond to time requests appropriately in<br>
>> >> >>>> RequestInformation and RequestData respectively. See<br>
>> >> >>>> vtkTimeSourceExample for an example of that.<br>
>> >> >>>><br>
>> >> >>>> David E DeMarle<br>
>> >> >>>> Kitware, Inc.<br>
>> >> >>>> R&D Engineer<br>
>> >> >>>> 21 Corporate Drive<br>
>> >> >>>> Clifton Park, NY 12065-8662<br>
>> >> >>>> Phone: <a href="tel:518-881-4909" value="+15188814909">518-881-4909</a><br>
>> >> >>>><br>
>> >> >>>><br>
>> >> >>>> On Thu, Aug 23, 2012 at 5:22 PM, Joe Ping-Lin Hsiao<br>
>> >> >>>> <<a href="mailto:phsiao@cs.unc.edu">phsiao@cs.unc.edu</a>><br>
>> >> >>>> wrote:<br>
>> >> >>>>> Hi,<br>
>> >> >>>>><br>
>> >> >>>>> I have written a customized reader in ParaView which reads 3D<br>
>> >> >>>>> stacks.<br>
>> >> >>>>> Now I'd like to add the function of reading time-varying data to<br>
>> >> >>>>> it,<br>
>> >> >>>>> so I can create animations from stacks.<br>
>> >> >>>>><br>
>> >> >>>>> ParaView has this function already. If I convert time-varying<br>
>> >> >>>>> stacks<br>
>> >> >>>>> and name them stack001.vtk, stack002.vtk, and etc, ParaView would<br>
>> >> >>>>> recognize the sequence and load them in at once, and I'd be able<br>
>> >> >>>>> to<br>
>> >> >>>>> play the animation just by clicking the 'Play' icon.<br>
>> >> >>>>><br>
>> >> >>>>> I wonder is there any example of how to do that to a reader?<br>
>> >> >>>>><br>
>> >> >>>>> Thanks,<br>
>> >> >>>>> Joe<br>
>> >> >>>>> _______________________________________________<br>
>> >> >>>>> Paraview-developers mailing list<br>
>> >> >>>>> <a href="mailto:Paraview-developers@paraview.org">Paraview-developers@paraview.org</a><br>
>> >> >>>>> <a href="http://public.kitware.com/mailman/listinfo/paraview-developers" target="_blank">http://public.kitware.com/mailman/listinfo/paraview-developers</a><br>
>> >> >>>> _______________________________________________<br>
>> >> >>>> Paraview-developers mailing list<br>
>> >> >>>> <a href="mailto:Paraview-developers@paraview.org">Paraview-developers@paraview.org</a><br>
>> >> >>>> <a href="http://public.kitware.com/mailman/listinfo/paraview-developers" target="_blank">http://public.kitware.com/mailman/listinfo/paraview-developers</a><br>
>> >> >>>><br>
>> >> >>><br>
>> >> >>><br>
>> >> >><br>
>> >> ><br>
>> >> _______________________________________________<br>
>> >> Paraview-developers mailing list<br>
>> >> <a href="mailto:Paraview-developers@paraview.org">Paraview-developers@paraview.org</a><br>
>> >> <a href="http://public.kitware.com/mailman/listinfo/paraview-developers" target="_blank">http://public.kitware.com/mailman/listinfo/paraview-developers</a><br>
>> ><br>
>> ><br>
><br>
><br>
</div></div></blockquote></div><br></div>