This commit is contained in:
ninja
2025-12-15 22:06:49 +08:00
commit 2b56cf87a8
225 changed files with 63711 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
/***********************************************************************************************************************
*
* 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.
*
***********************************************************************************************************************/
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::CompilerServices;
using namespace System::Runtime::InteropServices;
using namespace System::Security::Permissions;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly:AssemblyTitleAttribute("TechSoft3DExchangeNetWrapper")];
[assembly:AssemblyDescriptionAttribute("")];
[assembly:AssemblyConfigurationAttribute("")];
[assembly:AssemblyCompanyAttribute("Tech Soft 3D")];
[assembly:AssemblyProductAttribute("TechSoft3DExchangeNetWrapper")];
[assembly:AssemblyCopyrightAttribute("Copyright (c) 2010 - 2022 by Tech Soft 3D, Inc.")];
[assembly:AssemblyTrademarkAttribute("")];
[assembly:AssemblyCultureAttribute("")];
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the value or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly:AssemblyVersionAttribute("5.2.*")];
[assembly:ComVisible(false)];
[assembly:CLSCompliantAttribute(true)];

View File

@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{765D5D20-2470-4597-93CD-25A7E118814D}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ConsoleApplication</RootNamespace>
<AssemblyName>ConsoleApplication</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>Win32\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>Win32\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ConsoleApplication\Program.cs" />
<Compile Include="ConsoleApplication\Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="TechSoft3D.Exchange.NetWrapper.vcxproj">
<Project>{2e7e13b4-0ac4-480f-901f-024cf1938308}</Project>
<Name>TechSoft3D.Exchange.NetWrapper</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,196 @@
/***********************************************************************************************************************
*
* 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.
*
***********************************************************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using TechSoft3D.HOOPS;
namespace ConsoleApplication
{
class Program
{
static Exchange m_pExchange;
static string m_pcFileName;
static int m_iProgressBareSize;
static int m_iStart;
//##############################################################################################################
static void stFCTStart(int i)
{
m_iStart = i;
switch (i)
{
case 1:
{
Console.WriteLine("Start Parsing File: {0}", m_pcFileName);
break;
}
case 2:
{
Console.WriteLine("Start Writing to Parasolid");
break;
}
case 3:
{
// m_pExchange.Break();
Console.WriteLine("Start Reading File {0}", m_pcFileName);
break;
}
default:
break;
}
}
//##############################################################################################################
static void stFCTitle(string str)
{
m_pcFileName = str;
}
//##############################################################################################################
static void stFCTSize(int i)
{
m_iProgressBareSize = i;
}
//##############################################################################################################
static void stFCTIncr(int i)
{
if (m_iProgressBareSize != 0)
{
int iPercentage = (int)(i * 100 / (double)m_iProgressBareSize);
Console.WriteLine("Progress: {0} % ", iPercentage);
}
}
//##############################################################################################################
static void stFCTEnd()
{
Console.WriteLine("Progress: 100/% ");
m_iProgressBareSize = 0;
}
static int stFCTReportMessage(string Msg)
{
Console.Write(Msg);
return 1;
}
static int stFCTkReportWarning(string Code,string Msg)
{
Console.Write("WARNING " + Code + " " + Msg);
return 1;
}
static int stFCTReportError(string Code,string Msg)
{
Console.Write("ERROR " + Code + " " + Msg);
return 1;
}
//##############################################################################################################
static bool stTranslate(string InputCADFile, string OutputXTFile, string LogFile, bool bWriteBlankedEntities)
{
if (m_pExchange == null)
{
m_pExchange = new Exchange();
if (!m_pExchange.Init())
{
Console.WriteLine("Cannot initialize HOOPS Exchange");
return false;
}
if (LogFile.Length > 0)
m_pExchange.SetLogFile(LogFile);
Exchange.CallbackStart pStart = new Exchange.CallbackStart(stFCTStart);
Exchange.CallbackTitle pTitle = new Exchange.CallbackTitle(stFCTitle);
Exchange.CallbackIncrement pIncr = new Exchange.CallbackIncrement(stFCTIncr);
Exchange.CallbackSize pSize = new Exchange.CallbackSize(stFCTSize);
Exchange.CallbackEnd pEnd = new Exchange.CallbackEnd(stFCTEnd);
Exchange.CallbackReportMessage pMessage = new Exchange.CallbackReportMessage(stFCTReportMessage);
Exchange.CallbackReportWarning pWarning = new Exchange.CallbackReportWarning(stFCTkReportWarning);
Exchange.CallbackReportError pError = new Exchange.CallbackReportError(stFCTReportError);
m_pExchange.SetCallBackFct(pStart, pTitle, pSize, pIncr, pEnd);
m_pExchange.SetCallBackMessageFct(pMessage, pWarning, pError);
}
IDictionary<string, string> sOptions = new Dictionary<string, string>();
sOptions.Add("WriteBlankedEntities", bWriteBlankedEntities ? "true" : "false");
sOptions.Add("General.ReadSolids", "true");
sOptions.Add("General.ReadSurfaces", "false");
sOptions.Add("General.ReadWireframes", "false");
//sOptions.Add("General.ReadAttributes", "false");
//sOptions.Add("General.ReadConstructionAndReferences", "true");
//sOptions.Add("General.ReadActiveFilter", "true");
//sOptions.Add("Assembly.UseRootDirectory", "true");
//sOptions.Add("Assembly.RootDirRecursive", "true");
//sOptions.Add("Assembly.SearchDir[0].PhysicalPath", "C:\\temp\\");
//sOptions.Add("Assembly.SearchDir[0].Recursive", "C:\\temp\\");
//sOptions.Add("Assembly.SearchDir[1].PhysicalPath", "C:\\temp2\\");
//sOptions.Add("Assembly.SearchDir[1].Recursive", "true");
//sOptions.Add("Specifics.CatiaV4.RootDirLogicalName", "LogicalNameSample");
//sOptions.Add("Specifics.CatiaV4.AllowSearchInOtherLogicalNames", "true");
bool bIsProEFile = m_pExchange.IsProEFile(InputCADFile);
//m_pExchange.SetUnit(1.0); means mm
m_pcFileName = InputCADFile;
m_iProgressBareSize = 0;
if (!m_pExchange.ConvertToXT(InputCADFile, OutputXTFile, sOptions))
{
Console.WriteLine("ConvertToXT failure");
return false;
}
return true;
}
//##############################################################################################################
static void Main(string[] args)
{
if (args.Length < 2)
{
String thismodulefilenamestr = System.IO.Path.GetFullPath(System.Reflection.Assembly.GetEntryAssembly().Location);
Console.Write("\nUsage:\n " + thismodulefilenamestr + " <input CAD file> <output XT file> [-LogFile logfile] [-WriteBlankedEntities]\n");
}
else
{
bool bWriteBlankedEntities = false;
string LogFile = "";
int iArg;
for (iArg = 0; iArg < args.Length; iArg++)
{
if (args[iArg] == "-WriteBlankedEntities")
bWriteBlankedEntities = true;
if (args[iArg] == "-LogFile")
LogFile = args[iArg + 1];
}
if (stTranslate(args[0], args[1], LogFile, bWriteBlankedEntities))
Console.Write(args[1] + " has been created.\n");
else
Console.Write("Error: " + args[1] + " was not created.\n");
}
}
}
}

View File

@@ -0,0 +1,48 @@
/***********************************************************************************************************************
*
* 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.
*
***********************************************************************************************************************/
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ConsoleApplication")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Tech Soft 3D")]
[assembly: AssemblyProduct("ConsoleApplication")]
[assembly: AssemblyCopyright("Copyright (c) 2010 - 2022 by Tech Soft 3D, Inc.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("fb882bdf-689e-498c-9251-5b27e5c06a53")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,167 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.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>{2E7E13B4-0AC4-480F-901F-024CF1938308}</ProjectGuid>
<RootNamespace>TechSoft3DExchangeNetWrapper</RootNamespace>
<Keyword>ManagedCProj</Keyword>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v145</PlatformToolset>
<CLRSupport>true</CLRSupport>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v145</PlatformToolset>
<CLRSupport>true</CLRSupport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v145</PlatformToolset>
<CLRSupport>true</CLRSupport>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v145</PlatformToolset>
<CLRSupport>true</CLRSupport>
</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;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<MinimalRebuild>false</MinimalRebuild>
</ClCompile>
<Link>
<AdditionalDependencies>legacy_stdio_float_rounding.obj;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AssemblyDebug>true</AssemblyDebug>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>legacy_stdio_float_rounding.obj;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AssemblyDebug>true</AssemblyDebug>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<GenerateXMLDocumentationFiles>true</GenerateXMLDocumentationFiles>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<MinimalRebuild>false</MinimalRebuild>
</ClCompile>
<Link>
<AdditionalDependencies>legacy_stdio_float_rounding.obj;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>false</GenerateDebugInformation>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<GenerateXMLDocumentationFiles>true</GenerateXMLDocumentationFiles>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>legacy_stdio_float_rounding.obj;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>false</GenerateDebugInformation>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Reference Include="System">
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</Reference>
<Reference Include="System.Data">
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</Reference>
<Reference Include="System.Xml">
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</Reference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="AssemblyInfo.cpp" />
<ClCompile Include="Translation.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Translation.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,30 @@
<?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="AssemblyInfo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Translation.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Translation.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,583 @@
/***********************************************************************************************************************
*
* 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 use HOOPS Exchange with a .NET wrapper by converting any CAD file to XT.
***********************************************************************************************************************/
#pragma warning(disable: 4505) // "unreferenced local function has been removed"
#include <string>
#define INITIALIZE_A3D_API
#include <A3DSDKIncludes.h>
#include <hoops_license.h>
#include "Translation.h"
using namespace System;
using namespace System::Collections::Generic;
using namespace System::Text;
using namespace System::Runtime::InteropServices;
// If you're seeing three CS0246 errors right below (concerning unknown namespaces),
// coupled with a few dozens of MSB3258 and MSB3274 warnings in the ConsoleApplication project,
// it's because of a known Visual Studio bug happening when using more recent versions than Visual Studio 2008.
// To properly compile, simply go to the Properties of ConsoleApplication, and in the Application tab,
// select Target Framework and choose ".NET Framework 4.0".
namespace TechSoft3D
{
namespace HOOPS
{
static bool stBreakTranslation = false;
#define CHECK_CANCEL_OPERATION if(stBreakTranslation) { \
throw (gcnew System::OperationCanceledException()); } \
//##############################################################################################################
char* ConvertString(String^ text)
{
array<Byte> ^chars = Encoding::ASCII->GetBytes(text);
pin_ptr<Byte> charsPointer = &(chars[0]);
char *nativeCharsPointer = reinterpret_cast<char *>(static_cast<unsigned char *>(charsPointer));
std::string ret(nativeCharsPointer, chars->Length);
return _strdup(ret.c_str());
}
//##############################################################################################################
bool ConvertString(A3DUTF8Char* pTextUTF8, String^% sUnicode)
{
TCHAR pcUnicode[256];
A3DMiscUTF8ToUTF16(pTextUTF8, pcUnicode);
StringBuilder^ buf = gcnew StringBuilder(256);
//UTF8Encoding^ utf8 = gcnew UTF8Encoding();
size_t i, iCharCount = _tcslen(pcUnicode);
for(i = 0; i < iCharCount; ++i)
buf->Insert(int(i), pcUnicode[i]);
sUnicode = buf->ToString();
return true;
}
//##############################################################################################################
static A3DInt32 stbreak = 0;
static bool stbA3DLoaded = false;
static FILE* stOut = stdout;
static int stiSize = 0;
//##############################################################################################################
A3DInt32 ReportMessage(A3DUTF8Char* pMsg)
{
CHECK_CANCEL_OPERATION;
String^ sMsg;
if (Exchange::stm_pFctReportMessage && ConvertString(pMsg, sMsg))
Exchange::stm_pFctReportMessage(sMsg);
if (stOut)
return fprintf(stOut, "%s", pMsg);
return 0;
}
//##############################################################################################################
A3DInt32 ReportWarning(A3DUTF8Char* pCode, A3DUTF8Char* pMsg)
{
CHECK_CANCEL_OPERATION;
String^ sMsg;
String^ sCode;
if (Exchange::stm_pFctReportWarning && ConvertString(pCode, sCode) && ConvertString(pMsg, sMsg))
Exchange::stm_pFctReportWarning(sCode, sMsg);
if (stOut)
return fprintf(stOut, "WARNING(%pCode) %s", pCode, pMsg);
else
return 0;
}
//##############################################################################################################
A3DInt32 ReportError(A3DUTF8Char* pCode, A3DUTF8Char* pMsg)
{
CHECK_CANCEL_OPERATION;
String^ sMsg;
String^ sCode;
if (Exchange::stm_pFctReportError && ConvertString(pCode, sCode)&& ConvertString(pMsg, sMsg))
Exchange::stm_pFctReportError(sCode,sMsg);
if (stOut)
return fprintf(stOut, "ERROR(%pCode) %s", pCode, pMsg);
else
return 0;
}
//##############################################################################################################
void stStartPrg(A3DInt32 i)
{
CHECK_CANCEL_OPERATION;
if(Exchange::stm_pFCTStart)
Exchange::stm_pFCTStart(i);
}
//##############################################################################################################
void stTitlePrg(A3DUTF8Char* pChar)
{
CHECK_CANCEL_OPERATION;
String^ sTitle;
if(Exchange::stm_pFCTTitle && ConvertString(pChar, sTitle))
Exchange::stm_pFCTTitle(sTitle);
}
//##############################################################################################################
void stSizePrg(A3DInt32 i)
{
CHECK_CANCEL_OPERATION;
stiSize = i;
if(Exchange::stm_pFCTSize)
Exchange::stm_pFCTSize(i);
}
//##############################################################################################################
void stIncPrg(A3DInt32 i)
{
CHECK_CANCEL_OPERATION;
if (i > stiSize)
i = stiSize;
if (Exchange::stm_pFCTIncr)
Exchange::stm_pFCTIncr(i);
}
//##############################################################################################################
void stEndPrg()
{
CHECK_CANCEL_OPERATION;
stIncPrg(stiSize);
if(Exchange::stm_pFCTEnd)
Exchange::stm_pFCTEnd();
}
//##############################################################################################################
A3DStatus ScaleProductOccurence(A3DAsmProductOccurrence* pPOccurrences, double dScale)
{
// accessing the ProductOccurence transformation:
A3DAsmProductOccurrenceData sPOccurrencesData;
A3D_INITIALIZE_DATA(A3DAsmProductOccurrenceData, sPOccurrencesData);
A3DAsmProductOccurrenceGet(pPOccurrences, &sPOccurrencesData);
A3DStatus iRet = A3D_SUCCESS;
if(!sPOccurrencesData.m_pLocation)
{
A3DMiscGeneralTransformationData sData;
A3D_INITIALIZE_DATA(A3DMiscGeneralTransformationData, sData);
sData.m_adCoeff[0] = dScale;
sData.m_adCoeff[5] = dScale;
sData.m_adCoeff[10] = dScale;
sData.m_adCoeff[15] = 1.0;
A3DMiscCartesianTransformation* pNewScaledTransfo;
iRet = A3DMiscGeneralTransformationCreate(&sData,&pNewScaledTransfo);
sPOccurrencesData.m_pLocation = pNewScaledTransfo;
iRet = A3DAsmProductOccurrenceEdit(&sPOccurrencesData, pPOccurrences);
A3DAsmProductOccurrenceGet(NULL, &sPOccurrencesData);
return iRet;
}
A3DEEntityType eType = kA3DTypeUnknown;
A3DEntityGetType(sPOccurrencesData.m_pLocation, &eType);
// Two types of transformation exist in HOOPS Exchange: CartesianTransformation and GeneralTransformation
switch (eType)
{
case kA3DTypeMiscCartesianTransformation :
{
// getting the original transformation
A3DMiscCartesianTransformationData sData;
A3D_INITIALIZE_DATA(A3DMiscCartesianTransformationData, sData);
iRet = A3DMiscCartesianTransformationGet(sPOccurrencesData.m_pLocation, &sData);
if(iRet != A3D_SUCCESS)
return iRet;
// creating a new scaled CartesianTransformation from the existing one
sData.m_sScale.m_dX *= dScale;
sData.m_sScale.m_dY *= dScale;
sData.m_sScale.m_dZ *= dScale;
A3DMiscCartesianTransformation* pNewScaledTransfo;
iRet = A3DMiscCartesianTransformationCreate(&sData, &pNewScaledTransfo);
if(iRet!= A3D_SUCCESS)
return iRet;
iRet = A3DMiscCartesianTransformationGet(NULL, &sData);
if(iRet!= A3D_SUCCESS)
return iRet;
sPOccurrencesData.m_pLocation = pNewScaledTransfo;
}
break;
case kA3DTypeMiscGeneralTransformation :
{
// getting the original transformation
A3DMiscGeneralTransformationData sData;
A3D_INITIALIZE_DATA(A3DMiscGeneralTransformationData, sData);
iRet = A3DMiscGeneralTransformationGet(sPOccurrencesData.m_pLocation, &sData);
if(iRet != A3D_SUCCESS)
return iRet;
// creating a new scaled CartesianTransformation from the existing one
sData.m_adCoeff[0] *= dScale;
sData.m_adCoeff[1] *= dScale;
sData.m_adCoeff[2] *= dScale;
sData.m_adCoeff[4] *= dScale;
sData.m_adCoeff[5] *= dScale;
sData.m_adCoeff[6] *= dScale;
sData.m_adCoeff[8] *= dScale;
sData.m_adCoeff[9] *= dScale;
sData.m_adCoeff[10] *= dScale;
A3DMiscGeneralTransformation* pNewGeneralTransfo;
iRet = A3DMiscGeneralTransformationCreate(&sData, &pNewGeneralTransfo);
if( iRet!= A3D_SUCCESS)
return iRet;
iRet = A3DMiscGeneralTransformationGet(NULL, &sData);
if( iRet!= A3D_SUCCESS)
return iRet;
sPOccurrencesData.m_pLocation = pNewGeneralTransfo;
}
break;
default :
return A3D_ERROR;
}
iRet = A3DAsmProductOccurrenceEdit(&sPOccurrencesData, pPOccurrences);
A3DAsmProductOccurrenceGet(NULL, &sPOccurrencesData);
return A3D_SUCCESS;
}
//##############################################################################################################
bool Exchange::Init()
{
# ifdef _WIN64
const TCHAR* pcLibPath = _T("..\\..\\..\\..\\..\\..\\bin\\win64_v142\\");
# else
const TCHAR* pcLibPath = _T("..\\..\\..\\..\\..\\..\\bin\\win32_v142\\");
# endif
if(!A3DSDKLoadLibrary(pcLibPath))
{
printf("Cannot load the HOOPS Exchange library\n");
return false;
}
A3DLicPutUnifiedLicense(HOOPS_LICENSE);
A3DInt32 iMajorVersion = 0, iMinorVersion = 0;
A3DDllGetVersion(&iMajorVersion, &iMinorVersion);
if(A3DDllInitialize(A3D_DLL_MAJORVERSION, A3D_DLL_MINORVERSION) != A3D_SUCCESS)
{
printf("Cannot initialize the HOOPS Exchange library\n");
A3DSDKUnloadLibrary();
return false;
}
stbA3DLoaded = true;
stbreak = 0;
A3DDllSetCallbacksProgress(stStartPrg, stSizePrg, stIncPrg, stEndPrg, stTitlePrg, &stbreak);
A3DDllSetCallbacksReport(ReportMessage, ReportWarning, ReportError);
return true;
}
//##############################################################################################################
void Exchange::SetLogFile(String^ LogFileName)
{
if(stOut && stOut != stdout)
fclose(stOut);
if(fopen_s(&stOut, ConvertString(LogFileName), "w") != 0)
stOut = stdout;
}
//##############################################################################################################
void Exchange::SetUnit(double dUnit)
{
m_dUnit = dUnit;
}
//##############################################################################################################
bool Exchange::IsProEFile(String^ FileName)
{
A3DEModellerType sModellerType;
A3DGetFileFormat(ConvertString(FileName),&sModellerType);
return (sModellerType == kA3DModellerProE);
}
//##############################################################################################################
void Exchange::SetLoadParametersOptions(A3DRWParamsLoadData & sLoadParametersData, IDictionary<String^,
String^>^ sOptions)
{
#define MACRO_SET_CAT_OPTION_BOOL(CAT,KEY) \
{ \
String^ sKey = #CAT+"."+#KEY; \
if(kvp.Key == sKey && kvp.Value == "true") \
sLoadParametersData.m_s##CAT.m_b##KEY = true; \
}
#define MACRO_SET_SUBCAT_OPTION_BOOL(CAT,SUBCAT,KEY) \
{ \
String^ sKey = #CAT+"."+#SUBCAT+"."+#KEY; \
if(kvp.Key == sKey && kvp.Value == "true") \
sLoadParametersData.m_s##CAT.m_s##SUBCAT.m_b##KEY = true; \
}
#define MACRO_SET_SUBCAT_OPTION_STRING(CAT,SUBCAT,KEY) \
{ \
String^ sKey = #CAT+"."+#SUBCAT+"."+#KEY; \
if(kvp.Key == sKey) \
sLoadParametersData.m_s##CAT.m_s##SUBCAT.m_pc##KEY = ConvertString(kvp.Value); \
}
for each(KeyValuePair<String^,String^> kvp in sOptions)
{
MACRO_SET_CAT_OPTION_BOOL(General, ReadSolids);
MACRO_SET_CAT_OPTION_BOOL(General, ReadSurfaces);
MACRO_SET_CAT_OPTION_BOOL(General, ReadWireframes);
MACRO_SET_CAT_OPTION_BOOL(General, ReadConstructionAndReferences);
MACRO_SET_CAT_OPTION_BOOL(General, ReadActiveFilter);
MACRO_SET_CAT_OPTION_BOOL(General, ReadAttributes);
MACRO_SET_CAT_OPTION_BOOL(Assembly, UseRootDirectory);
MACRO_SET_CAT_OPTION_BOOL(Assembly, RootDirRecursive);
MACRO_SET_SUBCAT_OPTION_BOOL(Specifics, IGES, SewBrepModels);
MACRO_SET_SUBCAT_OPTION_STRING(Specifics, CatiaV4, RootDirLogicalName);
MACRO_SET_SUBCAT_OPTION_BOOL(Specifics, CatiaV4, AllowSearchInOtherLogicalNames);
MACRO_SET_SUBCAT_OPTION_BOOL(Specifics, Step, PreferProductName);
MACRO_SET_SUBCAT_OPTION_BOOL(Specifics, Step, PreferFirstColor);
if(kvp.Key->Contains("SearchDir") && kvp.Key->Contains("PhysicalPath"))
{
String^ Indice = kvp.Key;
array<Char>^chars = {'[',']'};
array<String^>^aIndice = Indice->Split( chars );
int myInt = System::Convert::ToInt32(aIndice[1]);
unsigned int uSize = sLoadParametersData.m_sAssembly.m_uiSearchDirectoriesSize;
if(uSize == 0)
{
sLoadParametersData.m_sAssembly.m_ppcSearchDirectories =
(A3DRWParamsSearchDirData**) malloc(sizeof(A3DRWParamsSearchDirData*)*(myInt + 1));
sLoadParametersData.m_sAssembly.m_uiSearchDirectoriesSize = myInt + 1;
sLoadParametersData.m_sAssembly.m_ppcSearchDirectories[0] = NULL;
}
else if((unsigned) myInt >= uSize)
{
sLoadParametersData.m_sAssembly.m_ppcSearchDirectories =
(A3DRWParamsSearchDirData**) realloc(sLoadParametersData.m_sAssembly.m_ppcSearchDirectories,
sizeof(A3DRWParamsSearchDirData*) * (myInt + 1));
sLoadParametersData.m_sAssembly.m_uiSearchDirectoriesSize = myInt + 1;
sLoadParametersData.m_sAssembly.m_ppcSearchDirectories[myInt] = NULL;
}
if(sLoadParametersData.m_sAssembly.m_ppcSearchDirectories[myInt] == NULL)
{
sLoadParametersData.m_sAssembly.m_ppcSearchDirectories[myInt] =
(A3DRWParamsSearchDirData*) malloc(sizeof(A3DRWParamsSearchDirData));
A3D_INITIALIZE_DATA(A3DRWParamsSearchDirData, *(sLoadParametersData.m_sAssembly.m_ppcSearchDirectories[myInt]));
}
sLoadParametersData.m_sAssembly.m_ppcSearchDirectories[myInt]->m_pcPhysicalPath = ConvertString(kvp.Value);
}
if(kvp.Key->Contains("SearchDir") && kvp.Key->Contains("Recursive"))
{
String^ Indice = kvp.Key;
array<Char>^chars = {'[',']'};
array<String^>^aIndice = Indice->Split(chars);
int myInt = System::Convert::ToInt32(aIndice[1]);
unsigned int uSize = sLoadParametersData.m_sAssembly.m_uiSearchDirectoriesSize;
if(uSize == 0)
{
sLoadParametersData.m_sAssembly.m_ppcSearchDirectories =
(A3DRWParamsSearchDirData**) malloc(sizeof(A3DRWParamsSearchDirData*)*(myInt + 1));
sLoadParametersData.m_sAssembly.m_uiSearchDirectoriesSize = myInt + 1;
sLoadParametersData.m_sAssembly.m_ppcSearchDirectories[0] = NULL;
}
else if((unsigned) myInt >= uSize)
{
sLoadParametersData.m_sAssembly.m_ppcSearchDirectories =
(A3DRWParamsSearchDirData**) realloc(sLoadParametersData.m_sAssembly.m_ppcSearchDirectories,
sizeof(A3DRWParamsSearchDirData*) * (myInt + 1));
sLoadParametersData.m_sAssembly.m_uiSearchDirectoriesSize = myInt + 1;
sLoadParametersData.m_sAssembly.m_ppcSearchDirectories[0] = NULL;
}
if(sLoadParametersData.m_sAssembly.m_ppcSearchDirectories[myInt] == NULL)
{
sLoadParametersData.m_sAssembly.m_ppcSearchDirectories[myInt] =
(A3DRWParamsSearchDirData*) malloc(sizeof(A3DRWParamsSearchDirData));
A3D_INITIALIZE_DATA(A3DRWParamsSearchDirData,
*(sLoadParametersData.m_sAssembly.m_ppcSearchDirectories[myInt]));
}
sLoadParametersData.m_sAssembly.m_ppcSearchDirectories[myInt]->m_bRecursive = (kvp.Value == "true");
}
}
}
//##############################################################################################################
bool Exchange::ConvertToXT(String^ SourceFileName, String^ DestinationFileName, IDictionary<String^,
String^>^ sOptions)
{
A3DAsmModelFile* modelFile = NULL;
try
{
A3DRWParamsLoadData sLoadParametersData;
A3D_INITIALIZE_DATA(A3DRWParamsLoadData, sLoadParametersData);
// default values
sLoadParametersData.m_sGeneral.m_bReadSolids = true;
sLoadParametersData.m_sGeneral.m_bReadSurfaces = true;
sLoadParametersData.m_sGeneral.m_bReadAttributes = true;
sLoadParametersData.m_sGeneral.m_bReadWireframes = true;
sLoadParametersData.m_sAssembly.m_bUseRootDirectory = true;
// optional values
SetLoadParametersOptions(sLoadParametersData,sOptions);
// specific syntax
for each(KeyValuePair<String^,String^> kvp in sOptions)
{
if(kvp.Key == "WriteBlankedEntities" && kvp.Value == "true")
sLoadParametersData.m_sGeneral.m_bReadHiddenObjects = true;
}
//if(Exchange::stm_pFCTTitle)
// Exchange::stm_pFCTTitle("A3DAsmModelFileLoadFromFile");
A3DStatus status = A3DAsmModelFileLoadFromFile(ConvertString(SourceFileName), &sLoadParametersData,
&modelFile);
if(status == A3D_LOAD_MISSING_COMPONENTS)
{
printf("HOOPS Exchange CAD file missing components\n");
status = A3D_SUCCESS;
}
if(status)
printf("HOOPS Exchange CAD file loading failure\n");
// changing the unit
if(m_dUnit != 1000) // applying a scale
{
A3DAsmModelFileData sModelFileData;
A3D_INITIALIZE_DATA(A3DAsmModelFileData, sModelFileData);
A3DAsmModelFileGet(modelFile, &sModelFileData);
unsigned int uI;
for(uI = 0; uI < sModelFileData.m_uiPOccurrencesSize; uI++)
{
status = ScaleProductOccurence(sModelFileData.m_ppPOccurrences[uI], 1000 / m_dUnit);
if(status)
printf("HOOPS Exchange failed to apply the unit\n");
}
A3DAsmModelFileGet(NULL, &sModelFileData);
}
if(status == A3D_SUCCESS)
{
A3DRWParamsExportParasolidData sExportParameters;
A3D_INITIALIZE_DATA(A3DRWParamsExportParasolidData, sExportParameters);
// specific syntax
for each(KeyValuePair<String^,String^> kvp in sOptions)
{
if(kvp.Key == "WriteBlankedEntities" && kvp.Value == "true")
sExportParameters.m_bWriteBlankedEntities = true;
}
//if(Exchange::stm_pFCTTitle)
// Exchange::stm_pFCTTitle("A3DAsmModelFileExportToParasolidFile");
status = A3DAsmModelFileExportToParasolidFile(modelFile, &sExportParameters,
ConvertString(DestinationFileName));
if(status)
printf("HOOPS Exchange Parasolid export failure\n");
//if(Exchange::stm_pFCTTitle)
// Exchange::stm_pFCTTitle("End");
A3DAsmModelFileDelete(modelFile);
return status == A3D_SUCCESS;
}
A3DAsmModelFileDelete(modelFile);
stbreak=0;
return false;
}
catch(OperationCanceledException ^)
{
A3DAsmModelFileDelete(modelFile);
stBreakTranslation = m_bBreakTranslation = false;
Terminate();
Init();
return false;
}
}
//##############################################################################################################
void Exchange::Break()
{
stBreakTranslation = m_bBreakTranslation = true;
}
//##############################################################################################################
void Exchange::Terminate()
{
if(stbA3DLoaded)
{
A3DDllTerminate();
A3DSDKUnloadLibrary();
stbA3DLoaded = false;
}
}
//##############################################################################################################
void Exchange::SetCallBackFct(CallbackStart^ pFCTStart, CallbackTitle^ pFCTTitle, CallbackSize^ pFCTSize,
CallbackIncrement^ pFCTIncr, CallbackEnd^ pFCTEnd)
{
stm_pFCTStart = pFCTStart;
stm_pFCTTitle = pFCTTitle;
stm_pFCTSize = pFCTSize;
stm_pFCTIncr = pFCTIncr;
stm_pFCTEnd = pFCTEnd;
}
//##############################################################################################################
void Exchange::SetCallBackMessageFct(CallbackReportMessage^ fctReportMessage,CallbackReportWarning^ fctReportWarning, CallbackReportError^ fctReportError)
{
stm_pFctReportMessage = fctReportMessage;
stm_pFctReportWarning = fctReportWarning;
stm_pFctReportError = fctReportError;
if(stOut == stdout)
stOut = 0;
}
//##############################################################################################################
Exchange::Exchange()
{
m_dUnit = 1000;
stBreakTranslation = m_bBreakTranslation = false;
}
//##############################################################################################################
Exchange::!Exchange()
{
if(stOut && stOut != stdout)
fclose(stOut);
stOut = stdout;
Terminate();
}
//##############################################################################################################
Exchange::~Exchange()
{
Terminate();
}
}
}

View File

@@ -0,0 +1,154 @@
/***********************************************************************************************************************
*
* 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.
*
***********************************************************************************************************************/
#pragma once
using namespace System;
using namespace System::Collections::Generic;
namespace TechSoft3D
{
namespace HOOPS
{
/// <summary>
/// Class wrapping the HOOPS Exchange DLL.
/// </summary>
public ref class Exchange
{
public:
/// <summary>
/// Callback functions indicating what's starting: iStart == 1: Parsing CAD File
/// iStart == 2: Reading CAD File
/// iStart == 3: Writing Parasolid File
/// </summary>
delegate void CallbackStart(int iStart);
/// <summary>
/// Callback function giving the name of the file being converted. Useful when managing assemblies.
/// </summary>
delegate void CallbackTitle(String^ sTitle);
/// <summary>
/// Callback function giving the size of the progress bar.
/// </summary>
delegate void CallbackSize(int iSize);
/// <summary>
/// Callback function giving the current position in the progress bar the positions relative to iSize (provided by CallbackSize).
/// </summary>
delegate void CallbackIncrement(int iIncr);
/// <summary>
/// Callback function indicating the end of a reading/parsing/writing phase.
/// </summary>
delegate void CallbackEnd(void);
/// <summary>
/// Callback function reporting messages.
/// </summary>
delegate int CallbackReportMessage(String^ pMsg);
/// <summary>
/// Callback function reporting warning messages.
/// </summary>
delegate int CallbackReportWarning(String^ pCode,String^ pMsg);
/// <summary>
/// Callback function reporting error messages.
/// </summary>
delegate int CallbackReportError(String^ pCode,String^ pMsg);
/// <summary>
/// Load HOOPS Exchange DLL and check if the license is valid.
/// </summary>
/// <returns>
/// true if DLL has been loaded and the license is valid.
/// </returns>
bool Init();
Exchange();
~Exchange();
!Exchange();
/// <summary>
/// Determine if a file is a ProeFile
/// </summary>
bool IsProEFile(String^ path);
/// <summary>
/// Function setting the unit in mm. The default value is 1000 as Parasolid files are usually in meters.
/// </summary>
void SetUnit(double dUnit);
/// <summary>
/// Function to define a log file
/// </summary>
void SetLogFile(String^ LogFileName);
/// <summary>
/// Convert any CAD file into XT file.
/// </summary>
/// <returns>
/// true if both reading and writing succeeded.
/// </returns>
bool ConvertToXT(String^ sourceFileName, String^ destinationFileName, IDictionary<String^,String^>^ sOptions);
/// <summary>
/// Break the conversion.
/// </summary>
void Break();
/// <summary>
/// Set callback functions to manage a progress bar.
/// </summary>
/// <param>
/// fctStart: Function called when the parsing or reading or writing phase of a file is starting.
/// fctTitle: Function called when a new file is being loaded.
/// fctSize: Function called during conversion that gives the size of the progress bar.
/// fctIncr: Function called during conversion that gives the position in the progress bar.
/// </param>
void SetCallBackFct(CallbackStart^ fctStart,CallbackTitle^ fctTitle, CallbackSize^ stm_pFCTSize, CallbackIncrement^ fctIncr, CallbackEnd^ fctEnd);
/// <summary>
/// Set callback functions to manage a progress bar.
/// </summary>
/// <param>
/// fctStart: Function called when the parsing or reading or writing phase of a file is starting.
/// fctTitle: Function called when a new file is being loaded.
/// fctSize: Function called during conversion that gives the size of the progress bar.
/// fctIncr: Function called during conversion that gives the position in the progress bar.
/// </param>
void SetCallBackMessageFct(CallbackReportMessage^ fctReportMessage,CallbackReportWarning^ fctReportWarning, CallbackReportError^ fctReportError);
static CallbackStart^ stm_pFCTStart;
static CallbackTitle^ stm_pFCTTitle;
static CallbackSize^ stm_pFCTSize;
static CallbackIncrement^ stm_pFCTIncr;
static CallbackEnd^ stm_pFCTEnd;
static CallbackReportMessage^ stm_pFctReportMessage;
static CallbackReportWarning^ stm_pFctReportWarning;
static CallbackReportError^ stm_pFctReportError;
private:
void Terminate();
void SetLoadParametersOptions(A3DRWParamsLoadData & sLoadParametersData, IDictionary<String^, String^>^ sOptions);
double m_dUnit;
bool m_bBreakTranslation;
};
}
}