<div dir="auto">Try data->NewInstance()</div><div class="gmail_extra"><br><div class="gmail_quote">On Nov 7, 2017 3:03 AM, "frank" <<a href="mailto:frank1985876@gmail.com">frank1985876@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi, all<br>
<br>
If I want to create a vtkDataSet according to type of the input (vtkDataSet*), I can do that with the code below.<br>
Is there any way to get rid of those if-else? Any way like vtkDataArray do? vtkDataArray* a = vtkDataArray::CreateDataArray(<wbr>array->GetDataType());<br>
<br>
//----------------<br>
vtkDataSet *data;<br>
if (input->IsA("vtkImageData"))<br>
    data = vtkImageData::New();<br>
else if (input->IsA("<wbr>vtkStructuredGrid"))<br>
    data = vtkStructuredGrid::New();<br>
…<br>
//----------------<br>
<br>
Thank you!<br>
<br>
______________________________<wbr>_________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>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" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_<wbr>FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/vtkusers</a><br>
</blockquote></div></div>