[vtkusers] Object size differs with two vtk actors
Gishara Indeewarie
gish.777 at gmail.com
Wed Jun 13 08:07:53 EDT 2012
Hi all,
I have a vtk render window where I am creating a surface using
vtkVoxelContoursToSurfaceFilter and display.
The surface displays well.
I want to add another vtk object which defines the outline of the surface.
I created it using vtk lines.
My problem is that when I add the second one, the first object becomes very
small,(not the actual size)
How could I fix this issue?
Below is a part of my code demonstrate the problem.
vtkSmartPointer<vtkCellArray> cells =
vtkSmartPointer<vtkCellArray>::New();
for (int i=0; i< (t_val-1) ;i++){
for (int j=0; j< (n+m-2);j++){
cells->InsertNextCell(4);
cells->InsertCellPoint((i*(n+m-1))+j);
cells->InsertCellPoint((i*(n+m-1))+(j+1));
cells->InsertCellPoint(((i+1)*(n+m-1))+(j+1));
cells->InsertCellPoint(((i+1)*(n+m-1)) +j);
}
}
vtkSmartPointer<vtkPolyData> poly = vtkSmartPointer<vtkPolyData>::New();
poly->SetPoints(points);
poly->SetPolys(cells);
CArray <double,double> *ScalarValues =
doc->get_CFD_ScalarValues(pAirfoil,m_value);
poly->GetPointData()->SetScalars(weights);
vtkSmartPointer<vtkVoxelContoursToSurfaceFilter> contoursToSurface =
vtkSmartPointer<vtkVoxelContoursToSurfaceFilter>::New();
contoursToSurface->SetInput(poly);
vtkSmartPointer<vtkPoints> points_sections =
vtkSmartPointer<vtkPoints>::New();
vtkSmartPointer<vtkCellArray> cells_sections =
vtkSmartPointer<vtkCellArray>::New();
vtkSmartPointer<vtkPolyData> polyData_sections =
vtkSmartPointer<vtkPolyData>::New();
polyData_sections->Allocate();
connectivity = new vtkIdType[a+b];
for(unsigned int c = 0; c < (a+b); c++)
{
connectivity[c] = c+i*(a+b);
}
polyData_sections->InsertNextCell(VTK_LINE,(a+b),connectivity);
}
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(poly->GetProducerPort());
mapper->ScalarVisibilityOn();
mapper->SetColorModeToMapScalars();
mapper->SetLookupTable(colorLookupTable);
mapper->SetScalarMaterialModeToDefault();
mapper->SetScalarRange(min,max);
polyData_sections->SetPoints(points_sections);
vtkSmartPointer<vtkPolyDataMapper> mapper_sections =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper_sections->SetInput(polyData_sections);
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
actor->Modified();
vtkSmartPointer<vtkActor> actor_sections =
vtkSmartPointer<vtkActor>::New();
actor_sections->SetMapper(mapper_sections);
actor_sections->GetProperty()->SetColor(255, 0, 0);
actor_sections->Modified();
renderer->RemoveAllViewProps();
renderer->Modified();
renderer->AddActor(actor);
renderer->AddActor(actor_sections);
renderer->ResetCamera();
renderer->SetBackground(1,1,1);
renderer->ResetCamera();
renWin->Render();
Please help me.
Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120613/85d812fb/attachment.htm>
More information about the vtkusers
mailing list