How to make a point cloud?

I suck at figuring out large projects; I can’t make heads or tails of the documentation. I don’t understand how people do it. :stuck_out_tongue: Basically, I want to know how to make a point cloud in C++. Well, more basically, I want to do some volume rendering. (Not positive that point clouds is the way to do it?)

I found the DensityPoints example ( https://lorensen.github.io/VTKExamples/site/Cxx/Points/DensifyPoints/ ), but when I build it it doesn’t produce an exe. I’m using VS 2019. Here’s the build output:
1>------ Rebuild All started: Project: ZERO_CHECK, Configuration: Debug x64 ------
1>Checking Build System
2>------ Skipped Rebuild All: Project: ALL_BUILD, Configuration: Debug x64 ------
2>Project not selected to build for this solution configuration
========== Rebuild All: 1 succeeded, 0 failed, 1 skipped ==========

If I try to run it, it says, “Unable to start program ‘D:\vtk\DensityPoints\x64\Debug\ALL_BUILD’. The system cannot find the file specified.”

So I tried changing the startup project in the solution to ZERO_CHECK, which is the only other project in the solution, and it still doesn’t produce an exe. When I try to run it in that case, it says, “Unable to start program ‘D:\vtk\DensityPoints\x64\Debug\ZERO_CHECK’. Access is denied.”

And even if I could get it to run, I can’t figure out by looking at the source code how to define my own points. Probably the best way for me to do it would be to define them all in a data structure and then call a function to process them, for efficiency’s sake, since I want to define millions of points. How do I do that?

Thanks.

if ALL_BUILD and ZERO_CHECK are the only prjoects in your solution, then the CMake configuration hasn’t worked properly. There needs to be a “DensifyPoints” project as well, in this case. Have you checked the CMake output for any errors or warnings?

Regarding your “basic” request, though:

Well, more basically, I want to do some volume rendering.

What do you exactly mean by volume, do you maybe want to render a regular grid where at each location you have an (intensity) value? Then you might want to use a vtkImageData object, some volume mapper and some transfer function to render it, see e.g. the Smart Volume Mapper example. In this example, the volume is created by the program, but instead you could also load it from a file (vtk comes with a bunch of readers for several formats).

Yeah, there’s no ‘DensifyPoints’ project, and the CMake didn’t report any errors. :confused: Hopefully ‘Smart Volume Mapper’ will work better.
And yes, that’s what I want to do, that’s what I mean by ‘volume’. Except that I want each point in the grid to be either on or off–no need for in-betweens. (I want to make a fractal.)
Anyway I’ll check out ‘Smart Volume Mapper’, and I’ll probably be back… =P

Okay, SmartVolumeMapper also just gives me ALL_BUILD and ZERO_CHECK. Sigh. No error messages or warnings.
Here’s what I did, just according to the instructions:

  • added D:\VTK-9.0.1\build2\bin\Debug to my path (it’s full of .dll files)
  • extracted SmartVolumeMapper to d:\vtk
  • cd d:\vtk\SmartVolumeMapper\build
  • cmake …\
  • opened SmartVolumeMapper.sln in VS 2019

Here’s what CMAKE outputted:

D:\vtk\SmartVolumeMapper\build>cmake …
– Building for: Visual Studio 16 2019
– Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19041.
– The C compiler identification is MSVC 19.26.28806.0
– The CXX compiler identification is MSVC 19.26.28806.0
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe - skipped
– Detecting C compile features
– Detecting C compile features - done
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe - skipped
– Detecting CXX compile features
– Detecting CXX compile features - done
Skipping SmartVolumeMapper:
– Configuring done
– Generating done
– Build files have been written to: D:/vtk/SmartVolumeMapper/build

Ah yes after having tried to CMake the example myself, I see the problem - the CMakeListst.txt “masks” the problem of not finding VTK.

You see the “Skipping SmartVolumeMapper:” part? That happens when VTK is not found; the examples instead should print a more meaningful warning (e.g. set VTK to required, which would tell you that VTK could not be found). We should probably report that somewhere…

To fix that, in CMake, set the VTK_DIR variable to the folder where you built VTK (according to what you wrote above, this should be D:\VTK-9.0.1\build2)

Ah, thanks.

I actually suspected that might be the problem, but I didn’t know how to tell it the VTK directory. I did cmake /? and found -D, so I passed -D VTK_DIR=D:\VTK-9.0.1\build2.

Now the SmartVolumeMapper project shows up.

I still get a couple of skips in the cmake output that don’t look right. Are they okay, should I fix them, and how would I?

D:\vtk\SmartVolumeMapper4\build>cmake -D VTK_DIR=D:\VTK-9.0.1\build2 …
– Building for: Visual Studio 16 2019
– Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19041.
– The C compiler identification is MSVC 19.26.28806.0
– The CXX compiler identification is MSVC 19.26.28806.0
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe - skipped
– Detecting C compile features
– Detecting C compile features - done
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe - skipped
– Detecting CXX compile features
– Detecting CXX compile features - done
– VTK_VERSION: 9.0.1
– Configuring done
– Generating done
– Build files have been written to: D:/vtk/SmartVolumeMapper4/build

It doesn’t seem to find cl.exe. Not sure if that’s a problem because I can just load the .sln in VS and compile it there (assuming that works - haven’t checked yet)

Before running cmake I ran C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat. Should I have run vcvars32,bat?


Okay, I just tried compiling SmartVolumeMapper in VS, and it didn’t work. sigh

1>------ Build started: Project: ZERO_CHECK, Configuration: Debug x64 ------
1>Checking Build System
2>------ Build started: Project: SmartVolumeMapper, Configuration: Debug x64 ------
2>Building Custom Rule D:/vtk/SmartVolumeMapper4/CMakeLists.txt
2>SmartVolumeMapper.cxx
2>D:\vtk\SmartVolumeMapper4\SmartVolumeMapper.cxx(90,58): error C2039: ‘SetRequestedRenderModeToRayCastAndTexture’: is not a member of ‘vtkSmartVolumeMapper’
2>D:\VTK-9.0.1\src\Rendering\VolumeOpenGL2\vtkSmartVolumeMapper.h(90): message : see declaration of ‘vtkSmartVolumeMapper’
2>Done building project “SmartVolumeMapper.vcxproj” – FAILED.
3>------ Skipped Build: Project: ALL_BUILD, Configuration: Debug x64 ------
3>Project not selected to build for this solution configuration
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 1 skipped ==========

Happens here too - I think the example is not yet fully adapted to VTK 9. To get it to run, remove the #if !defined … #endif block (lines 89 to 91), then it should work.

Thanks, that worked.

It seems that the example sets all the points at once by invoking a predefined sphere function:

vtkSmartPointer sphere = vtkSmartPointer::New();
sphere->SetRadius(0.1);
sphere->SetCenter(0.0,0.0,0.0);

I have this problem with a lot of volume renderers out there: the examples only work by loading predefined shapes, and I need to know how to set individual points. Can you show me how? Thanks.

On another note, I’m disappointed by the lack of realism of the resulting image. There’s hardly any shading. It just looks like a circle… is VTK low-quality at volume rendering?

The shown code generates the volume from an implicit function (the sphere). There is also no texture, no material information and no elaborate lighting involved, so what’s shown will not be spectacular…

the examples only work by loading predefined shapes

The typical use case is to show a dataset that was acquired by some imaging technique like computed tomography etc; but for test purposes it’s not practical to include a larger dataset, hence the generated sphere volume.

and I need to know how to set individual points.

I’m still a bit unclear on what exact positions you want to put your data? See e.g. the Paraview docs for an overview on the different grid types that vtk supports - the simplest case, for which vtkImageData is suited, is a " Uniform rectilinear grid (image data)". What kind of data do you want to show exactly? Maybe you have it in some file format that vtk can load already (e.g. dicom, raw file, etc.). Maybe you don’t need to “set individual points” by yourself?

Thanks for your help.
I basically want a regular 3D grid of voxels which can be either on or off (I guess 255 opacity or 0 opacity, respectively). I want to render a Julia-set fractal, so a given voxel is either within the set (on) or outside the set (off).
The ideal way to store the data in memory would probably be a sparse voxel octree or something similar, I don’t know if VTK supports those.
It seems inefficient to calculate all the points, then save them to file, then load the file when I’m doing all this from within the same session of the same program, so I was hoping there was a way to set voxels directly.
If I have to save the data to file, that’s okay, as long as there are functions in VTK (or some other library?) for creating such a file from individual points…?

I see, so setting all data points in a regular grid beforehand would not really make sense. Not sure about sparse voxel octrees, not my area of epxertise; maybe vtkImplicitVolume is something for you? It’s a volume that’s specified through a function computing its points as far as I can tell from a quick glance the docs… not sure how this determines at which positions it evaluates the function though, or whether it provides a kind of level-of-detail functionality, as you probably require, out-of-the-box…

Hi,

The same issue when building the CylinderExample. after doing cmake in the visual studio file I don’t have any project other than ALL_BUILD and ZERO_CHECK.
I see in the CMakeError.log there’s something reported like and error:
Determining if the include file pthread.h exists failed with the following output:
Change Dir: D:/projects/vtkcjs/CylinderExample/build/CMakeFiles/CMakeTmp

Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe cmTC_c58ac.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=16.0 /v:m && Microsoft ® Build Engine version 16.7.0+b89cb5fde for .NET Framework

Copyright © Microsoft Corporation. All rights reserved.

Microsoft ® C/C++ Optimizing Compiler Version 19.27.29111 for x64

CheckIncludeFile.c

Copyright © Microsoft Corporation. All rights reserved.

cl /c /Zi /W3 /WX- /diagnostics:column /Od /Ob0 /D WIN32 /D _WINDOWS /D “CMAKE_INTDIR=“Debug”” /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_c58ac.dir\Debug\" /Fd"cmTC_c58ac.dir\Debug\vc142.pdb" /Gd /TC /errorReport:queue D:\projects\vtkcjs\CylinderExample\build\CMakeFiles\CMakeTmp\CheckIncludeFile.c

D:\projects\vtkcjs\CylinderExample\build\CMakeFiles\CMakeTmp\CheckIncludeFile.c(1,10): fatal error C1083: Cannot open include file: ‘pthread.h’: No such file or directory [D:\projects\vtkcjs\CylinderExample\build\CMakeFiles\CMakeTmp\cmTC_c58ac.vcxproj]

Is that the problem? how can I resolve it?

Thanks in advance