[vtkusers] vtkusers Digest, Vol 51, Issue 23
Li Ganhua
liganhua at gmail.com
Fri Jul 25 09:06:57 EDT 2008
Hi, Every one,
I have read a data set with Plot3D format. But after I change the value
of the dataset, I cannot update the 3D modle in the render windows. How can
I update the model in the render window? Please help me!
Best regards,
Edward Li
My code is as shown as below:
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkFloatArray.h"
#include "vtkRectilinearGrid.h"
#include "vtkRectilinearGridGeometryFilter.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkProperty.h"
#include "vtkCamera.h"
#include "vtkPlot3DReader.h"
#include "vtkStructuredGrid.h"
#include "vtkContourFilter.h"
#include "vtkPolyDataNormals.h"
#include "vtkPolyDataMapper.h"
#include "vtkLODActor.h"
#include "vtkDataArray.h"
#include "vtkPointData.h"
#include "vtkStructuredGridOutlineFilter.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkScalarBarActor.h"
int main()
{
vtkPLOT3DReader *pl3d = vtkPLOT3DReader::New();
pl3d->BinaryFileOn();
pl3d->SetXYZFileName("combxyz.bin");
pl3d->SetQFileName("combq.bin");
pl3d->SetScalarFunctionNumber(100);
pl3d->SetVectorFunctionNumber(202);
pl3d->AddFunction(153);
pl3d->Update();
pl3d->DebugOn();
vtkStructuredGrid* output=pl3d->GetOutput();
vtkContourFilter* iso=vtkContourFilter::New();
iso->SetInput(output);
iso->SetValue(1,0.24);
vtkPolyDataNormals* normals=vtkPolyDataNormals::New();
normals->SetInput(iso->GetOutput());
normals->SetFeatureAngle( 45);
vtkPolyDataMapper* isoMapper=vtkPolyDataMapper::New();
isoMapper->SetInput(normals->GetOutput());
isoMapper->ScalarVisibilityOn();
isoMapper->SetScalarRange(0, 1500);
isoMapper->SetScalarModeToUsePointFieldData();
isoMapper->ColorByArrayComponent(2, 0);
vtkLODActor* isoActor=vtkLODActor::New();
isoActor->SetMapper(isoMapper);
isoActor->SetNumberOfCloudPoints(1000);
isoActor->GetProperty()->SetRepresentation(1);
vtkStructuredGridOutlineFilter*
outline=vtkStructuredGridOutlineFilter::New();
outline->SetInput(pl3d->GetOutput());
vtkPolyDataMapper* outlineMapper=vtkPolyDataMapper::New();;
outlineMapper->SetInput(outline->GetOutput());
vtkActor* outlineActor=vtkActor::New();
outlineActor->SetMapper(outlineMapper);
vtkRenderer* ren1=vtkRenderer::New();
vtkRenderWindow* renWin=vtkRenderWindow::New();
renWin->AddRenderer(ren1);
vtkRenderWindowInteractor* iren=vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
ren1->AddActor(outlineActor);
ren1->AddActor(isoActor);
ren1->SetBackground(1, 1, 1);
renWin->SetSize(500, 500);
ren1->SetBackground(0.1, 0.2, 0.4);
ren1->GetActiveCamera()->SetClippingRange(3.95297,50);
ren1->GetActiveCamera()->SetFocalPoint(9.71821, 0.458166, 29.3999);
ren1->GetActiveCamera()->SetPosition(2.7439, -37.3196, 38.7167);
ren1->GetActiveCamera()->SetViewUp(-0.16123, 0.264271, 0.950876);
int tupleMin,tupleMax,compMin,compmax;
vtkPoints *pd=output->GetPoints();
renWin->Render();
double temp;
int tumpleNum=pd->GetNumberOfPoints();
double x[3];
for(int j=0;j<100;j++)
{
for(int i=0;i<tumpleNum/5;i++)
{
pd->GetPoint(i,x);
x[0]=x[0]+10;
pd->SetPoint(i,x);
}
int debug=1;
output->Update();
output->UpdateData();
renWin->Render();
}
iren->Start();
ren1->Delete();
renWin->Delete();
outlineActor->Delete();
outlineMapper->Delete();
outline->Delete();
isoActor->Delete();
isoMapper->Delete();
normals->Delete();
iso->Delete();
pl3d->Delete();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080725/23e1fdb0/attachment.htm>
More information about the vtkusers
mailing list