<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<STYLE>BODY {
        MARGIN-TOP: 0em; FONT-SIZE: 10pt; MARGIN-BOTTOM: 0em; COLOR: #000000; FONT-FAMILY: Verdana
}
PRE {
        MARGIN-TOP: 0em; FONT-SIZE: 10pt; MARGIN-BOTTOM: 0em; COLOR: #000000; FONT-FAMILY: Verdana,Arial,sans-serif
}
BLOCKQUOTE {
        MARGIN-TOP: 0em; FONT-SIZE: 10pt; MARGIN-BOTTOM: 0em; COLOR: #000000; FONT-FAMILY: Verdana,Arial,sans-serif
}
A {
        MARGIN-TOP: 0em; FONT-SIZE: 10pt; MARGIN-BOTTOM: 0em; COLOR: #000000; FONT-FAMILY: Verdana,Arial,sans-serif
}
MENU {
        MARGIN-TOP: 0em; FONT-SIZE: 10pt; MARGIN-BOTTOM: 0em; COLOR: #000000; FONT-FAMILY: Verdana,Arial,sans-serif
}
DD {
        MARGIN-TOP: 0em; FONT-SIZE: 10pt; MARGIN-BOTTOM: 0em; COLOR: #000000; FONT-FAMILY: Verdana,Arial,sans-serif
}
UL {
        MARGIN-TOP: 0em; FONT-SIZE: 10pt; MARGIN-BOTTOM: 0em; COLOR: #000000; FONT-FAMILY: Verdana,Arial,sans-serif
}
DT {
        MARGIN-TOP: 0em; FONT-SIZE: 10pt; MARGIN-BOTTOM: 0em; COLOR: #000000; FONT-FAMILY: Verdana,Arial,sans-serif
}
DIR {
        MARGIN-TOP: 0em; FONT-SIZE: 10pt; MARGIN-BOTTOM: 0em; COLOR: #000000; FONT-FAMILY: Verdana,Arial,sans-serif
}
ADDRESS {
        MARGIN-TOP: 0em; FONT-SIZE: 10pt; MARGIN-BOTTOM: 0em; COLOR: #000000; FONT-FAMILY: Verdana,Arial,sans-serif
}
H5 {
        MARGIN-TOP: 0em; FONT-SIZE: 10pt; MARGIN-BOTTOM: 0em; COLOR: #000000; FONT-FAMILY: Verdana,Arial,sans-serif
}
H6 {
        MARGIN-TOP: 0em; FONT-SIZE: 10pt; MARGIN-BOTTOM: 0em; COLOR: #000000; FONT-FAMILY: Verdana,Arial,sans-serif
}
HR {
        MARGIN-TOP: 0em; FONT-SIZE: 10pt; MARGIN-BOTTOM: 0em; COLOR: #000000; FONT-FAMILY: Verdana,Arial,sans-serif
}
P {
        FONT-SIZE: 10pt; MARGIN: 0in 0in 6pt; COLOR: #000000; FONT-FAMILY: Verdana,Arial,sans-serif
}
TD {
        FONT-SIZE: 10pt; MARGIN: 0in 0in 6pt; COLOR: #000000; FONT-FAMILY: Verdana,Arial,sans-serif
}
TR {
        FONT-SIZE: 10pt; MARGIN: 0in 0in 6pt; COLOR: #000000; FONT-FAMILY: Verdana,Arial,sans-serif
}
P.MsoNormal {
        FONT-SIZE: 10pt; MARGIN: 0in 0in 6pt; COLOR: #000000; FONT-FAMILY: Verdana,Arial,sans-serif
}
LI.MsoNormal {
        FONT-SIZE: 10pt; MARGIN: 0in 0in 6pt; COLOR: #000000; FONT-FAMILY: Verdana,Arial,sans-serif
}
DIV.MsoNormal {
        FONT-SIZE: 10pt; MARGIN: 0in 0in 6pt; COLOR: #000000; FONT-FAMILY: Verdana,Arial,sans-serif
}
LI {
        MARGIN-TOP: 3pt; FONT-SIZE: 10pt; MARGIN-BOTTOM: 3pt; COLOR: #000000; FONT-FAMILY: Verdana,Arial,sans-serif
}
UL {
        MARGIN-TOP: 3pt; FONT-SIZE: 10pt; MARGIN-BOTTOM: 3pt; COLOR: #000000; FONT-FAMILY: Verdana,Arial,sans-serif
}
OL {
        MARGIN-TOP: 3pt; FONT-SIZE: 10pt; MARGIN-BOTTOM: 3pt; COLOR: #000000; FONT-FAMILY: Verdana,Arial,sans-serif
}
H1 {
        FONT-SIZE: 16pt; MARGIN: 12pt 0in 3pt; COLOR: #003366; FONT-FAMILY: Verdana,Arial,sans-serif
}
H2 {
        FONT-SIZE: 14pt; MARGIN: 12pt 0in 3pt; COLOR: #003366; FONT-STYLE: italic; FONT-FAMILY: Verdana,Arial,sans-serif
}
H3 {
        FONT-SIZE: 12pt; MARGIN: 12pt 0in 3pt; COLOR: #003366; FONT-FAMILY: Verdana,Arial,sans-serif
}
H4 {
        FONT-SIZE: 11pt; MARGIN: 12pt 0in 3pt; COLOR: #003366; FONT-FAMILY: Verdana,Arial,sans-serif
}
</STYLE>

