Commit 452d81be authored by Mark Olesen's avatar Mark Olesen

STYLE: use auto with vtkSmartPointer

parent 450c3091
......@@ -100,8 +100,7 @@ void Foam::functionObjects::fieldVisualisationBase::setColourMap
lut->SetNumberOfColors(nColours);
vtkSmartPointer<vtkColorTransferFunction> ctf =
vtkSmartPointer<vtkColorTransferFunction>::New();
auto ctf = vtkSmartPointer<vtkColorTransferFunction>::New();
switch (colourMap_)
{
......@@ -163,8 +162,7 @@ void Foam::functionObjects::fieldVisualisationBase::addScalarBar
return;
}
vtkSmartPointer<vtkScalarBarActor> sbar =
vtkSmartPointer<vtkScalarBarActor>::New();
auto sbar = vtkSmartPointer<vtkScalarBarActor>::New();
sbar->SetLookupTable(lut);
sbar->SetNumberOfLabels(scalarBar_.numberOfLabels_);
......@@ -174,8 +172,7 @@ void Foam::functionObjects::fieldVisualisationBase::addScalarBar
// - Default scalar bar title text is scales by the scalar bar box
// dimensions so if the title is a long string, the text is shrunk to fit
// Instead, suppress title and set the title using a vtkTextActor
vtkSmartPointer<vtkTextActor> titleActor =
vtkSmartPointer<vtkTextActor>::New();
auto titleActor = vtkSmartPointer<vtkTextActor>::New();
sbar->SetTitle(" ");
titleActor->SetInput(scalarBar_.title_.c_str());
titleActor->GetTextProperty()->SetFontFamilyToArial();
......@@ -282,8 +279,7 @@ void Foam::functionObjects::fieldVisualisationBase::setField
case cbField:
{
// Create look-up table for colours
vtkSmartPointer<vtkLookupTable> lut =
vtkSmartPointer<vtkLookupTable>::New();
auto lut = vtkSmartPointer<vtkLookupTable>::New();
setColourMap(lut);
lut->SetVectorMode(vtkScalarsToColors::MAGNITUDE);
......@@ -337,9 +333,8 @@ void Foam::functionObjects::fieldVisualisationBase::addGlyphs
vtkRenderer* renderer
) const
{
vtkSmartPointer<vtkGlyph3D> glyph = vtkSmartPointer<vtkGlyph3D>::New();
vtkSmartPointer<vtkPolyDataMapper> glyphMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
auto glyph = vtkSmartPointer<vtkGlyph3D>::New();
auto glyphMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
glyphMapper->SetInputConnection(glyph->GetOutputPort());
glyph->SetInputData(data);
......@@ -358,8 +353,7 @@ void Foam::functionObjects::fieldVisualisationBase::addGlyphs
else if (data->GetCellData()->HasArray(scaleFieldNameChar) == 1)
{
// Need to convert cell data to point data
vtkSmartPointer<vtkCellDataToPointData> cellToPoint =
vtkSmartPointer<vtkCellDataToPointData>::New();
auto cellToPoint = vtkSmartPointer<vtkCellDataToPointData>::New();
cellToPoint->SetInputData(data);
cellToPoint->Update();
vtkDataSet* pds = cellToPoint->GetOutput();
......@@ -380,8 +374,7 @@ void Foam::functionObjects::fieldVisualisationBase::addGlyphs
if (nComponents == 1)
{
vtkSmartPointer<vtkSphereSource> sphere =
vtkSmartPointer<vtkSphereSource>::New();
auto sphere = vtkSmartPointer<vtkSphereSource>::New();
sphere->SetCenter(0, 0, 0);
sphere->SetRadius(0.5);
......@@ -428,8 +421,7 @@ void Foam::functionObjects::fieldVisualisationBase::addGlyphs
}
else if (nComponents == 3)
{
vtkSmartPointer<vtkArrowSource> arrow =
vtkSmartPointer<vtkArrowSource>::New();
auto arrow = vtkSmartPointer<vtkArrowSource>::New();
arrow->SetTipResolution(10);
arrow->SetTipRadius(0.1);
arrow->SetTipLength(0.35);
......
......@@ -120,13 +120,11 @@ addGeometryToScene
if (fName.ext() == "vtk")
{
vtkSmartPointer<vtkPolyDataReader> points =
vtkSmartPointer<vtkPolyDataReader>::New();
auto points = vtkSmartPointer<vtkPolyDataReader>::New();
points->SetFileName(fName.c_str());
points->Update();
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
actor_->SetMapper(mapper);
......
......@@ -101,13 +101,11 @@ addGeometryToScene
if (fName.ext() == "vtk")
{
vtkSmartPointer<vtkPolyDataReader> lines =
vtkSmartPointer<vtkPolyDataReader>::New();
auto lines = vtkSmartPointer<vtkPolyDataReader>::New();
lines->SetFileName(fName.c_str());
lines->Update();
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
setField(position, fieldName_, mapper, renderer, lines->GetOutput());
actor_->SetMapper(mapper);
......
......@@ -101,8 +101,7 @@ addGeometryToScene
if (representation_ == rtGlyph)
{
vtkSmartPointer<vtkPolyDataReader> surf =
vtkSmartPointer<vtkPolyDataReader>::New();
auto surf = vtkSmartPointer<vtkPolyDataReader>::New();
surf->SetFileName(fName.c_str());
surf->Update();
......@@ -121,15 +120,13 @@ addGeometryToScene
{
if (fName.ext() == "vtk")
{
vtkSmartPointer<vtkPolyDataReader> surf =
vtkSmartPointer<vtkPolyDataReader>::New();
auto surf = vtkSmartPointer<vtkPolyDataReader>::New();
surf->SetFileName(fName.c_str());
surf->Update();
addFeatureEdges(renderer, surf->GetOutput());
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(surf->GetOutputPort());
setField(position, fieldName_, mapper, renderer, surf->GetOutput());
......
......@@ -79,11 +79,9 @@ void Foam::functionObjects::runTimePostPro::geometrySurface::addGeometryToScene
const Field<point>& surfPoints = surf.points();
const Field<vector>& surfFaceNormals = surf.faceNormals();
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
vtkSmartPointer<vtkCellArray> triangles =
vtkSmartPointer<vtkCellArray>::New();
vtkSmartPointer<vtkDoubleArray> faceNormals =
vtkSmartPointer<vtkDoubleArray>::New();
auto points = vtkSmartPointer<vtkPoints>::New();
auto triangles = vtkSmartPointer<vtkCellArray>::New();
auto faceNormals = vtkSmartPointer<vtkDoubleArray>::New();
faceNormals->SetNumberOfComponents(3);
......@@ -97,8 +95,7 @@ void Foam::functionObjects::runTimePostPro::geometrySurface::addGeometryToScene
{
const Foam::face& f = surf[i];
vtkSmartPointer<vtkTriangle> triangle =
vtkSmartPointer<vtkTriangle>::New();
auto triangle = vtkSmartPointer<vtkTriangle>::New();
triangle->GetPointIds()->SetId(0, f[0]);
triangle->GetPointIds()->SetId(1, f[1]);
triangle->GetPointIds()->SetId(2, f[2]);
......@@ -114,14 +111,12 @@ void Foam::functionObjects::runTimePostPro::geometrySurface::addGeometryToScene
surf.clearOut();
vtkSmartPointer<vtkPolyData> polyData =
vtkSmartPointer<vtkPolyData>::New();
auto polyData = vtkSmartPointer<vtkPolyData>::New();
polyData->SetPoints(points);
polyData->SetPolys(triangles);
polyData->GetCellData()->SetNormals(faceNormals);
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->ScalarVisibilityOff();
mapper->SetInputData(polyData);
......
......@@ -104,8 +104,7 @@ void Foam::functionObjects::runTimePostPro::pathline::addLines
}
case rtTube:
{
vtkSmartPointer<vtkTubeFilter> tubes =
vtkSmartPointer<vtkTubeFilter>::New();
auto tubes = vtkSmartPointer<vtkTubeFilter>::New();
tubes->SetInputData(data);
tubes->SetRadius(tubeRadius_);
tubes->SetNumberOfSides(20);
......
......@@ -150,8 +150,7 @@ bool Foam::functionObjects::runTimePostProcessing::write()
sigFpe::unset(false);
// Initialise render window
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
auto renderWindow = vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->OffScreenRenderingOn();
renderWindow->SetSize(output_.width_, output_.height_);
renderWindow->SetAAFrames(10);
......@@ -159,7 +158,7 @@ bool Foam::functionObjects::runTimePostProcessing::write()
renderWindow->SetMultiSamples(0);
// renderWindow->PolygonSmoothingOn();
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
auto renderer = vtkSmartPointer<vtkRenderer>::New();
scene_.initialise(renderer, output_.name_);
renderWindow->AddRenderer(renderer);
......
......@@ -186,20 +186,19 @@ void Foam::functionObjects::runTimePostPro::scene::initialise
renderer->SetOcclusionRatio(0);
// Set the camera
vtkSmartPointer<vtkCamera> camera = vtkSmartPointer<vtkCamera>::New();
auto camera = vtkSmartPointer<vtkCamera>::New();
camera->SetParallelProjection(parallelProjection_);
renderer->SetActiveCamera(camera);
// Add the lights
vtkSmartPointer<vtkLightKit> lightKit = vtkSmartPointer<vtkLightKit>::New();
auto lightKit = vtkSmartPointer<vtkLightKit>::New();
lightKit->AddLightsToRenderer(renderer);
if (!clipBox_.empty())
{
const point& min = clipBox_.min();
const point& max = clipBox_.max();
vtkSmartPointer<vtkCubeSource> clipBox =
vtkSmartPointer<vtkCubeSource>::New();
auto clipBox = vtkSmartPointer<vtkCubeSource>::New();
clipBox->SetXLength(max.x() - min.x());
clipBox->SetYLength(max.y() - min.y());
clipBox->SetZLength(max.z() - min.z());
......@@ -209,8 +208,7 @@ void Foam::functionObjects::runTimePostPro::scene::initialise
min.y() + 0.5*(max.y() - min.y()),
min.z() + 0.5*(max.z() - min.z())
);
vtkSmartPointer<vtkPolyDataMapper> clipMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
auto clipMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
clipMapper->SetInputConnection(clipBox->GetOutputPort());
clipBoxActor_ = vtkSmartPointer<vtkActor>::New();
......@@ -401,8 +399,7 @@ void Foam::functionObjects::runTimePostPro::scene::saveImage
renderWindow->Render();
// Set up off-screen rendering
vtkSmartPointer<vtkWindowToImageFilter> windowToImageFilter =
vtkSmartPointer<vtkWindowToImageFilter>::New();
auto windowToImageFilter = vtkSmartPointer<vtkWindowToImageFilter>::New();
windowToImageFilter->SetInput(renderWindow);
......@@ -414,7 +411,7 @@ void Foam::functionObjects::runTimePostPro::scene::saveImage
windowToImageFilter->Update();
// Save the image
vtkSmartPointer<vtkPNGWriter> writer = vtkSmartPointer<vtkPNGWriter>::New();
auto writer = vtkSmartPointer<vtkPNGWriter>::New();
fileName fName(prefix/outputName_ + '.' + frameIndexStr() + ".png");
writer->SetFileName(fName.c_str());
writer->SetInputConnection(windowToImageFilter->GetOutputPort());
......
......@@ -120,8 +120,7 @@ void Foam::functionObjects::runTimePostPro::surface::addFeatureEdges
return;
}
vtkSmartPointer<vtkFeatureEdges> featureEdges =
vtkSmartPointer<vtkFeatureEdges>::New();
auto featureEdges = vtkSmartPointer<vtkFeatureEdges>::New();
featureEdges->SetInputData(data);
featureEdges->BoundaryEdgesOn();
featureEdges->FeatureEdgesOn();
......@@ -131,8 +130,7 @@ void Foam::functionObjects::runTimePostPro::surface::addFeatureEdges
featureEdges->ColoringOff();
featureEdges->Update();
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(featureEdges->GetOutputPort());
mapper->ScalarVisibilityOff();
......
......@@ -81,7 +81,7 @@ void Foam::functionObjects::runTimePostPro::text::addGeometryToScene
return;
}
vtkSmartPointer<vtkTextActor> actor = vtkSmartPointer<vtkTextActor>::New();
auto actor = vtkSmartPointer<vtkTextActor>::New();
// Concatenate string with timeStamp if true
string textAndTime = string_;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment