[vtkusers] write unstructured grid vtk file to query-able database format

Cory Quammen cory.quammen at kitware.com
Fri Dec 8 09:44:11 EST 2017


Amine,

I don't believe there is anything in VTK to do what you are seeking.
You are right that the database connectivity is mainly for querying an
existing database. However, you *might* be able to write queries that
write to the database with statements such as 'INSERT INTO table_name
(col1, col2, ...) VALUES (val1, val2, ...)'. I haven't tried it,
though, so caveat emptor. You'll have to set up the database tables
beforehand in some way to store the points, which you might be able to
do with SQL 'create table' statements, and then iterate through the
points and add them into the database.

With all that work, however, you might be better off just iterating
through the points and extracting the data with Python directly. Are
you familiar with the numpy interface to VTK? If you use are
experienced with numpy, that might be the best way to select points
and process the numeric data at those points. See the blog post
starting at https://blog.kitware.com/improved-vtk-numpy-integration/
for more details on this interface.

HTH,
Cory

On Fri, Nov 17, 2017 at 3:40 PM, Amine Aboufirass
<amine.aboufirass at gmail.com> wrote:
> Hello,
>
> I would like to find out if there is a way to write unstructured grid vtk
> files containing scalar, tensor or vector data to any standard database
> format. This could be SQLite, JSON or XML for example.
>
> The reason  for this is that I would like to conduct queries on the data
> contained in the vtk file. I have no need to create new geometries or select
> by frustum for example. I need only basic SQL select-where type
> functionality where I can query and extract numerical data based on simple
> conditions.
>
> I saw that the vtk file contains some SQL readiness but as far as I can tell
> the tools are mainly to connect to an SQL database and extract data from it.
> I seek to go the other way, namely to start with an unstructured grid vtk
> dataset and write that into a database.
>
> The following examples look promising
>
> https://lorensen.github.io/VTKExamples/site/Cxx/Databases/SQL/MySQL/CreateDatabase/
> https://lorensen.github.io/VTKExamples/site/Cxx/Databases/SQL/MySQL/WriteToDatabase/
>
> But I have no C++ background and use mainly Python. Furthermore I'm not sure
> if the above applies for Unstructured grid data.
>
> Could anyone please enlighten me on this?
>
> Thanks,
>
> Amine
>
> _______________________________________________
> 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
>



-- 
Cory Quammen
Staff R&D Engineer
Kitware, Inc.


More information about the vtkusers mailing list