Difference between revisions of "VTK/Examples/Cxx/Filtering/SelectionSource"

From KitwarePublic
< VTK‎ | Examples‎ | Cxx
Jump to navigationJump to search
(Replaced content with "= '''See [https://lorensen.github.io/VTKExamples/site/Cxx/Filtering/SelectionSource SelectionSource] on the new [https://lorensen.github.io/VTKExamples/site/ VTKExamples w...")
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The output currently has 50 points when it should only have 10.
+
= '''See [https://lorensen.github.io/VTKExamples/site/Cxx/Filtering/SelectionSource SelectionSource] on the new [https://lorensen.github.io/VTKExamples/site/ VTKExamples website].''' =
 
 
==SelectionSource.cxx==
 
<source lang="cpp">
 
#include <vtkSmartPointer.h>
 
#include <vtkPointSource.h>
 
#include <vtkExtractSelection.h>
 
//#include <vtkSelection.h>
 
#include <vtkSelectionNode.h>
 
#include <vtkSelectionSource.h>
 
#include <vtkPolyData.h>
 
#include <vtkUnstructuredGrid.h>
 
#include <vtkIdTypeArray.h>
 
 
 
int main(int argc, char *argv[])
 
{
 
  vtkSmartPointer<vtkPointSource> pointSource =
 
      vtkSmartPointer<vtkPointSource>::New();
 
  pointSource->SetNumberOfPoints(50);
 
  pointSource->Update();
 
 
 
  cout << "There are " << pointSource->GetOutput()->GetNumberOfPoints() << " input points." << endl;
 
 
 
  vtkSmartPointer<vtkSelectionSource> selectionSource =
 
      vtkSmartPointer<vtkSelectionSource>::New();
 
  selectionSource->SetContentType(vtkSelectionNode::INDICES);
 
  selectionSource->SetFieldType(vtkSelectionNode::POINT);
 
 
 
  for (int i = 10; i <= 20; i++)
 
    {
 
    selectionSource->AddID(-1, i);
 
    }
 
 
 
  selectionSource->Update();
 
       
 
  vtkSmartPointer<vtkExtractSelection> extractSelection =
 
      vtkSmartPointer<vtkExtractSelection>::New();
 
 
 
  extractSelection->SetInput(0, pointSource->GetOutput());
 
  extractSelection->SetInput(1, selectionSource->GetOutput());
 
  extractSelection->Update();
 
 
 
  vtkDataSet* ds = vtkDataSet::SafeDownCast (extractSelection->GetOutput());
 
 
 
  cout << "There are " << ds->GetNumberOfPoints() << " output points." << endl;
 
 
 
  return EXIT_SUCCESS;
 
}
 
 
 
</source>
 
 
 
==CMakeLists.txt==
 
<source lang="cmake">
 
cmake_minimum_required(VERSION 2.6)
 
PROJECT(SelectionSource)
 
 
 
FIND_PACKAGE(VTK REQUIRED)
 
INCLUDE(${VTK_USE_FILE})
 
 
 
ADD_EXECUTABLE(SelectionSource SelectionSource.cxx)
 
TARGET_LINK_LIBRARIES(SelectionSource vtkHybrid)
 
 
 
 
 
</source>
 

Latest revision as of 20:47, 15 April 2019