Skip to content

Instantly share code, notes, and snippets.

@arnaudgelas
Created August 7, 2014 14:34
Show Gist options
  • Save arnaudgelas/0f20ebdaf53956f79997 to your computer and use it in GitHub Desktop.
Save arnaudgelas/0f20ebdaf53956f79997 to your computer and use it in GitHub Desktop.
smoothing qe mesh
cmake_minimum_required( VERSION 2.8 )
find_package( ITK REQUIRED )
include( ${ITK_USE_FILE} )
add_executable( smooth smooth.cxx )
target_link_libraries( smooth ${ITK_LIBRARIES} )
/////
#include<iostream>
#include<string>
#include <itkMeshFileWriter.h>
#include <itkMeshFileReader.h>
#include <itkMeshIOFactory.h>
#include <itkMeshIOBase.h>
#include "itkMesh.h"
#include "itkQuadEdgeMesh.h"
#include "itkQuadEdgeMeshTraits.h"
#include "itkSmoothingQuadEdgeMeshFilter.h"
int main( int argc, char* argv[] )
{
typedef itk::QuadEdgeMeshTraits<double, 3,double, double, double,double > qetraits;
typedef itk::QuadEdgeMesh< double, 3,qetraits > MeshType;
itk::OnesMatrixCoefficients< MeshType > coeff0;
typedef itk::SmoothingQuadEdgeMeshFilter< MeshType, MeshType >SmoothingQuadEdgeMeshFilter;
SmoothingQuadEdgeMeshFilter::Pointer QEMeshSmoother = SmoothingQuadEdgeMeshFilter::New();
typedef itk::MeshFileReader<MeshType> MeshReaderType;
MeshReaderType::Pointer Meshreader = MeshReaderType::New();
Meshreader->SetFileName( argv[1] );
/*MeshType::Pointer mesh = Meshreader->GetOutput();
mesh->DisconnectPipeline();*/
QEMeshSmoother->SetInput(Meshreader->GetOutput()/*mesh*/ );
QEMeshSmoother->SetNumberOfIterations( 5 );
QEMeshSmoother->SetRelaxationFactor( 0.5 );
QEMeshSmoother->SetDelaunayConforming(true);
QEMeshSmoother->SetCoefficientsMethod( &coeff0 );
typedef itk::MeshFileWriter<MeshType> MeshWriterType;
MeshWriterType::Pointer Meshwriter = MeshWriterType::New();
Meshwriter->SetFileName( argv[2] );
Meshwriter->SetInput(QEMeshSmoother->GetOutput());
try
{
Meshwriter->Update();
}
catch( itk::ExceptionObject& e )
{
std::cerr << e.what() << std::endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment