<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
Hi!<br>Iīm trying to write a filter with multiple input. Just for trying out, I want to add the scalar attribute data of two datasets (both should have the same structure) and have as an output one dataset with the same structure and the the added scalar data of the two input datasets. <br>The header vtkDataCalculator.h looks like this:<br><br>#ifndef __vtkDataCalculator_h<br>#define __vtkDataCalculator_h<br><br>#include "vtkDataSetAlgorithm.h"<br><br>class VTK_EXPORT vtkDataCalculator: public vtkDataSetAlgorithm<br>{ public:<br> static vtkDataCalculator *New();<br><br> vtkTypeRevisionMacro(vtkDataCalculator,vtkDataSetAlgorithm);<br> void PrintSelf(ostream& os, vtkIndent indent);<br><br>protected:<br> vtkDataCalculator(){};<br> ~vtkDataCalculator(){};<br><br> //virtual int FillInputPortInformation(int port, vtkInformation* info);<br> virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);<br>};<br>#endif<br><br><br>the vtkDataCalculator.cxx file:<br>#include "vtkDataCalculator.h"<br>#include "vtkDataSet.h"<br>#include "vtkDataArray.h"<br>#include "vtkObjectFactory.h"<br>#include "vtkPointData.h"<br>#include "vtkDoubleArray.h"<br>#include "vtkAlgorithm.h"<br>#include "vtkSmartPointer.h"<br>#include "vtkInformation.h"<br>#include "vtkInformationVector.h"<br><br>vtkStandardNewMacro(vtkDataCalculator);<br>//----------------------------------------------------------------------------<br>vtkCxxRevisionMacro(vtkDataCalculator,"$Revision$");<br>//----------------------------------------------------------------------------<br>void vtkDataCalculator::PrintSelf(ostream& os, vtkIndent indent)<br>{<br> this->Superclass::PrintSelf(os,indent);<br>}<br><br>//----------------------------------------------------------------------------<br><br><br>int vtkDataCalculator::RequestData(vtkInformation *vtkNotUsed(request),<br> vtkInformationVector **inputVector,<br> vtkInformationVector *outputVector)<br>{ <br> // int numOfInputs = inputVector -> GetNumberOfInformationObjects();<br> // if(numOfInputs != 2) vtkErrorMacro("Number of Inputs not equal 2");<br>//Get the input and the output<br> vtkDataSet* input1 = vtkDataSet::GetData(inputVector[0]);<br> vtkDataSet* input2 = vtkDataSet::GetData(inputVector[1]);<br> vtkDataSet* output = vtkDataSet::GetData(outputVector);<br><br> //check if the same number of points<br> int numOfTuples1 = input1 -> GetPointData() -> GetArray(0) -> GetNumberOfTuples();<br> int numOfTuples2 = input2 -> GetPointData() -> GetArray(0) -> GetNumberOfTuples();<br><br> vtkDoubleArray *scalars1 = vtkDoubleArray::New();<br> input1 -> GetPointData() -> GetArray(0) -> GetData(0,numOfTuples1,0,0,scalars1);<br> <br> vtkDoubleArray *scalars2 = vtkDoubleArray::New();<br> input2 -> GetPointData() -> GetArray(0) -> GetData(0,numOfTuples2,0,0,scalars2);<br><br> vtkDoubleArray *summe = vtkDoubleArray::New();<br> summe -> SetNumberOfComponents(1);<br> summe -> SetNumberOfTuples(numOfTuples1);<br><br> if(numOfTuples1 != numOfTuples2) {vtkErrorMacro("different Number of Tuples");<br> return 0;<br> }<br> else { for(int index = 0; index < numOfTuples1; index++)<br> { summe -> SetValue(index, (scalars1 -> GetValue(index)) + (scalars2 -> GetValue(index)));<br> }<br> <br> output -> CopyStructure(input1);<br> summe -> SetName("Summe");<br> output -> GetPointData() -> AddArray(summe);<br> output -> GetPointData() -> SetActiveScalars("Summe");<br> output -> Squeeze();<br> return 1;<br> }<br>}<br><br><br>and now the corresponding ServerManager.xml file:<br><br><ServerManagerConfiguration><br><ProxyGroup name="filters"><br><SourceProxy name="DataCalculator" class="vtkDataCalculator" label="Data Calculator"><br><Documentation><br>This filter adds the point data of their scalar attributes. The dimensions must coincide.<br></Documentation><br><br><InputProperty name="Input" command="AddInputConnection" clean_command="RemoveAllInputs" multiple_input="1"><br><ProxyGroupDomain name="groups"><br><Group name="sources"/><br><Group name="filters"/><br></ProxyGroupDomain><br><br><DataTypeDomain name="input_type"><br><DataType value="vtkDataSet"/><br></DataTypeDomain><br><br></InputProperty><br></SourceProxy><br><br></ProxyGroup><br></ServerManagerConfiguration><br><br><br>Well, thatīs my first try.. Paraview shuts down when I try to apply the filter, debugging I get the information that there is something wrong with the input (small wonder ;-) ). But it can also be the case that I just donīt know how to give two datasets to the filter, meaning that to apply the filter, I opened two files, so I had two of those "eye"-icons in paraviewīs pipeline browser displayed and hoped that Paraview would recognize those datasets as the input to the filter. <br><br>Thx for any piece of advice,<br>Natalie<br> <br /><hr />Express yourself instantly with MSN Messenger! <a href='http://clk.atdmt.com/AVE/go/onm00200471ave/direct/01/' target='_new'>MSN Messenger</a></body>
</html>