82 lines
3.3 KiB
C++
82 lines
3.3 KiB
C++
/***********************************************************************************************************************
|
|
*
|
|
* Copyright (c) 2010 - 2022 by Tech Soft 3D, Inc.
|
|
* The information contained herein is confidential and proprietary to Tech Soft 3D, Inc., and considered a trade secret
|
|
* as defined under civil and criminal statutes. Tech Soft 3D shall pursue its civil and criminal remedies in the event
|
|
* of unauthorized use or misappropriation of its trade secrets. Use of this information by anyone other than authorized
|
|
* employees of Tech Soft 3D, Inc. is granted only under a written non-disclosure agreement, expressly prescribing the
|
|
* scope and manner of such use.
|
|
*
|
|
***********************************************************************************************************************/
|
|
/**
|
|
\file PublishImportExport.cpp
|
|
|
|
This sample demonstrates how to load a model and export it as a model file of a different format. The chosen
|
|
format is determined by the file extension of the output file name.
|
|
|
|
***********************************************************************************************************************/
|
|
|
|
#define INITIALIZE_A3D_API
|
|
#define HOOPS_PRODUCT_PUBLISH_STANDARD
|
|
#include <A3DSDKIncludes.h>
|
|
#include "../common.hpp"
|
|
|
|
// Typical commandline parameters which can be used with VisualCpp IDE :
|
|
// "..\..\..\..\..\data\prc\helloworld.prc" "..\..\..\..\..\publish\publishgallery\helloworld3.jt"
|
|
// Following are default parameters used when the exe is called with no arguments:
|
|
// Console exe is supposed to be launched from exe directory
|
|
#ifdef _MSC_VER
|
|
# define IN_FILE _T(SAMPLES_DATA_DIRECTORY"\\prc\\helloworld.prc")
|
|
# define OUT_FILE _T(SAMPLES_PUBLISH_GALLERY_DIRECTORY"\\helloworld.step")
|
|
#else
|
|
# define IN_FILE SAMPLES_DATA_DIRECTORY"/prc/helloworld.prc"
|
|
# define OUT_FILE SAMPLES_PUBLISH_GALLERY_DIRECTORY"/helloworld.jt"
|
|
#endif
|
|
|
|
|
|
|
|
//######################################################################################################################
|
|
#ifdef _MSC_VER
|
|
int wmain(A3DInt32 iArgc, A3DUniChar** ppcArgv)
|
|
#else
|
|
int main(int iArgc, A3DUTF8Char** ppcArgv)
|
|
#endif
|
|
{
|
|
#ifndef _MSC_VER
|
|
setenv("LC_NUMERIC", "en_US.UTF-8", 1); // Locally force locale
|
|
#endif
|
|
|
|
if (iArgc < 2 || iArgc > 4)
|
|
#if defined _MSC_VER
|
|
_tprintf(_T("Usage:\n %ls [input CAD file] [output CAD file] [log file]\n"), ppcArgv[0]);
|
|
#else
|
|
printf("Usage:\n %s [input CAD file] [output CAD file] [log file]\n", ppcArgv[0]);
|
|
#endif
|
|
|
|
if (!(iArgc == 4 && stdout != GetLogFile(ppcArgv[3])))
|
|
// if no log file specified on command line or redirection failed, fall back to local file
|
|
#ifdef _MSC_VER
|
|
GetLogFile(_T(SAMPLES_PUBLISH_GALLERY_DIRECTORY"\\PublishImportExport.log.txt"));
|
|
#else
|
|
GetLogFile(SAMPLES_PUBLISH_GALLERY_DIRECTORY"/PublishImportExport.log.txt");
|
|
#endif
|
|
|
|
A3DSDKHOOPSExchangeLoader sHoopsExchangeLoader(_T(HOOPS_BINARY_DIRECTORY));
|
|
CHECK_RET(sHoopsExchangeLoader.m_eSDKStatus)
|
|
A3DDllSetCallbacksMemory(CheckMalloc, CheckFree);
|
|
|
|
CHECK_RET(A3DDllSetCallbacksReport(PrintLogMessage, PrintLogWarning, PrintLogError))
|
|
|
|
// specify input file
|
|
A3DImport sImport(iArgc > 1 ? ppcArgv[1] : IN_FILE);
|
|
|
|
// specify output file
|
|
A3DExport sExport(iArgc > 2 ? ppcArgv[2] : OUT_FILE);
|
|
|
|
// perform conversion
|
|
CHECK_RET(sHoopsExchangeLoader.Convert(sImport, sExport));
|
|
|
|
// Check memory allocations
|
|
return (int)ListLeaks();
|
|
}
|