<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"><<a href="mailto:pangqingyuan1991@gmail.com" target="_blank">pangqingyuan1991@gmail.com</a>></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"><<a href="mailto:pangqingyuan1991@gmail.com" target="_blank">pangqingyuan1991@gmail.com</a>></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 "vtkActor.h"</div>
<div>#include "vtkCamera.h"</div><div>#include "vtkCellArray.h"</div><div>#include "vtkFloatArray.h"</div><div>#include "vtkPointData.h"</div><div>#include "vtkPoints.h"</div>
<div>#include "vtkPolyData.h"</div><div>#include "vtkPolyDataMapper.h"</div><div>#include "vtkRenderWindow.h"</div><div>#include "vtkRenderWindowInteractor.h"</div><div>#include "vtkRenderer.h"</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'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<8; i++) points->InsertPoint(i,x[i]);</div><div> for (i=0; i<6; i++) polys->InsertNextCell(4,pts[i]);</div><div> for (i=0; i<8; i++) scalars->InsertTuple1(i,i);</div><div><br></div><div>
// We now assign the pieces to the vtkPolyData.</div><div> cube->SetPoints(points);</div><div> points->Delete();</div><div> cube->SetPolys(polys);</div><div> polys->Delete();</div><div> cube->GetPointData()->SetScalars(scalars);</div>
<div> scalars->Delete();</div><div><br></div><div> // Now we'll look at it.</div><div> vtkPolyDataMapper *cubeMapper = vtkPolyDataMapper::New();</div><div> cubeMapper->SetInputData(cube);</div><div> cubeMapper->SetScalarRange(0,7);</div>
<div> vtkActor *cubeActor = vtkActor::New();</div><div> cubeActor->SetMapper(cubeMapper);</div><div><br></div><div> // The usual rendering stuff.</div><div> vtkCamera *camera = vtkCamera::New();</div><div> camera->SetPosition(1,1,1);</div>
<div> camera->SetFocalPoint(0,0,0);</div><div><br></div><div> vtkRenderer *renderer = vtkRenderer::New();</div><div> vtkRenderWindow *renWin = vtkRenderWindow::New();</div><div> renWin->AddRenderer(renderer);</div>
<div><br></div><div> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();</div><div> iren->SetRenderWindow(renWin);</div><div><br></div><div> renderer->AddActor(cubeActor);</div><div> renderer->SetActiveCamera(camera);</div>
<div> renderer->ResetCamera();</div><div> renderer->SetBackground(1,1,1);</div><div><br></div><div> renWin->SetSize(300,300);</div><div><br></div><div> // interact with data</div><div> renWin->Render();</div>
<div> iren->Start();</div><div><br></div><div> // Clean up</div><div><br></div><div> cube->Delete();</div><div> cubeMapper->Delete();</div><div> cubeActor->Delete();</div><div> camera->Delete();</div>
<div> renderer->Delete();</div><div> renWin->Delete();</div><div> iren->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"><<a href="mailto:utkarsh.ayachit@kitware.com" target="_blank">utkarsh.ayachit@kitware.com</a>></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, 庞庆源 <<a href="mailto:pangqingyuan1991@gmail.com" target="_blank">pangqingyuan1991@gmail.com</a>> wrote:<br>
> scalararray is vtkFloatArray.I only call<br>
> pointScalars->InsertTuple1(myId,velocity) for every point.never call<br>
> SetNumberOfComponents();Is it the problem?<br>
><br>
><br>
> 2013/9/13 Utkarsh Ayachit <<a href="mailto:utkarsh.ayachit@kitware.com" target="_blank">utkarsh.ayachit@kitware.com</a>><br>
>><br>
>> WHat is the type of scalar array? If it's not an unsigned char array with<br>
>> 3 or 4 components, VTK will use a lookuptable to map the scalar to colors.<br>
>><br>
>> Utkarsh<br>
>><br>
>><br>
>> On Fri, Sep 13, 2013 at 8:52 AM, 庞庆源 <<a href="mailto:pangqingyuan1991@gmail.com" target="_blank">pangqingyuan1991@gmail.com</a>> wrote:<br>
>>><br>
>>><br>
>>> I write a simple reader,inheriting from vtkPolyDataAlgorithm.But<br>
>>> SetScalars() cannot color the plane.When I test it use general vtk<br>
>>> polydata->mapper->actor->renderer->renderwindow,I can see different color at<br>
>>> different point.Does someone know the reason?Thank you.<br>
>>> --<br>
>>> 庞庆源<br>
>>><br>
>>> _______________________________________________<br>
>>> Powered by <a href="http://www.kitware.com" 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" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>>><br>
>>> Please keep messages on-topic and check the ParaView Wiki at:<br>
>>> <a href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
>>><br>
>>> Follow this link to subscribe/unsubscribe:<br>
>>> <a href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
>>><br>
>><br>
><br>
><br>
><br>
> --<br>
> 庞庆源<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>