[vtkusers] how to write an unstructured grid into a stl file
Reza Faieghi
mfaieghi at westerneng.ca
Sun Nov 13 12:03:32 EST 2016
Hi Utkarsh,
Thanks for the reply. I use the following code just like yours but I get
some errors that dsf is a pointer to an incomplete class type:
1 vtkSmartPointer<vtkUnstructuredGrid> ug =
vtkSmartPointer<vtkUnstructuredGrid>::New();
2 vtkSmartPointer<vtkDataSetSurfaceFilter> dsf =
vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
3 dsf->SetInputData(ug);
4 dsf->Update();
5 vtkSmartPointer<vtkTriangleFilter> triangleFilterx
= vtkSmartPointer<vtkTriangleFilter>::New();
6 triangleFilterx->SetInputConnection(dsf);
7 triangleFilterx->Update();
8 vtkSmartPointer<vtkSTLWriter> stlWriter =
vtkSmartPointer<vtkSTLWriter>::New();
9 std::string name = "file.stl";
10 stlWriter->SetFileName(file.c_str());
11 stlWriter->SetInputConnection(triangleFilterx->GetOutputPort());
12 stlWriter->Write();
At line 3, I am getting these errors:
use of undefined type 'vtkDataSetSurfaceFilter'
'SetInputData' : is not a member of
'vtkSmartPointer<vtkDataSetSurfaceFilter>'
'Update' : is not a member of
'vtkSmartPointer<vtkDataSetSurfaceFilter>'
I think the way that I am using vtkDataSetSurfaceFilter is not correct. How
can I use it in a proper way?
Thanks,
Reza
On Sun, Nov 13, 2016 at 10:55 AM, Utkarsh Ayachit <
utkarsh.ayachit at kitware.com> wrote:
> vtkDataSetSurfaceFilter is indeed the way to go. You should be able to set
> an unstructrued grid as input. Not sure why it didn't work for you? Doesn't
> the following code work:
>
> vtkUnstructuredGrid* ug = ...
> vtkDataSetSurfaceFilter* dsf = ...
> dsf->SetInputDataObject(ug);
>
> Utkarsh
>
> On Sun, Nov 13, 2016 at 5:20 AM, Reza Faieghi <mfaieghi at westerneng.ca>
> wrote:
>
>> Hello,
>>
>> I am wondering is there a way to write an unstructured grid into
>> an STL file?
>>
>> I am not sure if this is correct but I realized that for writing
>> into an STL file, I have to create a triangle filter from my geometry. And,
>> to create the triangle filter, I need to extract surface of my unstructured
>> grid. I tried to use vtkDataSetSurfaceFilter for this purpose, but I was
>> not able to set an input to an instance of this class from a
>> vtkUnstructuredGrid.
>>
>> I am not sure if my approach is correct. I would be really grateful if
>> you have any idea how to solve this.
>>
>> Many Thanks,
>> Reza
>>
>> _______________________________________________
>> 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
>>
>>
>
--
PhD Candidate,
Spencer Engineering Building Room 37
University of Western Ontario
London, ON, Canada, N6A 5B9
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161113/9abf6938/attachment.html>
More information about the vtkusers
mailing list