<br><br><div class="gmail_quote">2012/8/7 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">
If both polydata have exactly the same scalars (type, dimensions )<br>
output should have a scalar field.<br>
If it does not , it is a bug.<br></blockquote><div> </div><div><div>myPolyData->GetNumberOfPoints() = 2421</div><div>myPolyData->GetNumberOfCells() = 3010 (so the scalar array for this polydata is the same length)</div>
</div><div><br></div><div><div>otherPolyData->GetNumberOfPoints() = 574</div><div>otherPolyData->GetNumberOfCells() = 524</div></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
But I doubt it. You do not show all significant code, so<br>
I am not sure these 2 scalars are compatible.<br></blockquote><div><br></div><div>What additional information do you need?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Did you want 1 scalar value per cell?<br>
If so, could you try to replace<br>
<div class="im"><br>
vtkIntArray* scalars = vtkIntArray::New();<br>
scalars->SetNumberOfComponents(1);<br>
scalars->SetNumberOfValues(myPolyData->GetNumberOfCells());<br>
scalars->SetNumberOfTuples(myPolyData->GetNumberOfCells());<br>
<br>
</div> with<br>
<div class="im"><br>
vtkIntArray* scalars = vtkIntArray::New();<br>
</div> scalars->SetNumberOfValues( myPolyData->GetNumberOfCells());<br></blockquote><div><br></div><div>Yes, I want 1 scalar per cell, I tried this but didn't work.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
if this does not help, or it is not what you want check what value (<br>
if not null, what type of array ) the following line would return<br>
<br>
vtkDataArray * pA =finalPolyData->GetCellData()->GetScalars();<br>
<br>
// replace the following line with line above<br>
<div class="im HOEnZb"> vtkIntArray* scalarArray =<br>
static_cast<vtkIntArray*>(finalPolyData->GetCellData()->GetScalars());<br>
<br></div></blockquote><div> </div><div>This make the program crash, so there is nothng there. </div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im HOEnZb">
<br>
</div><span class="HOEnZb"><font color="#888888">Alex<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Mon, Aug 6, 2012 at 2:18 AM, Gonzalo Amadio <<a href="mailto:gonzaloamadio@gmail.com">gonzaloamadio@gmail.com</a>> wrote:<br>
> Yes, what I wanted to mean with "is Strange" is that letting the input<br>
> without appending works fine, so it means that it has its scalars.<br>
> In other words, I printed the scalars of "otherPolyData" and "myPolyData"<br>
> before appending, and I obtain desired results. So it means that they have<br>
> scalars.<br>
><br>
> So I don't know what is happening here. Maybe I have to add something more<br>
> to satisfy conditions for using the filter, but I don't know.<br>
> Some help?<br>
><br>
> Thank you!<br>
><br>
><br>
><br>
> 2012/8/3 Alex Malyushytskyy <<a href="mailto:alexmalvtk@gmail.com">alexmalvtk@gmail.com</a>><br>
>><br>
>> >> appendGreenSubdAndRedBlue->AddInput(otherPolyData); // what is<br>
>> >> extrange is that if I comment this line, it works fine<br>
>> >> appendGreenSubdAndRedBlue->AddInput(myPolyData);<br>
>><br>
>> 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>
>><br>
>><br>
>> On Thu, Aug 2, 2012 at 4:25 AM, Gonzalo Amadio <<a href="mailto:gonzaloamadio@gmail.com">gonzaloamadio@gmail.com</a>><br>
>> wrote:<br>
>> > Hello everyone. Is there some reason whereby vtkAppendPolyData delete<br>
>> > 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<br>
>> >> 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<br>
>> >> 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<br>
>> >> 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<br>
>> > is<br>
>> > suppose that the scalars remains when I append them.<br>
>> ><br>
>> > Thank you!<br>
>> ><br>
>> > --<br>
>> > --------<br>
>> > Gonzalo<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<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<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>
><br>
><br>
> --<br>
> --------<br>
> Gonzalo Amadio<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>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>--------<br>Gonzalo Amadio<br><br>