<div dir="ltr">Please keep the discussion to the  mailing list.<div><br></div><div>What is the expected result here?</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Sep 13, 2013 at 11:06 AM, 庞庆源 <span dir="ltr">&lt;<a href="mailto:pangqingyuan1991@gmail.com" target="_blank">pangqingyuan1991@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Why this example can color the cube?</div><div class="gmail_extra"><div><div class="h5"><br><br><div class="gmail_quote">
2013/9/13 庞庆源 <span dir="ltr">&lt;<a href="mailto:pangqingyuan1991@gmail.com" target="_blank">pangqingyuan1991@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thank you for your reply.I would like to show you a example and its picture:<div><div>/*=========================================================================</div>

<div><br></div><div>  Program:   Visualization Toolkit</div>
<div>  Module:    Cube.cxx</div><div><br></div><div>  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen</div><div>  All rights reserved.</div><div>  See Copyright.txt or <a href="http://www.kitware.com/Copyright.htm" target="_blank">http://www.kitware.com/Copyright.htm</a> for details.</div>


<div><br></div><div>     This software is distributed WITHOUT ANY WARRANTY; without even</div><div>     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR</div><div>     PURPOSE.  See the above copyright notice for more information.</div>


<div><br></div><div>=========================================================================*/</div><div>// This example shows how to manually create vtkPolyData.</div><div><br></div><div>#include &quot;vtkActor.h&quot;</div>


<div>#include &quot;vtkCamera.h&quot;</div><div>#include &quot;vtkCellArray.h&quot;</div><div>#include &quot;vtkFloatArray.h&quot;</div><div>#include &quot;vtkPointData.h&quot;</div><div>#include &quot;vtkPoints.h&quot;</div>


<div>#include &quot;vtkPolyData.h&quot;</div><div>#include &quot;vtkPolyDataMapper.h&quot;</div><div>#include &quot;vtkRenderWindow.h&quot;</div><div>#include &quot;vtkRenderWindowInteractor.h&quot;</div><div>#include &quot;vtkRenderer.h&quot;</div>


<div><br></div><div>int main()</div><div>{</div><div>  int i;</div><div>  static float x[8][3]={{0,0,0}, {1,0,0}, {1,1,0}, {0,1,0},</div><div>                        {0,0,1}, {1,0,1}, {1,1,1}, {0,1,1}};</div><div>  static vtkIdType pts[6][4]={{0,1,2,3}, {4,5,6,7}, {0,1,5,4},</div>


<div>                        {1,2,6,5}, {2,3,7,6}, {3,0,4,7}};</div><div><br></div><div>  // We&#39;ll create the building blocks of polydata including data attributes.</div><div>  vtkPolyData *cube = vtkPolyData::New();</div>


<div>  vtkPoints *points = vtkPoints::New();</div><div>  vtkCellArray *polys = vtkCellArray::New();</div><div>  vtkFloatArray *scalars = vtkFloatArray::New();</div><div><br></div><div>  // Load the point, cell, and data attributes.</div>


<div>  for (i=0; i&lt;8; i++) points-&gt;InsertPoint(i,x[i]);</div><div>  for (i=0; i&lt;6; i++) polys-&gt;InsertNextCell(4,pts[i]);</div><div>  for (i=0; i&lt;8; i++) scalars-&gt;InsertTuple1(i,i);</div><div><br></div><div>


  // We now assign the pieces to the vtkPolyData.</div><div>  cube-&gt;SetPoints(points);</div><div>  points-&gt;Delete();</div><div>  cube-&gt;SetPolys(polys);</div><div>  polys-&gt;Delete();</div><div>  cube-&gt;GetPointData()-&gt;SetScalars(scalars);</div>


<div>  scalars-&gt;Delete();</div><div><br></div><div>  // Now we&#39;ll look at it.</div><div>  vtkPolyDataMapper *cubeMapper = vtkPolyDataMapper::New();</div><div>      cubeMapper-&gt;SetInputData(cube);</div><div>      cubeMapper-&gt;SetScalarRange(0,7);</div>


<div>  vtkActor *cubeActor = vtkActor::New();</div><div>      cubeActor-&gt;SetMapper(cubeMapper);</div><div><br></div><div>  // The usual rendering stuff.</div><div>  vtkCamera *camera = vtkCamera::New();</div><div>      camera-&gt;SetPosition(1,1,1);</div>


<div>      camera-&gt;SetFocalPoint(0,0,0);</div><div><br></div><div>  vtkRenderer *renderer = vtkRenderer::New();</div><div>  vtkRenderWindow *renWin = vtkRenderWindow::New();</div><div>    renWin-&gt;AddRenderer(renderer);</div>


<div><br></div><div>  vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();</div><div>    iren-&gt;SetRenderWindow(renWin);</div><div><br></div><div>  renderer-&gt;AddActor(cubeActor);</div><div>      renderer-&gt;SetActiveCamera(camera);</div>


<div>      renderer-&gt;ResetCamera();</div><div>      renderer-&gt;SetBackground(1,1,1);</div><div><br></div><div>  renWin-&gt;SetSize(300,300);</div><div><br></div><div>  // interact with data</div><div>  renWin-&gt;Render();</div>


<div>  iren-&gt;Start();</div><div><br></div><div>  // Clean up</div><div><br></div><div>  cube-&gt;Delete();</div><div>  cubeMapper-&gt;Delete();</div><div>  cubeActor-&gt;Delete();</div><div>  camera-&gt;Delete();</div>


<div>  renderer-&gt;Delete();</div><div>  renWin-&gt;Delete();</div><div>  iren-&gt;Delete();</div><div><br></div><div>  return 0;</div><div>}</div></div><div><img src="cid:ii_14117db204d78f8b" alt="内嵌图片 1"><br></div></div>


