Created
August 7, 2014 14:34
-
-
Save arnaudgelas/0f20ebdaf53956f79997 to your computer and use it in GitHub Desktop.
smoothing qe mesh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///// | |
#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