[vtkusers] how to create a vtkDataSet according to the type of the input

frank frank1985876 at gmail.com
Tue Nov 7 20:24:33 EST 2017


Thank you, David

data = input->NewInstance();


> 在 2017年11月7日,19:05,David E DeMarle <dave.demarle at kitware.com> 写道:
> 
> Try data->NewInstance()
> 
>> On Nov 7, 2017 3:03 AM, "frank" <frank1985876 at gmail.com> wrote:
>> Hi, all
>> 
>> If I want to create a vtkDataSet according to type of the input (vtkDataSet*), I can do that with the code below.
>> Is there any way to get rid of those if-else? Any way like vtkDataArray do? vtkDataArray* a = vtkDataArray::CreateDataArray(array->GetDataType());
>> 
>> //----------------
>> vtkDataSet *data;
>> if (input->IsA("vtkImageData"))
>>     data = vtkImageData::New();
>> else if (input->IsA("vtkStructuredGrid"))
>>     data = vtkStructuredGrid::New();
>>>> //----------------
>> 
>> Thank you!
>> 
>> _______________________________________________
>> Powered by www.kitware.com
>> 
>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>> 
>> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>> 
>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>> 
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171108/bd133a7e/attachment.html>


More information about the vtkusers mailing list