<META name=GENERATOR content="MSHTML 8.00.7600.16625"></HEAD>
<BODY style="FONT-FAMILY: Verdana; COLOR: #000000; FONT-SIZE: 10pt" id=ridBody 
background="">
<DIV dir=ltr align=left> </DIV>
<DIV align=left><SPAN class=368361607-12082010>Hi</SPAN></DIV>
<DIV align=left><SPAN class=368361607-12082010></SPAN> </DIV>
<DIV align=left><SPAN class=368361607-12082010><SPAN class=720055908-25082010>I 
am new in writing own vtk filters and have a question:</SPAN></SPAN></DIV>
<DIV align=left><SPAN class=368361607-12082010><SPAN 
class=720055908-25082010></SPAN></SPAN> </DIV>
<DIV align=left><SPAN class=368361607-12082010><SPAN 
class=720055908-25082010></SPAN></SPAN> </DIV>
<DIV align=left><SPAN class=368361607-12082010>I want to make a vtk filter which 
hast two input images and one output whereby the input images can have different 
sizes and the output has the size of the first input. </SPAN></DIV>
<DIV align=left><SPAN class=368361607-12082010></SPAN> </DIV>
<DIV align=left><SPAN class=368361607-12082010>My filter is working but when the 
first input is bigger than the second input i get <SPAN 
class=720055908-25082010> following Error in the output window (but the 
results seem to be right):</SPAN></SPAN></DIV>
<DIV align=left><SPAN class=368361607-12082010><SPAN 
class=720055908-25082010>ERROR: In 
..\..\Source\vtk-5.6.0\Filtering\vtkExecutive.cxx, line 378</SPAN></SPAN></DIV>
<DIV align=left><SPAN class=368361607-12082010><SPAN 
class=720055908-25082010>vtkStramingDemandDrivenPipeline (0000000000002FBB4E0): 
Attempt to get</SPAN></SPAN></DIV>
<DIV align=left><SPAN class=368361607-12082010><SPAN 
class=720055908-25082010></SPAN></SPAN> </DIV>
<DIV align=left><SPAN class=368361607-12082010><SPAN class=720055908-25082010>(i 
cannot read the rest because the vtkOutputWindow is deactivated, 
lol)</SPAN></SPAN></DIV>
<DIV align=left><SPAN class=368361607-12082010><SPAN 
class=720055908-25082010> </SPAN></SPAN><SPAN 
class=368361607-12082010></SPAN></DIV>
<DIV align=left><SPAN class=368361607-12082010>Can anyone say me what i making 
wrong:</SPAN></DIV>
<DIV align=left><SPAN class=368361607-12082010></SPAN> </DIV>
<DIV align=left><SPAN class=368361607-12082010>here some code snippets, it would 
be also great if anyone can say me how to make a better type handling than the 
if(dim ==3), switch(datatype) stuff:</SPAN></DIV>
<DIV align=left><SPAN class=368361607-12082010></SPAN> </DIV>
<DIV align=left><SPAN class=368361607-12082010>
<P>class C<SPAN class=368361607-12082010>Filter</SPAN> : <FONT 
color=#0000ff><FONT color=#0000ff>public</FONT></FONT> vtkImageAlgorithm </P>
<P>{</P>
<P><FONT color=#0000ff><FONT color=#0000ff>public</FONT></FONT>:</P>
<P><FONT color=#0000ff><SPAN class=368361607-12082010>   
</SPAN>static</FONT> C<SPAN class=368361607-12082010>Filter</SPAN> *New();</P>
<P><FONT color=#0000ff><SPAN class=368361607-12082010>   
</SPAN>void</FONT> PrintSelf(ostream& oStream, vtkIndent oIndent);</P>
<P><FONT color=#0000ff><FONT color=#0000ff>protected</FONT></FONT>:</P>
<P><SPAN class=368361607-12082010>   </SPAN>C<SPAN 
class=368361607-12082010>Filter</SPAN> ();</P>
<P><SPAN class=368361607-12082010>   </SPAN>~C<SPAN 
class=368361607-12082010>Filter</SPAN> (); </P>
<P><FONT color=#0000ff><SPAN class=368361607-12082010>    
</SPAN>int</FONT> RequestData(vtkInformation *poRequest, vtkInformationVector** 
ppoInputVector, vtkInformationVector* poOutputVector);</P>
<P><FONT color=#0000ff><FONT color=#0000ff>private</FONT></FONT>:</P>
<P><SPAN class=368361607-12082010>    </SPAN>C<SPAN 
class=368361607-12082010>Filter</SPAN> (C<SPAN 
class=368361607-12082010>Filter</SPAN> &); </P>
<P><FONT color=#0000ff><SPAN class=368361607-12082010>    
</SPAN>void</FONT> <FONT color=#0000ff><FONT 
color=#0000ff>operator</FONT></FONT>=(<FONT color=#0000ff><FONT 
color=#0000ff>const</FONT></FONT> C<SPAN class=368361607-12082010>Filter</SPAN> 
&); </P>
<P>};</P>
<P> </P>
<P>C<SPAN class=368361607-12082010>Filter</SPAN> ::C<SPAN 
class=368361607-12082010>Filter</SPAN> ()</P>
<P>{</P>
<P><FONT color=#0000ff><SPAN class=368361607-12082010>    
</SPAN>this</FONT>->SetNumberOfInputPorts(2);</P>
<P>}</P>
<P> </P><FONT color=#0000ff><FONT color=#0000ff>
<P>int</P></FONT></FONT>
<P>C<SPAN class=368361607-12082010>Filter</SPAN> ::RequestData(vtkInformation 
*poRequest, vtkInformationVector** ppoInputVector, vtkInformationVector* 
poOutputVector)</P>
<P>{</P>
<P><SPAN class=368361607-12082010>   </SPAN>vtkInformation* 
oInputInfo;</P>
<P><SPAN class=368361607-12082010>   </SPAN>oInputInfo = 
ppoInputVector[0]->GetInformationObject(0);</P>
<P><SPAN class=368361607-12082010>   </SPAN>vtkImageData *oInput1 = 
vtkImageData::SafeDownCast(oInputInfo->Get(vtkDataObject::DATA_OBJECT()));</P>
<P><SPAN class=368361607-12082010>   </SPAN>oInputInfo = 
ppoInputVector[1]->GetInformationObject(0);</P>
<P><SPAN class=368361607-12082010>   </SPAN>vtkImageData *oInput2 = 
vtkImageData::SafeDownCast(oInputInfo->Get(vtkDataObject::DATA_OBJECT()));</P>
<P><FONT color=#0000ff></FONT>
<P></P><FONT color=#0000ff><SPAN class=368361607-12082010>   
</SPAN>unsigned</FONT> <FONT color=#0000ff><FONT color=#0000ff>int</FONT></FONT> 
iDim; 
<P></P>
<P><FONT color=#0000ff><SPAN class=368361607-12082010>   
</SPAN>if</FONT>((oInput1->GetDataDimension() == 3) && 
(oInput2->GetDataDimension() == 3))</P>
<P><SPAN class=368361607-12082010>   </SPAN>{</P>
<P><SPAN class=368361607-12082010>       
</SPAN>iDim = 3;</P>
<P><SPAN class=368361607-12082010>   </SPAN>}</P>
<P><FONT color=#0000ff><SPAN 
class=368361607-12082010>   </SPAN>else</FONT> <FONT 
color=#0000ff><FONT color=#0000ff>if</FONT></FONT> 
((oInput1->GetDataDimension() == 2) && 
(oInput2->GetDataDimension() == 2))</P>
<P><SPAN class=368361607-12082010>   </SPAN>{</P>
<P><SPAN class=368361607-12082010>       
</SPAN>iDim = 2;</P>
<P><SPAN class=368361607-12082010>   </SPAN>}</P>
<P><FONT color=#0000ff><SPAN class=368361607-12082010>   
</SPAN>else</FONT></P>
<P><SPAN class=368361607-12082010>   </SPAN>{</P>
<P><SPAN class=368361607-12082010>       
</SPAN>std::cout << <FONT color=#a31515><FONT color=#a31515>"Error: This 
filter requires two or three dimensional data!"</FONT></FONT> << 
std::endl;</P>
<P><FONT color=#0000ff><SPAN 
class=368361607-12082010>       
</SPAN>return</FONT> 0;</P>
<P><SPAN class=368361607-12082010>   </SPAN>}</P>
<P><SPAN class=368361607-12082010>   </SPAN>vtkInformation* oInfo = 
poOutputVector->GetInformationObject(0);</P>
<P><SPAN class=368361607-12082010>   </SPAN>vtkImageData *oOutput 
= vtkImageData::SafeDownCast(oInfo->Get(vtkDataObject::DATA_OBJECT()));</P>
<P> </P><FONT color=#0000ff><FONT color=#0000ff>
<P><SPAN class=368361607-12082010>   </SPAN>int</FONT></FONT> 
iScalarType = oInput1->GetScalarType();</P>
<P><SPAN class=368361607-12082010>   
</SPAN>vtkSmartPointer<vtkImageCast> oInputCaster1 = 
vtkImageCast::New();</P>
<P><SPAN class=368361607-12082010>   
</SPAN>oInputCaster1->ReleaseDataFlagOn();</P>
<P><SPAN class=368361607-12082010>   
</SPAN>oInputCaster1->SetInput(oInput1);</P>
<P><SPAN class=368361607-12082010>   
</SPAN>vtkSmartPointer<vtkImageCast> oInputCaster2 = 
vtkImageCast::New();</P>
<P><SPAN class=368361607-12082010>   
</SPAN>oInputCaster2->ReleaseDataFlagOn();</P>
<P><SPAN class=368361607-12082010>   
</SPAN>oInputCaster2->SetInput(oInput2);</P>
<P><SPAN class=368361607-12082010>   
</SPAN>vtkSmartPointer<vtkImageCast> oOutputCaster = 
vtkImageCast::New();</P>
<P><SPAN class=368361607-12082010>   
</SPAN>oOutputCaster->SetOutputScalarType(iScalarType);</P>
<P><FONT color=#0000ff><SPAN class=368361607-12082010>   
</SPAN>if</FONT>(iDim == 2)</P>
<P><SPAN class=368361607-12082010>   </SPAN>{</P>
<P><FONT color=#0000ff><SPAN 
class=368361607-12082010>       
</SPAN>switch</FONT>(iScalarType)</P>
<P><SPAN class=368361607-12082010>      </SPAN>{</P>
<P><FONT color=#0000ff><SPAN 
class=368361607-12082010>           
</SPAN>case</FONT> VTK_FLOAT:</P>
<P><SPAN 
class=368361607-12082010>           
</SPAN>{<SPAN class=368361607-12082010> </SPAN></P>
<P><FONT color=#0000ff><SPAN 
class=368361607-12082010>               
</SPAN>typedef</FONT> itk::Image<<FONT color=#0000ff><FONT 
color=#0000ff>float</FONT></FONT>, 2> TInputImage;</P>
<P><FONT color=#0000ff><SPAN 
class=368361607-12082010>               
</SPAN>typedef</FONT> itk::Image<<FONT color=#0000ff><FONT 
color=#0000ff>float</FONT></FONT>, 2> TOutputImage;</P>
<P><FONT color=#0000ff><SPAN 
class=368361607-12082010>               
</SPAN>typedef</FONT> <SPAN 
class=368361607-12082010>MyITKFilter</SPAN><TInputImage,TOutputImage> 
TFilter;</P>
<P><FONT color=#0000ff><SPAN 
class=368361607-12082010>               </SPAN>typedef</FONT> 
itk::VTKImageToImageFilter<TInputImage> TInputConverter;</P>
<P><FONT color=#0000ff><SPAN 
class=368361607-12082010>               
</SPAN>typedef</FONT> itk::ImageToVTKImageFilter<TOutputImage> 
TOutputConverter;</P>
<P><SPAN 
class=368361607-12082010>               
</SPAN>oInputCaster1->SetOutputScalarTypeToFloat();</P>
<P><SPAN 
class=368361607-12082010>               
</SPAN>oInputCaster2->SetOutputScalarTypeToFloat();</P>
<P><SPAN 
class=368361607-12082010>               
</SPAN>TInputConverter::Pointer oInputConverter1 = TInputConverter::New();</P>
<P><SPAN 
class=368361607-12082010>               
</SPAN>oInputConverter1->ReleaseDataFlagOn();</P>
<P><SPAN 
class=368361607-12082010>               
</SPAN>oInputConverter1->SetInput(oInputCaster1->GetOutput());</P>
<P><SPAN 
class=368361607-12082010>               
</SPAN>TInputConverter::Pointer oInputConverter2 = TInputConverter::New();</P>
<P><SPAN 
class=368361607-12082010>               
</SPAN>oInputConverter2->ReleaseDataFlagOn();</P>
<P><SPAN 
class=368361607-12082010>               
</SPAN>oInputConverter2->SetInput(oInputCaster2->GetOutput());</P>
<P><SPAN 
class=368361607-12082010>               
</SPAN>TFilter::Pointer oFilter = TFilter::New();</P>
<P><SPAN 
class=368361607-12082010>               </SPAN>oFilter->Set<SPAN 
class=368361607-12082010>Input1</SPAN>(oInputConverter1->GetOutput());</P>
<P><SPAN 
class=368361607-12082010>               </SPAN>oFilter->Set<SPAN 
class=368361607-12082010>Input2</SPAN>(oInputConverter2->GetOutput());</P>
<P><SPAN 
class=368361607-12082010>               
</SPAN>oFilter->ReleaseDataFlagOn();</P>
<P><SPAN 
class=368361607-12082010>               
</SPAN>TOutputConverter::Pointer oOutputConverter = TOutputConverter::New();</P>
<P><SPAN 
class=368361607-12082010>               
</SPAN>oOutputConverter->ReleaseDataFlagOn();</P>
<P><SPAN 
class=368361607-12082010>               
</SPAN>oOutputConverter->SetInput(oFilter->GetOutput());</P>
<P><SPAN 
class=368361607-12082010>               
</SPAN>oOutputCaster->SetInput(oOutputConverter->GetOutput()); </P>
<P><SPAN 
class=368361607-12082010>              
</SPAN>oOutputCaster->Update();</P>
<P><SPAN 
class=368361607-12082010>          </SPAN>}</P>
<P><FONT color=#0000ff><SPAN 
class=368361607-12082010>          
</SPAN>break</FONT>;</P>
<P><FONT color=#0000ff><SPAN 
class=368361607-12082010>          
</SPAN>case</FONT> VTK_UNSIGNED_CHAR:</P>
<P><SPAN 
class=368361607-12082010>          </SPAN>{</P>
<P><FONT color=#0000ff><SPAN 
class=368361607-12082010>              
</SPAN>typedef</FONT> itk::Image<<FONT color=#0000ff><FONT 
color=#0000ff>unsigned</FONT></FONT> <FONT color=#0000ff><FONT 
color=#0000ff>char</FONT></FONT>, 2> TInputImage;</P>
<P><FONT color=#0000ff><SPAN 
class=368361607-12082010>              
</SPAN>typedef</FONT> itk::Image<<FONT color=#0000ff><FONT 
color=#0000ff>unsigned</FONT></FONT> <FONT color=#0000ff><FONT 
color=#0000ff>char</FONT></FONT>, 2> TOutputImage;</P>
<P><FONT color=#0000ff><SPAN 
class=368361607-12082010>              
</SPAN>typedef</FONT> CCheckerboard<TInputImage,TOutputImage> TFilter;</P>
<P><FONT color=#0000ff><SPAN 
class=368361607-12082010>              
</SPAN>typedef</FONT> itk::VTKImageToImageFilter<TInputImage> 
TInputConverter;</P>
<P><FONT color=#0000ff><SPAN 
class=368361607-12082010>              
</SPAN>typedef</FONT> itk::ImageToVTKImageFilter<TOutputImage> 
TOutputConverter;</P>
<P><SPAN 
class=368361607-12082010>              
</SPAN>oInputCaster1->SetOutputScalarTypeToUnsignedChar();</P>
<P><SPAN 
class=368361607-12082010>              
</SPAN>oInputCaster2->SetOutputScalarTypeToUnsignedChar();</P>
<P> </P>
<P><SPAN 
class=368361607-12082010>              
blablabla</SPAN></P>
<P><SPAN 
class=368361607-12082010>         
}</SPAN></P>
<P><SPAN class=368361607-12082010>        
//do for all cases</SPAN></P>
<P><SPAN class=368361607-12082010>     }</SPAN></P>
<P><SPAN class=368361607-12082010>}</SPAN></P>
<P><SPAN class=368361607-12082010>else if (iDim==3)</SPAN></P>
<P><SPAN class=368361607-12082010>{</SPAN></P>
<P><SPAN class=368361607-12082010>//do for dim = 3 and all cases</SPAN></P>
<P><SPAN class=368361607-12082010>}</SPAN></P>
<P>}</P>
<P>oOutput->ShallowCopy(oOutputCaster->GetOutput());</P>
<P></P>
<P>oOutputCaster->Delete();</P>
<P>oInputCaster1->Delete();</P>
<P>oInputCaster2->Delete();</P>
<P><FONT color=#0000ff><FONT color=#0000ff>return</FONT></FONT> 1;</P>
<P><SPAN class=368361607-12082010>}</SPAN></P></SPAN></DIV></BODY></HTML>