<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<style>
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 77.95pt 72.0pt 77.95pt;}
div.Section1
        {page:Section1;}
-->
</style>
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoPlainText><font size=2 face="Courier New"><span lang=FR-CA
style='font-size:10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span lang=FR-CA
style='font-size:10.0pt'>Hi vtkUsers,<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span lang=FR-CA
style='font-size:10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'>I'm trying to animate my unstructuredgrid by modifying the scalars. When
I update the unstructured grid the result shown is not correct.<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'>I'm using vtkAnimationScene and vtkAnimationCue for the animation.<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'>I would like know if I'm missing any thing in this code:<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'>// the unstructured grid was created like this<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'>void CGLModelViewCtrl::CreateModel(void)<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'>{ <o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'>m_pUnstructuredGrid = vtkUnstructuredGrid::New();<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> // We now assign the pieces to the
vtkPolyData.<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> vtkPolyData* theModel =
vtkPolyData::New();<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> theModel->SetPolys(m_pPolys);<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> vtkIdList *pIds = vtkIdList::New();<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> for (int i=0; i<theModel->GetNumberOfCells();
++i) <o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> pIds->InsertNextId(i);<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> for (i=0; i<
theModel->GetNumberOfCells(); ++i) <o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> {<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> theModel->GetCellPoints(i,
pIds);<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> m_pUnstructuredGrid->InsertNextCell(VTK_TETRA,pIds);<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> }<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> m_pUnstructuredGrid->SetPoints(m_pPoints);<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> if(m_PlotType == VECTORPLOT)<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> m_pUnstructuredGrid->GetPointData()->SetVectors(m_pVectors);<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> else<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> m_pUnstructuredGrid->GetPointData()->SetScalars(m_pScalars);<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> .................<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> // convert from unstructuredGrid to
PolyData<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> vtkGeometryFilter *extract =
vtkGeometryFilter::New(); <o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> extract->SetInput(m_pUnstructuredGrid);<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> extract->GetOutput()->ReleaseDataFlagOn();<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> vtkPolyDataNormals * normals =
vtkPolyDataNormals::New(); // none<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> normals->SetInputConnection(extract->GetOutputPort());<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> normals->SetFeatureAngle(60.0);<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> normals->GetOutput()->ReleaseDataFlagOn();<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> vtkStripper* stripper =
vtkStripper::New(); // none<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> stripper->SetInputConnection(normals->GetOutputPort());<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> vtkDataSetMapper *contourMapper =
vtkDataSetMapper::New();<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> contourMapper->SetInputConnection(stripper->GetOutputPort());<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> ...............<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> m_pContinuousFringeActor = vtkActor::New();<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> m_pContinuousFringeActor->SetMapper(contourMapper);<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> // add to rendering<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> m_prenderer->AddViewProp(m_pContinuousFringeActor);<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'>}<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'>// the animation function:<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'>void Tick(vtkAnimationCue::AnimationCueInfo* info, vtkRenderer* ren)<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'>{<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> if(!m_pUnstructuredGrid)<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> {<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> AfxMessageBox(_T("
Cue --> No data to plot"));<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> return;<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> }<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> <b><span style='font-weight:bold'>vtkDoubleArray*
pScalars =
(vtkDoubleArray*)(m_pUnstructuredGrid->GetPointData()->GetScalars());<o:p></o:p></span></b></span></font></p>
<p class=MsoPlainText><b><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-weight:bold'><o:p> </o:p></span></font></b></p>
<p class=MsoPlainText><b><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-weight:bold'> double
aNodeValue = 0;<o:p></o:p></span></font></b></p>
<p class=MsoPlainText><b><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-weight:bold'><o:p> </o:p></span></font></b></p>
<p class=MsoPlainText><b><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-weight:bold'> int
step = (int)(info->AnimationTime) - 1; <o:p></o:p></span></font></b></p>
<p class=MsoPlainText><b><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-weight:bold'> <o:p></o:p></span></font></b></p>
<p class=MsoPlainText><b><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-weight:bold'> double*
pPlotData = m_plotDataArray->GetAt(step);<o:p></o:p></span></font></b></p>
<p class=MsoPlainText><b><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-weight:bold'><o:p> </o:p></span></font></b></p>
<p class=MsoPlainText><b><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-weight:bold'> for(long
i = 0; i < m_Size; ++i)<o:p></o:p></span></font></b></p>
<p class=MsoPlainText><b><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-weight:bold'> {<o:p></o:p></span></font></b></p>
<p class=MsoPlainText><b><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-weight:bold'> if(pPlotData)<o:p></o:p></span></font></b></p>
<p class=MsoPlainText><b><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-weight:bold'> {<o:p></o:p></span></font></b></p>
<p class=MsoPlainText><b><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-weight:bold'> aNodeValue
= pPlotData[i];<o:p></o:p></span></font></b></p>
<p class=MsoPlainText><b><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-weight:bold'> pScalars->SetValue(i,
aNodeValue); <o:p></o:p></span></font></b></p>
<p class=MsoPlainText><b><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-weight:bold'> }<o:p></o:p></span></font></b></p>
<p class=MsoPlainText><b><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-weight:bold'> }<o:p></o:p></span></font></b></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> <b><span style='font-weight:bold'>pScalars->Modified();<o:p></o:p></span></b></span></font></p>
<p class=MsoPlainText><b><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-weight:bold'> m_pUnstructuredGrid->Modified;<o:p></o:p></span></font></b></p>
<p class=MsoPlainText><b><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-weight:bold'><o:p> </o:p></span></font></b></p>
<p class=MsoPlainText><b><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-weight:bold'> this->Actor->GetMapper()->GetInput()->Modified();<o:p></o:p></span></font></b></p>
<p class=MsoPlainText><b><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-weight:bold'> ren->Render();<o:p></o:p></span></font></b></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'> }<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'>Thanks.<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'>Naim Himrane<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt;color:black'>Electromagneticworks inc.<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt;color:black'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
</div>
</body>
</html>