From 42df06c13ccb48695f59d77cc06449517718e73b Mon Sep 17 00:00:00 2001
From: Andrew Maclean <andrew.amaclean@gmail.com>
Date: Wed, 14 Oct 2020 09:22:16 +1100
Subject: [PATCH] Modernising the code, improving images

---
 src/Cxx/Points/DensifyPoints.cxx              |   3 +-
 src/Cxx/Points/FitImplicitFunction.cxx        |   4 -
 src/Cxx/Points/NormalEstimation.cxx           |  87 ++++-----
 src/Cxx/Points/PointOccupancy.cxx             | 129 +++++++-------
 src/Cxx/Points/RadiusOutlierRemoval.cxx       | 165 +++++++++---------
 src/Cxx/Points/SignedDistance.cxx             |  94 ++++++----
 src/Cxx/Points/UnsignedDistance.cxx           |  77 ++++----
 .../Baseline/Cxx/Points/TestDensifyPoints.png |   4 +-
 .../Cxx/Points/TestDensifyPoints_1.png        |   3 -
 .../Baseline/Cxx/Points/TestDisplayPoints.png |   3 -
 .../Cxx/Points/TestExtractClusters.png        |   4 +-
 .../Cxx/Points/TestExtractClusters_1.png      |   3 -
 .../Cxx/Points/TestExtractClusters_2.png      |   3 -
 .../Cxx/Points/TestExtractEnclosedPoints.png  |   4 +-
 .../Cxx/Points/TestExtractPointsDemo.png      |   4 +-
 .../Cxx/Points/TestExtractSurface.png         |   4 +-
 .../Cxx/Points/TestExtractSurfaceDemo.png     |   4 +-
 .../Cxx/Points/TestExtractSurfaceDemo_1.png   |   3 -
 .../Cxx/Points/TestFitImplicitFunction.png    |   4 +-
 .../Cxx/Points/TestMaskPointsFilter.png       |   4 +-
 .../Cxx/Points/TestNormalEstimation.png       |   4 +-
 .../Cxx/Points/TestNormalEstimation_1.png     |   3 -
 .../Cxx/Points/TestPointOccupancy.png         |   4 +-
 .../Points/TestPowercrustExtractSurface_1.png |   3 -
 .../Cxx/Points/TestRadiusOutlierRemoval.png   |   4 +-
 .../Cxx/Points/TestSignedDistance.png         |   4 +-
 .../Cxx/Points/TestSignedDistance_1.png       |   3 -
 .../Cxx/Points/TestUnsignedDistance.png       |   4 +-
 .../Cxx/Points/TestUnsignedDistance_1.png     |   3 -
 29 files changed, 312 insertions(+), 326 deletions(-)
 delete mode 100644 src/Testing/Baseline/Cxx/Points/TestDensifyPoints_1.png
 delete mode 100644 src/Testing/Baseline/Cxx/Points/TestDisplayPoints.png
 delete mode 100644 src/Testing/Baseline/Cxx/Points/TestExtractClusters_1.png
 delete mode 100644 src/Testing/Baseline/Cxx/Points/TestExtractClusters_2.png
 delete mode 100644 src/Testing/Baseline/Cxx/Points/TestExtractSurfaceDemo_1.png
 delete mode 100644 src/Testing/Baseline/Cxx/Points/TestNormalEstimation_1.png
 delete mode 100644 src/Testing/Baseline/Cxx/Points/TestPowercrustExtractSurface_1.png
 delete mode 100644 src/Testing/Baseline/Cxx/Points/TestSignedDistance_1.png
 delete mode 100644 src/Testing/Baseline/Cxx/Points/TestUnsignedDistance_1.png

diff --git a/src/Cxx/Points/DensifyPoints.cxx b/src/Cxx/Points/DensifyPoints.cxx
index 4010434d53e..a38f3e3f9aa 100644
--- a/src/Cxx/Points/DensifyPoints.cxx
+++ b/src/Cxx/Points/DensifyPoints.cxx
@@ -1,6 +1,7 @@
 #include <vtkCamera.h>
 #include <vtkDensifyPointCloudFilter.h>
 #include <vtkGlyph3DMapper.h>
+#include <vtkMinimalStandardRandomSequence.h>
 #include <vtkNamedColors.h>
 #include <vtkNew.h>
 #include <vtkPointSource.h>
@@ -11,8 +12,8 @@
 #include <vtkRenderer.h>
 #include <vtkSmartPointer.h>
 #include <vtkSphereSource.h>
+
 #include <vtksys/SystemTools.hxx>
-#include <vtkMinimalStandardRandomSequence.h>
 
 #include <vtkBYUReader.h>
 #include <vtkOBJReader.h>
diff --git a/src/Cxx/Points/FitImplicitFunction.cxx b/src/Cxx/Points/FitImplicitFunction.cxx
index 811f992e1da..e7488c4bee6 100644
--- a/src/Cxx/Points/FitImplicitFunction.cxx
+++ b/src/Cxx/Points/FitImplicitFunction.cxx
@@ -2,7 +2,6 @@
 #include <vtkCamera.h>
 #include <vtkFitImplicitFunction.h>
 #include <vtkGlyph3D.h>
-#include <vtkMinimalStandardRandomSequence.h>
 #include <vtkNamedColors.h>
 #include <vtkNew.h>
 #include <vtkPolyDataMapper.h>
