Yes, what I wanted to mean with "is Strange" is that letting the input without appending works fine, so it means that it has its scalars.<br>In other words, I printed the scalars of "otherPolyData" and "myPolyData" before appending, and I obtain desired results. So it means that they have scalars.<div>
<br></div><div>So I don't know what is happening here. Maybe I have to add something more to satisfy conditions for using the filter, but I don't know. </div><div>Some help?<br><br>Thank you!</div><div><br></div>
<div>
<br><br><div class="gmail_quote">2012/8/3 Alex Malyushytskyy <span dir="ltr"><<a href="mailto:alexmalvtk@gmail.com" target="_blank">alexmalvtk@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">>> appendGreenSubdAndRedBlue->AddInput(otherPolyData); // what is extrange is that if I comment this line, it works fine<br>
>> appendGreenSubdAndRedBlue->AddInput(myPolyData);<br>
<br>
</div>there is nothing strange, if you comment this line there is no<br>
modification were made,<br>
so output is the same as input.<br>
<br>
why it removes scalar?<br>
otherPolyData probably does not the same scalar. From documentation:<br>
<br>
"All geometry is extracted and appended, but point and cell attributes<br>
(i.e., scalars, vectors, normals) are extracted and appended only if<br>
all datasets have the point and/or cell attributes available. (For<br>
example, if one dataset has point scalars but another does not, point<br>
scalars will not be appended.)"<br>
<br>
Regards,<br>
Alex<br>
<div><div class="h5"><br>
<br>
On Thu, Aug 2, 2012 at 4:25 AM, Gonzalo Amadio <<a href="mailto:gonzaloamadio@gmail.com">gonzaloamadio@gmail.com</a>> wrote:<br>
> Hello everyone. Is there some reason whereby vtkAppendPolyData delete the<br>
> scalars when I append 2 polydatas?<br>
><br>
> Here is my code.<br>
><br>
>> myPolyData->ShallowCopy(otherPolyData);<br>
>> SubdividePolyData(myPolyData); /// Here I modified the polydata,<br>
>> so I need to assign it again the scalar array.<br>
>><br>
>><br>
>><br>
>> // The problem I think is here in this lines, where I assign the<br>
>> scalar array<br>
>> vtkIntArray* scalars = vtkIntArray::New();<br>
>> scalars->SetNumberOfComponents(1);<br>
>> scalars->SetNumberOfValues(myPolyData->GetNumberOfCells());<br>
>> scalars->SetNumberOfTuples(myPolyData->GetNumberOfCells());<br>
>><br>
>><br>
>><br>
>> for (int i = 0; i < myPolyData->GetNumberOfCells(); i++)<br>
>> scalars->SetValue(i, 1);<br>
>><br>
>><br>
>><br>
>> myPolyData->GetCellData()->SetScalars(scalars);<br>
>><br>
>><br>
>><br>
>> vtkSmartPointer<vtkAppendPolyData> appendGreenSubdAndRedBlue =<br>
>> vtkSmartPointer<vtkAppendPolyData>::New();<br>
>> appendGreenSubdAndRedBlue->AddInput(otherPolyData); // what is extrange<br>
>> is that if I comment this line, it works fine<br>
>> appendGreenSubdAndRedBlue->AddInput(myPolyData);<br>
>> appendGreenSubdAndRedBlue->Update();<br>
>><br>
>><br>
>><br>
>> vtkPolyData * finalPolyData = appendGreenSubdAndRedBlue->GetOutput();<br>
>><br>
>><br>
>><br>
>> vtkIntArray* scalarArray =<br>
>> static_cast<vtkIntArray*>(finalPolyData->GetCellData()->GetScalars());<br>
>> std::cout << scalarArray->GetNumberOfTuples() << std::endl;<br>
>> //This line gives me an error<br>
><br>
><br>
><br>
> The error that I obtain is the following :<br>
><br>
> File : vtkAbstractArray.h - line 104<br>
><br>
> vtkIdType GetNumberOfTuples()<br>
> {return (this->MaxId + 1)/this->NumberOfComponents;}<br>
><br>
> error:<br>
><br>
> name type value<br>
> this vtkAbstractArray * const 0x0<br>
><br>
><br>
> I can assign "manually" again the scalars to the finalPolyData, but it is<br>
> suppose that the scalars remains when I append them.<br>
><br>
> Thank you!<br>
><br>
> --<br>
> --------<br>
> Gonzalo<br>
><br>
</div></div>> _______________________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Please keep messages on-topic and check the VTK FAQ at:<br>
> <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
><br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>--------<br>Gonzalo Amadio<br><br>
</div>