Delaunay Conform Edge Flipping#

Synopsis#

Flip the edges of one itk::QuadEdgeMesh to satisfy Delaunay condition.

Results#

Input mesh

Input mesh#

Output image

Output mesh#

Interactive input mesh

Code#

C++#

#include "itkMeshFileReader.h"
#include "itkMeshFileWriter.h"
#include "itkQuadEdgeMesh.h"

#include "itkDelaunayConformingQuadEdgeMeshFilter.h"

int
main(int argc, char * argv[])
{
  // Error message and help.
  if (argc != 3)
  {
    std::cerr << "Usage:" << std::endl;
    std::cerr << argv[0] << " <InputFileName> <OutputFileName>" << std::endl;
    return EXIT_FAILURE;
  }

  // Basic types.
  constexpr unsigned int Dimension = 3;
  using CoordType = double;

  using MeshType = itk::QuadEdgeMesh<CoordType, Dimension>;

  // Read the file in.
  using ReaderType = itk::MeshFileReader<MeshType>;
  auto reader = ReaderType::New();
  reader->SetFileName(argv[1]);

  // Process the mesh.
  MeshType::Pointer mesh = reader->GetOutput();
  using DelaunayConformFilterType = itk::DelaunayConformingQuadEdgeMeshFilter<MeshType, MeshType>;
  auto filter = DelaunayConformFilterType::New();
  filter->SetInput(mesh);

  // Write the output.
  using WriterType = itk::MeshFileWriter<MeshType>;
  auto writer = WriterType::New();
  writer->SetInput(filter->GetOutput());
  writer->SetFileName(argv[2]);

  try
  {
    writer->Update();
  }
  catch (const itk::ExceptionObject & error)
  {
    std::cerr << "Error: " << error << std::endl;
    return EXIT_FAILURE;
  }

  std::cout << "Number of Edge flipped performed: " << filter->GetNumberOfEdgeFlips() << std::endl;

  return EXIT_SUCCESS;
}

Classes demonstrated#

template<typename TInputMesh, typename TOutputMesh = TInputMesh>
class DelaunayConformingQuadEdgeMeshFilter : public itk::QuadEdgeMeshToQuadEdgeMeshFilter<TInputMesh, TOutputMesh>

FIXME Add documentation.

See itk::DelaunayConformingQuadEdgeMeshFilter for additional documentation.