@echo off
setlocal


rem ### Edit ###
set OUTPUT_FOLDER=%~dp0

set E3DS_COMPONENT=XXX
set TIMEOUT=360


rem ### Do Not Edit ###
set INPUT_FILE_NAME=%1
set SCRIPT_FOLDER=%~dp0..\COMMON

set WORK_DIR=%OUTPUT_FOLDER%\work\%~n1
set RESULTS_DIR=%OUTPUT_FOLDER%\result\%~n1
set DAIMLER_SUPPLIER_SCRIPT=%SCRIPT_FOLDER%\apply_daimler_setting.rb


rem ### CATIA V5 to PLMXML/JT ###
set OUTPUT_EXT=.jt
set PID=117841
if /i "%~x1" == ".CATProduct" (
  set PID=117941
  set OUTPUT_EXT=.plmxml
)

rem ### elybatch
set ELYBATCH=%E3DS_COMPONENT%\tools\win\elybatch.exe
rem ### files
set CONFIG_FILE=%~dp0daimler_config.cfg
set SCENARIOFILE=%~dp0daimler_scenario.xml
set PARAMETER_FILE=%~dp0daimler_v5_to_plmxml_jt.prm

rem ### environment variables
set ELY_AVOID_JTSP_WARNING=1
set ELY_CAAENF_FITSUR_NO_IMPOSE=1
set DIVIDE_CLOSED_CURVE=0
set DIVIDE_CLOSED_FACE=0
set DIVIDE_CREASE_SRF=2
set DIVIDE_SELFINT_FACE=3
set REPAIR_FACE_BAD_ASPECT=0
set UNSTITCH_GAP_EDGE=0
set EXTEND_SURF_NEAR_EDGE=0
set APPROXIMATE_CRV=0
set APPROXIMATE_SRF=0
set TRIM_LARGE_ANALYTIC_SRF=1
set MODIFY_REVSRF_HEIGHT=1

rem ### mkdir
mkdir %WORK_DIR%
mkdir %RESULTS_DIR%

call :TRANSLATE %INPUT_FILE_NAME%

goto :END


rem *******************************************************
:TRANSLATE

set OUTPUT_FILE_NAME=%RESULTS_DIR%\%~n1%OUTPUT_EXT%
set LOG_NAME=%WORK_DIR%\%~n1.log
set XML_LOG_NAME=%~n1.xml
set SCENARIOLOG=%~n1_scenario_log.xml

"%ELYBATCH%" -f"%CONFIG_FILE%" -p%PID% -w"%WORK_DIR%" -i%INPUT_FILE_NAME% -o"%OUTPUT_FILE_NAME%" -u"%LOG_NAME%" -X"%XML_LOG_NAME%" -c"%PARAMETER_FILE%" -t%TIMEOUT% -S"%SCENARIOFILE%" -U"%SCENARIOLOG%"

goto :EOF
rem *******************************************************


:END
endlocal
