Difference between revisions of "VTK/Examples/Cxx/PolyData/ConvexHullShrinkWrap"

From KitwarePublic
< VTK‎ | Examples‎ | Cxx
Jump to: navigation, search
(ConvexHullShrinkWrap.cxx)
(Replaced content with "= '''See [https://lorensen.github.io/VTKExamples/site/Cxx/PolyData/ConvexHullShrinkWrap ConvexHullShrinkWrap] on the new [https://lorensen.github.io/VTKExamples/site/ VTKE...")
 
Line 1: Line 1:
This example creates a point cloud, and a sphere larger than the point cloud which fully contains the cloud. It then "shrink wraps" the sphere onto the points. This produces approximately a convex hull.
+
= '''See [https://lorensen.github.io/VTKExamples/site/Cxx/PolyData/ConvexHullShrinkWrap ConvexHullShrinkWrap] on the new [https://lorensen.github.io/VTKExamples/site/ VTKExamples website].''' =
 
 
<div class="floatright">[[File:ConvexHullShrinkWrap.png|thumb|center|640x480px| Using ParaView to view to the results. Left is the sphere, centre the point cloud and right the result of wrapping the sphere around the point cloud.]]</div>
 
==ConvexHullShrinkWrap.cxx==
 
<source lang="cpp">
 
#include <vtkSmartPointer.h>
 
#include <vtkPolyData.h>
 
#include <vtkSphereSource.h>
 
#include <vtkPointSource.h>
 
#include <vtkSmoothPolyDataFilter.h>
 
#include <vtkXMLPolyDataWriter.h>
 
 
 
int main(int, char *[])
 
{
 
  vtkSmartPointer<vtkSphereSource> sphereSource =
 
    vtkSmartPointer<vtkSphereSource>::New();
 
  sphereSource->SetRadius(10);
 
  sphereSource->SetPhiResolution(50);
 
  sphereSource->SetThetaResolution(50);
 
  sphereSource->Update();
 
 
 
  vtkSmartPointer<vtkPointSource> pointSource =
 
    vtkSmartPointer<vtkPointSource>::New();
 
  pointSource->SetNumberOfPoints(40);
 
  pointSource->SetRadius(2);
 
  pointSource->Update();
 
 
 
  {
 
  vtkSmartPointer<vtkXMLPolyDataWriter> writer =
 
    vtkSmartPointer<vtkXMLPolyDataWriter>::New();
 
  writer->SetFileName("input.vtp");
 
  writer->SetInputConnection(sphereSource->GetOutputPort());
 
  writer->Write();
 
  }
 
 
 
  {
 
  vtkSmartPointer<vtkXMLPolyDataWriter> writer =
 
    vtkSmartPointer<vtkXMLPolyDataWriter>::New();
 
  writer->SetFileName("points.vtp");
 
  writer->SetInputConnection(pointSource->GetOutputPort());
 
  writer->Write();
 
  }
 
   
 
  vtkSmartPointer<vtkSmoothPolyDataFilter> smoothFilter =
 
    vtkSmartPointer<vtkSmoothPolyDataFilter>::New();
 
  smoothFilter->SetInputConnection(0, sphereSource->GetOutputPort());
 
  smoothFilter->SetInputConnection(1, pointSource->GetOutputPort());
 
  smoothFilter->Update();
 
 
 
  vtkSmartPointer<vtkXMLPolyDataWriter> writer =
 
    vtkSmartPointer<vtkXMLPolyDataWriter>::New();
 
  writer->SetFileName("output.vtp");
 
  writer->SetInputConnection(smoothFilter->GetOutputPort());
 
  writer->Write();
 
 
 
  return EXIT_SUCCESS;
 
}
 
</source>
 
 
 
{{VTKCMakeLists|{{SUBPAGENAME}}}}
 
 
 
 
 
I'm not sure the current code does what it claims to!?
 
[[Category:VTKAddVisualization]]
 

Latest revision as of 16:34, 9 September 2019

See ConvexHullShrinkWrap on the new VTKExamples website.