<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<div style="caret-color: rgb(0, 0, 0); font-family: -webkit-standard; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.4);">
Hi David,</div>
<div style="caret-color: rgb(0, 0, 0); font-family: -webkit-standard; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.4);">
<br>
</div>
<div style="caret-color: rgb(0, 0, 0); font-family: -webkit-standard; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.4);">
thank you very much again for your great explanations (i looked at the vtkImageStencilData class description before writing the e-mail and as you have pointed out it is really missing some explanations on how it works internally) and of course your hints to
improve the example code!</div>
<div style="caret-color: rgb(0, 0, 0); font-family: -webkit-standard; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.4);">
<br>
</div>
<div style="caret-color: rgb(0, 0, 0); font-family: -webkit-standard; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.4);">
As you have written, i changed my code from</div>
<div style="caret-color: rgb(0, 0, 0); font-family: -webkit-standard; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.4);">
<br>
</div>
<div style="caret-color: rgb(0, 0, 0); font-family: -webkit-standard; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.4);">
<span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> // Convert stencil to image</b></span></div>
<div style="caret-color: rgb(0, 0, 0); font-family: -webkit-standard; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.4);">
<span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> vtkNew<vtkImageStencil> stencil;</b></span></div>
<div style="caret-color: rgb(0, 0, 0); font-family: -webkit-standard; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.4);">
<span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> stencil->SetInputData(binaryLabelMap);</b></span></div>
<div style="caret-color: rgb(0, 0, 0); font-family: -webkit-standard; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.4);">
<span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> stencil->SetStencilConnection(polyDataToImageStencil->GetOutputPort());</b></span></div>
<div style="caret-color: rgb(0, 0, 0); font-family: -webkit-standard; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.4);">
<span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> stencil->ReverseStencilOn();</b></span></div>
<div style="caret-color: rgb(0, 0, 0); font-family: -webkit-standard; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.4);">
<span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> stencil->SetBackgroundValue(1); // General foreground value is 1 (background value because of reverse stencil)</b></span></div>
<div style="caret-color: rgb(0, 0, 0); font-family: -webkit-standard; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.4);">
<b><br>
</b></div>
<div style="caret-color: rgb(0, 0, 0); font-family: -webkit-standard; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.4);">
<span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> // Save result to output</b></span></div>
<div style="caret-color: rgb(0, 0, 0); font-family: -webkit-standard; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.4);">
<span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> vtkNew<vtkImageCast> imageCast;</b></span></div>
<div style="caret-color: rgb(0, 0, 0); font-family: -webkit-standard; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.4);">
<span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> imageCast->SetInputConnection(stencil->GetOutputPort());</b></span></div>
<div style="caret-color: rgb(0, 0, 0); font-family: -webkit-standard; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.4);">
<span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> imageCast->SetOutputScalarTypeToUnsignedChar();</b></span></div>
<div style="caret-color: rgb(0, 0, 0); font-family: -webkit-standard; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.4);">
<span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> imageCast->Update();</b></span></div>
<div style="caret-color: rgb(0, 0, 0); font-family: -webkit-standard; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.4);">
<span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> binaryLabelMap->ShallowCopy(imageCast->GetOutput());</b></span></div>
<div style="caret-color: rgb(0, 0, 0); font-family: -webkit-standard; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.4);">
<br>
</div>
<div><br>
</div>
<div><br>
To:</div>
<div>
<div></div>
<div><br>
</div>
<div> <span style="font-family: "Courier New", monospace; font-size: 9pt;"><b>// Convert stencil to image</b></span></div>
<div><span style="font-family: "Courier New", monospace;"><b><span style="font-size: 9pt;"> vtkNew<vtkImageStencilToImage> imageStencilToImage;</span></b></span></div>
<div><span style="font-family: "Courier New", monospace;"><b><span style="font-size: 9pt;"> imageStencilToImage->SetInputConnection(polyDataToImageStencil->GetOutputPort());</span></b></span></div>
<div><span style="font-family: "Courier New", monospace;"><b><span style="font-size: 9pt;"> imageStencilToImage->SetOutsideValue(0);</span></b></span></div>
<div><span style="font-family: "Courier New", monospace;"><b><span style="font-size: 9pt;"> imageStencilToImage->SetInsideValue(1);</span></b></span></div>
<div><span style="font-family: "Courier New", monospace;"><b><span style="font-size: 9pt;"> imageStencilToImage->Update();</span></b></span></div>
<div><b><br>
</b></div>
<div><span style="font-family: "Courier New", monospace;"><b><span style="font-size: 9pt;"> // Save result to output</span></b></span></div>
<div><span style="font-family: "Courier New", monospace;"><b><span style="font-size: 9pt;"> binaryLabelMap->DeepCopy(imageStencilToImage->GetOutput());</span></b></span></div>
<div><br>
</div>
<div><br>
</div>
<div>which is really much shorter and better.</div>
<div><br>
</div>
<div><br>
</div>
<div>I also found out that i can change the vtkImage initialization code from</div>
<div><br>
</div>
<div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b>// fill the image with background voxels:</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b>vtkIdType count = voxelImage->GetNumberOfPoints();</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b>for (vtkIdType i = 0; i < count; ++i)</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b>{</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> voxelImage->GetPointData()->GetScalars()->SetTuple1(i, outval);</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b>}</b></span></div>
<div><br>
</div>
<div>to simply:</div>
<div><br>
</div>
<div><span style="font-size: 9pt; font-family: "Courier New", monospace;"><b>voxelImage->GetPointData()->GetScalars()->Fill(outval);</b></span></div>
</div>
<div><br>
</div>
<div>I attached the improved version and the CMakeLists file.</div>
<div><br>
</div>
<div><br>
</div>
<div>So far it works really great and is quite fast:</div>
<div><br>
</div>
<div><img size="67748" contenttype="image/jpeg" id="598573_rs|1" style="user-select: none; max-width: 99.9%;" tabindex="0" width="568" height="786" data-outlook-trace="F:1|T:1" src="cid:c6c7244e-ff20-474f-a694-4c683d98b856"><br>
<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>But one thing is that i still get problems with some kind of meshes (i guess meshes which are not closed or watertight):</div>
<div><br>
</div>
<div><br>
</div>
<div><b><u>Alien Queen (minor problems):</u></b></div>
<div><img size="86457" contenttype="image/jpeg" id="img321509" style="max-width: 99.9%; user-select: none;" tabindex="0" data-outlook-trace="F:1|T:1" src="cid:23b830f9-073a-45d1-bad1-dddd550e2d69"><br>
<br>
</div>
<div><img size="65454" contenttype="image/jpeg" id="img23753" style="max-width: 99.9%; user-select: none;" tabindex="0" data-outlook-trace="F:1|T:1" src="cid:745f1387-542f-4562-8455-7e8b13d7ba62"><br>
</div>
<div><br>
<br>
</div>
<div><br>
</div>
<div><b><u>Eiffel Tower (completely wrong):</u></b></div>
<div><br>
</div>
<div><img size="39385" contenttype="image/jpeg" id="img258115" style="max-width: 99.9%; user-select: none;" tabindex="0" data-outlook-trace="F:1|T:1" src="cid:6c47ec8d-40cf-4b31-8183-62ff2a26a205"><img size="36468" contenttype="image/jpeg" id="img800117" style="max-width: 99.9%; user-select: none;" tabindex="0" data-outlook-trace="F:1|T:1" src="cid:b5391948-c2d3-4f6f-a54e-acd497194c10"><br>
<br>
<br>
</div>
<div><br>
</div>
<div>Maybe this could be solved by rasterizing the mesh in different directions and doing some kind of majority voting if a voxel is set or not.</div>
<div><br>
</div>
<div>I solved these cases by implementing a raycasting solution using a generalization of the point in polygon algorithm and </div>
<div><br>
</div>
<div></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> // load STL file</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> vtkNew<vtkSTLReader> reader;</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> reader->SetFileName("eiffel_tower_small.stl"); </b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> reader->Update();</b></span></div>
<div><b><br>
</b></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> vtkNew<vtkPolyData> pd;</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> pd->DeepCopy(reader->GetOutput());</b></span></div>
<div><b><br>
</b></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> <span style="color: rgb(0, 111, 201);">
<i>// compute bounds for stl mesh polydata</i></span></b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> double bounds[6];</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> pd->GetBounds(bounds);</b></span></div>
<div><b><br>
</b></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b><i><span style="color: rgb(0, 111, 201);">/*</span></i></b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b><i><span style="color: rgb(0, 111, 201);"> // Create the locator (obb tree)</span></i></b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b><span style="color: rgb(0, 111, 201);"><i> vtkNew<vtkOBBTree> obbTree</i></span></b></span><b style="font-family: "Courier New", monospace; font-size: 9pt;"><span style="color: rgb(0, 111, 201);"><i>;</i></span></b></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b><span style="color: rgb(0, 111, 201);"><i> tree->SetDataSet(pd);</i></span></b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b><span style="color: rgb(0, 111, 201);"><i> tree->BuildLocator();</i></span></b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b><span style="color: rgb(0, 111, 201);"><i>*/</i></span></b></span></div>
<div><b><br>
</b></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> <span style="color: rgb(0, 111, 201);">
<i>/</i></span><i><span style="color: rgb(0, 111, 201);">/ Create the </span><span style="color: rgb(0, 111, 201);">locator (modified bsp tree)</span></i></b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> vtkNew<vtkModifiedBSPTree> bspTree</b></span><b style="font-family: "Courier New", monospace; font-size: 9pt;">;</b></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> bspTree->SetDataSet(pd);</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> bspTree->BuildLocator();</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> </b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> constexpr int numSamples = 32;</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> </b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> </b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> <span style="color: rgb(0, 111, 201);">
<i>//#pragma omp parallel for // not for vtkModifiedBSPTree !!</i></span></b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> for(int x = 0; x < imageResolutionX; x++)</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> {</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> for(int y = 0; y < imageResolutionY; y++)</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> {</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> for(int z = 0; z < imageResolutionZ; z++)</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> {</b></span></div>
<div><b><span style="white-space: pre; font-family: "Courier New", monospace; font-size: 9pt;"></span><span style="font-family: "Courier New", monospace; font-size: 9pt;">
<span style="color: rgb(0, 111, 201);"><i>// pick an arbitrary sampling direction</i></span></span></b></div>
<div><b><span style="white-space: pre; font-family: "Courier New", monospace; font-size: 9pt;"></span><span style="font-family: "Courier New", monospace; font-size: 9pt;"> vtkVector3f ray_direction(0.0, 0.0, 0.0);</span></b></div>
<div><b><span style="white-space: pre; font-family: "Courier New", monospace; font-size: 9pt;"></span><span style="font-family: "Courier New", monospace; font-size: 9pt;"> vtkVector3f ray_direction2(0.0, 0.0, 0.0);</span></b></div>
<div><b><br>
</b></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> // find world space position of the voxel</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> constexpr int X_MIN = 0;</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> constexpr int Y_MIN = 2;</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> constexpr int Z_MIN = 4;</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> </b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> vtkVector3f ray_origin( bounds[X_MIN] + spacing[0] * x,</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> bounds[Y_MIN] + spacing[1] * y,</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> bounds[Z_MIN] + spacing[2] * z);</b></span></div>
<div><b><br>
</b></div>
<div><b><br>
</b></div>
<div><b><span style="white-space: pre; font-family: "Courier New", monospace; font-size: 9pt;"></span><span style="font-family: "Courier New", monospace; font-size: 9pt;">
<span style="color: rgb(0, 111, 201);"><i>// randomly sample 3D space by sending rays in randomized directions</i></span></span></b></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> unsigned int numIntersections = 0;</b></span></div>
<div><br>
</div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> int id = 0;</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> </b></span></div>
<div><b><span style="white-space: pre; font-family: "Courier New", monospace; font-size: 9pt;"></span><span style="font-family: "Courier New", monospace; font-size: 9pt;"> for (int j = 0; j < numSamples; ++j)</span></b></div>
<div><b><span style="white-space: pre; font-family: "Courier New", monospace; font-size: 9pt;"></span><span style="font-family: "Courier New", monospace; font-size: 9pt;"> {</span></b></div>
<div><b><span style="white-space: pre; font-family: "Courier New", monospace; font-size: 9pt;"></span><span style="font-family: "Courier New", monospace; font-size: 9pt;">
<span style="color: rgb(0, 111, 201);"><i>// compute the random direction. Convert from polar to </i></span></span></b></div>
<div><b><i><span style="white-space: pre; font-family: "Courier New", monospace; font-size: 9pt; color: rgb(0, 111, 201);"></span><span style="color: rgb(0, 111, 201);"> </span></i><span style="font-family: "Courier New", monospace; font-size: 9pt; color: rgb(0, 111, 201);"><i>
// euclidean to get an even distribution</i></span></b></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> float theta = 2 * M_PI * random(genenerator);</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> float phi = acos(1 - 2 * random(generator));</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> </b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> ray_direction[0] = sin(phi) * cos(theta);</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> ray_direction[1] = sin(phi) * sin(theta);</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> ray_direction[2] = cos(phi);</b></span></div>
<div><b><br>
</b></div>
<div><b><br>
</b></div>
<div><b><span style="white-space: pre; font-family: "Courier New", monospace; font-size: 9pt;"></span> <span style="font-family: "Courier New", monospace; font-size: 9pt; color: rgb(0, 111, 201);"><i>// check if the voxel is inside of the mesh.</i></span></b></div>
<div><b><span style="white-space: pre; font-family: "Courier New", monospace; font-size: 9pt;"></span> <span style="font-family: "Courier New", monospace; font-size: 9pt;">vtkNew<vtkPoints> intersectPoints;</span></b></div>
<div><b><span style="white-space: pre; font-family: "Courier New", monospace; font-size: 9pt;"></span><span style="font-family: "Courier New", monospace; font-size: 9pt;"> </span></b></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> double lineP0[3] = {ray_origin[0], ray_origin[1], ray_origin[2]};</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> </b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> double lineP1[3] = {ray_origin[0] + ray_direction[0] * 10000.0, </b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> ray_origin[1] + ray_direction[1] * 10000.0, </b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> ray_origin[2] + ray_direction[2] * 10000.0};</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> </b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> </b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> <i><span style="color: rgb(0, 111, 201);">//obb</span><span style="color: rgb(0, 111, 201);">T</span><span style="color: rgb(0, 111, 201);">ree->IntersectWithLine(lineP0,
lineP1, intersectPoints, NULL);</span></i></b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> </b></span></div>
<div><b><span style="font-family: "Courier New", monospace; font-size: 9pt;"> bspTree->IntersectWithLine(lineP0, lineP1, 0.0001, intersectPoints, NULL);</span><span style="white-space: pre; font-family: "Courier New", monospace; font-size: 9pt;">
</span><span style="font-family: "Courier New", monospace; font-size: 9pt;"> </span></b></div>
<div><b><br>
</b></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> if (intersectPoints->GetNumberOfPoints() % 2 == 1)</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> numIntersections++; </b></span></div>
<div><b><span style="white-space: pre; font-family: "Courier New", monospace; font-size: 9pt;"></span><span style="font-family: "Courier New", monospace; font-size: 9pt;"> }</span></b></div>
<div><b><span style="white-space: pre; font-family: "Courier New", monospace; font-size: 9pt;"></span><span style="font-family: "Courier New", monospace; font-size: 9pt;"> </span></b></div>
<div><b><span style="font-family: "Courier New", monospace; font-size: 9pt;">
</span> <span style="font-family: "Courier New", monospace; font-size: 9pt; color: rgb(0, 111, 201);"><i>// save answer</i></span></b></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> unsigned int index = x + y * imageResolutionX </b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> + z * imageResolutionX * imageResolutionY;</b></span></div>
<div><b><br>
</b></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> </b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> float hitPercentage = static_cast<float>(numIntersections) / static_cast<float>(numSamples);</b></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> </b></span></div>
<div><b><span style="font-family: "Courier New", monospace; font-size: 9pt;">if(hitPercentage >= 0.5)</span></b></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> voxelImage[index] = inval;</b></span></div>
<div><b><span style="white-space: pre; font-family: "Courier New", monospace; font-size: 9pt;"></span><span style="font-family: "Courier New", monospace; font-size: 9pt;"> else</span></b></div>
<div><b><span style="white-space: pre; font-family: "Courier New", monospace; font-size: 9pt;"></span><span style="font-family: "Courier New", monospace; font-size: 9pt;"> voxelImage[index] = outval;</span></b></div>
<div><b><span style="white-space: pre; font-family: "Courier New", monospace; font-size: 9pt;"></span><span style="font-family: "Courier New", monospace; font-size: 9pt;">}</span></b></div>
<div><b><span style="white-space: pre; font-family: "Courier New", monospace; font-size: 9pt;"></span><span style="font-family: "Courier New", monospace; font-size: 9pt;">}</span></b></div>
<div><span style="font-family: "Courier New", monospace; font-size: 9pt;"><b> }</b></span></div>
<div>
<div><span style="font-size: 9pt; font-family: "Courier New", monospace;"><b></b></span></div>
<br>
</div>
<div><br>
</div>
<div><br>
</div>
<br>
<div style="color: rgb(0, 0, 0);">
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>Von:</b> David Gobbi <david.gobbi@gmail.com><br>
<b>Gesendet:</b> Sonntag, 23. September 2018 16:15<br>
<b>An:</b> Berti Krüger<br>
<b>Cc:</b> Csaba Pinter; VTK Users<br>
<b>Betreff:</b> Re: [vtkusers] Solid Voxelization with VTK</font>
<div> </div>
</div>
<meta content="text/html; charset=utf-8">
<div>
<div dir="ltr">Hi Berti,
<div><br>
</div>
<div>Thanks for the code, I'm sure that people will find it useful. The vtkImageStencilData class isn't described in much detail in the VTK documentation, but I can provide a brief description.</div>
<div><br>
</div>
<div>The vtkImageStencilData object stores each raster-line of a binary image as a list of (begin, end) pairs. That is, each raster line has zero or more non-overlapping (begin, end) pairs. When vtkImageStencil operates on an image, it simply iterates through
the (begin, end) pairs to figure out what parts of the image to copy. One way to think about this is that if the original binary image volume is stored as O(n^3) voxels, the vtkImageStencilData stores O(n^2) values.</div>
<div><br>
</div>
<div>When a vtkImageStencilData is created, it allocates enough memory to store one (begin, end) pair per raster line, since this matches the most common use case (i.e. a mask that corresponds to a convex object). Thereafter it performs additional allocations
as necessary.</div>
<div><br>
</div>
<div>As for vtkPolyDataToImageStencil, it works by cutting your STL object along each XY plane to create polygons (zero or more polygons per slice), and then it rasterizes each polygon to create the (begin, end) pairs for each raster line.</div>
<div><br>
</div>
<div><br>
</div>
<div>One comment about your code: it would be more efficient to use vtkImageStencilToImage instead of vtkImageStencil and vtkImageCast. The vtkImageStencilToImage filter requires only one input (the stencil), i.e. it doesn't require 'binaryLabelMap' as input.
Also, you can set the data type of the image that it produces as output, so it doesn't have to be followed by a cast.</div>
<div><br>
</div>
<div>Cheers,</div>
<div> - David</div>
</div>
<br>
<div class="x_gmail_quote">
<div dir="ltr">On Sat, Sep 22, 2018 at 10:29 PM Berti Krüger <<a href="mailto:berti_krueger@hotmail.com" id="LPlnk642482" class="OWAAutoLink" previewremoved="true">berti_krueger@hotmail.com</a>> wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">
<div id="x_m_-8313790439840091783divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p style="margin-top:0; margin-bottom:0">Hi all.</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">I am very sorry to revive this ancient thread. </p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">But i thought that maybe it could help other vtk users in the future to have a compilable and working example of the final result. If someone thinks that this code could be useful as an vtk example then feel free to
modify / correct / pimp / add this to the vtk examples on github.</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">I adapted the 3D slicer vtk code Csaba has pointed me to and incorporated the hints from David and everything works like a charm:</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0"><img size="65894" id="x_m_-8313790439840091783652102_rs|3" width="384" height="281" style="width: 384px; height: 281.062px; user-select: none;" data-outlook-trace="F:0|T:1" src="cid:795e083b-ffaa-4d6b-8b3f-97deb637b01c"></p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">The whole procedure is incredibly simple. Basically the vtkPolyData of the mesh is converted via the <span>vtkPolyDataToImageStencil filter to a <span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:16px">vtkImageStencil</span> and
the rest of the </span>whole magic is only done by the vtkImageStencil filter:</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0"></p>
<div><span style="font-family:"Courier New",monospace"><b><span style="font-size:9pt">// Convert stencil to image</span></b></span></div>
<div><span style="font-family:"Courier New",monospace"><b><span style="font-size:9pt">vtkNew<vtkImageStencil> stencil;</span></b></span></div>
<div><span style="font-family:"Courier New",monospace"><b><span style="font-size:9pt">stencil->SetInputData(binaryLabelMap);</span></b></span></div>
<div><span style="font-family:"Courier New",monospace"><b><span style="font-size:9pt">stencil->SetStencilConnection(polyDataToImageStencil->GetOutputPort());</span></b></span></div>
<div><span style="font-family:"Courier New",monospace"><b><span style="font-size:9pt">stencil->ReverseStencilOn();</span></b></span></div>
<div><b><span style="font-family:"Courier New",monospace; font-size:9pt">stencil->SetBackgroundValue(1); // General foreground value is 1 (background value because of reverse </span></b><span style="font-family:"Courier New",monospace"><b><span style="font-size:9pt">stencil)</span></b></span></div>
<div><br>
</div>
I would really like to know very roughly how the vtkImageStencil works internally without digging through all of the source code. Because it is really fast (some kind of rasterization maybe ?). If someone could drop me a line on how it works only in principle
that would be really great.
<p></p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">So thanks again to Bill, Csaba, David, Elvis and everyone else on this thread.</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0"></p>
<p style="margin-top:0; margin-bottom:0">Kind regards,</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">Berti</p>
<p style="margin-top:0; margin-bottom:0"><br>
<br>
</p>
PS: Example code, CMakeLists and example STL mesh are attached<br>
<br>
<div style="color:rgb(0,0,0)">
<hr style="display:inline-block; width:98%">
<div id="x_m_-8313790439840091783divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>Von:</b> Csaba Pinter <<a href="mailto:csaba.pinter@queensu.ca" target="_blank" id="LPlnk481987" class="OWAAutoLink" previewremoved="true">csaba.pinter@queensu.ca</a>><br>
<b>Gesendet:</b> Montag, 11. Juni 2018 12:45<br>
<b>An:</b> Berti Krüger<br>
<b>Cc:</b> <a href="mailto:vtkusers@vtk.org" target="_blank" id="LPlnk363925" class="OWAAutoLink" previewremoved="true">
vtkusers@vtk.org</a><br>
<b>Betreff:</b> RE: [vtkusers] Solid Voxelization with VTK</font>
<div> </div>
</div>
<div lang="EN-US" style="background-color:white">
<div class="x_m_-8313790439840091783x_WordSection1">
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:windowtext">Hi Berti,</span></p>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:windowtext"> </span></p>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:windowtext">That code is under BSD-style license, so you’re free to do basically anything with it. This implementation is already pretty simple;
just a concatenation of several VTK filters, so you can just give it a try by copy-pasting the relevant part of that function into your code and see if it works. If you’re interested in using the vtkSegmentation library, let me know though!</span></p>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:windowtext"> </span></p>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:windowtext">Best,</span></p>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:windowtext">csaba</span></p>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:windowtext"> </span></p>
<div>
<div style="border:none; border-top:solid #e1e1e1 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="x_m_-8313790439840091783x_MsoNormal"><b><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:windowtext">From:</span></b><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:windowtext"> Berti Krüger <<a href="mailto:berti_krueger@hotmail.com" target="_blank" id="LPlnk949075" class="OWAAutoLink" previewremoved="true">berti_krueger@hotmail.com</a>>
<br>
<b>Sent:</b> Monday, June 11, 2018 02:46<br>
<b>To:</b> Csaba Pinter <<a href="mailto:csaba.pinter@queensu.ca" target="_blank" id="LPlnk540468" class="OWAAutoLink" previewremoved="true">csaba.pinter@queensu.ca</a>>; David Gobbi <<a href="mailto:david.gobbi@gmail.com" target="_blank" id="LPlnk966976" class="OWAAutoLink" previewremoved="true">david.gobbi@gmail.com</a>><br>
<b>Cc:</b> <a href="mailto:vtkusers@vtk.org" target="_blank" id="LPlnk354018" class="OWAAutoLink" previewremoved="true">
vtkusers@vtk.org</a><br>
<b>Subject:</b> Re: [vtkusers] Solid Voxelization with VTK</span></p>
</div>
</div>
<p class="x_m_-8313790439840091783x_MsoNormal"> </p>
<p>Hi Csaba,</p>
<p> </p>
<p>thank you very much for you answer and for offering your help.</p>
<p> </p>
<p>I already have looked at it and i think if no simpler option will come up, i will give it a try (hoping not to have to change too much to get it working with my pipeline since i am an absolute vtk beginner :-) ).</p>
<p> </p>
<p>How is this code licensed ? (i am only doing research work at the moment, the whole project i am working on is internal and just for testing and part of some larger work, it might be open sourced one day in the very far future but could even be not at all
and it will never be used commercially).</p>
<p> </p>
<p> </p>
<p>Regards</p>
<p> </p>
<p>Berti</p>
<p> </p>
<p class="x_m_-8313790439840091783x_MsoNormal"> </p>
<div>
<p class="x_m_-8313790439840091783x_MsoNormal">Am 05.06.2018 um 16:14 schrieb Csaba Pinter:</p>
</div>
<blockquote style="margin-top:5.0pt; margin-bottom:5.0pt">
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif">Hi Berti,</span></p>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif"> </span></p>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif">There is a pretty robust conversion algorithm implemented within 3D Slicer but using solely VTK:</span></p>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif"><a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FSlicer%2FSlicer%2Fblob%2Fmaster%2FLibs%2FvtkSegmentationCore%2FvtkClosedSurfaceToBinaryLabelmapConversionRule.cxx%23L118&data=02%7C01%7Ccsaba.pinter%40queensu.ca%7C3aab37ccc6914427982508d5cf66eedc%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C1%7C636642963366161717&sdata=p0ekXyWC0VAuADrfhvReHFywfi8%2BD7jhe59iVCIZmqs%3D&reserved=0" id="LPlnk200246" class="x_m_-8313790439840091783OWAAutoLink OWAAutoLink" target="_blank" previewremoved="true">https://github.com/Slicer/Slicer/blob/master/Libs/vtkSegmentationCore/vtkClosedSurfaceToBinaryLabelmapConversionRule.cxx#L118</a></span></p>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif">It consists of a short pipeline of standard VTK filters (some preprocessing then vtkPolyDataToImageStencil and vtkImageStencil).</span></p>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif"> </span></p>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif">Let me know if you have any questions.</span></p>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif"> </span></p>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif">csaba</span></p>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif"> </span></p>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif"> </span></p>
<div>
<div style="border:none; border-top:solid #e1e1e1 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="x_m_-8313790439840091783x_MsoNormal"><b><span style="font-size:11.0pt; font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt; font-family:"Calibri",sans-serif"> vtkusers
<a href="mailto:vtkusers-bounces@public.kitware.com" id="LPlnk970244" class="x_m_-8313790439840091783OWAAutoLink OWAAutoLink" target="_blank" previewremoved="true">
<vtkusers-bounces@public.kitware.com></a> <b>On Behalf Of </b>Berti Krüger<br>
<b>Sent:</b> Tuesday, June 5, 2018 03:26<br>
<b>To:</b> David Gobbi <a href="mailto:david.gobbi@gmail.com" id="LPlnk837410" class="x_m_-8313790439840091783OWAAutoLink OWAAutoLink" target="_blank" previewremoved="true">
<david.gobbi@gmail.com></a><br>
<b>Cc:</b> <a href="mailto:vtkusers@vtk.org" id="LPlnk821862" class="x_m_-8313790439840091783OWAAutoLink OWAAutoLink" target="_blank" previewremoved="true">
vtkusers@vtk.org</a><br>
<b>Subject:</b> Re: [vtkusers] Solid Voxelization with VTK</span></p>
</div>
</div>
<p class="x_m_-8313790439840091783x_MsoNormal"> </p>
<div id="x_m_-8313790439840091783x_divtagdefaultwrapper">
<p><span style="font-family:"Calibri",sans-serif">Hi David,</span></p>
<p><span style="font-family:"Calibri",sans-serif"> </span></p>
<p><span style="font-family:"Calibri",sans-serif">thank you very much for your help.</span></p>
<p><span style="font-family:"Calibri",sans-serif"> </span></p>
<p><span style="font-family:"Calibri",sans-serif">I tried the example from your link. Unfortunately the result is same as using the vtkVoxelModeller:</span></p>
<p><span style="font-family:"Calibri",sans-serif"> </span></p>
<p><span style="font-family:"Calibri",sans-serif"><img border="0" width="800" height="811" id="x_m_-8313790439840091783x__x0037_4177_rs_x007c_1" alt="Screenshot result voxelization" style="width: 8.3333in; height: 8.4479in; user-select: none;" data-outlook-trace="F:0|T:1" src="cid:image001.jpg@01D40160.9EEDCDA0"><br>
I get only a voxelization of the surface. The interior of the voxelized cone is still hollow and not filled with voxels (at least this is implied by the visualization).</span></p>
<p><span style="font-family:"Calibri",sans-serif"> </span></p>
<p><span style="font-family:"Calibri",sans-serif">For the visualization i use Bill Lorensen's example code from here:</span></p>
<p><span style="font-family:"Calibri",sans-serif"><a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Florensen.github.io%2FVTKExamples%2Fsite%2FCxx%2FMedical%2FGenerateCubesFromLabels%2F&data=02%7C01%7Ccsaba.pinter%40queensu.ca%7C63496d6b50e24ff32f7808d5cab5a98b%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C1%7C636637804016225671&sdata=4TKi7VbGBfbM4DpQuLib1m0YGmLJO%2FU7BAO6ZKCUpVU%3D&reserved=0" id="LPlnk313257" target="_blank" class="OWAAutoLink" previewremoved="true">https://lorensen.github.io/VTKExamples/site/Cxx/Medical/GenerateCubesFromLabels/</a></span></p>
<p><span style="font-family:"Calibri",sans-serif"> </span></p>
<p><span style="font-family:"Calibri",sans-serif"> </span></p>
<p><span style="font-family:"Calibri",sans-serif">I have attached this small example which compiles with VTK 8.1 to show the issue. It basicly only consist of the example code from your link (<a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Florensen.github.io%2FVTKExamples%2Fsite%2FCxx%2FPolyData%2FPolyDataToImageData%2F&data=02%7C01%7Ccsaba.pinter%40queensu.ca%7C63496d6b50e24ff32f7808d5cab5a98b%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C1%7C636637804016225671&sdata=hXqgnekqjjNPflRneU0sU7DFo%2B%2FcdBfIFDcpE%2FZXiOg%3D&reserved=0" id="LPlnk371946" target="_blank" class="OWAAutoLink" previewremoved="true">https://lorensen.github.io/VTKExamples/site/Cxx/PolyData/PolyDataToImageData/</a>)
and the visualization code from the Bill Lorensen's example from the link above. I have not changed much.</span></p>
<p><span style="font-family:"Calibri",sans-serif"> </span></p>
<p><span style="font-family:"Calibri",sans-serif">Any idea what is going wrong or what can i do get also voxelization of the interior (solid voxelization)?</span></p>
<p><span style="font-family:"Calibri",sans-serif"> </span></p>
<p><span style="font-family:"Calibri",sans-serif">Thank you very much in advance.</span></p>
<p><span style="font-family:"Calibri",sans-serif"> </span></p>
<p><span style="font-family:"Calibri",sans-serif"> </span></p>
<p><span style="font-family:"Calibri",sans-serif">Regards</span></p>
<p><span style="font-family:"Calibri",sans-serif"> </span></p>
<p><span style="font-family:"Calibri",sans-serif">Berti</span></p>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-family:"Calibri",sans-serif"> </span></p>
<div id="x_m_-8313790439840091783LPBorder_GT_15281833117650.8290773938385372" style="margin-bottom:15.0pt; overflow:auto">
<table class="x_m_-8313790439840091783x_MsoNormalTable" border="1" cellspacing="0" cellpadding="0" width="90%" style="width:90.0%; background:white; border-top:dotted #c8c8c8 1.0pt; border-left:none; border-bottom:dotted #c8c8c8 1.0pt; border-right:none">
<tbody>
<tr>
<td valign="top" style="border:none; padding:0in 0in 0in 0in">
<div id="x_m_-8313790439840091783LPTitle_15281833117630.11207222027314834">
<p class="x_m_-8313790439840091783x_MsoNormal" style="margin-top:15.0pt"><span style="font-size:16.0pt"><a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Florensen.github.io%2FVTKExamples%2Fsite%2FCxx%2FPolyData%2FPolyDataToImageData%2F&data=02%7C01%7Ccsaba.pinter%40queensu.ca%7C63496d6b50e24ff32f7808d5cab5a98b%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C1%7C636637804016225671&sdata=hXqgnekqjjNPflRneU0sU7DFo%2B%2FcdBfIFDcpE%2FZXiOg%3D&reserved=0" id="LPlnk56019" class="x_m_-8313790439840091783OWAAutoLink OWAAutoLink" target="_blank" previewremoved="true"><span style="text-decoration:none">PolyDataToImageData
- lorensen.github.io</span></a></span></p>
</div>
<div id="x_m_-8313790439840091783LPMetadata_15281833117640.37822664008060847" style="margin-top:7.5pt; margin-bottom:12.0pt">
<p class="x_m_-8313790439840091783x_MsoNormal" style="margin-top:15.0pt; line-height:10.5pt">
<span style="font-size:10.5pt"><a href="http://lorensen.github.io" target="_blank" id="LPlnk174970" class="OWAAutoLink" previewremoved="true">lorensen.github.io</a></span></p>
</div>
<div id="x_m_-8313790439840091783LPDescription_15281833117650.4396140244786022">
<p class="x_m_-8313790439840091783x_MsoNormal" style="margin-top:15.0pt; line-height:15.0pt">
<span style="font-size:10.5pt">If VTK is not installed but compiled on your system, you will need to specify the path to your VTK build:</span></p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<p><span style="font-family:"Calibri",sans-serif"> </span></p>
<p><span style="font-family:"Calibri",sans-serif"> </span></p>
<div id="x_m_-8313790439840091783LPBorder_GT_15281830212730.19571757144054258" style="margin-bottom:15.0pt; overflow:auto">
<table class="x_m_-8313790439840091783x_MsoNormalTable" border="1" cellspacing="0" cellpadding="0" width="90%" style="width:90.0%; background:white; border-top:dotted #c8c8c8 1.0pt; border-left:none; border-bottom:dotted #c8c8c8 1.0pt; border-right:none">
<tbody>
<tr>
<td valign="top" style="border:none; padding:0in 0in 0in 0in">
<div id="x_m_-8313790439840091783LPTitle_15281830212690.8554042823458445">
<p class="x_m_-8313790439840091783x_MsoNormal" style="margin-top:15.0pt"><span style="font-size:16.0pt"><a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Florensen.github.io%2FVTKExamples%2Fsite%2FCxx%2FMedical%2FGenerateCubesFromLabels%2F&data=02%7C01%7Ccsaba.pinter%40queensu.ca%7C63496d6b50e24ff32f7808d5cab5a98b%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C1%7C636637804016225671&sdata=4TKi7VbGBfbM4DpQuLib1m0YGmLJO%2FU7BAO6ZKCUpVU%3D&reserved=0" id="LPlnk133582" class="x_m_-8313790439840091783OWAAutoLink OWAAutoLink" target="_blank" previewremoved="true"><span style="text-decoration:none">GenerateCubesFromLabels
- GitHub Pages</span></a></span></p>
</div>
<div id="x_m_-8313790439840091783LPMetadata_15281830212710.7303898190223084" style="margin-top:7.5pt; margin-bottom:12.0pt">
<p class="x_m_-8313790439840091783x_MsoNormal" style="margin-top:15.0pt; line-height:10.5pt">
<span style="font-size:10.5pt"><a href="http://lorensen.github.io" target="_blank" id="LPlnk814537" class="OWAAutoLink" previewremoved="true">lorensen.github.io</a></span></p>
</div>
<div id="x_m_-8313790439840091783LPDescription_15281830212720.03673246019722454">
<p class="x_m_-8313790439840091783x_MsoNormal" style="margin-top:15.0pt; line-height:15.0pt">
<span style="font-size:10.5pt">Usage: GenerateCubesFromLabels FullHead.mhd StartLabel EndLabel where InputVolume is a meta file containing a 3 volume of discrete labels.</span></p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<p class="x_m_-8313790439840091783x_MsoNormal" style="margin-bottom:12.0pt"><span style="font-family:"Calibri",sans-serif"> </span></p>
<p class="x_m_-8313790439840091783x_MsoNormal" style="margin-bottom:12.0pt"><span style="font-family:"Calibri",sans-serif"> </span></p>
<div>
<div class="x_m_-8313790439840091783x_MsoNormal" align="center" style="text-align:center">
<span style="font-family:"Calibri",sans-serif">
<hr size="2" width="98%" align="center">
</span></div>
<div id="x_m_-8313790439840091783x_divRplyFwdMsg">
<p class="x_m_-8313790439840091783x_MsoNormal"><b><span style="font-size:11.0pt; font-family:"Calibri",sans-serif">Von:</span></b><span style="font-size:11.0pt; font-family:"Calibri",sans-serif"> David Gobbi <<a href="mailto:david.gobbi@gmail.com" id="LPlnk790167" class="x_m_-8313790439840091783OWAAutoLink OWAAutoLink" target="_blank" previewremoved="true">david.gobbi@gmail.com</a>><br>
<b>Gesendet:</b> Montag, 28. Mai 2018 23:13<br>
<b>An:</b> Berti Krüger<br>
<b>Cc:</b> <a href="mailto:vtkusers@vtk.org" id="LPlnk963170" class="x_m_-8313790439840091783OWAAutoLink OWAAutoLink" target="_blank" previewremoved="true">
vtkusers@vtk.org</a><br>
<b>Betreff:</b> Re: [vtkusers] Solid Voxelization with VTK</span><span style="font-family:"Calibri",sans-serif">
</span></p>
<div>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-family:"Calibri",sans-serif"> </span></p>
</div>
</div>
<div>
<div>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-family:"Calibri",sans-serif">Hi Berti,
</span></p>
<div>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-family:"Calibri",sans-serif"> </span></p>
</div>
<div>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-family:"Calibri",sans-serif">If its a triangulated surface that you want to fill with voxels, use vtkPolyDataToImageStencil:</span></p>
</div>
<div>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-family:"Calibri",sans-serif"><a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Florensen.github.io%2FVTKExamples%2Fsite%2FCxx%2FPolyData%2FPolyDataToImageData%2F&data=02%7C01%7Ccsaba.pinter%40queensu.ca%7C63496d6b50e24ff32f7808d5cab5a98b%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C1%7C636637804016225671&sdata=hXqgnekqjjNPflRneU0sU7DFo%2B%2FcdBfIFDcpE%2FZXiOg%3D&reserved=0" id="LPlnk778921" target="_blank" class="OWAAutoLink" previewremoved="true">https://lorensen.github.io/VTKExamples/site/Cxx/PolyData/PolyDataToImageData/</a>
</span></p>
<div id="x_m_-8313790439840091783LPBorder_GT_15281827222900.5768444366185992" style="margin-bottom:15.0pt; overflow:auto">
<table class="x_m_-8313790439840091783x_MsoNormalTable" border="1" cellspacing="0" cellpadding="0" width="90%" style="width:90.0%; background:white; border-top:dotted #c8c8c8 1.0pt; border-left:none; border-bottom:dotted #c8c8c8 1.0pt; border-right:none">
<tbody>
<tr>
<td valign="top" style="border:none; padding:0in 0in 0in 0in">
<div id="x_m_-8313790439840091783LPTitle_15281827222890.533190778266545">
<p class="x_m_-8313790439840091783x_MsoNormal" style="margin-top:15.0pt"><span style="font-size:16.0pt"><a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Florensen.github.io%2FVTKExamples%2Fsite%2FCxx%2FPolyData%2FPolyDataToImageData%2F&data=02%7C01%7Ccsaba.pinter%40queensu.ca%7C63496d6b50e24ff32f7808d5cab5a98b%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C1%7C636637804016225671&sdata=hXqgnekqjjNPflRneU0sU7DFo%2B%2FcdBfIFDcpE%2FZXiOg%3D&reserved=0" id="LPlnk781826" class="x_m_-8313790439840091783OWAAutoLink OWAAutoLink" target="_blank" previewremoved="true"><span style="text-decoration:none">PolyDataToImageData
- lorensen.github.io</span></a></span></p>
</div>
<div id="x_m_-8313790439840091783LPMetadata_15281827222890.7452275815734757" style="margin-top:7.5pt; margin-bottom:12.0pt">
<p class="x_m_-8313790439840091783x_MsoNormal" style="margin-top:15.0pt; line-height:10.5pt">
<span style="font-size:10.5pt"><a href="http://lorensen.github.io" target="_blank" id="LPlnk395295" class="OWAAutoLink" previewremoved="true">lorensen.github.io</a></span></p>
</div>
<div id="x_m_-8313790439840091783LPDescription_15281827222900.21981643030984221">
<p class="x_m_-8313790439840091783x_MsoNormal" style="margin-top:15.0pt; line-height:15.0pt">
<span style="font-size:10.5pt">If VTK is not installed but compiled on your system, you will need to specify the path to your VTK build:</span></p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<p class="x_m_-8313790439840091783x_MsoNormal" style="margin-bottom:12.0pt"><span style="font-family:"Calibri",sans-serif"> </span></p>
</div>
<div>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-family:"Calibri",sans-serif"> </span></p>
</div>
<div>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-family:"Calibri",sans-serif">If its a mesh of 3D elements and you want to sample the elements to create voxels, try vtkResampleToImage.</span></p>
</div>
<div>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-family:"Calibri",sans-serif"> </span></p>
</div>
<div>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-family:"Calibri",sans-serif"> - David</span></p>
</div>
<div>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-family:"Calibri",sans-serif"> </span></p>
</div>
<div>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-family:"Calibri",sans-serif"> </span></p>
<div>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-family:"Calibri",sans-serif"> </span></p>
<div>
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-family:"Calibri",sans-serif">On Mon, May 28, 2018 at 4:41 PM, Berti Krüger <<a href="mailto:berti_krueger@hotmail.com" id="LPlnk606364" target="_blank" class="OWAAutoLink" previewremoved="true">berti_krueger@hotmail.com</a>>
wrote:</span></p>
<blockquote style="border:none; border-left:solid #cccccc 1.0pt; padding:0in 0in 0in 6.0pt; margin-left:4.8pt; margin-top:5.0pt; margin-right:0in; margin-bottom:5.0pt">
<p class="x_m_-8313790439840091783x_MsoNormal"><span style="font-family:"Calibri",sans-serif">Hello Everyone.<br>
<br>
For my Project i have to voxelize a 3D-Triangle-Mesh. I already found the<br>
vtkVoxelModeller which, while somewhat slow (only around 200 Triangles per<br>
second), works, but only voxelizes the outer shell where the mesh boundary<br>
triangles are. The inner part of the mesh stays hollow. <br>
<br>
Is there some way to get solid voxelization of 3D-Triangle-Meshes out of the<br>
box with VTK ?<br>
<br>
<br>
Thank you very much in advance,<br>
<br>
Berti</span></p>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<p class="x_m_-8313790439840091783x_MsoNormal"> </p>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</body>
</html>