<div dir="ltr">Hi,<div><br></div><div>Thanks for help me.</div><div>I have confirmed the out.vti using Paraview's volume rendering. I don't know what is wrong, I get a solid cube again :-(</div><div>I am attaching a screenshot. Could you see, please?</div><div><br></div><div>Thanks</div><div>Lizeth<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 1, 2018 at 10:20 PM, kenichiro yoshimi <span dir="ltr"><<a href="mailto:rccm.kyoshimi@gmail.com" target="_blank">rccm.kyoshimi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Thanks for trying.<br>
Could you confirm if out.vti is visualized properly using ParaView's<br>
volume rendering?<br>
<br>
Regards<br>
2018年8月2日(木) 6:12 Lizeth Castellanos <<a href="mailto:castellanoslizan@gmail.com">castellanoslizan@gmail.com</a>>:<br>
<div class="HOEnZb"><div class="h5">><br>
> Hi,<br>
><br>
> I got VTK 7.1.1 in my computer, finally! So, I have tested the two solutions that you have suggested:<br>
> 1) using vtkProbeFilter<br>
> 2) using vtkResampleToImage<br>
><br>
> 1) I  have adjusted the image dimensions according to my own data and I am using  vtkSmartVolumeMapper, instead of vtkVolumeRaycastMapper.<br>
> No errors are generated in the terminal. However, I have been waiting for several minutes and nothing happens.<br>
> Do you have any idea what is wrong?<br>
><br>
><br>
> csvfile="directory path to my csv file/sample.csv"<br>
><br>
> reader = vtk.vtkDelimitedTextReader()<br>
> reader.<wbr>SetFieldDelimiterCharacters(" ")<br>
> reader.DetectNumericColumnsOn(<wbr>)<br>
> reader.SetFileName(csvfile)<br>
> reader.<wbr>MergeConsecutiveDelimitersOn()<br>
> reader.Update()<br>
><br>
> tableToPoints = vtk.vtkTableToPolyData()<br>
> tableToPoints.<wbr>SetInputConnection(reader.<wbr>GetOutputPort())<br>
> tableToPoints.SetXColumn('<wbr>Field 0')<br>
> tableToPoints.SetYColumn('<wbr>Field 1')<br>
> tableToPoints.SetZColumn('<wbr>Field 2')<br>
><br>
> imageData = vtk.vtkImageData()<br>
> imageData.SetDimensions(512, 512, 192)<br>
> imageData.SetOrigin(0.0, 0.0, 0.0)<br>
> imageData.SetSpacing(1.0, 1.0, 1.0)<br>
><br>
> probeFilter = vtk.vtkProbeFilter()<br>
> probeFilter.<wbr>SetSourceConnection(<wbr>tableToPoints.GetOutputPort())<br>
> probeFilter.SetInputData(<wbr>imageData)<br>
> probeFilter.Update()<br>
><br>
> writer = vtk.vtkXMLImageDataWriter()<br>
> writer.SetInputData(<wbr>probeFilter.GetOutput())<br>
> writer.SetFileName('out.vti')<br>
> writer.Write()<br>
><br>
> probeFilter.GetOutput().<wbr>GetPointData().<wbr>SetActiveScalars('Field 3')<br>
> range = probeFilter.GetOutput().<wbr>GetPointData().GetScalars().<wbr>GetRange()<br>
><br>
> colors = vtk.vtkNamedColors()<br>
><br>
> # Create the standard renderer, render window<br>
> # and interactor.<br>
> ren = vtk.vtkRenderer()<br>
><br>
> renWin = vtk.vtkRenderWindow()<br>
> renWin.AddRenderer(ren)<br>
><br>
> iren = vtk.vtkRenderWindowInteractor(<wbr>)<br>
> iren.SetRenderWindow(renWin)<br>
><br>
> # Create transfer mapping scalar value to opacity.<br>
> opacityTransferFunction = vtk.vtkPiecewiseFunction()<br>
> opacityTransferFunction.<wbr>AddPoint(range[0], 0.0)<br>
> opacityTransferFunction.<wbr>AddPoint(range[1], 1.0)<br>
><br>
> # Create transfer mapping scalar value to color.<br>
> colorTransferFunction = vtk.vtkColorTransferFunction()<br>
> colorTransferFunction.<wbr>AddRGBPoint(range[0], 0.0, 0.0, 1.0)<br>
> colorTransferFunction.<wbr>AddRGBPoint((range[0]+range[1]<wbr>)*0.5, 0.0, 1.0, 0.0)<br>
> colorTransferFunction.<wbr>AddRGBPoint(range[1], 1.0, 0.0, 0.0)<br>
><br>
> # The property describes how the data will look.<br>
> volumeProperty = vtk.vtkVolumeProperty()<br>
> volumeProperty.SetColor(<wbr>colorTransferFunction)<br>
> volumeProperty.<wbr>SetScalarOpacity(<wbr>opacityTransferFunction)<br>
> volumeProperty.<wbr>SetScalarOpacityUnitDistance(<wbr>1.73205080757)<br>
> volumeProperty.<wbr>SetInterpolationTypeToLinear()<br>
><br>
> # The mapper / ray cast function know how to render the data.<br>
> volumeMapper = vtk.vtkSmartVolumeMapper()<br>
> volumeMapper.<wbr>SetInputConnection(<wbr>probeFilter.GetOutputPort())<br>
> volumeMapper.<wbr>SetBlendModeToComposite()<br>
><br>
> # The volume holds the mapper and the property and<br>
> # can be used to position/orient the volume.<br>
> volume = vtk.vtkVolume()<br>
> volume.SetMapper(volumeMapper)<br>
> volume.SetProperty(<wbr>volumeProperty)<br>
><br>
> ren.AddVolume(volume)<br>
><br>
> ren.SetBackground(colors.<wbr>GetColor3d("White"))<br>
> ren.GetActiveCamera().<wbr>ParallelProjectionOn()<br>
> ren.ResetCameraClippingRange()<br>
> ren.ResetCamera()<br>
><br>
> renWin.SetSize(600, 600)<br>
> renWin.Render()<br>
> iren.Start()<br>
><br>
><br>
> 2) I have tested the vtkResampleToImage class, (the solution that you suggest at the beginning of this thread). However, I get a solid a cube as output.<br>
> Do you have any idea why that happens?<br>
><br>
> csvfile="directory path to my csv file/sample.csv"<br>
><br>
> reader = vtk.vtkDelimitedTextReader()<br>
> reader.<wbr>SetFieldDelimiterCharacters(" ")<br>
> reader.DetectNumericColumnsOn(<wbr>)<br>
> reader.SetFileName(csvfile)<br>
> reader.<wbr>MergeConsecutiveDelimitersOn()<br>
> reader.Update()<br>
><br>
> tableToPoints = vtk.vtkTableToPolyData()<br>
> tableToPoints.<wbr>SetInputConnection(reader.<wbr>GetOutputPort())<br>
> tableToPoints.SetXColumn("<wbr>Field 0")<br>
> tableToPoints.SetYColumn("<wbr>Field 1")<br>
> tableToPoints.SetZColumn("<wbr>Field 2")<br>
> tableToPoints.Update()<br>
><br>
> resample = vtk.vtkResampleToImage()<br>
> resample.SetInputConnection(<wbr>tableToPoints.GetOutputPort())<br>
> resample.<wbr>SetSamplingDimensions(3, 3, 3)<br>
> resample.<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><br></div><div><br></div></div></div></div></div></div>
</div></div>