<html><head></head><body bgcolor="#FFFFFF"><div>Can you try replacing test1.toFloat with toDouble()</div><div><br></div><div>Because your image data is populated with double?</div><div><br></div><div>Jothy<br><br><br></div><div><br>On 09-May-2012, at 11:39 PM, Brian Curtis &lt;<a href="mailto:bcurtis3@masonlive.gmu.edu">bcurtis3@masonlive.gmu.edu</a>&gt; wrote:<br><br></div><div></div><blockquote type="cite"><div>
  
    <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
  
  
    Thanks for your help,<br>
    <br>
    The following is the code that I wanted to create in the first place
    with the help from Jothy (Thank You). The values printed are weird
    and I wanted to send this to the community to help me correct any
    mistakes and so that I can gather some helpful hints from the
    community as to better practices in my code and using and
    understanding VTK.<br>
    <br>
    Thanks,<br>
    ~Brian<br>
    ==============================<br>
    #include &lt;vtkDoubleArray.h&gt;<br>
    #include &lt;vtkImageData.h&gt;<br>
    #include &lt;vtkPointData.h&gt;<br>
    #include &lt;vtkFloatArray.h&gt;<br>
    #include &lt;vtkPoints.h&gt;<br>
    #include &lt;vtkPolyData.h&gt;<br>
    #include &lt;vtkProbeFilter.h&gt;<br>
    #include &lt;vtkDataObjectToTable.h&gt;<br>
    #include &lt;vtkTable.h&gt;<br>
    #include &lt;vtkTableReader.h&gt;<br>
    #include &lt;vtkVariant.h&gt;<br>
    <br>
    int main(int, char *[]) {<br>
    &nbsp;&nbsp;&nbsp; printf("This is the beggining of the file\n");<br>
    <br>
    &nbsp;&nbsp;&nbsp; int i;<br>
    &nbsp;&nbsp;&nbsp; <br>
    &nbsp;&nbsp;&nbsp; vtkDoubleArray* myones = vtkDoubleArray::New();<br>
    &nbsp;&nbsp;&nbsp; myones-&gt;SetName("Ones Scalar Array");<br>
    &nbsp;&nbsp;&nbsp; myones-&gt;InsertNextValue(1.0);<br>
    &nbsp;&nbsp;&nbsp; myones-&gt;InsertNextValue(2.0);<br>
    &nbsp;&nbsp;&nbsp; myones-&gt;InsertNextValue(1.0);<br>
    &nbsp;&nbsp;&nbsp; myones-&gt;InsertNextValue(2.0);<br>
    &nbsp;&nbsp;&nbsp; myones-&gt;InsertNextValue(1.0);<br>
    &nbsp;&nbsp;&nbsp; myones-&gt;InsertNextValue(2.0);<br>
    &nbsp;&nbsp;&nbsp; myones-&gt;InsertNextValue(1.0);<br>
    &nbsp;&nbsp;&nbsp; myones-&gt;InsertNextValue(2.0);<br>
    &nbsp;&nbsp;&nbsp; printf("Created Scalar Array\n");<br>
    &nbsp;&nbsp;&nbsp; <br>
    &nbsp;&nbsp;&nbsp; //Now Creating the dataset<br>
    &nbsp;&nbsp;&nbsp; vtkImageData* griddata = vtkImageData::New();<br>
    &nbsp;&nbsp;&nbsp; //griddata-&gt;SetPoints(cubepoints);<br>
    &nbsp;&nbsp;&nbsp; griddata-&gt;SetDimensions(2,2,2);<br>
    &nbsp;&nbsp;&nbsp; griddata-&gt;SetSpacing(2.0,2.0,2.0);<br>
    &nbsp;&nbsp;&nbsp; griddata-&gt;SetOrigin(-1.0,-1.0,-1.0);<br>
    &nbsp;&nbsp;&nbsp; griddata-&gt;GetPointData()-&gt;SetScalars(myones);<br>
    &nbsp;&nbsp;&nbsp; printf("Set Image Data\n");<br>
    &nbsp;&nbsp;&nbsp; <br>
    &nbsp;&nbsp;&nbsp; //CREATE A LINE TO INTERPOLATE ONTO<br>
    &nbsp;&nbsp;&nbsp; float line[5][3] = { {-2.0, 2.0, -2.0}, {-1.0, 1.0, -1.0},<br>
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{0.0, 0.0, 0.0}, {1.0, -1.0, 1.0}, {2.0,
    -2.0, 2.0} };<br>
    &nbsp;&nbsp;&nbsp; vtkFloatArray* lcoords = vtkFloatArray::New();<br>
    &nbsp;&nbsp;&nbsp; lcoords-&gt;SetNumberOfComponents(3);<br>
    &nbsp;&nbsp;&nbsp; lcoords-&gt;SetNumberOfTuples(5);<br>
    &nbsp;&nbsp;&nbsp; for(i=1; i&lt;5; i++){<br>
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lcoords-&gt;SetTuple(i, line[i]);<br>
    &nbsp;&nbsp;&nbsp; }<br>
    <br>
    &nbsp;&nbsp;&nbsp; vtkPoints* linepoints = vtkPoints::New();<br>
    &nbsp;&nbsp;&nbsp; linepoints-&gt;SetData(lcoords);<br>
    &nbsp;&nbsp;&nbsp; printf("Created linepoints\n");<br>
    <br>
    &nbsp;&nbsp;&nbsp; vtkPolyData* linedata = vtkPolyData::New();<br>
    &nbsp;&nbsp;&nbsp; linedata-&gt;SetPoints(linepoints);<br>
    &nbsp;&nbsp;&nbsp; printf("Created line data\n");<br>
    &nbsp;&nbsp;&nbsp; <br>
    &nbsp;&nbsp;&nbsp; printf("Creating Probe Filter\n");<br>
    &nbsp;&nbsp;&nbsp; vtkProbeFilter* probe = vtkProbeFilter::New();<br>
    &nbsp;&nbsp;&nbsp; probe-&gt;SetInput(linedata);<br>
    &nbsp;&nbsp;&nbsp; probe-&gt;SetSource(griddata);<br>
    &nbsp;&nbsp;&nbsp; probe-&gt;Update();<br>
    <br>
    &nbsp;&nbsp;&nbsp; //RETURNING RESULTS AS A VTKTABLE<br>
    &nbsp;&nbsp;&nbsp; vtkDataObjectToTable* polyDataToTable =
    vtkDataObjectToTable::New();<br>
    &nbsp;&nbsp;&nbsp;
    polyDataToTable-&gt;SetInputConnection(probe-&gt;GetOutputPort());<br>
    &nbsp;&nbsp;&nbsp;
    polyDataToTable-&gt;SetFieldType(vtkDataObjectToTable::POINT_DATA);<br>
    &nbsp;&nbsp;&nbsp; polyDataToTable-&gt;Update();<br>
    &nbsp;&nbsp;&nbsp; <br>
    &nbsp;&nbsp;&nbsp; //PRINT THE RESULTANT SCALAR VALUES<br>
    &nbsp;&nbsp;&nbsp; vtkTable* table = polyDataToTable-&gt;GetOutput();<br>
    &nbsp;&nbsp;&nbsp; int A = table-&gt;GetNumberOfRows();<br>
    &nbsp;&nbsp;&nbsp; int B = table-&gt;GetNumberOfColumns();<br>
    &nbsp;&nbsp;&nbsp; printf("Rows: %i Columns: %i\n",A,B);<br>
    &nbsp;&nbsp;&nbsp; for(i=0; i&lt;A; i++){<br>
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtkVariant test1 = table-&gt;GetValue(i,0);<br>
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtkVariant test2 = table-&gt;GetValue(i,1);<br>
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; printf("Row %i:
    (%f,%f)\n",i,test1.ToFloat(),test2.ToFloat());<br>
    &nbsp;&nbsp;&nbsp; }<br>
    &nbsp;&nbsp;&nbsp; <br>
    &nbsp;&nbsp;&nbsp; printf("This is the end of the file\n");<br>
    &nbsp;&nbsp;&nbsp; <br>
    &nbsp;&nbsp;&nbsp; myones-&gt;Delete();<br>
    &nbsp;&nbsp;&nbsp; griddata-&gt;Delete();<br>
    &nbsp;&nbsp;&nbsp; lcoords-&gt;Delete();<br>
    &nbsp;&nbsp;&nbsp; linepoints-&gt;Delete();<br>
    &nbsp;&nbsp;&nbsp; linedata-&gt;Delete();<br>
    &nbsp;&nbsp;&nbsp; probe-&gt;Delete();<br>
    &nbsp;&nbsp;&nbsp; polyDataToTable-&gt;Delete();<br>
    &nbsp;&nbsp;&nbsp; table-&gt;Delete();<br>
    &nbsp;&nbsp;&nbsp; <br>
    &nbsp;&nbsp;&nbsp; return EXIT_SUCCESS;<br>
    <br>
    }<br>
    ==========================<br>
    <br>
    <br>
    <br>
    On 05/09/2012 12:21 PM, Jothybasu Selvaraj wrote:
    <blockquote cite="mid:CAKuw5X2_j27OSy8uVv7tGRFB7KT3E6+BPGX9t=mgNMiMNiBFuQ@mail.gmail.com" type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      <div dir="ltr">vtkTable::GetValue() shoudl do that.<br>
        <br>
        <br>
        Jothy<br>
        <br>
        <div class="gmail_quote">On Wed, May 9, 2012 at 5:11 PM, Brian
          Curtis <span dir="ltr">&lt;<a moz-do-not-send="true" href="mailto:bcurtis3@masonlive.gmu.edu" target="_blank">bcurtis3@masonlive.gmu.edu</a>&gt;</span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div bgcolor="#FFFFFF" text="#000000"> Jothy,<br>
              <br>
              Thanks for your reply.<br>
              <br>
              I am interested in printing the interpolated scalar values
              to the screen (Terminal window), how would I go about
              this?<br>
              <br>
              ~Brian<br>
              <br>
              <br>
              <br>
              On 05/09/2012 09:41 AM, Jothybasu Selvaraj wrote:
              <blockquote type="cite">
                <div dir="ltr">This should help you<br>
                  <br>
                  vtkSmartPointer&lt;vtkProbeFilter&gt;pf=<br>
                  vtkSmartPointer&lt;vtkProbeFilter&gt;::New();<br>
                  pf-&gt;SetInput(cube);//cube as vtkImageData<br>
                  pf-&gt;SetSource(line);line as vtkPolyData<br>
                  pf-&gt;Update();<br>
                  <br>
                  //Returns the result as a vtkTable<br>
vtkSmartPointer&lt;vtkDataObjectToTable&gt;polyDataToTable=<br>
                  vtkSmartPointer&lt;vtkDataObjectToTable&gt;::New();<br>
polyDataToTable-&gt;SetInputConnection(pf-&gt;GetOutputPort());<br>
polyDataToTable-&gt;SetFieldType(vtkDataObjectToTable::POINT_DATA);<br>
                  polyDataToTable-&gt;Update();<br>
                  <br>
                  Jothy<br>
                  <br>
                  <div class="gmail_quote">On Wed, May 9, 2012 at 2:17
                    PM, Brian Curtis <span dir="ltr">&lt;<a moz-do-not-send="true" href="mailto:bcurtis3@masonlive.gmu.edu" target="_blank">bcurtis3@masonlive.gmu.edu</a>&gt;</span>
                    wrote:<br>
                    <blockquote class="gmail_quote" style="margin:0 0 0
                      .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
                      <br>
                      I'm looking for an example that does this or a few
                      examples that show the proper way to do this.<br>
                      <br>
                      I'm not sure how to understand vtkProbeFilter from
                      <a moz-do-not-send="true" href="http://www.vtk.org/doc/nightly/html/classvtkProbeFilter.html" target="_blank">http://www.vtk.org/doc/nightly/html/classvtkProbeFilter.html</a>
                      and what part of it will do the work I need.<br>
                      <br>
                      vtkProbeFilter-&gt;Probe requires three vtkDataSet
                      but how do I get my points into a dataset?<br>
                      <br>
                      Thanks for your help,<br>
                      ~Brian<br>
                      <br>
                      On 05/08/2012 11:10 AM, Brian Curtis wrote:<br>
                      <blockquote class="gmail_quote" style="margin:0 0
                        0 .8ex;border-left:1px #ccc
                        solid;padding-left:1ex"> Hi,<br>
                        <br>
                        I am interested in creating the following simple
                        example in order to expand off of at a later
                        time:<br>
                        - Create a cube (8 points) with scalar values
                        all set to 1<br>
                        - Create a line (5 points) that intersects with
                        cube<br>
                        - Get scalar interpolations for the line from
                        the cube<br>
                        <br>
                        Cube pts:<br>
                        float pts[8][3] = { {-1.0, -1.0, -1.0}, {-1.0,
                        1.0, -1.0},<br>
                        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{-1.0, 1.0, 1.0}, {-1.0,
                        -1.0, 1.0},<br>
                        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{1.0, -1.0, -1.0}, {1.0,
                        1.0, -1.0},<br>
                        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{1.0, 1.0, 1.0}, {1.0,
                        -1.0, 1.0} };<br>
                        Line pts:<br>
                        float line[5][3] = { {-2.0, 2.0, -2.0}, {-1.0,
                        1.0, -1.0},<br>
                        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {0.0, 0.0, 0.0}, {1.0,
                        -1.0, 1.0}, {2.0, -2.0, 2.0} };<br>
                        <br>
                        I could not find a simple example to do this,
                        and I'm not exactly sure if probefilter is the
                        right way to go about this. What the best (and
                        easiest) way to approach this problem?<br>
                        <br>
                        Thanks,<br>
                        ~Brian<br>
                        <br>
                        _______________________________________________<br>
                        Powered by <a moz-do-not-send="true" href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
                        <br>
                        Visit other Kitware open-source projects at <a moz-do-not-send="true" href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
                        <br>
                        Please keep messages on-topic and check the VTK
                        FAQ at: <a moz-do-not-send="true" href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
                        <br>
                        Follow this link to subscribe/unsubscribe:<br>
                        <a moz-do-not-send="true" href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
                        <br>
                      </blockquote>
                      <br>
                      <br>
                      _______________________________________________<br>
                      Powered by <a moz-do-not-send="true" href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
                      <br>
                      Visit other Kitware open-source projects at <a moz-do-not-send="true" href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
                      <br>
                      Please keep messages on-topic and check the VTK
                      FAQ at: <a moz-do-not-send="true" href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
                      <br>
                      Follow this link to subscribe/unsubscribe:<br>
                      <a moz-do-not-send="true" href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
                    </blockquote>
                  </div>
                  <br>
                  <br clear="all">
                  <span class="HOEnZb"><font color="#888888"> <br>
                      -- <br>
                      <div dir="ltr">Jothy<br>
                      </div>
                      <br>
                    </font></span></div>
              </blockquote>
              <br>
            </div>
          </blockquote>
        </div>
        <br>
        <br clear="all">
        <br>
        -- <br>
        <div dir="ltr">Jothy<br>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  

</div></blockquote></body></html>