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,201 @@
/***********************************************************************************************************************
*
* 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 UpdateData.cpp
This file demonstrates how to update a PDF file generated with Tetra 4D Enrich, using HOOPS Publish.
***********************************************************************************************************************/
#define INITIALIZE_A3D_API
#define HOOPS_PRODUCT_PUBLISH_ADVANCED
#include <A3DSDKIncludes.h>
#include "../common.hpp"
#include "../CommonInit.h"
#include <iostream>
// default sample arguments:
// in visual c++: the current directory is set through properties to $OutDir, which is $(Platform)\$(Configuration)
// in linux: the current directory is supposed to be the same as this cpp file
#ifdef _MSC_VER
# define IN_3DFILE SAMPLES_DATA_DIRECTORY"\\prc\\_micro engine.prc"
# define IN_PDFFILE SAMPLES_DATA_DIRECTORY"\\pdf_templates\\Tetra4D_Enrich_Template_PartList.pdf"
# define IN_XMLATTRIBS SAMPLES_DATA_DIRECTORY"\\prc\\_micro engine_Add3DAttributes.xml"
# define IN_XMLTEXTS SAMPLES_DATA_DIRECTORY"\\prc\\_micro engine_ImportTextField.xml"
# define IN_POSTERIMAGE SAMPLES_DATA_DIRECTORY"\\images\\empty.jpg"
# define OUT_FILE SAMPLES_PUBLISH_GALLERY_DIRECTORY"\\sample_UpdateData.pdf"
#else
# define MAX_PATH 4096 // let's be large
# define IN_3DFILE SAMPLES_DATA_DIRECTORY"/prc/_micro engine.prc"
# define IN_PDFFILE SAMPLES_DATA_DIRECTORY"/pdf_templates/Tetra4D_Enrich_Template_PartList.pdf"
# define IN_XMLATTRIBS SAMPLES_DATA_DIRECTORY"/prc/_micro engine_Add3DAttributes.xml"
# define IN_XMLTEXTS SAMPLES_DATA_DIRECTORY"/prc/_micro engine_ImportTextField.xml"
# define IN_POSTERIMAGE SAMPLES_DATA_DIRECTORY"/images/empty.jpg"
# define OUT_FILE SAMPLES_PUBLISH_GALLERY_DIRECTORY"/sample_UpdateData.pdf"
#endif
A3DStatus BuildPDFDocument(A3DUTF8Char *in_3dfile, A3DUTF8Char *out_pdffile)
{
A3DStatus iRet = A3D_SUCCESS;
// create document from template file.
// it is necessary to use the function A3DPDFDocumentCreateFromPDFFile to create a document that will be provided to A3DPDFDocumentUpdateData,
// so that all necessary information are kept(javascript and all internal data stored in the document).
A3DPDFDocument* pDoc = NULL;
CHECK_RET(A3DPDFDocumentCreateFromPDFFile(IN_PDFFILE, &pDoc));
if (pDoc != NULL)
{
// reading the input file; the file can be disposed of afterwards.
A3DAsmModelFile* pModelFile;
A3DRWParamsLoadData sReadParam;
A3D_INITIALIZE_DATA(A3DRWParamsLoadData, sReadParam);
sReadParam.m_sGeneral.m_bReadSolids = true;
sReadParam.m_sGeneral.m_bReadSurfaces = true;
sReadParam.m_sGeneral.m_bReadWireframes = true;
sReadParam.m_sGeneral.m_bReadPmis = true;
sReadParam.m_sGeneral.m_bReadAttributes = true;
sReadParam.m_sGeneral.m_bReadHiddenObjects = false;
sReadParam.m_sGeneral.m_bReadConstructionAndReferences = false;
sReadParam.m_sGeneral.m_bReadActiveFilter = true;
sReadParam.m_sGeneral.m_eReadingMode2D3D = kA3DRead_3D;
sReadParam.m_sGeneral.m_eReadGeomTessMode = kA3DReadGeomAndTess;
sReadParam.m_sGeneral.m_eDefaultUnit = kA3DUnitUnknown;
sReadParam.m_sPmi.m_bAlwaysSubstituteFont = false;
sReadParam.m_sPmi.m_pcSubstitutionFont = const_cast<A3DUTF8Char*>("Myriad CAD");
sReadParam.m_sTessellation.m_eTessellationLevelOfDetail = kA3DTessLODMedium;
sReadParam.m_sMultiEntries.m_bLoadDefault = true;
sReadParam.m_sAssembly.m_bUseRootDirectory = true;
iRet = A3DAsmModelFileLoadFromFile(in_3dfile, &sReadParam, &pModelFile);
if (iRet != A3D_SUCCESS && iRet != A3D_LOAD_MISSING_COMPONENTS)
{
std::cout << "Error number=" << iRet << std::endl;
return iRet;
}
if (pModelFile)
{
// creating a poster image to be used as a poster for 3D.
A3DPDFImage* pImage = NULL;
A3DPDFImageCreateFromFile(pDoc, IN_POSTERIMAGE, kA3DPDFImageFormatUnknown, &pImage);
// creating the 3D artwork
A3DPDF3DArtworkData2 s3DArtworkData;
A3D_INITIALIZE_DATA(A3DPDF3DArtworkData2, s3DArtworkData);
s3DArtworkData.m_sDisplaySectionData.m_bAddSectionCaps = true;
A3DPDF3DAnnotData sAnnotData;
A3D_INITIALIZE_DATA(A3DPDF3DAnnotData, sAnnotData);
sAnnotData.m_bOpenModelTree = false;
sAnnotData.m_bShowToolbar = false;
sAnnotData.m_eLighting = kA3DPDFLightCADOptimized;
sAnnotData.m_eRenderingStyle = kA3DPDFRenderingSolid;
sAnnotData.m_sBackgroundColor.m_dRed = 0.75;
sAnnotData.m_sBackgroundColor.m_dGreen = 0.75;
sAnnotData.m_sBackgroundColor.m_dBlue = 0.75;
sAnnotData.m_bTransparentBackground = false;
sAnnotData.m_eActivateWhen = kA3DPDFActivPageOpened;
sAnnotData.m_eDesactivateWhen = kA3DPDFActivPageClosed;
sAnnotData.m_iAppearanceBorderWidth = 0;
sAnnotData.m_pPosterImage = pImage;
// the modelfile pModelFile is stored in the PDF document as PRC, using these parameters
A3DRWParamsExportPrcData sParamExportPrcData;
A3D_INITIALIZE_DATA(A3DRWParamsExportPrcData, sParamExportPrcData);
A3DRWParamsPrcWriteHelper* pHelper = NULL;
iRet = A3DPDFDocumentUpdateData(pDoc,
NULL, -1, -1, // 3Dannot identifier: get the first one met in the document
pModelFile, &sParamExportPrcData, &pHelper, // modelfile to use to update 3D data
&s3DArtworkData, &sAnnotData, // options to create the replaced 3D annot
false, // bAddStandardViews
NULL, // pDefaultViewData
IN_XMLATTRIBS, // pcIn3dAttribsFile
IN_XMLTEXTS); // pcInTextFieldDataFile
// cleaning up -- WARNING: DO NOT CALL THIS BEFORE A3DPDF3DArtworkCreate!
CHECK_RET(A3DAsmModelFileDelete(pModelFile));
// saving the document
CHECK_RET(A3DPDFDocumentSaveEx(pDoc, kA3DPDFSaveFull | kA3DPDFSaveOptimized, out_pdffile));
CHECK_RET(A3DPDFDocumentClose(pDoc));
}
}
return iRet;
}
//######################################################################################################################
// Main function
#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
// init A3DLIB library - automatically handled init/terminate
A3DSDKHOOPSPublishLoader sHoopsPublishLoader(_T(HOOPS_BINARY_DIRECTORY));
CHECK_RET(sHoopsPublishLoader.m_eSDKStatus);
A3DDllSetCallbacksMemory(CheckMalloc, CheckFree);
// init HOOPS Publish related PDF library - automatically handled init/terminate
// do it only only once during the life of the application
CHECK_RET(sHoopsPublishLoader.InitPDFLib());
A3DUTF8Char in_3dfile[MAX_PATH * 4];
A3DUTF8Char out_pdffile[MAX_PATH * 4];
switch (iArgc)
{
case 1:
// no arguments provided
strcpy(in_3dfile, IN_3DFILE);
strcpy(out_pdffile, OUT_FILE);
break;
case 3:
// converting the input parameters to UTF-8
#ifdef _MSC_VER
A3DMiscUTF16ToUTF8(ppcArgv[1], in_3dfile);
A3DMiscUTF16ToUTF8(ppcArgv[2], out_pdffile);
#else
strcpy(in_3dfile, ppcArgv[1]);
strcpy(out_pdffile, ppcArgv[2]);
#endif
break;
default:
std::cout << "Usage:\n" << ppcArgv[0] << " <in_3dfile> <out_pdffile>\n";
return A3D_ERROR;
}
// launch PDF treatment
A3DStatus iRet = BuildPDFDocument(in_3dfile, out_pdffile);
if (iRet != A3D_SUCCESS)
return iRet;
// Check memory allocations
return (int)ListLeaks();
}

View File

@@ -0,0 +1,162 @@
<?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|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{3fc16f11-56b6-47da-a8d1-385ffe2e3107}</ProjectGuid>
<RootNamespace>UpdateData</RootNamespace>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<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|Win32'" 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|Win32'" 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)'=='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|Win32'">
<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>MachineX86</TargetMachine>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalDependencies>legacy_stdio_float_rounding.obj;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<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>
<AdditionalDependencies>legacy_stdio_float_rounding.obj;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<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>MachineX86</TargetMachine>
<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="UpdateData.cpp" />
</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="UpdateData.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>