<div class="gmail_extra"><div><div><br><br><div class="gmail_quote">2013/9/13 Utkarsh Ayachit <span dir="ltr">&lt;<a href="mailto:utkarsh.ayachit@kitware.com" target="_blank">utkarsh.ayachit@kitware.com</a>&gt;</span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Float arrays cannot be directly mapped to colors. They need a LUT to<br>
convert to color. If you want to pass RGB colors, create a<br>
vtkUnsignedCharArray with 3 components instead. Then VTK can render<br>
those colors directly without mapping.<br>
<div><div><br>
On Fri, Sep 13, 2013 at 10:55 AM, 庞庆源 &lt;<a href="mailto:pangqingyuan1991@gmail.com" target="_blank">pangqingyuan1991@gmail.com</a>&gt; wrote:<br>
&gt; scalararray is vtkFloatArray.I only call<br>
&gt; pointScalars-&gt;InsertTuple1(myId,velocity) for every point.never call<br>
&gt; SetNumberOfComponents();Is it the problem?<br>
&gt;<br>
&gt;<br>
&gt; 2013/9/13 Utkarsh Ayachit &lt;<a href="mailto:utkarsh.ayachit@kitware.com" target="_blank">utkarsh.ayachit@kitware.com</a>&gt;<br>
&gt;&gt;<br>
&gt;&gt; WHat is the type of scalar array? If it&#39;s not an unsigned char array with<br>
&gt;&gt; 3 or 4 components, VTK will use a lookuptable to map the scalar to colors.<br>
&gt;&gt;<br>
&gt;&gt; Utkarsh<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Fri, Sep 13, 2013 at 8:52 AM, 庞庆源 &lt;<a href="mailto:pangqingyuan1991@gmail.com" target="_blank">pangqingyuan1991@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I write a simple reader,inheriting from vtkPolyDataAlgorithm.But<br>
&gt;&gt;&gt; SetScalars() cannot color the plane.When I test it use general vtk<br>
&gt;&gt;&gt; polydata-&gt;mapper-&gt;actor-&gt;renderer-&gt;renderwindow,I can see different color at<br>
&gt;&gt;&gt; different point.Does someone know the reason?Thank you.<br>
&gt;&gt;&gt; --<br>
&gt;&gt;&gt; 庞庆源<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Visit other Kitware open-source projects at<br>
&gt;&gt;&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Please keep messages on-topic and check the ParaView Wiki at:<br>
&gt;&gt;&gt; <a href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Follow this link to subscribe/unsubscribe:<br>
&gt;&gt;&gt; <a href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; 庞庆源<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div></div></div><span><font color="#888888">-- <br><font face="arial, helvetica, sans-serif" size="6" color="#33ff33"><a href="mailto:pangqingyuan1991@gmail.com" target="_blank">庞庆源<span></span><span></span></a></font>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><font face="arial, helvetica, sans-serif" size="6" color="#33ff33"><a href="mailto:pangqingyuan1991@gmail.com" target="_blank">庞庆源<span></span><span></span></a></font>
</font></span></div>
</blockquote></div><br></div>