Difference between revisions of "VTK/Examples/Cxx/Meshes/BoundaryEdges"

From KitwarePublic
< VTK‎ | Examples‎ | Cxx
Jump to navigationJump to search
(New page: This filter will extract the boundary edges of a mesh. An example file is [http://www.vtk.org/Wiki/Image:Plane.vtp here]. This is a 10x10 grid which forms a plane. The boundary edges are t...)
 
Line 1: Line 1:
 
This filter will extract the boundary edges of a mesh. An example file is [http://www.vtk.org/Wiki/Image:Plane.vtp here]. This is a 10x10 grid which forms a plane. The boundary edges are the outside edge of the plane only.
 
This filter will extract the boundary edges of a mesh. An example file is [http://www.vtk.org/Wiki/Image:Plane.vtp here]. This is a 10x10 grid which forms a plane. The boundary edges are the outside edge of the plane only.
  
==BoundaryEdges.cxx
+
==BoundaryEdges.cxx==
 
<source lang="cpp">
 
<source lang="cpp">
 
#include <vtkSmartPointer.h>
 
#include <vtkSmartPointer.h>

Revision as of 09:42, 25 November 2009

This filter will extract the boundary edges of a mesh. An example file is here. This is a 10x10 grid which forms a plane. The boundary edges are the outside edge of the plane only.

BoundaryEdges.cxx

#include <vtkSmartPointer.h>
#include <vtkFeatureEdges.h>
#include <vtkPolyData.h>
#include <vtkXMLPolyDataReader.h>
#include <vtkXMLPolyDataWriter.h>

int main(int argc, char *argv[])
{
  if(argc != 3)
  {
    vtkstd::cout << "Required arguments: InputFilename OutputFilename" << vtkstd::endl;
    exit(-1);
  }
  
  vtkstd::string InputFilename = argv[1];
  vtkstd::string OutputFilename = argv[2];
  
  vtkSmartPointer<vtkXMLPolyDataReader> Reader = vtkSmartPointer<vtkXMLPolyDataReader>::New();
  Reader->SetFileName(InputFilename.c_str());
  Reader->Update();
  
  vtkSmartPointer<vtkFeatureEdges> FeatureEdges = vtkSmartPointer<vtkFeatureEdges>::New();
  FeatureEdges->SetInput(Reader->GetOutput());
  FeatureEdges->BoundaryEdgesOn();
  FeatureEdges->FeatureEdgesOff();
  FeatureEdges->ManifoldEdgesOff();
  FeatureEdges->NonManifoldEdgesOff();
  
  vtkSmartPointer<vtkXMLPolyDataWriter> Writer = vtkSmartPointer<vtkXMLPolyDataWriter>::New();
  Writer->SetFileName(OutputFilename.c_str());
  Writer->SetInput(FeatureEdges->GetOutput());
  Writer->Write();
  
  return 0;
}

==CMakeLists.txt

cmake_minimum_required(VERSION 2.6)

PROJECT(BoundaryEdges)

FIND_PACKAGE(VTK REQUIRED)
INCLUDE(${VTK_USE_FILE})

ADD_EXECUTABLE(BoundaryEdges BoundaryEdges.cxx)
TARGET_LINK_LIBRARIES(BoundaryEdges vtkHybrid)