=head1 NAME

CFX5::Simulation::Configuration::Remeshing::Remesh::GeometryMod - Geometry modification module

=head1 SYNOPSIS

Functions for geometry modification setp of the remesh process

$Id: GeometryMod.pm 97857 2008-04-07 15:11:15Z owalsh $

=cut

package CFX5::Simulation::Configuration::Remeshing::Remesh::GeometryMod ;

use strict ;

use vars qw($CVSVersion);
$CVSVersion='$Id: GeometryMod.pm 97857 2008-04-07 15:11:15Z owalsh $ ';

use Exporter ; 
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@ISA=qw(Exporter);
@EXPORT_OK=qw(GeomMod);
%EXPORT_TAGS = (
  'all' => [qw(GeomMod)],  
);

use CFX5::Output qw(:all error_text);
use CFX5::PathManip qw(change_cwd);
use CFX5::PkgLoader qw(cfx5_require);

#
################################################################################
# GeomMod - High level GeometryMod routine
################################################################################
#
sub GeomMod {
  my ($self) = @_ ; 
#
#===============================================================================
# Setup
#===============================================================================
#
# Connect to text output file
#
  my $outfile=$self->Get("OutObj");
  unless (defined $outfile) {
    _error "Remeshing: Could not connect to out file" ;
    return 0;
  }
#
#===============================================================================
# Gather required information from the remesh object
#===============================================================================
#
  my $rundir = $self->Get("RunDir") ; 
  if (!defined $rundir) {
    _error "Preprocess: Run directory not available" ;
    return 0; 
  }
  my $cclapi=$self->Get("CCLAPI");
  unless (defined $cclapi) {
    _error "GeometryMod: Could not connect to CCL" ;
    return 0; 
  }
  my $CCLPath = $self->Get("CCLPath");
  unless (defined $CCLPath) {
    _error "GeometryMod: CCLPath not available" ;
    return 0; 
  }
#
#===============================================================================
#  ICEM CFD Replay
#===============================================================================
#   
  if    ($self->Get("Option") eq "ICEM CFD Replay") {
#
# Nothing to do here
#  
  }
#
#===============================================================================
#  User Defined
#===============================================================================
#   
  elsif ($self->Get("Option") eq "User Defined") {
#
#----------------------------------------------------------------------- 
# Setup
#----------------------------------------------------------------------- 
#
    my $cmdLine ;
    
    $cclapi->getStringValue("$CCLPath/GEOMETRY CONTROL/Command Line",\$cmdLine) ;
    if (defined $cmdLine) {
      $outfile->print("\n  Executing geometry control command:\n  $cmdLine\n") ;
      $rundir->enter() ;
      system ($cmdLine) ; 
      $rundir->leave() ;
    }
  }
#
#===============================================================================
#  Unhandled Option
#===============================================================================
#   
  else {
    _error "GeomMod: Invalid Remesh Option found" ;
    return 0 ; 
  }

  1 ;
}

1 ;
