<div dir="ltr"><div>Hello,</div><div><br></div><div>The reason why resampling fails cannot be found, but at least, the order of IJK-coordinates of the structured points is needed to be changed in reverse.</div><div><br></div><div>for (int z = 0; z < gridSize.z; z++) {</div><div>  for (int y = 0; y < gridSize.y; y++) {</div><div>    for (int x = 0; x < gridSize.x; x++) {</div><div>     ...</div><div><br></div><div>Also I attached a sample that works. </div><div>Hope that helps to solve.</div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-11-28 23:23 GMT+09:00 Jochen Jankowai <span dir="ltr"><<a href="mailto:jochen.jankowai@gmail.com" target="_blank">jochen.jankowai@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
Thank you for your reply! I have adjusted my code according to your suggestions which had the effect that I am not getting a nullptr any longer.<br>
The resulting structured grid has 0 values at all positions though.<br>
Am I forgetting to specify that/how I want to interpolate the tensors or something like that?<br>
<br>
See code below:<br>
<span class=""><br>
    auto reader = vtkUnstructuredGridReader::<wbr>New();<br>
<br>
    reader->SetFileName(file_.get(<wbr>).c_str());<br>
<br>
</span>    reader->SetReadAllTensors(1);<br>
<span class=""><br>
    reader->Update();<br>
<br>
    auto unstructuredGrid = reader->GetOutput();<br>
<br>
</span>    auto bounds = unstructuredGrid->GetBounds();<br>
<span class=""><br>
    // Create a grid of points to interpolate over<br>
</span>    auto gridSize = ivec3(32);<br>
    const auto gridBounds = dvec3(31);<br>
<span class="">    vtkSmartPointer<vtkPoints> gridPoints = vtkSmartPointer<vtkPoints>::<wbr>New();<br>
<br>
</span>    const auto xRange = std::abs(bounds[0] - bounds[1]);<br>
    const auto yRange = std::abs(bounds[2] - bounds[3]);<br>
    const auto zRange = std::abs(bounds[4] - bounds[5]);<br>
<br>
    const auto stepSize = dvec3(xRange / gridBounds.x, yRange / gridBounds.y, zRange / gridBounds.z);<br>
<span class=""><br>
    for (int x = 0; x < gridSize.x; x++) {<br>
        for (int y = 0; y < gridSize.y; y++) {<br>
            for (int z = 0; z < gridSize.z; z++) {<br>
</span>                const auto xCoord = bounds[0] + static_cast<double>(x) * stepSize.x;<br>
                const auto yCoord = bounds[2] + static_cast<double>(y) * stepSize.y;<br>
                const auto zCoord = bounds[4] + static_cast<double>(z) * stepSize.z;<br>
                gridPoints->InsertNextPoint(<wbr>xCoord, yCoord, zCoord);<br>
<span class="">            }<br>
        }<br>
    }<br>
<br>
    // Create a dataset from the grid points<br>
     vtkSmartPointer<<wbr>vtkStructuredGrid> pointSet =<br>
        vtkSmartPointer<<wbr>vtkStructuredGrid>::New();<br>
     pointSet->SetDimensions(glm::<wbr>value_ptr(gridSize));<br>
     pointSet->SetPoints(<wbr>gridPoints);<br>
<br>
     vtkSmartPointer<<wbr>vtkProbeFilter> probeFilter =<br>
        vtkSmartPointer<<wbr>vtkProbeFilter>::New();<br>
     probeFilter->SetSourceData(<wbr>unstructuredGrid);<br>
<br>
     probeFilter->SetInputData(<wbr>pointSet);<br>
<br>
     probeFilter->Update();<br>
<br>
     auto structuredGrid = probeFilter-><wbr>GetStructuredGridOutput();<br>
<br>
     auto pointData = structuredGrid->GetPointData()<wbr>;<br>
</span>     auto tensors = pointData->GetArray("strain_0.<wbr>0");<br>
<div><div class="h5"><br>
<br>
<br>
-----Original Message-----<br>
From: kenichiro yoshimi [mailto:<a href="mailto:rccm.kyoshimi@gmail.com">rccm.kyoshimi@gmail.<wbr>com</a>]<br>
Sent: den 25 november 2017 04:50<br>
To: PetiteViking <<a href="mailto:jochen.jankowai@gmail.com">jochen.jankowai@gmail.com</a>><br>
Cc: <a href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a><br>
Subject: Re: [vtkusers] Regularly sample 3D unstructured tensor grid<br>
<br>
Hi,<br>
<br>
The standard way of retrieving PointData is not  auto tensors = pointData->GetArray(); but  auto tensors = pointData->GetArray(0);  auto tensors = pointData->GetArray("array-<wbr>name");<br>
 auto tensors = pointData->GetTensors("array-<wbr>name");<br>
<br>
vtkPointData inherits from vtkDataSetAttributes and<br>
pointData->GetArray() is trying to access the FieldData which<br>
describes global properties of pointData, but it is null.<br>
<br>
Thanks<br>
<br>
2017-11-24 21:48 GMT+09:00 PetiteViking <<a href="mailto:jochen.jankowai@gmail.com">jochen.jankowai@gmail.com</a>>:<br>
> Hello everyone! I've tried to find an answer to my problem in the<br>
> forum for quite some time now but I cannot seem to find a solution. I<br>
> have an unstructured hexahedral grid that stores one tensor per cell.<br>
> What I need in my application though is a regulargrid so I would like<br>
> to regularly sample the field. So far, this is what I am trying to<br>
> (see code below). In one of the posts here I have read that<br>
> vtkProbeFilter will produce output that corresponds to the input so I<br>
> amusing a structured grid as input for which I have computed points.<br>
> And while I manage to retreive a structured grid from the probeFilter,<br>
> the variable tensors ends up being a nullptr. auto reader =<br>
> vtkUnstructuredGridReader::<wbr>New();<br>
> reader->SetFileName(file_.get(<wbr>).c_str());<br>
> reader->Update(); auto unstructuredGrid = reader->GetOutput(); //<br>
</div></div>> reader->Create a<br>
<span class="">> grid of points to interpolate over auto gridSize = glm::ivec3(32, 32,<br>
> 32); vtkSmartPointer<vtkPoints> gridPoints =<br>
> vtkSmartPointer<vtkPoints>::<wbr>New();<br>
> for (int x = 0; x < gridSize.x; x++) { for (int y = 0; y <<br>
> gridSize.y; y++) { for (int z = 0; z < gridSize.z; z++) {<br>
> gridPoints->InsertNextPoint(x, y, z); } } } // Create a dataset<br>
> from the grid points vtkSmartPointer<<wbr>vtkStructuredGrid> pointSet =<br>
> vtkSmartPointer<<wbr>vtkStructuredGrid>::New();<br>
> pointSet->SetDimensions(glm::<wbr>value_ptr(gridSize));<br>
> pointSet->SetPoints(<wbr>gridPoints); vtkSmartPointer<<wbr>vtkProbeFilter><br>
</span>> pointSet->probeFilter<br>
<div class="HOEnZb"><div class="h5">> = vtkSmartPointer<<wbr>vtkProbeFilter>::New();<br>
> probeFilter->SetSourceData(<wbr>unstructuredGrid);<br>
> probeFilter->SetInputData(<wbr>pointSet); probeFilter->Update(); auto<br>
> structuredGrid = probeFilter-><wbr>GetStructuredGridOutput(); auto<br>
> pointData =<br>
> structuredGrid->GetPointData()<wbr>; auto tensors =<br>
> structuredGrid->GetPointData()<wbr>->GetTensors();<br>
> ______________________________<wbr>__<br>
> Sent from the VTK - Users mailing list archive at Nabble.com.<br>
><br>
> ______________________________<wbr>_________________<br>
> Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
><br>
> Please keep messages on-topic and check the VTK FAQ at:<br>
> <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_<wbr>FAQ</a><br>
><br>
> Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>vtkusers</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/vtkusers</a><br>
><br>
<br>
</div></div></blockquote></div><br></div>