Using vtkVoxelModeller from VTK platform

Hello Everyone,
I've got some problem with roundtrip using of vtkVoxelModeller from Open CASCADE environment. I constructed vtk object from TopoDS_Shape, executed voxel modeller, but I do not understand, how to convert back the result to TopoDS_Shape.
Is it possible in principal?

Thank you in advance.

My code below:

IVtkOCC_Shape::Handle aShapeImpl = new IVtkOCC_Shape( shape );
auto pDataSource = vtkSmartPointer::New();
pDataSource->SetShape( aShapeImpl );

double bounds[6] = {};
pDataSource->GetOutput()->GetBounds( bounds );
auto voxelModeller = vtkSmartPointer::New();
voxelModeller->SetSampleDimensions( 20, 20, 20 );
voxelModeller->SetModelBounds( bounds );

voxelModeller->SetInputConnection( pDataSource->GetOutputPort() );
voxelModeller->Update();
[some code to get TopoDS_Shape]

Kirill Gavrilov's picture

TopoDS_Shape does not support voxel representation, so that at minimum vtkVoxelModeller output should be somehow converted to triangulation. Drawing each voxel as triangulated box is almost of no use (if you are not exporting a model to Minecraft), so that normally the algorithms like Marching Cubes are applied reconstructing triangulated surfaces from voxel data set.

Having a triangulation, it is possible constructing Poly_Triangulation and put it into TopoDS_Face. It should be noted, though, that OCCT has very limited support of such triangulation-only shapes, so that many algorithms will not be able to use them anyhow.

Reconstructing B-Spline surfaces from triangulation is also possible, but it is a complex matter difficult to automate.
https://www.opencascade.com/content/surfaces-scattered-points

Eugene Zaliznyak's picture

Thank you, kgv, for your usefull answer.

With respects, Eugene.