@@ -18,9 +17,6 @@ int main(int, char*[])
 {
   vtkNew<vtkNamedColors> colors;
 
-  //  vtkNew<vtkMinimalStandardRandomSequence> randomSequence;
-  // randomSequence->SetSeed(8775070);
-
   double radius = 1.0;
   vtkNew<vtkBoundedPointSource> points;
   points->SetNumberOfPoints(1000000);
diff --git a/src/Cxx/Points/NormalEstimation.cxx b/src/Cxx/Points/NormalEstimation.cxx
index 651f4d780a4..183cdb65203 100644
--- a/src/Cxx/Points/NormalEstimation.cxx
+++ b/src/Cxx/Points/NormalEstimation.cxx
@@ -1,91 +1,76 @@
-#include <vtkSmartPointer.h>
-#include <vtkPCANormalEstimation.h>
-#include <vtkPointSource.h>
-
-#include <vtkSphereSource.h>
 #include <vtkArrowSource.h>
+#include <vtkCamera.h>
 #include <vtkGlyph3D.h>
-#include <vtkMath.h>
-
+#include <vtkNamedColors.h>
+#include <vtkNew.h>
+#include <vtkPCANormalEstimation.h>
+#include <vtkPointSource.h>
 #include <vtkPolyDataMapper.h>
 #include <vtkProperty.h>
 #include <vtkRenderWindow.h>
 #include <vtkRenderWindowInteractor.h>
 #include <vtkRenderer.h>
-#include <vtkCamera.h>
-#include <vtkNamedColors.h>
+#include <vtkSphereSource.h>
 
-namespace
-{
-void MakeGlyphs(vtkPolyData *src, double size, vtkGlyph3D *glyph);
+namespace {
+void MakeGlyphs(vtkPolyData* src, double size, vtkGlyph3D* glyph);
 }
 
-int main (int, char *[])
+int main(int, char*[])
 {
-  vtkMath::RandomSeed(4355412); // for test result consistency
-
   double radius = 1.0;
-  vtkSmartPointer<vtkPointSource> points =
-    vtkSmartPointer<vtkPointSource>::New();
+  vtkNew<vtkPointSource> points;
   points->SetNumberOfPoints(1000);
   points->SetRadius(radius);
   points->SetCenter(0.0, 0.0, 0.0);
   points->SetDistributionToShell();
 
   int sampleSize = 10;
-  vtkSmartPointer<vtkPCANormalEstimation> normals =
-    vtkSmartPointer<vtkPCANormalEstimation>::New();
-  normals->SetInputConnection (points->GetOutputPort());
+  vtkNew<vtkPCANormalEstimation> normals;
+  normals->SetInputConnection(points->GetOutputPort());
   normals->SetSampleSize(sampleSize);
   normals->SetNormalOrientationToGraphTraversal();
   normals->Update();
 
-  vtkSmartPointer<vtkNamedColors>colors =
-    vtkSmartPointer<vtkNamedColors>::New();
+  vtkNew<vtkNamedColors> colors;
 
-  vtkSmartPointer<vtkGlyph3D> glyph3D =
-    vtkSmartPointer<vtkGlyph3D>::New();
-  MakeGlyphs(normals->GetOutput(), radius * .2, glyph3D.GetPointer());
+  vtkNew<vtkGlyph3D> glyph3D;
+  MakeGlyphs(normals->GetOutput(), radius * 0.2, glyph3D.GetPointer());
 
-  vtkSmartPointer<vtkPolyDataMapper> glyph3DMapper =
-    vtkSmartPointer<vtkPolyDataMapper>::New();
+  vtkNew<vtkPolyDataMapper> glyph3DMapper;
   glyph3DMapper->SetInputConnection(glyph3D->GetOutputPort());
 
-  vtkSmartPointer<vtkActor> glyph3DActor =
-    vtkSmartPointer<vtkActor>::New();
+  vtkNew<vtkActor> glyph3DActor;
   glyph3DActor->SetMapper(glyph3DMapper);
-  glyph3DActor->GetProperty()->SetDiffuseColor(colors->GetColor3d("Banana").GetData());
+  glyph3DActor->GetProperty()->SetDiffuseColor(
+      colors->GetColor3d("Banana").GetData());
 
-  vtkSmartPointer<vtkSphereSource> sphere =
-    vtkSmartPointer<vtkSphereSource>::New();
+  vtkNew<vtkSphereSource> sphere;
   sphere->SetRadius(1.0);
   sphere->SetThetaResolution(41);
   sphere->SetPhiResolution(21);
 
-  vtkSmartPointer<vtkPolyDataMapper> sphereMapper =
-    vtkSmartPointer<vtkPolyDataMapper>::New();
+  vtkNew<vtkPolyDataMapper> sphereMapper;
   sphereMapper->SetInputConnection(sphere->GetOutputPort());
 
-  vtkSmartPointer<vtkActor> sphereActor =
-    vtkSmartPointer<vtkActor>::New();
+  vtkNew<vtkActor> sphereActor;
   sphereActor->SetMapper(sphereMapper);
-  sphereActor->GetProperty()->SetDiffuseColor(colors->GetColor3d("Tomato").GetData());
+  sphereActor->GetProperty()->SetDiffuseColor(
+      colors->GetColor3d("Tomato").GetData());
 
   // Create graphics stuff
   //
-  vtkSmartPointer<vtkRenderer> renderer =
-    vtkSmartPointer<vtkRenderer>::New();
+  vtkNew<vtkRenderer> renderer;
   renderer->SetBackground(colors->GetColor3d("SlateGray").GetData());
 
-  vtkSmartPointer<vtkRenderWindow> renderWindow =
-    vtkSmartPointer<vtkRenderWindow>::New();
+  vtkNew<vtkRenderWindow> renderWindow;
   renderWindow->AddRenderer(renderer);
   renderWindow->SetSize(640, 480);
+  renderWindow->SetWindowName("NormalEstimation");
 
-  vtkSmartPointer<vtkRenderWindowInteractor> interactor =
-    vtkSmartPointer<vtkRenderWindowInteractor>::New();
+  vtkNew<vtkRenderWindowInteractor> interactor;
   interactor->SetRenderWindow(renderWindow);
-  
+
   // Add the actors to the renderer, set the background and size
   //
   renderer->AddActor(glyph3DActor);
@@ -105,16 +90,14 @@ int main (int, char *[])
 
   return EXIT_SUCCESS;
 }
-namespace
-{
-void MakeGlyphs(vtkPolyData *src, double size, vtkGlyph3D *glyph)
+namespace {
+void MakeGlyphs(vtkPolyData* src, double size, vtkGlyph3D* glyph)
 {
   // Source for the glyph filter
-  vtkSmartPointer<vtkArrowSource> arrow =
-    vtkSmartPointer<vtkArrowSource>::New();
+  vtkNew<vtkArrowSource> arrow;
   arrow->SetTipResolution(16);
-  arrow->SetTipLength(.3);
-  arrow->SetTipRadius(.1);
+  arrow->SetTipLength(0.3);
+  arrow->SetTipRadius(0.1);
 
   glyph->SetSourceConnection(arrow->GetOutputPort());
   glyph->SetInputData(src);
@@ -124,4 +107,4 @@ void MakeGlyphs(vtkPolyData *src, double size, vtkGlyph3D *glyph)
   glyph->OrientOn();
   glyph->Update();
 }
-}
+} // namespace
diff --git a/src/Cxx/Points/PointOccupancy.cxx b/src/Cxx/Points/PointOccupancy.cxx
index 412377ce613..c3a1e31c4f8 100644
--- a/src/Cxx/Points/PointOccupancy.cxx
+++ b/src/Cxx/Points/PointOccupancy.cxx
@@ -1,5 +1,17 @@
-#include <vtkSmartPointer.h>
+#include <vtkCamera.h>
+#include <vtkDataSetMapper.h>
+#include <vtkImageData.h>
+#include <vtkMinimalStandardRandomSequence.h>
+#include <vtkNamedColors.h>
+#include <vtkNew.h>
+#include <vtkPointOccupancyFilter.h>
 #include <vtkPointSource.h>
+#include <vtkProperty.h>
+#include <vtkRenderWindow.h>
+#include <vtkRenderWindowInteractor.h>
+#include <vtkRenderer.h>
+#include <vtkSmartPointer.h>
+#include <vtkThreshold.h>
 
 #include <vtkBYUReader.h>
 #include <vtkOBJReader.h>
@@ -8,76 +20,57 @@
 #include <vtkSTLReader.h>
 #include <vtkXMLPolyDataReader.h>
 
-#include <vtkPointOccupancyFilter.h>
-#include <vtkThreshold.h>
-#include <vtkDataSetMapper.h>
-#include <vtkImageData.h>
-
-#include <vtkNamedColors.h>
-#include <vtkProperty.h>
-#include <vtkRenderWindow.h>
-#include <vtkRenderWindowInteractor.h>
-#include <vtkRenderer.h>
-#include <vtkCamera.h>
-
 #include <vtksys/SystemTools.hxx>
 
-namespace
-{
-vtkSmartPointer<vtkPolyData> ReadPolyData(const char *fileName);
+namespace {
+vtkSmartPointer<vtkPolyData> ReadPolyData(const char* fileName);
 }
 
-int main (int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-  vtkSmartPointer<vtkPolyData> polyData = ReadPolyData(argc > 1 ? argv[1] : "");;
+  auto polyData = ReadPolyData(argc > 1 ? argv[1] : "");
+
   int dimension = 128;
-  vtkSmartPointer<vtkPointOccupancyFilter> occupancy = 
-    vtkSmartPointer<vtkPointOccupancyFilter>::New();
+  vtkNew<vtkPointOccupancyFilter> occupancy;
   occupancy->SetInputData(polyData);
   occupancy->SetSampleDimensions(dimension, dimension, dimension);
   occupancy->SetOccupiedValue(255);
   occupancy->Update();
 
-  vtkSmartPointer<vtkThreshold> threshold =
-    vtkSmartPointer<vtkThreshold>::New();
+  vtkNew<vtkThreshold> threshold;
   threshold->SetInputConnection(occupancy->GetOutputPort());
   threshold->ThresholdByUpper(255);
   threshold->AllScalarsOff();
 
-  vtkSmartPointer<vtkDataSetMapper> mapper =
-    vtkSmartPointer<vtkDataSetMapper>::New();
+  vtkNew<vtkDataSetMapper> mapper;
   mapper->SetInputConnection(threshold->GetOutputPort());
   mapper->ScalarVisibilityOff();
 
-  vtkSmartPointer<vtkActor> actor =
-    vtkSmartPointer<vtkActor>::New();
+  vtkNew<vtkActor> actor;
   actor->SetMapper(mapper);
 
   // Colors
-  vtkSmartPointer<vtkNamedColors> nc =
-    vtkSmartPointer<vtkNamedColors>::New();
+  vtkNew<vtkNamedColors> nc;
   double flesh[3];
   nc->GetColorRGB("moccasin", flesh);
   actor->GetProperty()->SetColor(flesh);
 
   // Create graphics stuff
   //
-  vtkSmartPointer<vtkRenderer> ren1 =
-    vtkSmartPointer<vtkRenderer>::New();
-  ren1->SetBackground(.3, .4, .6);
+  vtkNew<vtkRenderer> ren1;
+  ren1->AddActor(actor);
+  ren1->SetBackground(nc->GetColor3d("CornflowerBLue").GetData());
 
-  vtkSmartPointer<vtkRenderWindow> renWin =
-    vtkSmartPointer<vtkRenderWindow>::New();
+  vtkNew<vtkRenderWindow> renWin;
   renWin->AddRenderer(ren1);
-  renWin->SetSize(512,512);
+  renWin->SetSize(512, 512);
+  renWin->SetWindowName("PointOccupancy");
 
-  vtkSmartPointer<vtkRenderWindowInteractor> iren =
-    vtkSmartPointer<vtkRenderWindowInteractor>::New();
+  vtkNew<vtkRenderWindowInteractor> iren;
   iren->SetRenderWindow(renWin);
-  
+
   // Add the actors to the renderer, set the background and size
   //
-  ren1->AddActor(actor);
 
   // Generate an interesting view
   //
@@ -94,73 +87,75 @@ int main (int argc, char *argv[])
   return EXIT_SUCCESS;
 }
 
-namespace
-{
-vtkSmartPointer<vtkPolyData> ReadPolyData(const char *fileName)
+namespace {
+vtkSmartPointer<vtkPolyData> ReadPolyData(const char* fileName)
 {
   vtkSmartPointer<vtkPolyData> polyData;
-  std::string extension = vtksys::SystemTools::GetFilenameExtension(std::string(fileName));
+  std::string extension =
+      vtksys::SystemTools::GetFilenameExtension(std::string(fileName));
   if (extension == ".ply")
   {
-    vtkSmartPointer<vtkPLYReader> reader =
-      vtkSmartPointer<vtkPLYReader>::New();
-    reader->SetFileName (fileName);
+    vtkNew<vtkPLYReader> reader;
+    reader->SetFileName(fileName);
     reader->Update();
     polyData = reader->GetOutput();
   }
   else if (extension == ".vtp")
   {
-    vtkSmartPointer<vtkXMLPolyDataReader> reader =
-      vtkSmartPointer<vtkXMLPolyDataReader>::New();
-    reader->SetFileName (fileName);
+    vtkNew<vtkXMLPolyDataReader> reader;
+    reader->SetFileName(fileName);
     reader->Update();
     polyData = reader->GetOutput();
   }
   else if (extension == ".vtk")
   {
-    vtkSmartPointer<vtkPolyDataReader> reader =
-      vtkSmartPointer<vtkPolyDataReader>::New();
-    reader->SetFileName (fileName);
+    vtkNew<vtkPolyDataReader> reader;
+    reader->SetFileName(fileName);
     reader->Update();
     polyData = reader->GetOutput();
   }
   else if (extension == ".obj")
   {
-    vtkSmartPointer<vtkOBJReader> reader =
-      vtkSmartPointer<vtkOBJReader>::New();
-    reader->SetFileName (fileName);
+    vtkNew<vtkOBJReader> reader;
+    reader->SetFileName(fileName);
     reader->Update();
     polyData = reader->GetOutput();
   }
   else if (extension == ".stl")
   {
-    vtkSmartPointer<vtkSTLReader> reader =
-      vtkSmartPointer<vtkSTLReader>::New();
-    reader->SetFileName (fileName);
+    vtkNew<vtkSTLReader> reader;
+    reader->SetFileName(fileName);
     reader->Update();
     polyData = reader->GetOutput();
   }
   else if (extension == ".g")
   {
-    vtkSmartPointer<vtkBYUReader> reader =
-      vtkSmartPointer<vtkBYUReader>::New();
-    reader->SetGeometryFileName (fileName);
+    vtkNew<vtkBYUReader> reader;
+    reader->SetGeometryFileName(fileName);
     reader->Update();
     polyData = reader->GetOutput();
   }
   else
   {
-    vtkSmartPointer<vtkPointSource> points =
-      vtkSmartPointer<vtkPointSource>::New();
-    points->SetNumberOfPoints(1000);
+    vtkNew<vtkMinimalStandardRandomSequence> randomSequence;
+    randomSequence->SetSeed(8775070);
+
+    vtkNew<vtkPointSource> points;
+    points->SetNumberOfPoints(100000);
     points->SetRadius(10.0);
-    points->SetCenter(vtkMath::Random(-100, 100),
-                      vtkMath::Random(-100, 100),
-                      vtkMath::Random(-100, 100));
+    double x, y, z;
+    // random position
+    x = randomSequence->GetRangeValue(-100, 100);
+    randomSequence->Next();
+    y = randomSequence->GetRangeValue(-100, 100);
+    randomSequence->Next();
+    z = randomSequence->GetRangeValue(-100, 100);
+    randomSequence->Next();
+    points->SetCenter(x, y, z);
     points->SetDistributionToShell();
     points->Update();
     polyData = points->GetOutput();
   }
   return polyData;
 }
-}
+} // namespace
diff --git a/src/Cxx/Points/RadiusOutlierRemoval.cxx b/src/Cxx/Points/RadiusOutlierRemoval.cxx
index 1d1f5bff844..3114717de28 100644
--- a/src/Cxx/Points/RadiusOutlierRemoval.cxx
+++ b/src/Cxx/Points/RadiusOutlierRemoval.cxx
@@ -1,112 +1,108 @@
-#include <vtkSmartPointer.h>
-#include <vtkRadiusOutlierRemoval.h>
-
-#include <vtkBYUReader.h>
-#include <vtkPLYReader.h>
-#include <vtkXMLPolyDataReader.h>
-#include <vtkPolyDataReader.h>
-#include <vtkOBJReader.h>
-#include <vtkSTLReader.h>
-#include <vtkPointSource.h>
-
-#include <vtkSphereSource.h>
+#include <vtkCamera.h>
 #include <vtkGlyph3D.h>
-
+#include <vtkMinimalStandardRandomSequence.h>
+#include <vtkNamedColors.h>
+#include <vtkNew.h>
+#include <vtkPointSource.h>
 #include <vtkPolyDataMapper.h>
 #include <vtkProperty.h>
+#include <vtkRadiusOutlierRemoval.h>
 #include <vtkRenderWindow.h>
 #include <vtkRenderWindowInteractor.h>
 #include <vtkRenderer.h>
-#include <vtkCamera.h>
+#include <vtkSmartPointer.h>
+#include <vtkSphereSource.h>
+
+#include <vtkBYUReader.h>
+#include <vtkOBJReader.h>
+#include <vtkPLYReader.h>
+#include <vtkPolyDataReader.h>
+#include <vtkSTLReader.h>
+#include <vtkXMLPolyDataReader.h>
 
 #include <vtksys/SystemTools.hxx>
 
-static vtkSmartPointer<vtkPolyData> ReadPolyData(const char *fileName);
+namespace {
+vtkSmartPointer<vtkPolyData> ReadPolyData(const char* fileName);
+}
 
-int main (int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-  vtkSmartPointer<vtkPolyData> polyData = ReadPolyData(argc > 1 ? argv[1] : "");;
+  vtkNew<vtkNamedColors> colors;
+
+  auto polyData = ReadPolyData(argc > 1 ? argv[1] : "");
 
   double bounds[6];
   polyData->GetBounds(bounds);
   double range[3];
   for (int i = 0; i < 3; ++i)
   {
-    range[i] = bounds[2*i + 1] - bounds[2*i];
+    range[i] = bounds[2 * i + 1] - bounds[2 * i];
   }
-  std::cout << "Range: "
-            << range[0] << ", "
-            << range[1] << ", "
-            << range[2] << std::endl;
-  std::cout << "# of original points: " << polyData->GetNumberOfPoints() << std::endl;
-  vtkSmartPointer<vtkRadiusOutlierRemoval> removal =
-    vtkSmartPointer<vtkRadiusOutlierRemoval>::New();
+  std::cout << "Range: " << range[0] << ", " << range[1] << ", " << range[2]
+            << std::endl;
+  std::cout << "# of original points: " << polyData->GetNumberOfPoints()
+            << std::endl;
+  vtkNew<vtkRadiusOutlierRemoval> removal;
   removal->SetInputData(polyData);
   removal->SetRadius(range[0] / 50.0);
   removal->SetNumberOfNeighbors(6);
   removal->GenerateOutliersOn();
   removal->Update();
-  std::cout << "# of removed points: " << removal->GetNumberOfPointsRemoved() << std::endl;
+  std::cout << "# of removed points: " << removal->GetNumberOfPointsRemoved()
+            << std::endl;
 
-///
+  ///
   double radius = range[0] * .01;
-  vtkSmartPointer<vtkSphereSource> sphereSource1 =
-    vtkSmartPointer<vtkSphereSource>::New();
+  vtkNew<vtkSphereSource> sphereSource1;
   sphereSource1->SetRadius(radius);
 
-  vtkSmartPointer<vtkGlyph3D> glyph3D1 =
-    vtkSmartPointer<vtkGlyph3D>::New();
+  vtkNew<vtkGlyph3D> glyph3D1;
   glyph3D1->SetInputConnection(removal->GetOutputPort());
   glyph3D1->SetSourceConnection(sphereSource1->GetOutputPort());
   glyph3D1->ScalingOff();
   glyph3D1->Update();
-  vtkSmartPointer<vtkPolyDataMapper> glyph3DMapper1 =
-    vtkSmartPointer<vtkPolyDataMapper>::New();
+  vtkNew<vtkPolyDataMapper> glyph3DMapper1;
   glyph3DMapper1->SetInputConnection(glyph3D1->GetOutputPort());
   glyph3DMapper1->ScalarVisibilityOff();
 
-  vtkSmartPointer<vtkActor> glyph3DActor1 =
-    vtkSmartPointer<vtkActor>::New();
+  vtkNew<vtkActor> glyph3DActor1;
   glyph3DActor1->SetMapper(glyph3DMapper1);
-  glyph3DActor1->GetProperty()->SetColor(0.8900, 0.8100, 0.3400);
+  glyph3DActor1->GetProperty()->SetColor(
+      colors->GetColor3d("Banana").GetData());
 
-////
-  vtkSmartPointer<vtkSphereSource> sphereSource2 =
-    vtkSmartPointer<vtkSphereSource>::New();
-  sphereSource2->SetRadius(radius * .75);
+  ////
+  vtkNew<vtkSphereSource> sphereSource2;
+  sphereSource2->SetRadius(radius * 0.75);
 
-  vtkSmartPointer<vtkGlyph3D> glyph3D2 =
-    vtkSmartPointer<vtkGlyph3D>::New();
+  vtkNew<vtkGlyph3D> glyph3D2;
   glyph3D2->SetInputConnection(removal->GetOutputPort(1));
   glyph3D2->SetSourceConnection(sphereSource2->GetOutputPort());
   glyph3D2->ScalingOff();
   glyph3D2->Update();
 
-  vtkSmartPointer<vtkPolyDataMapper> glyph3DMapper2 =
-    vtkSmartPointer<vtkPolyDataMapper>::New();
+  vtkNew<vtkPolyDataMapper> glyph3DMapper2;
   glyph3DMapper2->SetInputConnection(glyph3D2->GetOutputPort());
   glyph3DMapper2->ScalarVisibilityOff();
 
-  vtkSmartPointer<vtkActor> glyph3DActor2 =
-    vtkSmartPointer<vtkActor>::New();
+  vtkNew<vtkActor> glyph3DActor2;
   glyph3DActor2->SetMapper(glyph3DMapper2);
-  glyph3DActor2->GetProperty()->SetColor(1.0000, 0.4900, 0.2500);
+  glyph3DActor2->GetProperty()->SetColor(
+      colors->GetColor3d("Tomato").GetData());
 
   // Create graphics stuff
   //
-  vtkSmartPointer<vtkRenderer> ren1 =
-    vtkSmartPointer<vtkRenderer>::New();
-  ren1->SetBackground(.3, .4, .6);
+  vtkNew<vtkRenderer> ren1;
+  ren1->SetBackground(colors->GetColor3d("CornflowerBlue").GetData());
 
-  vtkSmartPointer<vtkRenderWindow> renWin =
-    vtkSmartPointer<vtkRenderWindow>::New();
+  vtkNew<vtkRenderWindow> renWin;
   renWin->AddRenderer(ren1);
-  renWin->SetSize(512,512);
+  renWin->SetSize(512, 512);
+  renWin->SetWindowName("RadiusOutlierRemoval");
 
-  vtkSmartPointer<vtkRenderWindowInteractor> iren =
-    vtkSmartPointer<vtkRenderWindowInteractor>::New();
+  vtkNew<vtkRenderWindowInteractor> iren;
   iren->SetRenderWindow(renWin);
-  
+
   // Add the actors to the renderer, set the background and size
   //
   ren1->AddActor(glyph3DActor1);
@@ -127,70 +123,75 @@ int main (int argc, char *argv[])
   return EXIT_SUCCESS;
 }
 
-static vtkSmartPointer<vtkPolyData> ReadPolyData(const char *fileName)
+namespace {
+vtkSmartPointer<vtkPolyData> ReadPolyData(const char* fileName)
 {
   vtkSmartPointer<vtkPolyData> polyData;
-  std::string extension = vtksys::SystemTools::GetFilenameExtension(std::string(fileName));
+  std::string extension =
+      vtksys::SystemTools::GetFilenameExtension(std::string(fileName));
   if (extension == ".ply")
   {
-    vtkSmartPointer<vtkPLYReader> reader =
-      vtkSmartPointer<vtkPLYReader>::New();
-    reader->SetFileName (fileName);
+    vtkNew<vtkPLYReader> reader;
+    reader->SetFileName(fileName);
     reader->Update();
     polyData = reader->GetOutput();
   }
   else if (extension == ".vtp")
   {
-    vtkSmartPointer<vtkXMLPolyDataReader> reader =
-      vtkSmartPointer<vtkXMLPolyDataReader>::New();
-    reader->SetFileName (fileName);
+    vtkNew<vtkXMLPolyDataReader> reader;
+    reader->SetFileName(fileName);
     reader->Update();
     polyData = reader->GetOutput();
   }
   else if (extension == ".vtk")
   {
-    vtkSmartPointer<vtkPolyDataReader> reader =
-      vtkSmartPointer<vtkPolyDataReader>::New();
-    reader->SetFileName (fileName);
+    vtkNew<vtkPolyDataReader> reader;
+    reader->SetFileName(fileName);
     reader->Update();
     polyData = reader->GetOutput();
   }
   else if (extension == ".obj")
   {
-    vtkSmartPointer<vtkOBJReader> reader =
-      vtkSmartPointer<vtkOBJReader>::New();
-    reader->SetFileName (fileName);
+    vtkNew<vtkOBJReader> reader;
+    reader->SetFileName(fileName);
     reader->Update();
     polyData = reader->GetOutput();
   }
   else if (extension == ".stl")
   {
-    vtkSmartPointer<vtkSTLReader> reader =
-      vtkSmartPointer<vtkSTLReader>::New();
-    reader->SetFileName (fileName);
+    vtkNew<vtkSTLReader> reader;
+    reader->SetFileName(fileName);
     reader->Update();
     polyData = reader->GetOutput();
   }
   else if (extension == ".g")
   {
-    vtkSmartPointer<vtkBYUReader> reader =
-      vtkSmartPointer<vtkBYUReader>::New();
-    reader->SetGeometryFileName (fileName);
+    vtkNew<vtkBYUReader> reader;
+    reader->SetGeometryFileName(fileName);
     reader->Update();
     polyData = reader->GetOutput();
   }
   else
   {
-    vtkSmartPointer<vtkPointSource> points =
-      vtkSmartPointer<vtkPointSource>::New();
-    points->SetNumberOfPoints(10000);
+    vtkNew<vtkMinimalStandardRandomSequence> randomSequence;
+    randomSequence->SetSeed(8775070);
+
+    vtkNew<vtkPointSource> points;
+    points->SetNumberOfPoints(100000);
     points->SetRadius(10.0);
-    points->SetCenter(vtkMath::Random(-100, 100),
-                      vtkMath::Random(-100, 100),
-                      vtkMath::Random(-100, 100));
+    double x, y, z;
+    // random position
+    x = randomSequence->GetRangeValue(-100, 100);
+    randomSequence->Next();
+    y = randomSequence->GetRangeValue(-100, 100);
+    randomSequence->Next();
+    z = randomSequence->GetRangeValue(-100, 100);
+    randomSequence->Next();
+    points->SetCenter(x, y, z);
     points->SetDistributionToShell();
     points->Update();
     polyData = points->GetOutput();
   }
   return polyData;
 }
+} // namespace
diff --git a/src/Cxx/Points/SignedDistance.cxx b/src/Cxx/Points/SignedDistance.cxx
index f0ad638538b..9c6d6000de3 100644
--- a/src/Cxx/Points/SignedDistance.cxx
+++ b/src/Cxx/Points/SignedDistance.cxx
@@ -4,6 +4,8 @@
 #include <vtkImageMapToColors.h>
 #include <vtkImageMapper3D.h>
 #include <vtkLookupTable.h>
+#include <vtkMinimalStandardRandomSequence.h>
+#include <vtkNew.h>
 #include <vtkPCANormalEstimation.h>
 #include <vtkPointSource.h>
 #include <vtkProperty.h>
@@ -13,6 +15,8 @@
 #include <vtkScalarBarActor.h>
 #include <vtkSignedDistance.h>
 #include <vtkSmartPointer.h>
+#include <vtkNamedColors.h>
+
 
 // Readers
 #include <vtkBYUReader.h>
@@ -35,8 +39,9 @@ vtkSmartPointer<vtkPolyData> ReadPolyData(std::string const& fileName);
 
 int main(int argc, char* argv[])
 {
+  vtkNew<vtkNamedColors> colors;
+
   auto polyData = ReadPolyData(argc > 1 ? argv[1] : "");
-  ;
 
   double bounds[6];
   polyData->GetBounds(bounds);
@@ -52,7 +57,7 @@ int main(int argc, char* argv[])
     sampleSize = 10;
   }
   std::cout << "Sample size is: " << sampleSize << std::endl;
-  auto normals = vtkSmartPointer<vtkPCANormalEstimation>::New();
+  vtkNew<vtkPCANormalEstimation> normals;
   normals->SetInputData(polyData);
   normals->SetSampleSize(sampleSize);
   normals->SetNormalOrientationToGraphTraversal();
@@ -61,82 +66,87 @@ int main(int argc, char* argv[])
             << std::endl;
   int dimension = 256;
   dimension = 128;
-  // auto radius = range[0] * .02;
+  // auto radius = range[0] * 0.02;
   auto radius = range[0] / static_cast<double>(dimension) * 5; // ~5 voxels
   std::cout << "Radius: " << radius << std::endl;
-  auto distance = vtkSmartPointer<vtkSignedDistance>::New();
+  vtkNew<vtkSignedDistance> distance;
   distance->SetInputConnection(normals->GetOutputPort());
   distance->SetRadius(radius);
   distance->SetDimensions(dimension, dimension, dimension);
-  distance->SetBounds(bounds[0] - range[0] * .1, bounds[1] + range[0] * .1,
-                      bounds[2] - range[1] * .1, bounds[3] + range[1] * .1,
-                      bounds[4] - range[2] * .1, bounds[5] + range[2] * .1);
+  distance->SetBounds(bounds[0] - range[0] * 0.1, bounds[1] + range[0] * 0.1,
+                      bounds[2] - range[1] * 0.1, bounds[3] + range[1] * 0.1,
+                      bounds[4] - range[2] * 0.1, bounds[5] + range[2] * 0.1);
 
   // Create a lookup table that consists of the full hue circle
   // (from HSV).
-  auto hueLut = vtkSmartPointer<vtkLookupTable>::New();
-  hueLut->SetTableRange(-.99 * radius, .99 * radius);
-  hueLut->SetHueRange(.667, 0);
+  auto belowRangeColor = colors->GetColor4d("Black").GetData();
+  belowRangeColor[3] = 0.2;
+  auto aboveRangeColor = colors->GetColor4d("White").GetData();
+  aboveRangeColor[3] = 0.2;
+  vtkNew<vtkLookupTable> hueLut;
+  hueLut->SetTableRange(-0.99 * radius, 0.99 * radius);
+  hueLut->SetHueRange(0.667, 0);
   hueLut->SetSaturationRange(1, 1);
   hueLut->SetValueRange(1, 1);
   hueLut->UseBelowRangeColorOn();
-  hueLut->SetBelowRangeColor(0, 0, 0, 0);
+  hueLut->SetBelowRangeColor(belowRangeColor);
   hueLut->UseAboveRangeColorOn();
-  hueLut->SetAboveRangeColor(0, 0, 0, 0);
+  hueLut->SetAboveRangeColor(aboveRangeColor);
   hueLut->SetNumberOfColors(5);
   hueLut->Build();
   double* last = hueLut->GetTableValue(4);
   hueLut->SetAboveRangeColor(last[0], last[1], last[2], 0);
 
-  auto sagittalColors = vtkSmartPointer<vtkImageMapToColors>::New();
+  vtkNew<vtkImageMapToColors> sagittalColors;
   sagittalColors->SetInputConnection(distance->GetOutputPort());
   sagittalColors->SetLookupTable(hueLut);
   sagittalColors->Update();
 
-  auto sagittal = vtkSmartPointer<vtkImageActor>::New();
+  vtkNew<vtkImageActor> sagittal;
   sagittal->GetMapper()->SetInputConnection(sagittalColors->GetOutputPort());
   sagittal->SetDisplayExtent(dimension / 2, dimension / 2, 0, dimension - 1, 0,
                              dimension - 1);
   sagittal->ForceOpaqueOn();
 
-  auto axialColors = vtkSmartPointer<vtkImageMapToColors>::New();
+  vtkNew<vtkImageMapToColors> axialColors;
   axialColors->SetInputConnection(distance->GetOutputPort());
   axialColors->SetLookupTable(hueLut);
   axialColors->Update();
 
-  auto axial = vtkSmartPointer<vtkImageActor>::New();
+  vtkNew<vtkImageActor> axial;
   axial->GetMapper()->SetInputConnection(axialColors->GetOutputPort());
   axial->SetDisplayExtent(0, dimension - 1, 0, dimension - 1, dimension / 2,
                           dimension / 2);
   axial->ForceOpaqueOn();
 
-  auto coronalColors = vtkSmartPointer<vtkImageMapToColors>::New();
+  vtkNew<vtkImageMapToColors> coronalColors;
   coronalColors->SetInputConnection(distance->GetOutputPort());
   coronalColors->SetLookupTable(hueLut);
   coronalColors->Update();
 
-  auto coronal = vtkSmartPointer<vtkImageActor>::New();
+  vtkNew<vtkImageActor> coronal;
   coronal->GetMapper()->SetInputConnection(coronalColors->GetOutputPort());
   coronal->SetDisplayExtent(0, dimension - 1, dimension / 2, dimension / 2, 0,
                             dimension - 1);
   coronal->ForceOpaqueOn();
 
   // Create a scalar bar
-  auto scalarBar = vtkSmartPointer<vtkScalarBarActor>::New();
+  vtkNew<vtkScalarBarActor> scalarBar;
   scalarBar->SetLookupTable(hueLut);
   scalarBar->SetTitle("Distance");
   scalarBar->SetNumberOfLabels(5);
 
   // Create graphics stuff
   //
-  auto ren1 = vtkSmartPointer<vtkRenderer>::New();
-  ren1->SetBackground(.3, .4, .6);
+  vtkNew<vtkRenderer> ren1;
+  ren1->SetBackground(colors->GetColor3d("CornflowerBlue").GetData());
 
-  auto renWin = vtkSmartPointer<vtkRenderWindow>::New();
+  vtkNew<vtkRenderWindow> renWin;
   renWin->AddRenderer(ren1);
-  renWin->SetSize(512, 512);
+  renWin->SetSize(600, 400);
+  renWin->SetWindowName("SignedDistance");
 
-  auto iren = vtkSmartPointer<vtkRenderWindowInteractor>::New();
+  vtkNew<vtkRenderWindowInteractor> iren;
   iren->SetRenderWindow(renWin);
 
   // Add the actors to the renderer, set the background and size
@@ -159,6 +169,7 @@ int main(int argc, char* argv[])
   iren->Start();
   std::cout << distance->GetOutput()->GetScalarRange()[0] << ", "
             << distance->GetOutput()->GetScalarRange()[1] << std::endl;
+
   return EXIT_SUCCESS;
 }
 
@@ -176,58 +187,67 @@ vtkSmartPointer<vtkPolyData> ReadPolyData(std::string const& fileName)
                  ::tolower);
   if (extension == ".ply")
   {
-    auto reader = vtkSmartPointer<vtkPLYReader>::New();
+    vtkNew<vtkPLYReader> reader;
     reader->SetFileName(fileName.c_str());
     reader->Update();
     polyData = reader->GetOutput();
   }
   else if (extension == ".vtp")
   {
-    auto reader = vtkSmartPointer<vtkXMLPolyDataReader>::New();
+    vtkNew<vtkXMLPolyDataReader> reader;
     reader->SetFileName(fileName.c_str());
     reader->Update();
     polyData = reader->GetOutput();
   }
-  else if (extension == ".obj")
+  else if (extension == ".vtk")
   {
-    auto reader = vtkSmartPointer<vtkOBJReader>::New();
+    vtkNew<vtkPolyDataReader> reader;
     reader->SetFileName(fileName.c_str());
     reader->Update();
     polyData = reader->GetOutput();
   }
-  else if (extension == ".stl")
+  else if (extension == ".obj")
   {
-    auto reader = vtkSmartPointer<vtkSTLReader>::New();
+    vtkNew<vtkOBJReader> reader;
     reader->SetFileName(fileName.c_str());
     reader->Update();
     polyData = reader->GetOutput();
   }
-  else if (extension == ".vtk")
+  else if (extension == ".stl")
   {
-    auto reader = vtkSmartPointer<vtkPolyDataReader>::New();
+    vtkNew<vtkSTLReader> reader;
     reader->SetFileName(fileName.c_str());
     reader->Update();
     polyData = reader->GetOutput();
   }
   else if (extension == ".g")
   {
-    auto reader = vtkSmartPointer<vtkBYUReader>::New();
+    vtkNew<vtkBYUReader> reader;
     reader->SetGeometryFileName(fileName.c_str());
     reader->Update();
     polyData = reader->GetOutput();
   }
   else
   {
-    auto points = vtkSmartPointer<vtkPointSource>::New();
+    vtkNew<vtkMinimalStandardRandomSequence> randomSequence;
+    randomSequence->SetSeed(8775070);
+
+    vtkNew<vtkPointSource> points;
     points->SetNumberOfPoints(100000);
     points->SetRadius(10.0);
-    points->SetCenter(vtkMath::Random(-100, 100), vtkMath::Random(-100, 100),
-                      vtkMath::Random(-100, 100));
+    double x, y, z;
+    // random position
+    x = randomSequence->GetRangeValue(-100, 100);
+    randomSequence->Next();
+    y = randomSequence->GetRangeValue(-100, 100);
+    randomSequence->Next();
+    z = randomSequence->GetRangeValue(-100, 100);
+    randomSequence->Next();
+    points->SetCenter(x, y, z);
     points->SetDistributionToShell();
     points->Update();
     polyData = points->GetOutput();
   }
   return polyData;
 }
