Files
Hoops_Exchange/exchange/exchangesource/CreatePRCCubes/CreatePRCCubes.cpp
2025-12-15 23:22:33 +08:00

129 lines
4.5 KiB
C++

/***********************************************************************************************************************
*
* Copyright (c) 2010 - 2025 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.
*
***********************************************************************************************************************/
/**
* Sample CreatePRCCubes
* file CreatePRCCubes.cpp
* This file is containing the main trunc of the CreatePRCCubes sample.
*
* The purpose of this sample is to propose an embryo set of functionality allowing the creation of various PRC entities.
* It proposes and tackles different modules such as:
* - creation of markups: see CreateMarkups.cpp
* - creation of views: see CreateViews.cpp
* - creation of textures: see CreateTextures.cpp
* - creation of colors: see CreateGraphics.cpp
* - creation of links between entities: see CreateLinkedItem.cpp
*
* Inside this files is created either a PRC or a PDF file with a defined structures,
* a certain number of markups and a certain number of views.
*
* The function createAssemblyTree, createFileMarkups, createFileViews
* can be modified to create your own PRC or PDF file:
* modifying the structure can be done in createAssemblyTree.
* modifying the views can be done in createFileViews.
* modifying the markups can be done in createFileMarkups.
*
* It should be the reference sample for PRC entity creation but is also a great tool to understand how the PRC tree is working.
*
***********************************************************************************************************************/
#include <hoops_license.h>
#define INITIALIZE_A3D_API
#include "CreatePRCCubesDef.h"
#include "CreateModelFile.h"
#include <vector>
static MY_CHAR acDstFileName[_MAX_PATH * 2];
static MY_CHAR acJpgFileName[_MAX_PATH * 2];
static MY_CHAR acLogFileName[_MAX_PATH * 2];
//######################################################################################################################
/*
void debugCheckRet()
{
printf("debug");
}
#define CHECK_RET(function_call) {\
iRet = function_call; if(iRet != A3D_SUCCESS) { debugCheckRet(); std::cout << "Error number=" << iRet << std::endl; return iRet; }\
}
*/
//######################################################################################################################
// Main function
#ifdef _MSC_VER
int wmain(A3DInt32 iArgc, A3DUniChar** ppcArgv)
#else
int main(A3DInt32 iArgc, A3DUTF8Char** ppcArgv)
#endif
{
//
// ### COMMAND LINE ARGUMENTS
//
if (iArgc > 4 || iArgc < 2)
{
MY_PRINTF2("Usage:\n %s [output PRC file] [existing JPG file] [output LOG file]\n", ppcArgv[0]);
MY_PRINTF(" Default existing JPG file is [output PRC file].jpg\n");
MY_PRINTF(" Default output LOG file is [output PRC file]_Log.txt\n\n");
return A3D_ERROR;
}
MY_STRCPY(acDstFileName, ppcArgv[1]);
if (iArgc > 2) MY_STRCPY(acJpgFileName, ppcArgv[2]);
else MY_SPRINTF(acJpgFileName, "%s.jpg", acDstFileName);
if (iArgc > 3) MY_STRCPY(acLogFileName, ppcArgv[3]);
else MY_SPRINTF(acLogFileName, "%s_Log.txt", acDstFileName);
GetLogFile(acLogFileName); // Initialize log file
//
// ### INITIALIZE HOOPS EXCHANGE
//
A3DSDKHOOPSExchangeLoader sHoopsExchangeLoader(_T(HOOPS_BINARY_DIRECTORY), HOOPS_LICENSE);
CHECK_RET(sHoopsExchangeLoader.m_eSDKStatus);
// Initialize callbacks
CHECK_RET(A3DDllSetCallbacksMemory(CheckMalloc, CheckFree));
CHECK_RET(A3DDllSetCallbacksReport(PrintLogMessage, PrintLogWarning, PrintLogError));
//
// ### PROCESS SAMPLE CODE
//
A3DUTF8Char sJPGFileNameUTF8[_MAX_PATH];
#ifdef _MSC_VER
A3DMiscUTF16ToUTF8(acJpgFileName, sJPGFileNameUTF8);
#else
MY_STRCPY(sJPGFileNameUTF8, acJpgFileName);
#endif
CHECK_RET(createPRCCubesFile(&sHoopsExchangeLoader.m_psModelFile, sJPGFileNameUTF8));
if (sHoopsExchangeLoader.m_psModelFile)
{
A3DExport sExport(acDstFileName); // see A3DSDKInternalConvert.hxx for import and export detailed parameters
CHECK_RET(sHoopsExchangeLoader.Export(sExport));
}
//
// ### TERMINATE HOOPS EXCHANGE
//
// Check memory allocations
return (int)ListLeaks();
}