MOAB: Mesh Oriented datABase  (version 5.2.1)
shape-improve.cpp
Go to the documentation of this file.
00001 #include "ShapeImprover.hpp"
00002 #include "MeshImpl.hpp"
00003 #include "CLArgs.hpp"
00004 #include "MsqError.hpp"
00005 
00006 #include "domain.hpp"
00007 
00008 #include <iostream>
00009 
00010 using namespace MBMesquite;
00011 
00012 int main( int argc, char* argv[] )
00013 {
00014     const double zero = 0.0, one = 1.0;
00015     double default_cpu_time = 0.0;
00016     CLArgs::DoubleRangeArg movement_beta( &zero, &one ), cpu_time( default_cpu_time, &zero, 0 );
00017 
00018     CLArgs args( "msqshape", "Run Shape Improvement smoother for input mesh.",
00019                  "Read VTK file, smooth, and re-write file." );
00020     args.double_flag( 'b', "Vtx Movement Beta",
00021                       "fraction of mean edge length to use as termination criterion on vertex movement",
00022                       &movement_beta );
00023     args.double_flag( 't', "Cpu Seconds", "time-out", &cpu_time );
00024 
00025     add_domain_args( args );
00026     args.add_required_arg( "input_file" );
00027     args.add_required_arg( "output_file" );
00028 
00029     std::vector< std::string > files;
00030     if( !args.parse_options( argc, argv, files, std::cerr ) )
00031     {
00032         args.print_usage( std::cerr );
00033         exit( 1 );
00034     }
00035     std::string input_file  = files[0];
00036     std::string output_file = files[1];
00037 
00038     MsqError err;
00039     MeshImpl mesh;
00040     mesh.read_vtk( input_file.c_str(), err );
00041     if( err )
00042     {
00043         std::cerr << "ERROR READING FILE: " << input_file << std::endl << err << std::endl;
00044         return 2;
00045     }
00046     MeshDomain* domain = process_domain_args( &mesh );
00047 
00048     ShapeImprover smoother;
00049     if( movement_beta.seen() ) smoother.set_vertex_movement_limit_factor( movement_beta.value() );
00050     if( cpu_time.seen() ) smoother.set_cpu_time_limit( cpu_time.value() );
00051     MeshDomainAssoc mesh_and_domain = MeshDomainAssoc( &mesh, domain );
00052     smoother.run_instructions( &mesh_and_domain, err );
00053     if( err )
00054     {
00055         std::cerr << err << std::endl;
00056         return 3;
00057     }
00058 
00059     mesh.write_vtk( output_file.c_str(), err );
00060     if( err )
00061     {
00062         std::cerr << "ERROR WRITING FILE: " << output_file << std::endl << err << std::endl;
00063         return 2;
00064     }
00065 
00066     return 0;
00067 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines