BoundaryEdges
vtk-examples/Java/Meshes/BoundaryEdges
Description¶
vtkFeatureEdges object is a filter to extract special types of edges from input polygonal data.
These edges are either 1) boundary (used by one polygon) or a line cell 2) non-manifold (used by three or more polygons) 3) feature edges (edges used by two triangles and whose dihedral angle > FeatureAngle) or 4) manifold edges (edges used by exactly two polygons).
Edges may also be "colored" (i.e., scalar values assigned) based on edge type. The cell coloring is assigned to the cell data of the extracted edges.
Question
If you have a question about this example, please use the VTK Discourse Forum
Code¶
BoundaryEdges.java
import vtk.vtkNativeLibrary;
import vtk.vtkDiskSource;
import vtk.vtkFeatureEdges;
import vtk.vtkNamedColors;
import vtk.vtkPolyDataMapper;
import vtk.vtkRenderWindow;
import vtk.vtkRenderWindowInteractor;
import vtk.vtkRenderer;
import vtk.vtkActor;
public class BoundaryEdges
{
// -----------------------------------------------------------------
// Load VTK library and print which library was not properly loaded
static
{
if (!vtkNativeLibrary.LoadAllNativeLibraries())
{
for (vtkNativeLibrary lib : vtkNativeLibrary.values())
{
if (!lib.IsLoaded())
{
System.out.println(lib.GetLibraryName() + " not loaded");
}
}
}
vtkNativeLibrary.DisableOutputWindow(null);
}
// -----------------------------------------------------------------
public static void main(String args[])
{
vtkNamedColors colors = new vtkNamedColors();
//Renderer Background Color
double Bgcolor[] = new double[4];
colors.GetColor("DarkSeaGreen", Bgcolor);
vtkDiskSource diskSource = new vtkDiskSource();
diskSource.Update();
vtkFeatureEdges featureEdges = new vtkFeatureEdges();
featureEdges.SetInputConnection(diskSource.GetOutputPort());
featureEdges.BoundaryEdgesOn();
featureEdges.FeatureEdgesOff();
featureEdges.ManifoldEdgesOff();
featureEdges.NonManifoldEdgesOff();
featureEdges.Update();
//Visualize the Actor
vtkPolyDataMapper edgeMapper = new vtkPolyDataMapper();
edgeMapper.SetInputConnection(featureEdges.GetOutputPort());
vtkActor edgeActor = new vtkActor();
edgeActor.SetMapper(edgeMapper);
vtkPolyDataMapper diskMapper = new vtkPolyDataMapper();
diskMapper.SetInputConnection(diskSource.GetOutputPort());
vtkActor diskActor = new vtkActor();
diskActor.SetMapper(diskMapper);
//Create the renderer, render window and interactor.
vtkRenderer ren = new vtkRenderer();
vtkRenderWindow renWin = new vtkRenderWindow();
renWin.AddRenderer(ren);
vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();
iren.SetRenderWindow(renWin);
ren.AddActor(diskActor);
ren.AddActor(edgeActor);
ren.SetBackground(Bgcolor);
renWin.SetSize(300, 300);
renWin.Render();
iren.Initialize();
iren.Start();
}
}