Commit fd04b442 authored by Andrew Bauer's avatar Andrew Bauer
Browse files

Improvements for vtkNew for stl containers and comparison operations

Adding in functionality to allow inserting vtkNew objects into
stl containers of vtkSmartPointer objects as well as comparisons
between vtkNew objects and raw pointers. Also removing Get() and
GetPointer() calls from vtkNew objects since in most instances we
can just pass in the vtkNew<> object instead of having to use the
Get() or GetPointer() methods to get the raw pointer.
parent 459017a8
......@@ -43,21 +43,21 @@ int TestVTKMCleanGrid(int argc, char *argv[])
mapper->SetScalarRange(37, 277);
vtkNew<vtkActor> actor;
actor->SetMapper(mapper.GetPointer());
actor->SetMapper(mapper);
vtkNew<vtkRenderer> renderer;
renderer->AddActor(actor.GetPointer());
renderer->AddActor(actor);
renderer->ResetCamera();
vtkNew<vtkRenderWindow> renWin;
renWin->AddRenderer(renderer.GetPointer());
renWin->AddRenderer(renderer);
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renWin.GetPointer());
iren->SetRenderWindow(renWin);
iren->Initialize();
renWin->Render();
int retVal = vtkRegressionTestImage(renWin.GetPointer());
int retVal = vtkRegressionTestImage(renWin);
if (retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
......
......@@ -51,7 +51,7 @@ void GenerateScalars(DataSetT *dataset, bool negate)
scalars->SetTypedComponent(i, 0, (negate ?-point[0] - point[1]
: point[0] + point[1]));
}
dataset->GetPointData()->SetScalars(scalars.Get());
dataset->GetPointData()->SetScalars(scalars);
}
} // end anon namespace
......@@ -86,10 +86,10 @@ int TestVTKMClip(int, char*[])
sphereMapper->SetScalarRange(0, 1);
vtkNew<vtkActor> sphereActor;
sphereActor->SetMapper(sphereMapper.Get());
sphereActor->SetMapper(sphereMapper);
sphereActor->SetPosition(0.5, 0.5, 0.);
sphereActor->RotateWXYZ(90., 0., 0., 1.);
renderer->AddActor(sphereActor.Get());
renderer->AddActor(sphereActor);
// Second input is an unstructured grid with 3D cells. This should produce an
// unstructured grid output from vtkmClip.
......@@ -124,9 +124,9 @@ int TestVTKMClip(int, char*[])
tetMapper->SetScalarRange(0, 10);
vtkNew<vtkActor> tetActor;
tetActor->SetMapper(tetMapper.Get());
tetActor->SetMapper(tetMapper);
tetActor->SetScale(1. / 5.);
renderer->AddActor(tetActor.Get());
renderer->AddActor(tetActor);
// Third dataset tests imagedata. This should produce an unstructured grid:
vtkImageData *image = imageSource->GetOutput();
......@@ -148,16 +148,16 @@ int TestVTKMClip(int, char*[])
imageMapper->SetScalarRange(0, 10);
vtkNew<vtkActor> imageActor;
imageActor->SetMapper(imageMapper.Get());
imageActor->SetMapper(imageMapper);
imageActor->SetScale(1. / 5.);
imageActor->SetPosition(1.0, 1.0, 0.);
renderer->AddActor(imageActor.Get());
renderer->AddActor(imageActor);
vtkNew<vtkRenderWindowInteractor> iren;
vtkNew<vtkRenderWindow> renWin;
renWin->SetMultiSamples(0);
iren->SetRenderWindow(renWin.Get());
renWin->AddRenderer(renderer.Get());
iren->SetRenderWindow(renWin);
renWin->AddRenderer(renderer);
renWin->SetSize(500,500);
renderer->GetActiveCamera()->SetPosition(0,0,1);
......
......@@ -40,7 +40,7 @@ int TestVTKMClipWithImplicitFunction(int argc, char* argv[])
sphere->SetRadius(10);
vtkNew<vtkmClip> clip;
clip->SetInputConnection(wavelet->GetOutputPort());
clip->SetClipFunction(sphere.GetPointer());
clip->SetClipFunction(sphere);
vtkNew<vtkDataSetSurfaceFilter> surface;
surface->SetInputConnection(clip->GetOutputPort());
......@@ -50,21 +50,21 @@ int TestVTKMClipWithImplicitFunction(int argc, char* argv[])
mapper->SetScalarRange(37, 150);
vtkNew<vtkActor> actor;
actor->SetMapper(mapper.GetPointer());
actor->SetMapper(mapper);
vtkNew<vtkRenderer> renderer;
renderer->AddActor(actor.GetPointer());
renderer->AddActor(actor);
renderer->ResetCamera();
vtkNew<vtkRenderWindow> renWin;
renWin->AddRenderer(renderer.GetPointer());
renWin->AddRenderer(renderer);
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renWin.GetPointer());
iren->SetRenderWindow(renWin);
iren->Initialize();
renWin->Render();
int retVal = vtkRegressionTestImage(renWin.GetPointer());
int retVal = vtkRegressionTestImage(renWin);
if (retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
......
......@@ -78,7 +78,7 @@ int TestVTKMExternalFaces(int argc, char* argv[])
cylinder->SetAxis(0, 1, 0);
vtkNew<vtkTableBasedClipDataSet> clipCyl;
clipCyl->SetInputConnection(wavelet->GetOutputPort());
clipCyl->SetClipFunction(cylinder.GetPointer());
clipCyl->SetClipFunction(cylinder);
clipCyl->InsideOutOn();
vtkNew<vtkSphere> sphere;
......@@ -86,13 +86,13 @@ int TestVTKMExternalFaces(int argc, char* argv[])
sphere->SetRadius(12);
vtkNew<vtkTableBasedClipDataSet> clipSphr;
clipSphr->SetInputConnection(clipCyl->GetOutputPort());
clipSphr->SetClipFunction(sphere.GetPointer());
clipSphr->SetClipFunction(sphere);
vtkNew<vtkTransform> transform;
transform->RotateZ(45);
vtkNew<vtkTransformFilter> transFilter;
transFilter->SetInputConnection(clipSphr->GetOutputPort());
transFilter->SetTransform(transform.GetPointer());
transFilter->SetTransform(transform);
vtkNew<vtkRandomAttributeGenerator> cellDataAdder;
cellDataAdder->SetInputConnection(transFilter->GetOutputPort());
......@@ -130,7 +130,7 @@ int TestVTKMExternalFaces(int argc, char* argv[])
}
vtkNew<vtkPolyData> polydata;
if (!Convert2DUnstructuredGridToPolyData(result, polydata.GetPointer()))
if (!Convert2DUnstructuredGridToPolyData(result, polydata))
{
std::cout << "Error converting result to polydata\n";
return 1;
......@@ -142,25 +142,25 @@ int TestVTKMExternalFaces(int argc, char* argv[])
polydata->GetPointData()->GetArray("RTData")->GetRange(scalarRange);
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputData(polydata.GetPointer());
mapper->SetInputData(polydata);
mapper->SetScalarRange(scalarRange);
vtkNew<vtkActor> actor;
actor->SetMapper(mapper.GetPointer());
actor->SetMapper(mapper);
vtkNew<vtkRenderer> renderer;
renderer->AddActor(actor.GetPointer());
renderer->AddActor(actor);
renderer->ResetCamera();
vtkNew<vtkRenderWindow> renWin;
renWin->AddRenderer(renderer.GetPointer());
renWin->AddRenderer(renderer);
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renWin.GetPointer());
iren->SetRenderWindow(renWin);
iren->Initialize();
renWin->Render();
int retVal = vtkRegressionTestImage(renWin.GetPointer());
int retVal = vtkRegressionTestImage(renWin);
if (retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
......
......@@ -38,7 +38,7 @@ int TestVTKMExtractVOI(int argc, char* argv[])
sphereMapper->ImmediateModeRenderingOn();
vtkNew<vtkActor> sphereActor;
sphereActor->SetMapper(sphereMapper.GetPointer());
sphereActor->SetMapper(sphereMapper);
vtkNew<vtkRTAnalyticSource> rt;
rt->SetWholeExtent(-50, 50, -50, 50, 0, 0);
......@@ -61,22 +61,22 @@ int TestVTKMExtractVOI(int argc, char* argv[])
mapper->SetScalarRange(130, 280);
vtkNew<vtkActor> actor;
actor->SetMapper(mapper.GetPointer());
actor->SetMapper(mapper);
vtkNew<vtkRenderer> renderer;
renderer->AddActor(actor.GetPointer());
renderer->AddActor(sphereActor.GetPointer());
renderer->AddActor(actor);
renderer->AddActor(sphereActor);
renderer->ResetCamera();
vtkNew<vtkRenderWindow> renWin;
renWin->AddRenderer(renderer.GetPointer());
renWin->AddRenderer(renderer);
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renWin.GetPointer());
iren->SetRenderWindow(renWin);
iren->Initialize();
renWin->Render();
int retVal = vtkRegressionTestImage(renWin.GetPointer());
int retVal = vtkRegressionTestImage(renWin);
if (retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
......
......@@ -41,8 +41,8 @@ int TestVTKMLevelOfDetail(int argc, char *argv[])
vtkNew<vtkRenderWindow> renWin;
vtkNew<vtkRenderWindowInteractor> iren;
renWin->AddRenderer(ren.GetPointer());
iren->SetRenderWindow(renWin.GetPointer());
renWin->AddRenderer(ren);
iren->SetRenderWindow(renWin);
//---------------------------------------------------
// Load file and make only triangles
......@@ -80,10 +80,10 @@ int TestVTKMLevelOfDetail(int argc, char *argv[])
mappers[i]->SetInputConnection(surfaces[i]->GetOutputPort());
actors[i]->SetMapper(mappers[i].GetPointer());
actors[i]->SetMapper(mappers[i]);
actors[i]->SetPosition( i * 10, 0, 0);
ren->AddActor(actors[i].GetPointer());
ren->AddActor(actors[i]);
}
ren->SetBackground(0.1, 0.2, 0.4);
......@@ -93,7 +93,7 @@ int TestVTKMLevelOfDetail(int argc, char *argv[])
renWin->Render();
int retVal = vtkRegressionTestImage(renWin.GetPointer());
int retVal = vtkRegressionTestImage(renWin);
if(retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
......
......@@ -37,8 +37,8 @@ int RunVTKPipeline(T *t, int argc, char* argv[])
vtkNew<vtkRenderWindow> renWin;
vtkNew<vtkRenderWindowInteractor> iren;
renWin->AddRenderer(ren.GetPointer());
iren->SetRenderWindow(renWin.GetPointer());
renWin->AddRenderer(ren);
iren->SetRenderWindow(renWin);
vtkNew<vtkmContour> cubes;
......@@ -58,13 +58,13 @@ int RunVTKPipeline(T *t, int argc, char* argv[])
mapper->SetScalarRange(0.0, 1.0);
vtkNew<vtkActor> actor;
actor->SetMapper(mapper.GetPointer());
actor->SetMapper(mapper);
ren->AddActor(actor.GetPointer());
ren->AddActor(actor);
ren->ResetCamera();
renWin->Render();
int retVal = vtkRegressionTestImage(renWin.GetPointer());
int retVal = vtkRegressionTestImage(renWin);
if(retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
......
......@@ -35,8 +35,8 @@ int TestVTKMMarchingCubes2(int argc, char* argv[])
vtkNew<vtkRenderWindow> renWin;
vtkNew<vtkRenderWindowInteractor> iren;
renWin->AddRenderer(ren.GetPointer());
iren->SetRenderWindow(renWin.GetPointer());
renWin->AddRenderer(ren);
iren->SetRenderWindow(renWin);
vtkNew<vtkRTAnalyticSource> imageSource;
imageSource->SetWholeExtent(-EXTENT, EXTENT, -EXTENT, EXTENT, -EXTENT, EXTENT);
......@@ -63,13 +63,13 @@ int TestVTKMMarchingCubes2(int argc, char* argv[])
mapper->SetScalarRange(0.0, 1.0);
vtkNew<vtkActor> actor;
actor->SetMapper(mapper.GetPointer());
actor->SetMapper(mapper);
ren->AddActor(actor.GetPointer());
ren->AddActor(actor);
ren->ResetCamera();
renWin->Render();
int retVal = vtkRegressionTestImage(renWin.GetPointer());
int retVal = vtkRegressionTestImage(renWin);
if(retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
......
......@@ -62,25 +62,25 @@ void MakeInputDataSet(vtkPolyData *ds)
int TestVTKMPolyDataNormals(int argc, char* argv[])
{
vtkNew<vtkPolyData> input;
MakeInputDataSet(input.GetPointer());
MakeInputDataSet(input);
vtkNew<vtkmPolyDataNormals> normals;
normals->SetInputData(input.GetPointer());
normals->SetInputData(input);
normals->ComputePointNormalsOn();
normals->ComputeCellNormalsOn();
// cylinder mapper and actor
vtkNew<vtkPolyDataMapper> cylinderMapper;
cylinderMapper->SetInputData(input.GetPointer());
cylinderMapper->SetInputData(input);
vtkNew<vtkActor> cylinderActor;
cylinderActor->SetMapper(cylinderMapper.GetPointer());
cylinderActor->SetMapper(cylinderMapper);
vtkSmartPointer<vtkProperty> cylinderProperty;
cylinderProperty.TakeReference(cylinderActor->MakeProperty());
cylinderProperty->SetRepresentationToWireframe();
cylinderProperty->SetColor(0.3, 0.3, 0.3);
cylinderActor->SetProperty(cylinderProperty.GetPointer());
cylinderActor->SetProperty(cylinderProperty);
vtkNew<vtkArrowSource> arrow;
......@@ -97,11 +97,11 @@ int TestVTKMPolyDataNormals(int argc, char* argv[])
pnMapper->SetInputConnection(pnGlyphs->GetOutputPort());
vtkNew<vtkActor> pnActor;
pnActor->SetMapper(pnMapper.GetPointer());
pnActor->SetMapper(pnMapper);
vtkNew<vtkRenderer> pnRenderer;
pnRenderer->AddActor(cylinderActor.GetPointer());
pnRenderer->AddActor(pnActor.GetPointer());
pnRenderer->AddActor(cylinderActor);
pnRenderer->AddActor(pnActor);
pnRenderer->ResetCamera();
pnRenderer->GetActiveCamera()->SetPosition(0.0, 4.5, 7.5);
......@@ -121,11 +121,11 @@ int TestVTKMPolyDataNormals(int argc, char* argv[])
cnMapper->SetInputConnection(cnGlyphs->GetOutputPort());
vtkNew<vtkActor> cnActor;
cnActor->SetMapper(cnMapper.GetPointer());
cnActor->SetMapper(cnMapper);
vtkNew<vtkRenderer> cnRenderer;
cnRenderer->AddActor(cylinderActor.GetPointer());
cnRenderer->AddActor(cnActor.GetPointer());
cnRenderer->AddActor(cylinderActor);
cnRenderer->AddActor(cnActor);
cnRenderer->ResetCamera();
cnRenderer->GetActiveCamera()->SetPosition(0.0, 8.0, 0.1);
......@@ -134,16 +134,16 @@ int TestVTKMPolyDataNormals(int argc, char* argv[])
vtkNew<vtkRenderWindow> renWin;
renWin->SetSize(600, 300);
pnRenderer->SetViewport(0.0, 0.0, 0.5, 1.0);
renWin->AddRenderer(pnRenderer.GetPointer());
renWin->AddRenderer(pnRenderer);
cnRenderer->SetViewport(0.5, 0.0, 1.0, 1.0);
renWin->AddRenderer(cnRenderer.GetPointer());
renWin->AddRenderer(cnRenderer);
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renWin.GetPointer());
iren->SetRenderWindow(renWin);
iren->Initialize();
renWin->Render();
int retVal = vtkRegressionTestImage(renWin.GetPointer());
int retVal = vtkRegressionTestImage(renWin);
if (retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
......
......@@ -51,13 +51,13 @@ namespace
vtkNew<vtkRenderWindow> renWin;
vtkNew<vtkRenderWindowInteractor> iren;
renWin->AddRenderer(ren.GetPointer());
iren->SetRenderWindow(renWin.GetPointer());
renWin->AddRenderer(ren);
iren->SetRenderWindow(renWin);
//compute an elevation array
vtkNew<vtkFloatArray> elevationPoints;
fillElevationArray(elevationPoints.GetPointer(), grid);
grid->GetPointData()->AddArray(elevationPoints.GetPointer());
fillElevationArray(elevationPoints, grid);
grid->GetPointData()->AddArray(elevationPoints);
vtkNew<vtkTrivialProducer> producer;
producer->SetOutput(grid);
......@@ -80,13 +80,13 @@ namespace
mapper->SetScalarRange(0.0, 100.0);
vtkNew<vtkActor> actor;
actor->SetMapper(mapper.GetPointer());
actor->SetMapper(mapper);
ren->AddActor(actor.GetPointer());
ren->AddActor(actor);
ren->ResetCamera();
renWin->Render();
int retVal = vtkRegressionTestImage(renWin.GetPointer());
int retVal = vtkRegressionTestImage(renWin);
if(retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
......@@ -107,5 +107,5 @@ int TestVTKMThreshold(int argc, char* argv[])
grid->SetExtent(0, dim-1,0, dim-1,0, dim-1);
//run the pipeline
return RunVTKPipeline(grid.GetPointer(), argc, argv);
return RunVTKPipeline(grid, argc, argv);
}
......@@ -35,8 +35,8 @@ int TestVTKMThreshold2(int argc, char *argv[])
vtkNew<vtkRenderWindow> renWin;
vtkNew<vtkRenderWindowInteractor> iren;
renWin->AddRenderer(ren.GetPointer());
iren->SetRenderWindow(renWin.GetPointer());
renWin->AddRenderer(ren);
iren->SetRenderWindow(renWin);
//---------------------------------------------------
// Test using different thresholding methods
......@@ -74,13 +74,13 @@ int TestVTKMThreshold2(int argc, char *argv[])
mapper->SetScalarRange(0.0, 1.0);
vtkNew<vtkActor> actor;
actor->SetMapper(mapper.GetPointer());
actor->SetMapper(mapper);
ren->AddActor(actor.GetPointer());
ren->AddActor(actor);
ren->ResetCamera();
renWin->Render();
int retVal = vtkRegressionTestImage(renWin.GetPointer());
int retVal = vtkRegressionTestImage(renWin);
if(retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
......
......@@ -63,7 +63,7 @@ int TestVTKMTriangleMeshPointNormals(int argc, char* argv[])
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputConnection(normFilter->GetOutputPort());
vtkNew<vtkActor> actor;
actor->SetMapper(mapper.GetPointer());
actor->SetMapper(mapper);
// glyphs
vtkNew<vtkArrowSource> glyphsource;
......@@ -77,31 +77,31 @@ int TestVTKMTriangleMeshPointNormals(int argc, char* argv[])
vtkNew<vtkPolyDataMapper> glyphmapper;
glyphmapper->SetInputConnection(glyph->GetOutputPort());
vtkNew<vtkActor> glyphactor;
glyphactor->SetMapper(glyphmapper.GetPointer());
glyphactor->SetMapper(glyphmapper);
// renderer
vtkNew<vtkRenderer> renderer;
renderer->AddActor(actor.GetPointer());
renderer->AddActor(glyphactor.GetPointer());
renderer->AddActor(actor);
renderer->AddActor(glyphactor);
renderer->SetBackground(0.0, 0.0, 0.0);
renderer->ResetCamera();
// renderwindow, interactor
vtkNew<vtkRenderWindow> renWin ;
renWin->AddRenderer(renderer.GetPointer());
renWin->AddRenderer(renderer);
renWin->SetSize(300,300);
renWin->SetMultiSamples(0);
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renWin.GetPointer());
iren->SetRenderWindow(renWin);
iren->Initialize();
renWin->Render();
int retVal = vtkRegressionTestImage(renWin.GetPointer());
int retVal = vtkRegressionTestImage(renWin);
if (retVal == vtkRegressionTester::DO_INTERACTOR)
{
vtkNew<vtkInteractorStyleTrackballCamera> iStyle;
iren->SetInteractorStyle(iStyle.GetPointer());
iren->SetInteractorStyle(iStyle);
renWin->SetSize(1000,1000);
iren->Start();
}
......
......@@ -124,11 +124,11 @@ int vtkmPolyDataNormals::RequestData(
if (pointNormals)
{
output->GetPointData()->SetNormals(pointNormals.GetPointer());
output->GetPointData()->SetNormals(pointNormals);
}
if (cellNormals)
{
output->GetCellData()->SetNormals(cellNormals.GetPointer());
output->GetCellData()->SetNormals(cellNormals);
}
return 1;
......
......@@ -119,7 +119,7 @@ int vtkmTriangleMeshPointNormals::RequestData(
if (pointNormals)
{
output->GetPointData()->SetNormals(pointNormals.GetPointer());
output->GetPointData()->SetNormals(pointNormals);
}
return 1;
......
......@@ -36,32 +36,32 @@ int TestAreaPlot( int, char * [] )
vtkNew<vtkContextView> view;
view->GetRenderWindow()->SetSize(400, 300);
vtkNew<vtkChartXY> chart;
view->GetScene()->AddItem(chart.GetPointer());
view->GetScene()->AddItem(chart);
// Create a table with some points in it...
vtkNew<vtkTable> table;
vtkNew<vtkFloatArray> arrX;
arrX->SetName("X Axis");
table->AddColumn(arrX.GetPointer());
table->AddColumn(arrX);
vtkNew<vtkFloatArray> arrC;
arrC->SetName("Cosine");
table->AddColumn(arrC.GetPointer());
table->AddColumn(arrC);
vtkNew<vtkFloatArray> arrS;
arrS->SetName("Sine");
table->AddColumn(arrS.GetPointer());
table->AddColumn(arrS);
vtkNew<vtkFloatArray> arrS2;
arrS2->SetName("Sine2");
table->AddColumn(arrS2.GetPointer());
table->AddColumn(arrS2);
vtkNew<vtkFloatArray> arrS3;
arrS3->SetName("Sine3");
table->AddColumn(arrS3.GetPointer());
table->AddColumn(arrS3);
vtkNew<vtkFloatArray> arr1;
arr1->SetName("One");
table->AddColumn(arr1.GetPointer());
table->AddColumn(arr1);
vtkNew<vtkCharArray> validMask;
validMask->SetName("ValidMask");
table->AddColumn(validMask.GetPointer());
table->AddColumn(validMask);
// Test charting with a few more points...
int numPoints = 69;
......@@ -81,7 +81,7 @@ int TestAreaPlot( int, char * [] )
// Add multiple line plots, setting the colors etc
vtkPlotArea* area = vtkPlotArea::SafeDownCast(chart->AddPlot(vtkChart::AREA));