Hello everyone. Is there some reason whereby vtkAppendPolyData delete the scalars when I append 2 polydatas?<br><br>Here is my code.<div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span class="Apple-tab-span" style="white-space:pre">        </span>myPolyData->ShallowCopy(otherPolyData);<br> SubdividePolyData(myPolyData); /// Here I modified the polydata, so I need to assign it again the scalar array.<br>
</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"> </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<font color="#ff0000">// The problem I think is here in this lines, where I assign the scalar array<br></font><span class="Apple-tab-span" style="white-space:pre">        </span>vtkIntArray* scalars = vtkIntArray::New();<br>
<span class="Apple-tab-span" style="white-space:pre">        </span>scalars->SetNumberOfComponents(1);<br><span class="Apple-tab-span" style="white-space:pre">        </span>scalars->SetNumberOfValues(myPolyData->GetNumberOfCells());<br>
<span class="Apple-tab-span" style="white-space:pre">        </span>scalars->SetNumberOfTuples(myPolyData->GetNumberOfCells());<br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="Apple-tab-span" style="white-space:pre">        </span>for (int i = 0; i < myPolyData->GetNumberOfCells(); i++)<br>
<span class="Apple-tab-span" style="white-space:pre">                </span>scalars->SetValue(i, 1);<br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="Apple-tab-span" style="white-space:pre">        </span>myPolyData->GetCellData()->SetScalars(scalars);<br>
</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"> </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
vtkSmartPointer<vtkAppendPolyData> appendGreenSubdAndRedBlue = vtkSmartPointer<vtkAppendPolyData>::New();<br><span class="Apple-tab-span" style="white-space:pre">        </span>appendGreenSubdAndRedBlue->AddInput(otherPolyData); <font color="#ff0000"> // what is extrange is that if I comment this line, it works fine</font><br>
<span class="Apple-tab-span" style="white-space:pre">        </span>appendGreenSubdAndRedBlue->AddInput(myPolyData);<br><span class="Apple-tab-span" style="white-space:pre">        </span>appendGreenSubdAndRedBlue->Update();<br>
</blockquote>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"> </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span class="Apple-tab-span" style="white-space:pre">        </span>vtkPolyData * finalPolyData = appendGreenSubdAndRedBlue->GetOutput();<br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"> vtkIntArray* scalarArray = static_cast<vtkIntArray*>(finalPolyData->GetCellData()->GetScalars());<br>
std::cout << scalarArray->GetNumberOfTuples() << std::endl; <font color="#ff0000">//This line gives me an error</font></blockquote><div><font color="#ff0000"><br></font></div><div><font color="#ff0000"><br>
</font></div><div><font color="#ff0000">The error that I obtain is the following :</font></div><div><font color="#ff0000"><br></font></div><div><font color="#ff0000"><div><u>File </u>: vtkAbstractArray.h - line 104</div>
<div><br></div><div> vtkIdType GetNumberOfTuples() </div><div> {return (this->MaxId + 1)/this->NumberOfComponents;}</div><div> </div><div><u>error:</u></div><div><br></div><div>name type value</div>
<div>this vtkAbstractArray * const 0x0</div></font></div><div><br></div><div><br></div><div>I can assign "manually" again the scalars to the finalPolyData, but it is suppose that the scalars remains when I append them.</div>
<div><br></div><div>Thank you!</div><div><br></div>-- <br>--------<br>Gonzalo <br>
</div>