-
 } // namespace
diff --git a/src/Cxx/Points/UnsignedDistance.cxx b/src/Cxx/Points/UnsignedDistance.cxx
index 12ac2463725..85ec2c54b73 100644
--- a/src/Cxx/Points/UnsignedDistance.cxx
+++ b/src/Cxx/Points/UnsignedDistance.cxx
@@ -4,7 +4,11 @@
 #include <vtkImageMapToColors.h>
 #include <vtkImageMapper3D.h>
 #include <vtkLookupTable.h>
+#include <vtkMinimalStandardRandomSequence.h>
+#include <vtkNamedColors.h>
+#include <vtkNew.h>
 #include <vtkPointSource.h>
+#include <vtkPolyData.h>
 #include <vtkProperty.h>
 #include <vtkRenderWindow.h>
 #include <vtkRenderWindowInteractor.h>
@@ -21,9 +25,6 @@
 #include <vtkSTLReader.h>
 #include <vtkXMLPolyDataReader.h>
 
-#include <vtkPointSource.h>
-#include <vtkPolyData.h>
-
 #include <algorithm> // For transform()
 #include <cctype>    // For to_lower
 #include <string>    // For find_last_of()
@@ -34,8 +35,9 @@ vtkSmartPointer<vtkPolyData> ReadPolyData(std::string const& fileName);
 
 int main(int argc, char* argv[])
 {
+  vtkNew<vtkNamedColors> colors;
+
   auto polyData = ReadPolyData(argc > 1 ? argv[1] : "");
-  ;
 
   double bounds[6];
   polyData->GetBounds(bounds);
@@ -59,7 +61,7 @@ int main(int argc, char* argv[])
   auto radius = range[0] / static_cast<double>(dimension) * 5;
   ; // ~5 voxels
   std::cout << "Radius: " << radius << std::endl;
-  auto distance = vtkSmartPointer<vtkUnsignedDistance>::New();
+  vtkNew<vtkUnsignedDistance> distance;
   distance->SetInputData(polyData);
   distance->SetRadius(radius);
   distance->SetDimensions(dimension, dimension, dimension);
@@ -69,67 +71,70 @@ int main(int argc, char* argv[])
 
   // Create a lookup table that consists of the full hue circle
   // (from HSV).
-  auto hueLut = vtkSmartPointer<vtkLookupTable>::New();
+  auto aboveRangeColor = colors->GetColor4d("White").GetData();
+  aboveRangeColor[3] = 0.2;
+  vtkNew<vtkLookupTable> hueLut;
   hueLut->SetTableRange(-.99 * radius, .99 * radius);
   hueLut->SetHueRange(.667, 0);
   hueLut->SetSaturationRange(1, 1);
   hueLut->SetValueRange(1, 1);
   hueLut->UseAboveRangeColorOn();
-  hueLut->SetAboveRangeColor(0, 0, 0, 0);
+  hueLut->SetAboveRangeColor(aboveRangeColor);
   hueLut->SetNumberOfColors(5);
   hueLut->Build();
   double* last = hueLut->GetTableValue(4);
   hueLut->SetAboveRangeColor(last[0], last[1], last[2], 0);
 
-  auto sagittalColors = vtkSmartPointer<vtkImageMapToColors>::New();
+  vtkNew<vtkImageMapToColors> sagittalColors;
   sagittalColors->SetInputConnection(distance->GetOutputPort());
   sagittalColors->SetLookupTable(hueLut);
   sagittalColors->Update();
 
-  auto sagittal = vtkSmartPointer<vtkImageActor>::New();
+  vtkNew<vtkImageActor> sagittal;
   sagittal->GetMapper()->SetInputConnection(sagittalColors->GetOutputPort());
   sagittal->SetDisplayExtent(dimension / 2, dimension / 2, 0, dimension - 1, 0,
                              dimension - 1);
   sagittal->ForceOpaqueOn();
 
-  auto axialColors = vtkSmartPointer<vtkImageMapToColors>::New();
+  vtkNew<vtkImageMapToColors> axialColors;
   axialColors->SetInputConnection(distance->GetOutputPort());
   axialColors->SetLookupTable(hueLut);
   axialColors->Update();
 
-  auto axial = vtkSmartPointer<vtkImageActor>::New();
+  vtkNew<vtkImageActor> axial;
   axial->GetMapper()->SetInputConnection(axialColors->GetOutputPort());
   axial->SetDisplayExtent(0, dimension - 1, 0, dimension - 1, dimension / 2,
                           dimension / 2);
   axial->ForceOpaqueOn();
 
-  auto coronalColors = vtkSmartPointer<vtkImageMapToColors>::New();
+  vtkNew<vtkImageMapToColors> coronalColors;
   coronalColors->SetInputConnection(distance->GetOutputPort());
   coronalColors->SetLookupTable(hueLut);
   coronalColors->Update();
 
-  auto coronal = vtkSmartPointer<vtkImageActor>::New();
+  vtkNew<vtkImageActor> coronal;
   coronal->GetMapper()->SetInputConnection(coronalColors->GetOutputPort());
   coronal->SetDisplayExtent(0, dimension - 1, dimension / 2, dimension / 2, 0,
                             dimension - 1);
   coronal->ForceOpaqueOn();
 
   // Create a scalar bar
-  auto scalarBar = vtkSmartPointer<vtkScalarBarActor>::New();
+  vtkNew<vtkScalarBarActor> scalarBar;
   scalarBar->SetLookupTable(hueLut);
   scalarBar->SetTitle("Distance");
   scalarBar->SetNumberOfLabels(5);
 
   // Create graphics stuff
   //
-  auto ren1 = vtkSmartPointer<vtkRenderer>::New();
+  vtkNew<vtkRenderer> ren1;
   ren1->SetBackground(.3, .4, .6);
 
-  auto renWin = vtkSmartPointer<vtkRenderWindow>::New();
+  vtkNew<vtkRenderWindow> renWin;
   renWin->AddRenderer(ren1);
-  renWin->SetSize(512, 512);
+  renWin->SetSize(600, 400);
+  renWin->SetWindowName("UnsignedDistance");
 
-  auto iren = vtkSmartPointer<vtkRenderWindowInteractor>::New();
+  vtkNew<vtkRenderWindowInteractor> iren;
   iren->SetRenderWindow(renWin);
 
   // Add the actors to the renderer, set the background and size
@@ -138,6 +143,7 @@ int main(int argc, char* argv[])
   ren1->AddActor(axial);
   ren1->AddActor(coronal);
   ren1->AddActor2D(scalarBar);
+  ren1->SetBackground(colors->GetColor3d("CornflowerBlue").GetData());
 
   // Generate an interesting view
   //
@@ -152,6 +158,7 @@ int main(int argc, char* argv[])
   iren->Start();
   std::cout << distance->GetOutput()->GetScalarRange()[0] << ", "
             << distance->GetOutput()->GetScalarRange()[1] << std::endl;
+
   return EXIT_SUCCESS;
 }
 
