[vtkusers] Fwd: create the polydata volume from unstructured grid

Alex Malyushytskyy alexmalvtk at gmail.com
Fri Apr 5 17:45:55 EDT 2013


You would not have to build VTK if you could use existing script and would
not need do something special,
If you are going to use C++ you will end up with building VTK yourself.
You will need to download and install CMAKE, which according to options you
would provide will generate projects for your compiler .
Then you will build that huge project with your compiler.
Then you have a choice either to include headers and link against needed
dlls manually in your project or create your project with CMake which would
simplify the process, especially for latest VTK version.

Iterating over cells will be your least problem if you did not install VTK
yet.
Once you have vtkUnstructuredGrid loaded with data it is pretty easy.
vtkIdType<http://www.vtk.org/doc/nightly/html/vtkType_8h.html#a20bd6b6dedfe1bbb096c50354d52cc7e>vtkUnstructuredGrid::
GetNumberOfCells<http://www.vtk.org/doc/nightly/html/classvtkUnstructuredGrid.html#aa3f89fb37b91e068b3ad971a8d6769d0>()
will give you number of cells.

int<http://www.vtk.org/doc/nightly/html/vtkVectorOperators_8h.html#a61569f2965b7a369eb10b6d75d410d11>vtkUnstructuredGrid::GetCellType
( vtkIdType<http://www.vtk.org/doc/nightly/html/vtkType_8h.html#a20bd6b6dedfe1bbb096c50354d52cc7e>
  *cellId*)
will tell you what type specific cell is.





vtkUnstructuredGrid::GetCellPoints (
vtkIdType<http://www.vtk.org/doc/nightly/html/vtkType_8h.html#a20bd6b6dedfe1bbb096c50354d52cc7e>
  *cellId*,

vtkIdList <http://www.vtk.org/doc/nightly/html/classvtkIdList.html> *  *
ptIds*
)
will give you points for specific cells, then you could use these points to
create triangle.

Or you can get everything from
vtkCell<http://www.vtk.org/doc/nightly/html/classvtkCell.html>pointer
you can get with
vtkCell <http://www.vtk.org/doc/nightly/html/classvtkCell.html>*
vtkUnstructuredGrid::GetCell
(vtkIdType<http://www.vtk.org/doc/nightly/html/vtkType_8h.html#a20bd6b6dedfe1bbb096c50354d52cc7e>
 *cellId*)


If your goal is just to handle the geometry you currently have once you
might want to check what Paraview offers. There are a plenty addons which
might do what you want.


Regards,
   Alex




---------- Forwarded message ----------
From: Dmitry Tyulin <dmitry.tyulin at gmail.com>
Date: Fri, Apr 5, 2013 at 1:17 PM
Subject: Re: [vtkusers] create the polydata volume from unstructured grid
To: Alex Malyushytskyy <alexmalvtk at gmail.com>


I just want to print my volume on 3D printer. In that case, I think I would
be satisfied if all my cells are presented by the the set of separated
triangles. That's why I want to convert vtk to stl. In my vtk file I have a
tetrahedral mesh.
So, there are my questions:
- how can I iterate over them(tetrahedrons) and create appropriate
triangles?
- when i download VTK, I need to build them or just include necessary
headers in my project?
(may be dump questions, but I am new at programming with VTK, and I don't
find answers in FAQ)

Regards,
Dmitry


2013/4/5 Alex Malyushytskyy <alexmalvtk at gmail.com>

> It is not enough details, so it is not clear what you want to do and where.
>
> I assume you want to do it in your code in VTK since AFAIK Paraview has
> its mailing list.
> Then you have to remember that stl file is basically a list of triangles.
> Questions are:
>  - do you need handle only triangles or  other 2d and/or 3d cells.
>  - are you satisfied if all your cells are presented by the the set of
> separated triangles?
>
> If yes:
> If your unstructured grid contains only triangles you could convert it to
> polydata then use vtkSTLWriter to write stl file.
> if you need to support all 2D cells, you might need to use
> vtkTriangleFilter
>  <http://www.vtk.org/doc/release/4.2/html/classvtkTriangleFilter.html>
> before vtkSTLWrite.
> If you have 3d cells you might need iterate over them and create
> appropriate triangles which would describe cell surface.
>
> Regards,
>    Alex
>
>
> On Thu, Apr 4, 2013 at 10:59 AM, Dmitry Tyulin <dmitry.tyulin at gmail.com>wrote:
>
>> Hello there!
>> I have a volume in vtk unstructured grid. How can I convert it to CAD
>> file format? .stl, for example. In paraview I can run Extract Surface
>> module, but it gives to me only a surface. So, how can i convert the whole
>> volume to .stl or .ply?
>>
>> Regards,
>> Dmitry.
>>
>> _______________________________________________
>> 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
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130405/5040263a/attachment.htm>


More information about the vtkusers mailing list