Difference between revisions of "VTK/Examples/CSharp/PolyData/ClosedSurface"

From KitwarePublic
< VTK‎ | Examples‎ | CSharp
Jump to navigationJump to search
(initial creation)
 
(changed windows forms app to to a console application cause nothing gets displayed graphically)
 
Line 1: Line 1:
A tutorial on how to setup a Windows Forms Application utilizing ActiViz.NET can be found here: [http://www.vtk.org/Wiki/VTK/CSharp/ActiViz.NET Setup a Windows Forms Application to use ActiViz.NET]<br />
+
A tutorial on how to setup a Console Application utilizing Kitware.VTK.dll can be found here: [http://www.vtk.org/Wiki/VTK/CSharp/ActiViz.NET Setup a Console Application to use Kitware.VTK.dll]<br />
 
==ClosedSurface.cs==
 
==ClosedSurface.cs==
 
<source lang="CSharp">
 
<source lang="CSharp">
 
using System;
 
using System;
using System.Collections.Generic;
 
using System.ComponentModel;
 
using System.Windows.Forms;
 
using System.Diagnostics;
 
  
 
using Kitware.VTK;
 
using Kitware.VTK;
  
 
namespace ActiViz.Examples {
 
namespace ActiViz.Examples {
   public partial class Form1 : Form {
+
   class Program {
       public Form1() {
+
       static void Main(string[] args) {
         InitializeComponent();
+
         ClosedSurface();
 
       }
 
       }
  
  
       private void renderWindowControl1_Load(object sender, EventArgs e) {
+
       private static void ClosedSurface() {
        try {
 
            ClosedSurface();
 
        }
 
        catch(Exception ex) {
 
            MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK);
 
        }
 
      }
 
 
 
 
 
      private void ClosedSurface() {
 
 
         // Create a sphere
 
         // Create a sphere
 
         vtkSphereSource sphereSource = vtkSphereSource.New();
 
         vtkSphereSource sphereSource = vtkSphereSource.New();
Line 42: Line 28:
  
 
         if(numberOfOpenEdges > 0) {
 
         if(numberOfOpenEdges > 0) {
             Debug.WriteLine("Surface is not closed");
+
             Console.WriteLine("Surface is not closed");
 
         }
 
         }
 
         else {
 
         else {
             Debug.WriteLine("Surface is closed");
+
             Console.WriteLine("Surface is closed");
 
         }
 
         }
 
         // nothing to show graphically
 
         // nothing to show graphically
 +
        Console.WriteLine("\nPress any key to continue...");
 +
        Console.ReadKey();
 
       }
 
       }
 
   }
 
   }
 
}
 
}
 
</source>
 
</source>

Latest revision as of 03:53, 21 June 2012

A tutorial on how to setup a Console Application utilizing Kitware.VTK.dll can be found here: Setup a Console Application to use Kitware.VTK.dll

ClosedSurface.cs

using System;

using Kitware.VTK;

namespace ActiViz.Examples {
   class Program {
      static void Main(string[] args) {
         ClosedSurface();
      }


      private static void ClosedSurface() {
         // Create a sphere
         vtkSphereSource sphereSource = vtkSphereSource.New();
         sphereSource.Update();

         vtkFeatureEdges featureEdges = vtkFeatureEdges.New();
         featureEdges.FeatureEdgesOff();
         featureEdges.BoundaryEdgesOn();
         featureEdges.NonManifoldEdgesOn();
         featureEdges.SetInputConnection(sphereSource.GetOutputPort());
         featureEdges.Update();

         int numberOfOpenEdges = featureEdges.GetOutput().GetNumberOfCells();

         if(numberOfOpenEdges > 0) {
            Console.WriteLine("Surface is not closed");
         }
         else {
            Console.WriteLine("Surface is closed");
         }
         // nothing to show graphically
         Console.WriteLine("\nPress any key to continue...");
         Console.ReadKey();
      }
   }
}