@@ -169,53 +176,63 @@ vtkSmartPointer<vtkPolyData> ReadPolyData(std::string const& fileName)
                  ::tolower);
   if (extension == ".ply")
   {
-    auto reader = vtkSmartPointer<vtkPLYReader>::New();
+    vtkNew<vtkPLYReader> reader;
     reader->SetFileName(fileName.c_str());
     reader->Update();
     polyData = reader->GetOutput();
   }
   else if (extension == ".vtp")
   {
-    auto reader = vtkSmartPointer<vtkXMLPolyDataReader>::New();
+    vtkNew<vtkXMLPolyDataReader> reader;
     reader->SetFileName(fileName.c_str());
     reader->Update();
     polyData = reader->GetOutput();
   }
-  else if (extension == ".obj")
+  else if (extension == ".vtk")
   {
-    auto reader = vtkSmartPointer<vtkOBJReader>::New();
+    vtkNew<vtkPolyDataReader> reader;
     reader->SetFileName(fileName.c_str());
     reader->Update();
     polyData = reader->GetOutput();
   }
-  else if (extension == ".stl")
+  else if (extension == ".obj")
   {
-    auto reader = vtkSmartPointer<vtkSTLReader>::New();
+    vtkNew<vtkOBJReader> reader;
     reader->SetFileName(fileName.c_str());
     reader->Update();
     polyData = reader->GetOutput();
   }
