Add publish

This commit is contained in:
ninja
2025-12-15 22:10:55 +08:00
parent 2b56cf87a8
commit c06fe95a1e
285 changed files with 69398 additions and 1 deletions

View File

@@ -0,0 +1,174 @@
/***********************************************************************************************************************
*
* 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.
*
***********************************************************************************************************************/
/*
* This sample demonstrates how to load a model and export it as HTML or SCS format. The chosen
* format is determined by the file extension of the output file name.
* -- HTML Export:
* . The HTML output file is self-contenant without external dependancies and can be read as-is in a web browser.
* . The HTML is generated from a template HTML file provided as input. A template sample is provided in the package.
* -- SCS Export:
* . The SCS output file is a cache file to be reffered by a html file. The html file should typically be launched into
* a web server.
* . The package provides a sample HTTP server for that usage. See \samples\publish\publishhtml\htmlforserver\.
*/
#define INITIALIZE_A3D_API
#define HOOPS_PRODUCT_PUBLISH_ADVANCED
#include <A3DSDKIncludes.h>
#include "../common.hpp"
#include <iostream>
//######################################################################################################################
// Usage: All parameters are defaultable.
// Export3DToHtml [INPUT] [HTML] [FORMAT] [OUTPUT] [LOG_FILE]
// - INPUT : The path to the input CAD file. Defaults to IN_FILE
// - HTML : The HTML template used by the exporter. Default to IN_FILE_HTMLTEMPLATE
// - FORMAT : The export format. Must be either 'html' or 'scs'. Defaults to "html".
// - OUTPUT : The path to output file.
// : If FORMAT=html, defaults to OUT_FILE_HTML
// : Else , defaults to OUT_FILE_SCS
// - LOG_FILE : The output log file. If not specified, the program writes in:
// : SAMPLES_PUBLISH_HTML_DIRECTORY/htmlsinglefile/Export3DToHtml.log.txt for html
// : SAMPLES_PUBLISH_HTML_DIRECTORY/htmlforserver/export3dtohtml/Export3DToHtml.log.txt for scs
#ifdef _MSC_VER
# define IN_FILE _T(SAMPLES_DATA_DIRECTORY"\\prc\\helloworld.prc")
# define IN_FILE_HTMLTEMPLATE _T(SAMPLES_DATA_DIRECTORY"\\html\\export3dtohtml_template.html")
# define IN_EXPORTFORMAT _T("html") // values are "html" or "scs"
# define OUT_FILE_SCS _T(SAMPLES_PUBLISH_HTML_DIRECTORY"\\htmlforserver\\export3dtohtml\\root\\helloworld.scs")
# define OUT_FILE_HTML _T(SAMPLES_PUBLISH_HTML_DIRECTORY"\\htmlsinglefile\\helloworld.html")
#else
# define IN_FILE SAMPLES_DATA_DIRECTORY"/prc/helloworld.prc"
# define IN_FILE_HTMLTEMPLATE SAMPLES_DATA_DIRECTORY"/html/export3dtohtml_template.html"
# define IN_EXPORTFORMAT "html" // values are "html" or "scs"
# define OUT_FILE_SCS SAMPLES_PUBLISH_HTML_DIRECTORY"/htmlforserver/export3dtohtml/root/helloworld.scs"
# define OUT_FILE_HTML SAMPLES_PUBLISH_HTML_DIRECTORY"/htmlsinglefile/helloworld.html"
#endif
bool ReadPdfFileWithPrcStream(A3DImport const& a_sImport, A3DAsmModelFile*& a_psModelFile);
//######################################################################################################################
#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 > 6)
{
printf("Usage: Export3DToHtml [INPUT] [HTML] [FORMAT] [OUTPUT] [LOG_FILE]\nAll parameters are defaultable.\nSee source file for details.\n");
return 0;
}
bool bExportAsHtml = false;
if (iArgc > 3)
bExportAsHtml = (MY_STRCMP(ppcArgv[3], "html") == 0);
else
bExportAsHtml = (MY_STRCMP(IN_EXPORTFORMAT, "html") == 0);
if (!(iArgc >= 6 && stdout != GetLogFile(ppcArgv[5])))
{
// if no log file specified on command line or redirection failed, fall back to local file
#ifdef _MSC_VER
if (bExportAsHtml)
GetLogFile(_T(SAMPLES_PUBLISH_HTML_DIRECTORY"\\htmlsinglefile\\Export3DToHtml.log.txt"));
else
GetLogFile(_T(SAMPLES_PUBLISH_HTML_DIRECTORY"\\htmlforserver\\export3dtohtml\\Export3DToHtml.log.txt"));
#else
if (bExportAsHtml)
GetLogFile(SAMPLES_PUBLISH_HTML_DIRECTORY"/htmlsinglefile/Export3DToHtml.log.txt");
else
GetLogFile(SAMPLES_PUBLISH_HTML_DIRECTORY"/htmlforserver/export3dtohtml/Export3DToHtml.log.txt");
#endif
}
A3DSDKHOOPSExchangeLoader sHoopsExchangeLoader(_T(HOOPS_BINARY_DIRECTORY));
CHECK_RET(sHoopsExchangeLoader.m_eSDKStatus)
CHECK_RET(A3DDllSetCallbacksMemory(CheckMalloc, CheckFree));
CHECK_RET(A3DDllSetCallbacksReport(PrintLogMessage, PrintLogWarning, PrintLogError))
// specify input file
A3DImport sImport(iArgc > 1 ? ppcArgv[1] : IN_FILE);
A3DAsmModelFile* psModelFile = nullptr;
if(ReadPdfFileWithPrcStream(sImport, psModelFile) == false)
{
CHECK_RET(A3DAsmModelFileLoadFromFile(sImport.GetFilePath(), &sImport.m_sLoadData, &psModelFile));
}
if (psModelFile)
{
if (bExportAsHtml)
{
// specify output file
A3DExport sExport(iArgc > 4 ? ppcArgv[4] : OUT_FILE_HTML);
sExport.m_sExportHtmlData.m_bIncludeMeasurementInformation = true;
#ifdef _MSC_VER
A3DUTF8Char acFileNameUTF8[_MAX_PATH];
A3DMiscUTF16ToUTF8((iArgc > 2 ? ppcArgv[2] : IN_FILE_HTMLTEMPLATE), acFileNameUTF8);
sExport.m_sExportHtmlData.m_pcHtmlTemplateName = acFileNameUTF8;
#else
sExport.m_sExportHtmlData.m_pcHtmlTemplateName = (A3DUTF8Char *)(iArgc > 2 ? ppcArgv[2] : IN_FILE_HTMLTEMPLATE);
#endif
// conversion is performed
CHECK_RET(A3DAsmModelFileExportToHTMLFile(psModelFile, &sExport.m_sExportHtmlData, sExport.GetFilePath()));
}
else
{
// specify output file
A3DExport sExport(iArgc > 4 ? ppcArgv[4] : OUT_FILE_SCS);
sExport.m_sExportScsData.m_bIncludeMeasurementInformation = true;
// conversion is performed
CHECK_RET(A3DAsmModelFileExportToSCSFile(psModelFile, &sExport.m_sExportScsData, sExport.GetFilePath()));
}
A3DAsmModelFileDelete(psModelFile);
}
// Check memory allocations
return (int)ListLeaks();
}
bool ReadPdfFileWithPrcStream(A3DImport const& a_sImport, A3DAsmModelFile*& a_psModelFile)
{
if (strstr(a_sImport.GetFilePath(), ".pdf") != nullptr)
{
A3DStream3DPDFData* pStream3DPDFData;
A3DInt32 iNumStreams;
A3DStatus iRet = A3DPDFGetStreams(a_sImport.GetFilePath(), kA3DPDFFilterNativeViews, &pStream3DPDFData, &iNumStreams);
if (iRet != A3D_SUCCESS || iNumStreams == 0)
{
return false;
}
// a real use case might parse every streams in the input file. Here we just take the first one (pStream3DPDFData[0]).
// even an input PRC file must be read in memory and mapped into modelfile data structures
if (pStream3DPDFData[0].m_bIsPrc)
{
iRet = A3DAsmModelFileLoadFromPrcStream(pStream3DPDFData[0].m_acStream, pStream3DPDFData[0].m_uiStreamSize, NULL, &a_psModelFile);
}
A3DPDFGetStreams(nullptr, kA3DPDFFilterNativeViews, &pStream3DPDFData, &iNumStreams); // to clean up the array of stream data
return iRet == A3D_SUCCESS && a_psModelFile != nullptr;
}
else
{
return false;
}
}

View File

@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{26fc13db-2678-42bd-926c-8865669af1b3}</ProjectGuid>
<RootNamespace>Export3DToHtml</RootNamespace>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(SolutionDir)\HOOPSExchangePublishSample.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(SolutionDir)\HOOPSExchangePublishSample.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>12.0.30501.0</_ProjectFileVersion>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader />
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX64</TargetMachine>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalDependencies>legacy_stdio_float_rounding.obj;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader />
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX64</TargetMachine>
<AdditionalDependencies>legacy_stdio_float_rounding.obj;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Export3DToHtml.cpp">
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Level3</WarningLevel>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Export3DToHtml.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>