VTK: create cubes from pointcoud

480 views Asked by At

i've got an unstructured point-cloud saved in *.vtk-format:

# vtk DataFile Version 2.0
loop
ASCII
DATASET UNSTRUCTURED_GRID
POINTS 16 float
32.4834848065 46.1737449255 21.3773504796
31.8539914061 46.6530202252 24.1360388749
34.985082367 45.0535326148 22.1600305341
33.7041073758 48.7497314453 21.2070765244
34.3626221954 45.5313865672 24.9052288048
33.0703310838 49.2290967531 23.9608212671
36.2000985576 47.6284123117 21.9870579818
35.5643379844 48.1062670078 24.7403762929
155.334824299 27.1678594564 100.788873694
157.101523005 29.3547013724 101.293587216
155.20738527 27.9081979692 98.0373959332
153.088866365 28.8571788191 101.342479281
156.980368832 30.0879791299 98.5351865187
154.859387622 31.0412738992 101.854674535
152.964845811 29.5928340487 98.5897383417
154.732175888 31.7754190361 99.0886951745
CELLS 2 18
8 0 1 2 3 4 5 6 7
8 8 9 10 11 12 13 14 15
CELL_TYPES 2
11
11

In total, there are 2x8 vertices. Now I'd like to impose 2 cubes onto each set of 8 vertices. Unfortunately the ordering of the Points is essential for proper display. Is there an easy way to reorder my points in order to obtain 2 cubes with their faces aligned to the "outside" ?

Maybe there's some CELLTYPE as "outline" or something similar? I haven't found a solution so far. Do you know of some Python-package which takes care of a proper ordering for my vertices?

Thanks in advance. Best regards, Frank.

1

There are 1 answers

2
Victor Bai On

I met exact same problem. Actually you should use Cell_type 12 for HEXAHEDRON. Cell_type=11 is for voxel(I don't know in what case we use it).

My example is here.

    example 
    ASCII
    DATASET UNSTRUCTURED_GRID
    POINTS 12 FLOAT 
    0 0 0
    0 1 0
    1 1 0
    1 0 0
    0 0 1
    0 1 1
    1 1 1
    1 0 1
    0 2 0
    1 2 0
    0 2 1
    1 2 1


    CELLS 2 18
    8 0 1 2 3 4 5 6 7 
    8 1 8 9 2 5 10 11 6

    CELL_TYPES 2
    12 
    12 


    CELL_DATA 2
    SCALARS Cell_Temperature FLOAT 
    LOOKUP_TABLE default
    0
    1