-  else if (extension == ".vtk")
+  else if (extension == ".stl")
   {
-    auto reader = vtkSmartPointer<vtkPolyDataReader>::New();
+    vtkNew<vtkSTLReader> reader;
     reader->SetFileName(fileName.c_str());
     reader->Update();
     polyData = reader->GetOutput();
   }
   else if (extension == ".g")
   {
-    auto reader = vtkSmartPointer<vtkBYUReader>::New();
+    vtkNew<vtkBYUReader> reader;
     reader->SetGeometryFileName(fileName.c_str());
     reader->Update();
     polyData = reader->GetOutput();
   }
   else
   {
-    auto points = vtkSmartPointer<vtkPointSource>::New();
+    vtkNew<vtkMinimalStandardRandomSequence> randomSequence;
+    randomSequence->SetSeed(8775070);
+
+    vtkNew<vtkPointSource> points;
     points->SetNumberOfPoints(100000);
     points->SetRadius(10.0);
-    points->SetCenter(vtkMath::Random(-100, 100), vtkMath::Random(-100, 100),
-                      vtkMath::Random(-100, 100));
+    double x, y, z;
+    // random position
+    x = randomSequence->GetRangeValue(-100, 100);
+    randomSequence->Next();
+    y = randomSequence->GetRangeValue(-100, 100);
+    randomSequence->Next();
+    z = randomSequence->GetRangeValue(-100, 100);
+    randomSequence->Next();
+    points->SetCenter(x, y, z);
     points->SetDistributionToShell();
     points->Update();
     polyData = points->GetOutput();
diff --git a/src/Testing/Baseline/Cxx/Points/TestDensifyPoints.png b/src/Testing/Baseline/Cxx/Points/TestDensifyPoints.png
index 988fbe5f645..62b3a979ea3 100644
--- a/src/Testing/Baseline/Cxx/Points/TestDensifyPoints.png
+++ b/src/Testing/Baseline/Cxx/Points/TestDensifyPoints.png
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:98b8132016e1b1f30ef2605c8a6fbcfd43d7695140b3143c4f4b39fea488429f
-size 162863
+oid sha256:04ab5c2bac1d65a3258b6e91e5226081f9b166dc85b5a69506ff9864b8f9d590
+size 174650
diff --git a/src/Testing/Baseline/Cxx/Points/TestDensifyPoints_1.png b/src/Testing/Baseline/Cxx/Points/TestDensifyPoints_1.png
deleted file mode 100644
index e50d04c4ad3..00000000000
--- a/src/Testing/Baseline/Cxx/Points/TestDensifyPoints_1.png
+++ /dev/null
@@ -1,3 +0,0 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:67d3d94d7f7865660ece2b24429a6b4584ed256d8135f6ed555646c5ed090f0c
-size 200914
diff --git a/src/Testing/Baseline/Cxx/Points/TestDisplayPoints.png b/src/Testing/Baseline/Cxx/Points/TestDisplayPoints.png
deleted file mode 100644
index ac44118eb8e..00000000000
--- a/src/Testing/Baseline/Cxx/Points/TestDisplayPoints.png
+++ /dev/null
@@ -1,3 +0,0 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:2c19797e802a947198dde27e0fc610120be69abcc2e198ad7061871ec28accbf
-size 25692
diff --git a/src/Testing/Baseline/Cxx/Points/TestExtractClusters.png b/src/Testing/Baseline/Cxx/Points/TestExtractClusters.png
index c73f58de75a..021060308a3 100644
--- a/src/Testing/Baseline/Cxx/Points/TestExtractClusters.png
+++ b/src/Testing/Baseline/Cxx/Points/TestExtractClusters.png
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:029fd84ab523db4b664c6c4873a25157f0a241f10d0e0922e4407eaba2c5c965
-size 180002
+oid sha256:a9d942a1ff2681c65c11ffd26f0eeaef18e354157d6e4a70dd81aa83e99f0f92
+size 188102
diff --git a/src/Testing/Baseline/Cxx/Points/TestExtractClusters_1.png b/src/Testing/Baseline/Cxx/Points/TestExtractClusters_1.png
deleted file mode 100644
index 450f5bda3bd..00000000000
--- a/src/Testing/Baseline/Cxx/Points/TestExtractClusters_1.png
+++ /dev/null
@@ -1,3 +0,0 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:e56e0132c3a17317ef5b460eff2684d074d25f389809cd9c70d1e1226672c61c
-size 191361
diff --git a/src/Testing/Baseline/Cxx/Points/TestExtractClusters_2.png b/src/Testing/Baseline/Cxx/Points/TestExtractClusters_2.png
deleted file mode 100644
index 98655cb6d0c..00000000000
--- a/src/Testing/Baseline/Cxx/Points/TestExtractClusters_2.png
+++ /dev/null
@@ -1,3 +0,0 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:4000a9083d77056c14b689c58bf505f8df01c0890ad4f2d87dac94e34f06d398
-size 184566
diff --git a/src/Testing/Baseline/Cxx/Points/TestExtractEnclosedPoints.png b/src/Testing/Baseline/Cxx/Points/TestExtractEnclosedPoints.png
index 5f73baaab44..1f7fc54dac9 100644
--- a/src/Testing/Baseline/Cxx/Points/TestExtractEnclosedPoints.png
+++ b/src/Testing/Baseline/Cxx/Points/TestExtractEnclosedPoints.png
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:d9f557cc1729988014b1a1f2dc47e2e43a5ca6d5cb4598583649e840a609f92f
-size 77462
+oid sha256:2cea781b3613ed59e4c755275e33a659ccdba905e018164c841c88db17e51064
+size 80078
diff --git a/src/Testing/Baseline/Cxx/Points/TestExtractPointsDemo.png b/src/Testing/Baseline/Cxx/Points/TestExtractPointsDemo.png
index 28b7dac935d..a872335baff 100644
--- a/src/Testing/Baseline/Cxx/Points/TestExtractPointsDemo.png
+++ b/src/Testing/Baseline/Cxx/Points/TestExtractPointsDemo.png
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:3e323f1ca86aaa6b8e98b366243a55c47bd530e1de8bd93fad37eca8d1182a43
-size 208332
+oid sha256:223065b367cc74b68019f3be4035d1a4c796c221ef71582d98ebcdf4b89a589e
+size 220472
diff --git a/src/Testing/Baseline/Cxx/Points/TestExtractSurface.png b/src/Testing/Baseline/Cxx/Points/TestExtractSurface.png
index 72dd8f80b44..4e735213529 100644
--- a/src/Testing/Baseline/Cxx/Points/TestExtractSurface.png
+++ b/src/Testing/Baseline/Cxx/Points/TestExtractSurface.png
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:8c948dc94b5787812241fb34314dab0f30aef1e3928e096bca2e824b27ef2fb8
-size 75028
+oid sha256:4c35481f6548abd81cffbc90b99a64113c0bfe2bee0e34df3d823091bc1f75de
+size 73955
diff --git a/src/Testing/Baseline/Cxx/Points/TestExtractSurfaceDemo.png b/src/Testing/Baseline/Cxx/Points/TestExtractSurfaceDemo.png
index 3d2e116057f..2f9323f0b32 100644
--- a/src/Testing/Baseline/Cxx/Points/TestExtractSurfaceDemo.png
+++ b/src/Testing/Baseline/Cxx/Points/TestExtractSurfaceDemo.png
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:cfc7d7c96dcc5c8ba22564c46dbe5d5c9a795478ddb7e52e3d3db3465dad66b0
-size 91849
+oid sha256:7cca1f2e52a2c8fa31e674ec3a0624230b0faf7177bf2261a1640586cd59a040
+size 95456
diff --git a/src/Testing/Baseline/Cxx/Points/TestExtractSurfaceDemo_1.png b/src/Testing/Baseline/Cxx/Points/TestExtractSurfaceDemo_1.png
deleted file mode 100644
index 7da12f161f0..00000000000
--- a/src/Testing/Baseline/Cxx/Points/TestExtractSurfaceDemo_1.png
+++ /dev/null
@@ -1,3 +0,0 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:093bdf9520c8ee056580c61de2af79c08692b840b4ff4afb69520d956c98ae05
-size 90634
diff --git a/src/Testing/Baseline/Cxx/Points/TestFitImplicitFunction.png b/src/Testing/Baseline/Cxx/Points/TestFitImplicitFunction.png
index 9a08b8d30de..505f66c8adf 100644
--- a/src/Testing/Baseline/Cxx/Points/TestFitImplicitFunction.png
+++ b/src/Testing/Baseline/Cxx/Points/TestFitImplicitFunction.png
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:2f6b409f7431bd2df75d697844550e1a5f04a1a97e2569e19ea9d388f7cf5446
-size 146378
+oid sha256:65cec412bb0d3de85b461f04da37bbb600fa9dc355489834e2fc2b0008ed24a2
+size 148431
diff --git a/src/Testing/Baseline/Cxx/Points/TestMaskPointsFilter.png b/src/Testing/Baseline/Cxx/Points/TestMaskPointsFilter.png
index d598bfae6aa..8072755d456 100644
--- a/src/Testing/Baseline/Cxx/Points/TestMaskPointsFilter.png
+++ b/src/Testing/Baseline/Cxx/Points/TestMaskPointsFilter.png
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:d8a40e2deffb083dd631c9dd21044f3b68b38d5a09146210389e61496b990eff
-size 150261
+oid sha256:14091e2105cc1a260b47140b1a8e6543252aed96b6af93760c532abf4b1c4599
+size 151243
diff --git a/src/Testing/Baseline/Cxx/Points/TestNormalEstimation.png b/src/Testing/Baseline/Cxx/Points/TestNormalEstimation.png
index e29038f419d..1c969412459 100644
--- a/src/Testing/Baseline/Cxx/Points/TestNormalEstimation.png
+++ b/src/Testing/Baseline/Cxx/Points/TestNormalEstimation.png
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:ee0c96b665ae3b7267c54260b1fe4510ee30f5a76bad8988d95c6a7f951df4b1
-size 82741
+oid sha256:50c5bf7b17e79cf64342a940b8cda4d5f7550e0e8c852a3e3a28960d74cd7cf6
+size 97293
diff --git a/src/Testing/Baseline/Cxx/Points/TestNormalEstimation_1.png b/src/Testing/Baseline/Cxx/Points/TestNormalEstimation_1.png
deleted file mode 100644
index ef7c7b1d7a8..00000000000
--- a/src/Testing/Baseline/Cxx/Points/TestNormalEstimation_1.png
+++ /dev/null
@@ -1,3 +0,0 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:a040ff5011edaef0b4d29f2daa83e45ebb2357fa415c6a31b5609d24f0a98d8c
-size 88630
diff --git a/src/Testing/Baseline/Cxx/Points/TestPointOccupancy.png b/src/Testing/Baseline/Cxx/Points/TestPointOccupancy.png
index e0abfb64e0e..70da40ffc81 100644
--- a/src/Testing/Baseline/Cxx/Points/TestPointOccupancy.png
+++ b/src/Testing/Baseline/Cxx/Points/TestPointOccupancy.png
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:e7e53229bb39030f218720253727d90cdbafc6305d8402a8cac13c592daaf38a
-size 41096
+oid sha256:d6aecd738787d4fb7c8a289b4d0a2dc03a20f128020f3c7b97944a45ed1cced3
+size 92001
diff --git a/src/Testing/Baseline/Cxx/Points/TestPowercrustExtractSurface_1.png b/src/Testing/Baseline/Cxx/Points/TestPowercrustExtractSurface_1.png
deleted file mode 100644
index bfd3f22d8f5..00000000000
--- a/src/Testing/Baseline/Cxx/Points/TestPowercrustExtractSurface_1.png
+++ /dev/null
@@ -1,3 +0,0 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:8e78a5e96ad65801f7e8908da045bff2bbb19235186d04c8b6c07f149158f66d
-size 17774
diff --git a/src/Testing/Baseline/Cxx/Points/TestRadiusOutlierRemoval.png b/src/Testing/Baseline/Cxx/Points/TestRadiusOutlierRemoval.png
index 5867ac7d5b1..f227cd8ccbc 100644
--- a/src/Testing/Baseline/Cxx/Points/TestRadiusOutlierRemoval.png
+++ b/src/Testing/Baseline/Cxx/Points/TestRadiusOutlierRemoval.png
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:32e87e889e2a26503fc7e5494f1279caa0c34ef42431294a665cee22f4d13031
-size 217808
+oid sha256:934f90ae9d9b44b1d17852e18f1f40bcc0fba015d3d3c148158ce06c1cf40abd
+size 224755
diff --git a/src/Testing/Baseline/Cxx/Points/TestSignedDistance.png b/src/Testing/Baseline/Cxx/Points/TestSignedDistance.png
index ea2907c71f5..6d3b525dc34 100644
--- a/src/Testing/Baseline/Cxx/Points/TestSignedDistance.png
+++ b/src/Testing/Baseline/Cxx/Points/TestSignedDistance.png
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:711e60cf29e84abaee3429a3aae56ab0ffae8dd00cdecbbbc397d66332a169f1
-size 76878
+oid sha256:a2f8fe71f3ca5135fee6a876cb266c76a8f720d52dea11ad511d0423efb39b0b
+size 56182
diff --git a/src/Testing/Baseline/Cxx/Points/TestSignedDistance_1.png b/src/Testing/Baseline/Cxx/Points/TestSignedDistance_1.png
deleted file mode 100644
index 8c325bef329..00000000000
--- a/src/Testing/Baseline/Cxx/Points/TestSignedDistance_1.png
+++ /dev/null
@@ -1,3 +0,0 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:f6d1de7673a173f26cc5fdddd8d90c618fdc671d2c76301d583ba6ddaac9dd03
-size 76387
diff --git a/src/Testing/Baseline/Cxx/Points/TestUnsignedDistance.png b/src/Testing/Baseline/Cxx/Points/TestUnsignedDistance.png
index 027e274ef0a..c96d5bb557e 100644
--- a/src/Testing/Baseline/Cxx/Points/TestUnsignedDistance.png
+++ b/src/Testing/Baseline/Cxx/Points/TestUnsignedDistance.png
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:8e79b1c08c7f374e166a958c7b02039b5186bf35dae9cceeeb46a4050dbe4f7b
-size 73278
+oid sha256:49fea53f08f297796d9d45d6f4818783a53adc2a4da34e1c386c0a1c763f367e
+size 56964
diff --git a/src/Testing/Baseline/Cxx/Points/TestUnsignedDistance_1.png b/src/Testing/Baseline/Cxx/Points/TestUnsignedDistance_1.png
deleted file mode 100644
index d96d3d41b29..00000000000
--- a/src/Testing/Baseline/Cxx/Points/TestUnsignedDistance_1.png
+++ /dev/null
@@ -1,3 +0,0 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:0b5b7e1e2c4632742d2c146aace726162386102d29ea7c657e5adefa4c3e93ba
-size 74631
-- 
GitLab