VTK Format and Histogram Data

To post any request/idea for new functionalities
Post Reply
dsims1980
Posts: 4
Joined: Wed Jun 12, 2013 5:48 pm

VTK Format and Histogram Data

Post by dsims1980 »

Hi Daniel,

I'm currently using CC for my research and I'm mainly dealing with files in VTK format. CC seems to be a great tool and I'm trying to leverage its power for 3D models comparison. I noticed that whenever I try to open a .VTK file in CC, it fails to open it unless it is strictly formatted according to VTK standards (3D Slicer opens the file without problems). So I wrote a little program to format the files and after successfully opening the VTK file in CC, I noticed that normals and triangular_strips information are not imported in CC. I just wonder if importing this information is supported in CC. The other thing is the histogram data, is there a way to export the histogram data to a file?

Thanks for your time,
Dave
dsims1980
Posts: 4
Joined: Wed Jun 12, 2013 5:48 pm

Re: VTK Format and Histogram Data

Post by dsims1980 »

Sorry, I forgot to attach the VTK file sample:

# vtk DataFile Version 3.0
vtk output
ASCII
DATASET POLYDATA
POINTS 19463 float
-41.1564 17.9532 -35.446 -40.9208 17.664 -34.8494 -40.6763 18.1286 -35.1109
-41.9545 18.8063 -35.5746 -41.73 17.4134 -34.8113 -43.3217 18.962 -35.4466
-42.7489 17.7293 -35.0861 -43.4704 17.8828 -34.7176 -40.9641 18.6481 -35.5556
-40.5916 18.9202 -34.7204 -43.892 18.4234 -35.0192 -44.0816 19.0856 -35.3418
.
.
.
TRIANGLE_STRIPS 7854 60162
7 2 8 9 13 14 17 18
5 0 1 4 274 740
3 31 3 5
.
.
.

POINT_DATA 19463
NORMALS Normals float
0.237654 -0.542709 -0.805598 0.591894 -0.711758 -0.378237 0.854714 -0.296173 -0.426316
-0.061334 -0.211227 -0.975511 0.0533837 -0.761726 -0.645697 -0.171033 -0.300091 -0.938453
-0.221158 -0.607781 -0.762687 -0.525921 -0.695291 -0.489874 0.554873 -0.0221245 -0.831641
0.9533 0.0606188 -0.29588 -0.562127 -0.595953 -0.573457 -0.561446 -0.353363 -0.748273
.
.
.
daniel
Site Admin
Posts: 7709
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: VTK Format and Histogram Data

Post by daniel »

Hi,

In fact the VTK importer was written for an outside project and was quite simple. It handles:
  • POINTS
  • POLYGONS (but CC only handles polygons with 3 edges, i.e. triangles ;)
  • NORMALS (per vertex only, i.e. there must be as many normals as points)
  • COLOR_SCALARS (per vertex RGB colors)
  • SCALARS (per vertex scalars --> named 'Scalar field' in CC)
I'll try to add the TRANGLE_STRIPS keyword on my side. Meanwhile, instead of TRIANGLE_STRIPS you should use POLYGONS (and normals are not mandatory, CC will compute them itself if it can't find any).

With this you should be able to load proper meshes (distance computation will be much more accurate). And to export the histogram values, the best thing to do is to export the whole scalar field (corresponding to distances in this case): select the 'vertices' of the compared mesh, and save it as ASCII format (you'll get on each line, "X Y Z dist ..." for each vertex. You can then easily import such a file in Excel or Matlab for instance to compute your own histogram.
Daniel, CloudCompare admin
dsims1980
Posts: 4
Joined: Wed Jun 12, 2013 5:48 pm

Re: VTK Format and Histogram Data

Post by dsims1980 »

Thanks Daniel for you quick response,

I was able to load the mesh into CC after converting TRIANGLE_STRIPS to POLYGONS in the VTK files.

Thanks again.
Post Reply