Init
This commit is contained in:
214
exchange/exchangesource/DrawingViewer/DrawingViewer.vcxproj
Normal file
214
exchange/exchangesource/DrawingViewer/DrawingViewer.vcxproj
Normal file
@@ -0,0 +1,214 @@
|
||||
<?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>{0C9C33A6-D497-45A8-A74D-95E794C3AF78}</ProjectGuid>
|
||||
<RootNamespace>A3DPRCDrawingViewerGL</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>v145</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v145</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v145</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v145</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
</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>..\Viewer\glut\include;..\Viewer;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<ExceptionHandling>Sync</ExceptionHandling>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>
|
||||
<PrecompiledHeader />
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<DisableSpecificWarnings>4505;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>glut32.lib;legacy_stdio_float_rounding.obj;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<ShowProgress>LinkVerboseLib</ShowProgress>
|
||||
<OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\Viewer\glut\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention />
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>if $(SolutionName) equ exchange copy /y ..\Viewer\glut\dll\glut32.dll .\$(Platform)\$(Configuration)\</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\Viewer\glut\include;..\Viewer;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<ExceptionHandling>Sync</ExceptionHandling>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>
|
||||
<PrecompiledHeader />
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<DisableSpecificWarnings>4505;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>glut64.lib;legacy_stdio_float_rounding.obj;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<ShowProgress>LinkVerboseLib</ShowProgress>
|
||||
<OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\Viewer\glut\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention />
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>if $(SolutionName) equ exchange copy /y ..\Viewer\glut\dll\glut64.dll .\$(Platform)\$(Configuration)\</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\Viewer\glut\include;..\Viewer;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader />
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<DisableSpecificWarnings>4505;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>glut32.lib;legacy_stdio_float_rounding.obj;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\Viewer\glut\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention />
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>if $(SolutionName) equ exchange copy /y ..\Viewer\glut\dll\glut32.dll .\$(Platform)\$(Configuration)\</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\Viewer\glut\include;..\Viewer;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader />
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<DisableSpecificWarnings>4505;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>glut64.lib;legacy_stdio_float_rounding.obj;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\Viewer\glut\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention />
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>if $(SolutionName) equ exchange copy /y ..\Viewer\glut\dll\glut64.dll .\$(Platform)\$(Configuration)\</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\Viewer\Draw.cpp" />
|
||||
<ClCompile Include="..\Viewer\trackball.cpp" />
|
||||
<ClCompile Include="callback_opengl.cpp" />
|
||||
<ClCompile Include="drawing_collect.cpp" />
|
||||
<ClCompile Include="drawing_draw.cpp" />
|
||||
<ClCompile Include="drawing_main.cpp" />
|
||||
<ClCompile Include="drawing_parse.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\Viewer\callback_opengl.h" />
|
||||
<ClInclude Include="drawing_main.h" />
|
||||
<ClInclude Include="drawing_parse.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,57 @@
|
||||
<?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="Source Files\Viewer">
|
||||
<UniqueIdentifier>{4926d425-3139-4fe4-8496-5b3d2825b658}</UniqueIdentifier>
|
||||
</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>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\Viewer">
|
||||
<UniqueIdentifier>{8add5ea3-1594-44e8-986b-a7e276db34a7}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="drawing_collect.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="drawing_draw.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="drawing_main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="drawing_parse.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="callback_opengl.cpp">
|
||||
<Filter>Source Files\Viewer</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Viewer\Draw.cpp">
|
||||
<Filter>Source Files\Viewer</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Viewer\trackball.cpp">
|
||||
<Filter>Source Files\Viewer</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="drawing_main.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="drawing_parse.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Viewer\callback_opengl.h">
|
||||
<Filter>Header Files\Viewer</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
1260
exchange/exchangesource/DrawingViewer/callback_opengl.cpp
Normal file
1260
exchange/exchangesource/DrawingViewer/callback_opengl.cpp
Normal file
File diff suppressed because it is too large
Load Diff
190
exchange/exchangesource/DrawingViewer/callback_opengl.h
Normal file
190
exchange/exchangesource/DrawingViewer/callback_opengl.h
Normal file
@@ -0,0 +1,190 @@
|
||||
/***********************************************************************************************************************
|
||||
*
|
||||
* 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 callback_opengl.h
|
||||
|
||||
This file demonstrates how to programmatically visualize a PRC file from a basic OpenGL program using HOOPS Exchange.
|
||||
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef _CALLBACK_OPENGL_H_
|
||||
#define _CALLBACK_OPENGL_H_
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <GLUT/glut.h>
|
||||
#else
|
||||
#include <GL/glut.h>
|
||||
#endif
|
||||
|
||||
|
||||
//#define USE_A3D_CALLBACKS
|
||||
|
||||
#ifdef USE_A3D_CALLBACKS
|
||||
#define A3DORNOTDrawGetBoundingBox A3DDrawGetBoundingBox
|
||||
#define A3DORNOTDraw A3DDraw
|
||||
#define A3DORNOTDrawInitCallbacks A3DDrawInitCallbacks
|
||||
#else
|
||||
#define A3DORNOTDrawGetBoundingBox DrawGetBoundingBox
|
||||
#define A3DORNOTDraw Draw
|
||||
#define A3DORNOTDrawInitCallbacks DrawInitCallbacks
|
||||
#endif
|
||||
|
||||
//######################################################################################################################
|
||||
A3DStatus OpenGL_SetAndInitCallBack(A3DDrawCallbacksData &sDrawCallbacksData);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_PushMatrix();
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_PopMatrix();
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_MultMatrix(const A3DDouble adMatrix[16]);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_GetMatrix(A3DDouble adMatrix[16]);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_SetIgnoreViewMatrix(A3DDouble adIgnoreViewMatrix[16]);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_Begin(A3DEDrawBeginEndType eType, const A3DUTF8Char* pcName, A3DUns32 uiTrianglesCount);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_End(A3DEDrawBeginEndType eType);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_Triangle(const A3DVector3dData* pasNormals, const A3DVector3dData* pasPoints, A3DUns32 uiPointSize);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_TriangleFan(const A3DVector3dData* pasNormals, const A3DVector3dData* pasPoints, A3DUns32 uiPointSize);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_TriangleStripe(const A3DVector3dData* pasNormals, const A3DVector3dData* pasPoints, A3DUns32 uiPointSize);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_TriangleOneNormal(const A3DVector3dData* pasNormals, const A3DVector3dData* pasPoints,
|
||||
A3DUns32 uiPointSize);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_TriangleFanOneNormal(const A3DVector3dData* psNormal, const A3DVector3dData* pasPoints,
|
||||
A3DUns32 uiPointSize);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_TriangleStripeOneNormal(const A3DVector3dData* psNormal, const A3DVector3dData* pasPoints,
|
||||
A3DUns32 uiPointSize);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_TriangleTextured(const A3DVector3dData* pasNormals, const A3DVector3dData* pasPoints, A3DUns32 uiPointSize);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_TriangleFanTextured(const A3DVector3dData* pasNormals, const A3DVector3dData* pasPoints,
|
||||
A3DUns32 uiPointSize);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_TriangleStripeTextured(const A3DVector3dData* pasNormals, const A3DVector3dData* pasPoints,
|
||||
A3DUns32 uiPointSize);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_TriangleOneNormalTextured(const A3DVector3dData* pasNormals, const A3DVector3dData* pasPoints,
|
||||
A3DUns32 uiPointSize);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_TriangleFanOneNormalTextured(const A3DVector3dData* psNormal, const A3DVector3dData* pasPoints,
|
||||
A3DUns32 uiPointSize);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_TriangleStripeOneNormalTextured(const A3DVector3dData* psNormal, const A3DVector3dData* pasPoints,
|
||||
A3DUns32 uiPointSize);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_Material(A3DEDrawMaterialType eType, const A3DDouble* pdValues, A3DUns32 uiSize);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_BeginMaterial(void);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_EndMaterial(void);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_GetDrawContext(A3DDouble adProjection[16], A3DDouble adModelView[16], A3DInt32 aiViewport[4]);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_MarkupTriangle(const A3DDouble* pdPoints, A3DUns32 uiPointSize);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_UnProject(const A3DVector3dData* psPoint, A3DVector3dData* psResult);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_BeginFrameDraw(const A3DVector3dData* psPoint3d, A3DBool bIsZoomable, A3DDouble dFixedSize);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_EndFrameDraw(void);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_BeginFixedSize(const A3DVector3dData* psPoint3d);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_EndFixedSize(void);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_Cylinder(A3DDouble dBaseRadius, A3DDouble dTopRadius, A3DDouble dHeight);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_Polygon(const A3DDouble* pdPoints, A3DUns32 uiPointSize);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_BeginLineWidth(A3DDouble dWidth);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_EndLineWidth(void);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_Point(const A3DDouble* pdPoints, A3DUns32 uiPointSize);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_Font(const A3DFontKeyData* psFontKeyData);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_BeginLineStipple(const A3DGraphStyleData* psGraphStyleData);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_EndLineStipple(void);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_Symbol(const A3DGraphVPicturePatternData* psPatternData, const A3DVector3dData* psPosition);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_PolyLine(const A3DDouble* pdPoints, A3DUns32 uiPointSize);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_Text(const A3DUTF8Char* pcBuffer, A3DDouble dWidth, A3DDouble dHeight);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_Pattern(A3DUns32 uiLoopsSize, A3DUns32 uiPatternId, A3DUns32 uiFilledMode, A3DUns32 uiBehavior,
|
||||
const A3DDouble* pdPoints, const A3DUns32* puiLoopsPointSize);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_Picture(const A3DGraphPictureData* psPictureData);
|
||||
|
||||
//######################################################################################################################
|
||||
void OpenGL_Color(const A3DDouble* pdValues, A3DUns32 uiSize);
|
||||
|
||||
//######################################################################################################################
|
||||
int& DisplayTriangles();
|
||||
|
||||
//######################################################################################################################
|
||||
int& DisplayTriangleNormals();
|
||||
|
||||
//######################################################################################################################
|
||||
double& DisplayTriangleNormalLength();
|
||||
|
||||
#endif // _CALLBACK_OPENGL_H_
|
||||
138
exchange/exchangesource/DrawingViewer/drawing_collect.cpp
Normal file
138
exchange/exchangesource/DrawingViewer/drawing_collect.cpp
Normal file
@@ -0,0 +1,138 @@
|
||||
/***********************************************************************************************************************
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
#include <A3DSDKIncludes.h>
|
||||
|
||||
|
||||
|
||||
//######################################################################################################################
|
||||
#define CHECK_RET(function_call) {\
|
||||
iRet = function_call; if(iRet != A3D_SUCCESS) { std::cout << "Error number=" << iRet << std::endl; return iRet; }\
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
static A3DStatus stCollectDrawingOnPartDefinition(A3DEntity* psEntity, std::vector<A3DDrawingModel*> &apDrawingModels)
|
||||
{
|
||||
// Check type of entity
|
||||
A3DEEntityType eType = kA3DTypeUnknown;
|
||||
A3DEntityGetType(psEntity, &eType);
|
||||
if(eType != kA3DTypeAsmPartDefinition)
|
||||
return A3D_INVALID_ENTITY_TYPE;
|
||||
|
||||
A3DStatus iRet = A3D_SUCCESS;
|
||||
|
||||
// Get data of A3DAsmPartDefinition
|
||||
A3DAsmPartDefinition* pPartDefinition = (A3DAsmPartDefinition*) psEntity;
|
||||
A3DAsmPartDefinitionData sPartData;
|
||||
A3D_INITIALIZE_DATA(A3DAsmPartDefinitionData, sPartData);
|
||||
CHECK_RET(A3DAsmPartDefinitionGet(pPartDefinition, &sPartData));
|
||||
|
||||
// Collect all DrawingModels
|
||||
if(sPartData.m_uiDrawingModelsSize != 0)
|
||||
{
|
||||
A3DUns32 uiElem;
|
||||
for(uiElem = 0; uiElem < sPartData.m_uiDrawingModelsSize; uiElem++)
|
||||
{
|
||||
if(sPartData.m_ppDrawingModels[uiElem] != NULL)
|
||||
apDrawingModels.push_back(sPartData.m_ppDrawingModels[uiElem]);
|
||||
}
|
||||
}
|
||||
|
||||
// Free allocated data
|
||||
A3DAsmPartDefinitionGet(NULL, &sPartData);
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
static A3DStatus stProductOccurrenceGetPart(A3DAsmProductOccurrenceData* psPOccData, A3DAsmPartDefinition** ppPart)
|
||||
{
|
||||
if(psPOccData == NULL)
|
||||
return A3D_ERROR;
|
||||
|
||||
A3DStatus iRet = A3D_SUCCESS;
|
||||
|
||||
*ppPart = NULL;
|
||||
|
||||
if(psPOccData->m_pPart != NULL)
|
||||
{
|
||||
*ppPart = psPOccData->m_pPart;
|
||||
return iRet;
|
||||
}
|
||||
|
||||
A3DAsmProductOccurrence* pProductPrototype = psPOccData->m_pPrototype;
|
||||
while(pProductPrototype != NULL)
|
||||
{
|
||||
A3DAsmProductOccurrenceData sProductPrototypeData;
|
||||
A3D_INITIALIZE_DATA(A3DAsmProductOccurrenceData, sProductPrototypeData);
|
||||
CHECK_RET(A3DAsmProductOccurrenceGet(pProductPrototype, &sProductPrototypeData));
|
||||
|
||||
if(sProductPrototypeData.m_pPart != NULL)
|
||||
{
|
||||
CHECK_RET(A3DAsmProductOccurrenceGet(NULL, &sProductPrototypeData));
|
||||
*ppPart = sProductPrototypeData.m_pPart;
|
||||
return iRet;
|
||||
}
|
||||
else
|
||||
pProductPrototype = sProductPrototypeData.m_pPrototype;
|
||||
CHECK_RET(A3DAsmProductOccurrenceGet(NULL, &sProductPrototypeData));
|
||||
}
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
static A3DStatus stParseProductOccurrence(A3DAsmProductOccurrence* pOccurrence,
|
||||
std::vector<A3DDrawingModel*> &apDrawingModels)
|
||||
{
|
||||
A3DStatus iRet = A3D_SUCCESS;
|
||||
|
||||
A3DAsmProductOccurrenceData sData;
|
||||
A3D_INITIALIZE_DATA(A3DAsmProductOccurrenceData, sData);
|
||||
CHECK_RET(A3DAsmProductOccurrenceGet(pOccurrence, &sData));
|
||||
|
||||
if(sData.m_ucBehaviour != 1)
|
||||
{
|
||||
A3DAsmPartDefinition* pPart = NULL;
|
||||
stProductOccurrenceGetPart(&sData, &pPart);
|
||||
|
||||
if(pPart)
|
||||
CHECK_RET(stCollectDrawingOnPartDefinition(pPart, apDrawingModels));
|
||||
|
||||
unsigned int uiPO;
|
||||
for(uiPO = 0; uiPO < sData.m_uiPOccurrencesSize; ++uiPO)
|
||||
CHECK_RET(stParseProductOccurrence(sData.m_ppPOccurrences[uiPO], apDrawingModels));
|
||||
}
|
||||
CHECK_RET(A3DAsmProductOccurrenceGet(NULL, &sData));
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
A3DStatus CollectDrawing(A3DAsmModelFile* pModelFile, std::vector<A3DDrawingModel*> &apDrawingModels)
|
||||
{
|
||||
A3DStatus iRet = A3D_SUCCESS;
|
||||
|
||||
A3DAsmModelFileData sData;
|
||||
A3D_INITIALIZE_DATA(A3DAsmModelFileData, sData);
|
||||
CHECK_RET(A3DAsmModelFileGet(pModelFile, &sData));
|
||||
|
||||
for(A3DUns32 ui = 0; ui < sData.m_uiPOccurrencesSize; ++ui)
|
||||
{
|
||||
CHECK_RET(stParseProductOccurrence(sData.m_ppPOccurrences[ui], apDrawingModels));
|
||||
}
|
||||
|
||||
CHECK_RET(A3DAsmModelFileGet(NULL, &sData));
|
||||
|
||||
return iRet;
|
||||
}
|
||||
481
exchange/exchangesource/DrawingViewer/drawing_draw.cpp
Normal file
481
exchange/exchangesource/DrawingViewer/drawing_draw.cpp
Normal file
@@ -0,0 +1,481 @@
|
||||
/***********************************************************************************************************************
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include <A3DSDKIncludes.h>
|
||||
#include "drawing_parse.h"
|
||||
#include "callback_opengl.h"
|
||||
#include <math.h>
|
||||
#include <vector>
|
||||
|
||||
|
||||
|
||||
//######################################################################################################################
|
||||
typedef struct
|
||||
{
|
||||
std::vector<GLuint>* m_paSheetDL;
|
||||
std::vector<A3DVector2dData>* m_paSheetSize;
|
||||
bool m_bDrawMarkup;
|
||||
} GLGlobalData;
|
||||
|
||||
//######################################################################################################################
|
||||
static A3DDrawCallbacksData *st_psDrawCallBacks = NULL;
|
||||
#define A3D_DRAW_CALL0(name) { if(st_psDrawCallBacks) st_psDrawCallBacks->m_pfunc##name(); }
|
||||
#define A3D_DRAW_CALL1(name, p1) { if(st_psDrawCallBacks) st_psDrawCallBacks->m_pfunc##name(p1); }
|
||||
#define A3D_DRAW_CALL2(name, p1, p2) { if(st_psDrawCallBacks) st_psDrawCallBacks->m_pfunc##name(p1, p2); }
|
||||
#define A3D_DRAW_CALL3(name, p1, p2, p3) { if(st_psDrawCallBacks) st_psDrawCallBacks->m_pfunc##name(p1, p2, p3); }
|
||||
#define A3D_DRAW_CALL6(name, p1, p2, p3, p4, p5, p6) { if(st_psDrawCallBacks) st_psDrawCallBacks->m_pfunc##name(p1, p2, p3, p4, p5, p6); }
|
||||
|
||||
//######################################################################################################################
|
||||
#define MAT_INIT_ANGLE(mat, angle) \
|
||||
memset(mat,0, sizeof(double)*16); \
|
||||
mat[0] = +cos(angle);\
|
||||
mat[1] = +sin(angle);\
|
||||
mat[4] = -sin(angle);\
|
||||
mat[5] = +cos(angle);\
|
||||
mat[10] = 1.; \
|
||||
mat[15] = 1
|
||||
|
||||
#define MAT_SCALE(mat, scale) \
|
||||
for(int iInd = 0; iInd < 15; ++iInd) mat[iInd] *= scale
|
||||
|
||||
#define MAT_TRANSLAT(mat, offsetX, offsetY, offsetZ) \
|
||||
mat[12] += offsetX;\
|
||||
mat[13] += offsetY;\
|
||||
mat[14] += offsetZ
|
||||
|
||||
//######################################################################################################################
|
||||
A3DStatus DrawRepresentationItem(const A3DRiRepresentationItem* pRepItem, const A3DMiscCascadedAttributes* pFatherAttr);
|
||||
|
||||
//######################################################################################################################
|
||||
A3DStatus DrawMarkup(const A3DMkpMarkup* pMarkup, const A3DMiscCascadedAttributes* pFatherAttr);
|
||||
|
||||
//######################################################################################################################
|
||||
static void stVectoriel(const A3DVector3dData* X, const A3DVector3dData* Y, A3DVector3dData* Z)
|
||||
{
|
||||
Z->m_dX=X->m_dY*Y->m_dZ - X->m_dZ*Y->m_dY;
|
||||
Z->m_dY=X->m_dZ*Y->m_dX - X->m_dX*Y->m_dZ;
|
||||
Z->m_dZ=X->m_dX*Y->m_dY - X->m_dY*Y->m_dX;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
static void stInitializeMatrix(A3DDouble adMatrix[16])
|
||||
{
|
||||
adMatrix[0] = 1.; adMatrix[4] = 0.; adMatrix[8] = 0.; adMatrix[12] = 0.;
|
||||
adMatrix[1] = 0.; adMatrix[5] = 1.; adMatrix[9] = 0.; adMatrix[13] = 0.;
|
||||
adMatrix[2] = 0.; adMatrix[6] = 0.; adMatrix[10] = 1.; adMatrix[14] = 0.;
|
||||
adMatrix[3] = 0.; adMatrix[7] = 0.; adMatrix[11] = 0.; adMatrix[15] = 1.;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
static bool stbGetVisibilityFromAttribute(A3DMiscCascadedAttributes const* pAttr)
|
||||
{
|
||||
bool bVibility = true;
|
||||
if(pAttr != NULL)
|
||||
{
|
||||
A3DMiscCascadedAttributesData sAttribData;
|
||||
A3D_INITIALIZE_DATA(A3DMiscCascadedAttributesData, sAttribData);
|
||||
if(A3DMiscCascadedAttributesGet(pAttr, &sAttribData)==A3D_SUCCESS)
|
||||
{
|
||||
bVibility = (sAttribData.m_bShow && !sAttribData.m_bRemoved);
|
||||
A3DMiscCascadedAttributesGet(NULL, &sAttribData);
|
||||
}
|
||||
}
|
||||
|
||||
return bVibility;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
// Apply current transformation, to current matrix
|
||||
static A3DStatus stDrawTransformation(const A3DMiscTransformation* pTransfo3d)
|
||||
{
|
||||
if(pTransfo3d == NULL)
|
||||
return A3D_SUCCESS;
|
||||
|
||||
A3DStatus iRet = A3D_SUCCESS;
|
||||
|
||||
A3DEEntityType eType = kA3DTypeUnknown;
|
||||
A3DEntityGetType(pTransfo3d, &eType);
|
||||
switch(eType)
|
||||
{
|
||||
case kA3DTypeMiscCartesianTransformation :
|
||||
{
|
||||
A3DMiscCartesianTransformationData sData;
|
||||
A3D_INITIALIZE_DATA(A3DMiscCartesianTransformationData, sData);
|
||||
|
||||
CHECK_RET(A3DMiscCartesianTransformationGet(pTransfo3d, &sData));
|
||||
|
||||
double adMatrix[16];
|
||||
double dMirror = (sData.m_ucBehaviour & kA3DTransformationMirror) ? -1. : 1.;
|
||||
|
||||
A3DVector3dData sZVector;
|
||||
memset(adMatrix, 0, 16*sizeof(double));
|
||||
stVectoriel(&sData.m_sXVector, &sData.m_sYVector, &sZVector);
|
||||
|
||||
adMatrix[12] = sData.m_sOrigin.m_dX;
|
||||
adMatrix[13] = sData.m_sOrigin.m_dY;
|
||||
adMatrix[14] = sData.m_sOrigin.m_dZ;
|
||||
|
||||
adMatrix[0] = sData.m_sXVector.m_dX*sData.m_sScale.m_dX;
|
||||
adMatrix[1] = sData.m_sXVector.m_dY*sData.m_sScale.m_dX;
|
||||
adMatrix[2] = sData.m_sXVector.m_dZ*sData.m_sScale.m_dX;
|
||||
|
||||
adMatrix[4] = sData.m_sYVector.m_dX*sData.m_sScale.m_dY;
|
||||
adMatrix[5] = sData.m_sYVector.m_dY*sData.m_sScale.m_dY;
|
||||
adMatrix[6] = sData.m_sYVector.m_dZ*sData.m_sScale.m_dY;
|
||||
|
||||
adMatrix[8] = dMirror*sZVector.m_dX*sData.m_sScale.m_dZ;
|
||||
adMatrix[9] = dMirror*sZVector.m_dY*sData.m_sScale.m_dZ;
|
||||
adMatrix[10] = dMirror*sZVector.m_dZ*sData.m_sScale.m_dZ;
|
||||
|
||||
adMatrix[15] = 1.;
|
||||
|
||||
A3D_DRAW_CALL1(MultMatrix, adMatrix);
|
||||
|
||||
CHECK_RET(A3DMiscCartesianTransformationGet(NULL, &sData));
|
||||
}
|
||||
break;
|
||||
|
||||
case kA3DTypeMiscGeneralTransformation :
|
||||
{
|
||||
A3DMiscGeneralTransformationData sData;
|
||||
A3D_INITIALIZE_DATA(A3DMiscGeneralTransformationData, sData);
|
||||
|
||||
CHECK_RET(A3DMiscGeneralTransformationGet(pTransfo3d, &sData));
|
||||
|
||||
A3D_DRAW_CALL1(MultMatrix, sData.m_adCoeff);
|
||||
|
||||
CHECK_RET(A3DMiscGeneralTransformationGet(NULL, &sData));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
iRet = A3D_INVALID_ENTITY_TYPE;
|
||||
}
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
// DrawingBlockBasic and DrawingBlockOperator are A3DRiRepresentationItem: use the same function
|
||||
A3DStatus stPreDrawBlock(A3DEntity* psEntity, A3DMiscCascadedAttributes const* pAttr, A3DVoid* pGlobalData,
|
||||
A3DVoid** pFunctionData, A3DUns32 /*uiBehavior*/)
|
||||
{
|
||||
A3DStatus iRet = A3D_SUCCESS;
|
||||
*pFunctionData = NULL;
|
||||
|
||||
if(!stbGetVisibilityFromAttribute(pAttr))
|
||||
return A3D_CALLBACK_CONTINUE;
|
||||
|
||||
// Get and apply local transformation
|
||||
A3DRiRepresentationItemData sData;
|
||||
A3D_INITIALIZE_DATA(A3DRiRepresentationItemData, sData);
|
||||
CHECK_RET(A3DRiRepresentationItemGet(psEntity, &sData));
|
||||
|
||||
const A3DRiCoordinateSystem* pCoordSys = sData.m_pCoordinateSystem;
|
||||
if(pCoordSys != NULL)
|
||||
{
|
||||
*pFunctionData = (void*) 1;
|
||||
A3D_DRAW_CALL0(PushMatrix);
|
||||
|
||||
A3DRiCoordinateSystemData sCSysData;
|
||||
A3D_INITIALIZE_DATA(A3DRiCoordinateSystemData, sCSysData);
|
||||
CHECK_RET(A3DRiCoordinateSystemGet(sData.m_pCoordinateSystem, &sCSysData));
|
||||
CHECK_RET(stDrawTransformation(sCSysData.m_pTransformation));
|
||||
|
||||
// free memory
|
||||
CHECK_RET(A3DRiCoordinateSystemGet(NULL, &sCSysData));
|
||||
}
|
||||
|
||||
bool bDrawMkupOnly = ((GLGlobalData*)pGlobalData)->m_bDrawMarkup;
|
||||
|
||||
// Parse current tessellation
|
||||
if(!bDrawMkupOnly)
|
||||
CHECK_RET(DrawRepresentationItem(psEntity, pAttr));
|
||||
|
||||
// free memory
|
||||
CHECK_RET(A3DRiRepresentationItemGet(NULL, &sData));
|
||||
|
||||
// Parse markup
|
||||
if(bDrawMkupOnly)
|
||||
{
|
||||
A3DDrawingBlockBasicData sBlkData;
|
||||
A3D_INITIALIZE_DATA(A3DDrawingBlockBasicData, sBlkData);
|
||||
A3DDrawingBlockBasicGet(psEntity, &sBlkData);
|
||||
|
||||
unsigned int uiMk, uiNbMk = sBlkData.m_uiMarkupsSize;
|
||||
for(uiMk=0; uiMk<uiNbMk; uiMk++)
|
||||
{
|
||||
A3DMkpMarkup* pCurMk = sBlkData.m_ppMarkups[uiMk];
|
||||
if(pCurMk != NULL)
|
||||
CHECK_RET(DrawMarkup(pCurMk, pAttr));
|
||||
}
|
||||
|
||||
A3DDrawingBlockBasicGet(NULL, &sBlkData);
|
||||
}
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
A3DStatus stPostDrawBlock(A3DEntity* /*psEntity*/, A3DMiscCascadedAttributes const* /*pAttr*/, A3DVoid* /*pGlobalData*/,
|
||||
A3DVoid* pFunctionData, A3DUns32 /*uiBehavior*/)
|
||||
{
|
||||
// pop current transformation
|
||||
if(pFunctionData != NULL)
|
||||
{
|
||||
A3D_DRAW_CALL0(PopMatrix);
|
||||
}
|
||||
|
||||
return A3D_SUCCESS;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
A3DStatus stTreatClipFrame(A3DDrawingClipFrame const* const pClipFrame)
|
||||
{
|
||||
A3DDrawingClipFrameData sClipData;
|
||||
A3D_INITIALIZE_DATA(A3DDrawingClipFrameData, sClipData);
|
||||
A3DStatus iRet = A3DDrawingClipFrameGet(pClipFrame, &sClipData);
|
||||
if (iRet == A3D_SUCCESS)
|
||||
{
|
||||
if (sClipData.m_bDrawBound)
|
||||
{
|
||||
A3DDouble aPts[4 * 4];
|
||||
aPts[0] = sClipData.m_sRectangularBox.m_sMin.m_dX;
|
||||
aPts[1] = sClipData.m_sRectangularBox.m_sMin.m_dY;
|
||||
aPts[2] = 0;
|
||||
|
||||
aPts[3] = sClipData.m_sRectangularBox.m_sMax.m_dX;
|
||||
aPts[4] = sClipData.m_sRectangularBox.m_sMin.m_dY;
|
||||
aPts[5] = 0;
|
||||
|
||||
aPts[6] = sClipData.m_sRectangularBox.m_sMax.m_dX;
|
||||
aPts[7] = sClipData.m_sRectangularBox.m_sMax.m_dY;
|
||||
aPts[8] = 0;
|
||||
|
||||
aPts[9] = sClipData.m_sRectangularBox.m_sMin.m_dX;
|
||||
aPts[10] = sClipData.m_sRectangularBox.m_sMax.m_dY;
|
||||
aPts[11] = 0;
|
||||
|
||||
aPts[9] = sClipData.m_sRectangularBox.m_sMin.m_dX;
|
||||
aPts[10] = sClipData.m_sRectangularBox.m_sMin.m_dY;
|
||||
aPts[11] = 0;
|
||||
|
||||
GLfloat afValues[3] = { 1, 1, 0 };
|
||||
glColor3fv(afValues);
|
||||
OpenGL_Polygon(aPts, 4);
|
||||
}
|
||||
A3DDrawingClipFrameGet(nullptr, &sClipData);
|
||||
}
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
A3DStatus stPreDrawDrawingView(A3DEntity* psEntity, A3DMiscCascadedAttributes const* pAttr, A3DVoid* /*pGlobalData*/,
|
||||
A3DVoid** pFunctionData, A3DUns32 /*uiBehavior*/)
|
||||
{
|
||||
*pFunctionData = NULL;
|
||||
|
||||
if(!stbGetVisibilityFromAttribute(pAttr))
|
||||
return A3D_CALLBACK_CONTINUE;
|
||||
|
||||
A3DStatus iRet = A3D_SUCCESS;
|
||||
|
||||
// Get Data
|
||||
A3DDrawingViewData sViewData;
|
||||
A3D_INITIALIZE_DATA(A3DDrawingViewData, sViewData);
|
||||
iRet = A3DDrawingViewGet(psEntity, &sViewData);
|
||||
if(iRet == A3D_SUCCESS)
|
||||
{
|
||||
// Transformation matrix
|
||||
A3DDouble adMatrix[16];
|
||||
MAT_INIT_ANGLE(adMatrix, sViewData.m_dAngle);
|
||||
MAT_TRANSLAT(adMatrix, sViewData.m_sOffsetLocation.m_dX, sViewData.m_sOffsetLocation.m_dY, 0);
|
||||
MAT_SCALE(adMatrix, sViewData.m_dScale);
|
||||
MAT_TRANSLAT(adMatrix, sViewData.m_sOriginOnSheet.m_dX, sViewData.m_sOriginOnSheet.m_dY, 0);
|
||||
|
||||
OpenGL_PushMatrix();
|
||||
OpenGL_MultMatrix(adMatrix);
|
||||
|
||||
if(sViewData.m_pClipFrame)
|
||||
{
|
||||
// Clipping activation
|
||||
stTreatClipFrame(sViewData.m_pClipFrame);
|
||||
*pFunctionData = (void*) 1;
|
||||
}
|
||||
A3DDrawingViewGet(nullptr, &sViewData);
|
||||
}
|
||||
|
||||
return A3D_SUCCESS;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
A3DStatus stPostDrawDrawingView(A3DEntity* /*psEntity*/, A3DMiscCascadedAttributes const* /*pAttr*/, A3DVoid* /*pGlobalData*/,
|
||||
A3DVoid* pFunctionData, A3DUns32 /*uiBehavior*/)
|
||||
{
|
||||
if(pFunctionData != NULL)
|
||||
{
|
||||
// Clipping desactivation
|
||||
}
|
||||
|
||||
A3D_DRAW_CALL0(PopMatrix);
|
||||
|
||||
return A3D_SUCCESS;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
A3DStatus stPreDrawDrawingSheet(A3DEntity* psEntity, A3DMiscCascadedAttributes const* pAttr, A3DVoid* pGlobalData,
|
||||
A3DVoid** pFunctionData, A3DUns32 /*uiBehavior*/)
|
||||
{
|
||||
*pFunctionData = NULL;
|
||||
if(!stbGetVisibilityFromAttribute(pAttr))
|
||||
return A3D_CALLBACK_CONTINUE;
|
||||
|
||||
// each sheet are in a DisplayList
|
||||
GLuint uiDisplayList = glGenLists(1);
|
||||
if(uiDisplayList == 0)
|
||||
return A3D_ERROR;
|
||||
|
||||
// memory DisplayList in global data
|
||||
std::vector<GLuint>* paGLSheetDisplayList = ((GLGlobalData*) pGlobalData)->m_paSheetDL;
|
||||
std::vector<A3DVector2dData> *paGLSheetSize = ((GLGlobalData*) pGlobalData)->m_paSheetSize;
|
||||
bool bDrawMkupOnly = ((GLGlobalData*) pGlobalData)->m_bDrawMarkup;
|
||||
paGLSheetDisplayList->push_back(uiDisplayList);
|
||||
|
||||
// activate DisplayList
|
||||
glNewList(uiDisplayList, GL_COMPILE_AND_EXECUTE);
|
||||
A3DUns32* puiInternalData = new A3DUns32;
|
||||
*pFunctionData = puiInternalData;
|
||||
*puiInternalData = 1;
|
||||
|
||||
A3DStatus iRet = A3D_SUCCESS;
|
||||
|
||||
A3DDrawingSheetData sSheetData;
|
||||
A3D_INITIALIZE_DATA(A3DDrawingSheetData, sSheetData);
|
||||
iRet = A3DDrawingSheetGet((A3DDrawingSheet*) psEntity, &sSheetData);
|
||||
if(iRet == A3D_SUCCESS)
|
||||
{
|
||||
if(sSheetData.m_pFormat != NULL)
|
||||
{
|
||||
A3DDrawingSheetFormatData sFormatData;
|
||||
A3D_INITIALIZE_DATA(A3DDrawingSheetFormatData, sFormatData);
|
||||
iRet = A3DDrawingSheetFormatGet(sSheetData.m_pFormat, &sFormatData);
|
||||
if (iRet==A3D_SUCCESS)
|
||||
{
|
||||
if (!bDrawMkupOnly)
|
||||
{
|
||||
A3DDouble aPts[5 * 3];
|
||||
aPts[0] = 0;
|
||||
aPts[1] = 0;
|
||||
aPts[2] = 0;
|
||||
|
||||
aPts[3] = sFormatData.m_sSize.m_dX;
|
||||
aPts[4] = 0;
|
||||
aPts[5] = 0;
|
||||
|
||||
aPts[6] = sFormatData.m_sSize.m_dX;
|
||||
aPts[7] = sFormatData.m_sSize.m_dY;
|
||||
aPts[8] = 0;
|
||||
|
||||
aPts[9] = 0;
|
||||
aPts[10] = sFormatData.m_sSize.m_dY;
|
||||
aPts[11] = 0;
|
||||
|
||||
aPts[12] = 0;
|
||||
aPts[13] = 0;
|
||||
aPts[14] = 0;
|
||||
|
||||
GLfloat afValues[3] = { 1, 1, 0 };
|
||||
glColor3fv(afValues);
|
||||
OpenGL_PolyLine(aPts, 5);
|
||||
}
|
||||
iRet = A3DDrawingSheetFormatGet(NULL, &sFormatData);
|
||||
}
|
||||
if(paGLSheetSize != NULL)
|
||||
paGLSheetSize->push_back(sFormatData.m_sSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(paGLSheetSize != NULL)
|
||||
paGLSheetSize->push_back(sSheetData.m_sSize);
|
||||
}
|
||||
|
||||
*puiInternalData = 2;
|
||||
A3D_DRAW_CALL0(PushMatrix);
|
||||
|
||||
// Transformation matrix
|
||||
A3DDouble adMatrix[16];
|
||||
stInitializeMatrix(adMatrix);
|
||||
adMatrix[0] = sSheetData.m_dScale;
|
||||
adMatrix[5] = sSheetData.m_dScale;
|
||||
adMatrix[12] = sSheetData.m_sRefPoint.m_dX * sSheetData.m_dScale;
|
||||
adMatrix[13] = sSheetData.m_sRefPoint.m_dY * sSheetData.m_dScale;
|
||||
OpenGL_MultMatrix(adMatrix);
|
||||
A3DDrawingSheetGet(NULL, &sSheetData);
|
||||
}
|
||||
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
unsigned int OpenGL_GetPushLevel();
|
||||
|
||||
//######################################################################################################################
|
||||
A3DStatus stPostDrawDrawingSheet(A3DEntity* /*psEntity*/, A3DMiscCascadedAttributes const* /*pAttr*/, A3DVoid* /*pGlobalData*/,
|
||||
A3DVoid* pFunctionData, A3DUns32 /*uiBehavior*/)
|
||||
{
|
||||
if(pFunctionData != NULL)
|
||||
{
|
||||
A3DUns32* puiInternalData = (A3DUns32*) pFunctionData;
|
||||
// pop current transformation
|
||||
if(*puiInternalData > 1)
|
||||
A3D_DRAW_CALL0(PopMatrix);
|
||||
|
||||
// Close DisplayList
|
||||
glEndList();
|
||||
delete puiInternalData;
|
||||
}
|
||||
|
||||
return A3D_SUCCESS;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
A3DStatus A3DDrawDrawing(A3DDrawingModel* pDrawingModel, A3DDrawCallbacksData* psCallbacks,
|
||||
std::vector<GLuint> &aGLSheetDisplayList, std::vector<A3DVector2dData>* paGLSheetSize,
|
||||
bool bDrawMarkup)
|
||||
{
|
||||
st_psDrawCallBacks = psCallbacks;
|
||||
|
||||
A3DParseDrawingModelData sCallBackData;
|
||||
A3D_INITIALIZE_DATA_VAR(sCallBackData);
|
||||
sCallBackData.m_pfSheet.m_pfPreProcess = stPreDrawDrawingSheet;
|
||||
sCallBackData.m_pfSheet.m_pfPostProcess = stPostDrawDrawingSheet;
|
||||
sCallBackData.m_pfView.m_pfPreProcess = stPreDrawDrawingView;
|
||||
sCallBackData.m_pfView.m_pfPostProcess = stPostDrawDrawingView;
|
||||
sCallBackData.m_pfBlockBasic.m_pfPreProcess = stPreDrawBlock;
|
||||
sCallBackData.m_pfBlockBasic.m_pfPostProcess = stPostDrawBlock;
|
||||
sCallBackData.m_pfBlockOperator.m_pfPreProcess = stPreDrawBlock;
|
||||
sCallBackData.m_pfBlockOperator.m_pfPostProcess = stPostDrawBlock;
|
||||
|
||||
GLGlobalData sGlobalData;
|
||||
sGlobalData.m_paSheetDL = &aGLSheetDisplayList;
|
||||
sGlobalData.m_paSheetSize = paGLSheetSize;
|
||||
sGlobalData.m_bDrawMarkup = bDrawMarkup;
|
||||
sCallBackData.m_pGlobalData = &sGlobalData;
|
||||
|
||||
sCallBackData.m_pDrawingModel = pDrawingModel;
|
||||
|
||||
A3DStatus iRet = A3DParseDrawingModel(&sCallBackData);
|
||||
|
||||
st_psDrawCallBacks = NULL;
|
||||
|
||||
return iRet;
|
||||
}
|
||||
868
exchange/exchangesource/DrawingViewer/drawing_main.cpp
Normal file
868
exchange/exchangesource/DrawingViewer/drawing_main.cpp
Normal file
@@ -0,0 +1,868 @@
|
||||
/***********************************************************************************************************************
|
||||
*
|
||||
* 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 drawing_main.cpp
|
||||
|
||||
This file demonstrates how to programmatically visualize a drawing PRC file
|
||||
from a basic OpenGL program using HOOPS Exchange.
|
||||
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#define INITIALIZE_A3D_API
|
||||
#include <A3DSDKIncludes.h>
|
||||
|
||||
#include "../common.hpp"
|
||||
|
||||
#include "callback_opengl.h"
|
||||
#include "drawing_main.h"
|
||||
#include "trackball.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
#include <vector>
|
||||
|
||||
//######################################################################################################################
|
||||
A3DStatus CollectDrawing(A3DAsmModelFile* pModelFile, std::vector<A3DDrawingModel*> &apDrawingModels);
|
||||
|
||||
//######################################################################################################################
|
||||
A3DStatus A3DDrawDrawing(A3DDrawingModel* pDrawingModel, A3DDrawCallbacksData* psCallbacks,
|
||||
std::vector<GLuint> &aGLSheetDisplayList, std::vector<A3DVector2dData>* paGLSheetSize,
|
||||
bool bDrawMarkup);
|
||||
|
||||
//######################################################################################################################
|
||||
static bool stbTrackBallAnimate = GL_FALSE;
|
||||
|
||||
//######################################################################################################################
|
||||
static GLsizei stiXScreen = 0;
|
||||
static GLsizei stiYScreen = 0;
|
||||
static GLdouble stdXPan = 0.0;
|
||||
static GLdouble stdYPan = 0.0;
|
||||
static GLdouble stdZoom = 1.0;
|
||||
static GLint staiViewport[4];
|
||||
|
||||
//######################################################################################################################
|
||||
static bool stbLButtonDown = false;
|
||||
static bool stbRButtonDown = false;
|
||||
|
||||
//######################################################################################################################
|
||||
static GLuint stuiModelFileDisplayList = 0;
|
||||
static GLuint stuiMarkupsDisplayList = 0;
|
||||
static GLuint stuiTriedronDisplayList = 0;
|
||||
|
||||
//######################################################################################################################
|
||||
static std::vector<GLuint> st_aGLSheetDisplayList;
|
||||
static std::vector<A3DVector2dData> st_aGLSheetSize;
|
||||
|
||||
//######################################################################################################################
|
||||
static std::vector<GLuint> st_aGLSheetMarkupDisplayList;
|
||||
static GLuint st_CurrentSheetIndex = 0;
|
||||
|
||||
//######################################################################################################################
|
||||
static GLfloat stafLightDiffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
static GLfloat stafLightAmbient[] = { 0.1f, 0.1f, 0.1f, 1.0f };
|
||||
static GLfloat stafLightPosition[] = { 0.0f, 0.0f, 1.0f, 0.0f };
|
||||
|
||||
//######################################################################################################################
|
||||
static GLfloat stafMaterialDiffuse[] = { 0.6f, 0.6f, 0.6f, 1.0f };
|
||||
static GLfloat stafMaterialSpecular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
static GLfloat stafMaterialShininess[] = { 100.0f };
|
||||
|
||||
//######################################################################################################################
|
||||
static GLfloat stafTextColor[] = { 1.0f, 1.0f, 0.0f, 1.0f };
|
||||
|
||||
//######################################################################################################################
|
||||
static unsigned int stuiClearColor = 0xB2B2B2;
|
||||
|
||||
//######################################################################################################################
|
||||
static GLint staiWinSize[2];
|
||||
static GLint staiWinPosition[2];
|
||||
static bool stbFullScreen = false;
|
||||
|
||||
//######################################################################################################################
|
||||
static clock_t stiStart, stiEnd;
|
||||
static float stfElapsed;
|
||||
static unsigned int stiNbFrames = 0;
|
||||
static float stfFps = 0.0f;
|
||||
|
||||
//######################################################################################################################
|
||||
static A3DUTF8Char stpcWinTitle[_MAX_PATH];
|
||||
|
||||
//######################################################################################################################
|
||||
static bool stbDisplayHelp = false;
|
||||
static bool stbDisplayInfos = false;
|
||||
static bool stbDisplayMarkups = true;
|
||||
|
||||
//######################################################################################################################
|
||||
#define TRIEDRON_SIZE 40.0
|
||||
|
||||
//######################################################################################################################
|
||||
#define A3DGL_MIN(a,b) (((a)<(b)) ? (a) : (b))
|
||||
#define A3DGL_MAX(a,b) (((a)>(b)) ? (a) : (b))
|
||||
|
||||
//######################################################################################################################
|
||||
class A3DPRCViewerGLInfo
|
||||
{
|
||||
public:
|
||||
A3DBoundingBoxData sBoundingBox;
|
||||
double dBoundingBoxRadius;
|
||||
A3DVector3dData sBoundingBoxCenter;
|
||||
A3DVector2dData sDelta;
|
||||
|
||||
public:
|
||||
//##################################################################################################################
|
||||
A3DPRCViewerGLInfo() { Init(); }
|
||||
|
||||
//##################################################################################################################
|
||||
void Init()
|
||||
{
|
||||
A3D_INITIALIZE_DATA(A3DBoundingBoxData, sBoundingBox);
|
||||
A3D_INITIALIZE_DATA(A3DVector3dData, sBoundingBoxCenter);
|
||||
dBoundingBoxRadius = 0.0;
|
||||
}
|
||||
|
||||
//##################################################################################################################
|
||||
void operator=(const A3DPRCViewerGLInfo& sOther)
|
||||
{
|
||||
sBoundingBox.m_sMin.m_dX = sOther.sBoundingBox.m_sMin.m_dX;
|
||||
sBoundingBox.m_sMin.m_dY = sOther.sBoundingBox.m_sMin.m_dY;
|
||||
sBoundingBox.m_sMin.m_dZ = sOther.sBoundingBox.m_sMin.m_dZ;
|
||||
sBoundingBox.m_sMax.m_dX = sOther.sBoundingBox.m_sMax.m_dX;
|
||||
sBoundingBox.m_sMax.m_dY = sOther.sBoundingBox.m_sMax.m_dY;
|
||||
sBoundingBox.m_sMax.m_dZ = sOther.sBoundingBox.m_sMax.m_dZ;
|
||||
dBoundingBoxRadius = sOther.dBoundingBoxRadius;
|
||||
sBoundingBoxCenter.m_dX = sOther.sBoundingBoxCenter.m_dX;
|
||||
sBoundingBoxCenter.m_dY = sOther.sBoundingBoxCenter.m_dY;
|
||||
sBoundingBoxCenter.m_dZ = sOther.sBoundingBoxCenter.m_dZ;
|
||||
}
|
||||
|
||||
//##################################################################################################################
|
||||
void Calculate()
|
||||
{
|
||||
A3DVector3dData sMin;
|
||||
A3DVector3dData sMax;
|
||||
sMin.m_dX = sBoundingBox.m_sMin.m_dX;
|
||||
sMin.m_dY = sBoundingBox.m_sMin.m_dY;
|
||||
sMin.m_dZ = sBoundingBox.m_sMin.m_dZ;
|
||||
sMax.m_dX = sBoundingBox.m_sMax.m_dX;
|
||||
sMax.m_dY = sBoundingBox.m_sMax.m_dY;
|
||||
sMax.m_dZ = sBoundingBox.m_sMax.m_dZ;
|
||||
|
||||
A3DDouble dBX = sMax.m_dX - sMin.m_dX;
|
||||
A3DDouble dBY = sMax.m_dY - sMin.m_dY;
|
||||
A3DDouble dBZ = sMax.m_dZ - sMin.m_dZ;
|
||||
dBoundingBoxRadius = (float)sqrt(dBX*dBX + dBY*dBY + dBZ*dBZ) / 2.0f;
|
||||
sBoundingBoxCenter.m_dX = (sMin.m_dX + sMax.m_dX) / 2.0;
|
||||
sBoundingBoxCenter.m_dY = (sMin.m_dY + sMax.m_dY) / 2.0;
|
||||
sBoundingBoxCenter.m_dZ = (sMin.m_dZ + sMax.m_dZ) / 2.0;
|
||||
}
|
||||
|
||||
//##################################################################################################################
|
||||
A3DPRCViewerGLInfo operator+(const A3DPRCViewerGLInfo& sOther)
|
||||
{
|
||||
A3DPRCViewerGLInfo sSum;
|
||||
ExtentUnion(&sBoundingBox, &sOther.sBoundingBox, &sSum.sBoundingBox);
|
||||
sSum.Calculate();
|
||||
return sSum;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//##################################################################################################################
|
||||
void ExtentUnion(const A3DBoundingBoxData* e1, const A3DBoundingBoxData* e2, A3DBoundingBoxData* r)
|
||||
{
|
||||
r->m_sMin.m_dX = A3DGL_MIN(e1->m_sMin.m_dX, e2->m_sMin.m_dX);
|
||||
r->m_sMax.m_dX = A3DGL_MAX(e1->m_sMax.m_dX, e2->m_sMax.m_dX);
|
||||
r->m_sMin.m_dY = A3DGL_MIN(e1->m_sMin.m_dY, e2->m_sMin.m_dY);
|
||||
r->m_sMax.m_dY = A3DGL_MAX(e1->m_sMax.m_dY, e2->m_sMax.m_dY);
|
||||
r->m_sMin.m_dZ = A3DGL_MIN(e1->m_sMin.m_dZ, e2->m_sMin.m_dZ);
|
||||
r->m_sMax.m_dZ = A3DGL_MAX(e1->m_sMax.m_dZ, e2->m_sMax.m_dZ);
|
||||
}
|
||||
};
|
||||
|
||||
//######################################################################################################################
|
||||
static A3DDrawCallbacksData stsDrawCallbacksData;
|
||||
static A3DSDKHOOPSExchangeLoader* stpHOOPSExchangeLoader = NULL;
|
||||
|
||||
//######################################################################################################################
|
||||
static A3DPRCViewerGLInfo stsInfo;
|
||||
static A3DPRCViewerGLInfo stsInfo3D;
|
||||
static A3DPRCViewerGLInfo stsInfoMarkups;
|
||||
|
||||
//######################################################################################################################
|
||||
#define HEX_TO_RED(hexcolor) ((GLclampf) ((hexcolor & 0xFF0000) >> 16) / 255.0f)
|
||||
#define HEX_TO_GREEN(hexcolor) ((GLclampf) ((hexcolor & 0x00FF00) >> 8) / 255.0f)
|
||||
#define HEX_TO_BLUE(hexcolor) ((GLclampf) (hexcolor & 0x0000FF) / 255.0f)
|
||||
|
||||
//######################################################################################################################
|
||||
static enum
|
||||
{
|
||||
KE_NONE = 0,
|
||||
KE_ZOOMING,
|
||||
KE_PANNING
|
||||
} eMotionType;
|
||||
|
||||
//######################################################################################################################
|
||||
void Reshape(GLsizei w, GLsizei h)
|
||||
{
|
||||
tbReshape(w, h);
|
||||
|
||||
glViewport(0, 0, w, h);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
double dLengthX = stsInfo.sBoundingBox.m_sMax.m_dX - stsInfo.sBoundingBox.m_sMin.m_dX;
|
||||
double dLengthY = stsInfo.sBoundingBox.m_sMax.m_dY - stsInfo.sBoundingBox.m_sMin.m_dY;
|
||||
|
||||
stsInfo.sDelta.m_dX = (dLengthY * w / h - dLengthX)/2.;
|
||||
stsInfo.sDelta.m_dY = (dLengthX * h / w - dLengthY)/2.;
|
||||
if(stsInfo.sDelta.m_dX > stsInfo.sDelta.m_dY)
|
||||
stsInfo.sDelta.m_dY = 0;
|
||||
else
|
||||
stsInfo.sDelta.m_dX = 0;
|
||||
|
||||
glOrtho(stsInfo.sBoundingBox.m_sMin.m_dX - stsInfo.sDelta.m_dX,
|
||||
stsInfo.sBoundingBox.m_sMax.m_dX + stsInfo.sDelta.m_dX,
|
||||
stsInfo.sBoundingBox.m_sMin.m_dY - stsInfo.sDelta.m_dY,
|
||||
stsInfo.sBoundingBox.m_sMax.m_dY + stsInfo.sDelta.m_dY,
|
||||
-1, 1);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
glGetIntegerv(GL_VIEWPORT, staiViewport);
|
||||
|
||||
if(!stbFullScreen)
|
||||
{
|
||||
staiWinSize[0] = w;
|
||||
staiWinSize[1] = h;
|
||||
}
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
void InitGL(void)
|
||||
{
|
||||
glClearColor(HEX_TO_RED(stuiClearColor), HEX_TO_GREEN(stuiClearColor), HEX_TO_BLUE(stuiClearColor), 1.0f);
|
||||
|
||||
glPointSize(5.0f);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glEnable(GL_NORMALIZE);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
stuiTriedronDisplayList = glGenLists(1);
|
||||
glNewList(stuiTriedronDisplayList, GL_COMPILE);
|
||||
{
|
||||
glPushAttrib(GL_LIGHTING_BIT | GL_LINE_BIT);
|
||||
glDisable(GL_LIGHTING);
|
||||
glLineWidth(2.0);
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(1.0f, 0.0f, 0.0f);
|
||||
glVertex3f(0.0f, 0.0f, 0.0f);
|
||||
glVertex3f(TRIEDRON_SIZE, 0.0f, 0.0f);
|
||||
glColor3f(0.0f, 1.0f, 0.0f);
|
||||
glVertex3f(0.0f, 0.0f, 0.0f);
|
||||
glVertex3f(0.0f, TRIEDRON_SIZE, 0.0f);
|
||||
glColor3f(0.0f, 0.0f, 1.0f);
|
||||
glVertex3f(0.0f, 0.0f, 0.0f);
|
||||
glVertex3f(0.0f, 0.0f, TRIEDRON_SIZE);
|
||||
glEnd();
|
||||
glPopAttrib();
|
||||
}
|
||||
glEndList();
|
||||
|
||||
stdZoom = 1.;
|
||||
stdXPan = 0.0;
|
||||
stdYPan = 0.0;
|
||||
|
||||
#ifdef _DEBUG
|
||||
stiStart = clock();
|
||||
#endif
|
||||
|
||||
glClearDepth(1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
static float stfX = 1.0f, stfY = 97.0f, stfLineH = 2.0f;
|
||||
static char stpcMsg[2048];
|
||||
|
||||
//######################################################################################################################
|
||||
void PrintString(const char* format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vsprintf(stpcMsg, format, args);
|
||||
va_end(args);
|
||||
|
||||
glRasterPos2f(stfX, stfY);
|
||||
char* pcPos = &stpcMsg[0];
|
||||
while(*pcPos)
|
||||
{
|
||||
if(*pcPos == '\n')
|
||||
{
|
||||
stfY -= stfLineH;
|
||||
glRasterPos2f(stfX, stfY);
|
||||
}
|
||||
else
|
||||
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, *pcPos);
|
||||
pcPos++;
|
||||
}
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
void DrawStrings(void)
|
||||
{
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
gluOrtho2D(0.0, 100.0, 0.0, 100.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
glPushAttrib(GL_ENABLE_BIT);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
glColor3fv(stafTextColor);
|
||||
|
||||
if(stbDisplayInfos)
|
||||
{
|
||||
stfX = 1.0f;
|
||||
stfY = 97.0f;
|
||||
|
||||
stiNbFrames++;
|
||||
stiEnd = clock();
|
||||
stfElapsed = (float)(stiEnd - stiStart) / CLOCKS_PER_SEC;
|
||||
if(stfElapsed >= 1.0)
|
||||
{
|
||||
stfFps = stiNbFrames/stfElapsed;
|
||||
stiStart = stiEnd;
|
||||
stiNbFrames = 0;
|
||||
}
|
||||
|
||||
PrintString("%.2f fps\n", stfFps);
|
||||
PrintString("Bounding box\n");
|
||||
A3DVector3dData& sMin = stsInfo.sBoundingBox.m_sMin;
|
||||
A3DVector3dData& sMax = stsInfo.sBoundingBox.m_sMax;
|
||||
PrintString(" Extent: [%.3f, %.3f, %.3f] -> [%.3f, %.3f, %.3f]\n", sMin.m_dX, sMin.m_dY, sMin.m_dZ,
|
||||
sMax.m_dX, sMax.m_dY, sMax.m_dZ);
|
||||
PrintString(" Radius: %.3f\n", stsInfo.dBoundingBoxRadius);
|
||||
}
|
||||
|
||||
if(stbDisplayHelp)
|
||||
{
|
||||
stfX = 1.0f;
|
||||
stfY = 70.0f;
|
||||
PrintString("HELP\n");
|
||||
PrintString(" MOUSE :\n");
|
||||
PrintString(" Left button: panning\n");
|
||||
PrintString(" Right button: zooming\n");
|
||||
PrintString("\n");
|
||||
PrintString(" KEYBOARD :\n");
|
||||
PrintString(" F1: print this help\n");
|
||||
PrintString(" F2: open a file (in the console)\n");
|
||||
PrintString(" F3: save file as Prc\n");
|
||||
PrintString(" F4: toggle display markups\n");
|
||||
PrintString(" F5: toggle full screen\n");
|
||||
PrintString(" F6: change background color\n");
|
||||
PrintString(" F11: toggle display information\n");
|
||||
PrintString(" PAGE_UP / PAGE_DOWN: change current sheet\n");
|
||||
}
|
||||
|
||||
glPopAttrib();
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
void Display(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
{
|
||||
glLoadIdentity();
|
||||
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, stafLightPosition);
|
||||
double dOffsetX = (stsInfo.sBoundingBox.m_sMax.m_dX-stsInfo.sBoundingBox.m_sMin.m_dX)/2. + stsInfo.sDelta.m_dX;
|
||||
double dOffsetY = (stsInfo.sBoundingBox.m_sMax.m_dY-stsInfo.sBoundingBox.m_sMin.m_dY)/2. + stsInfo.sDelta.m_dY;
|
||||
|
||||
glTranslated(dOffsetX, dOffsetY, 0.);
|
||||
|
||||
glScaled(stdZoom, stdZoom, 1.);
|
||||
|
||||
glTranslated(-dOffsetX, -dOffsetY, 0.);
|
||||
|
||||
glTranslated(-stsInfo.dBoundingBoxRadius*stdXPan, -stsInfo.dBoundingBoxRadius*stdYPan, 0);
|
||||
//-stsInfo.dBoundingBoxRadius*stdZoom);
|
||||
|
||||
if (st_aGLSheetDisplayList.size() > 0)
|
||||
{
|
||||
GLfloat afValues[3] = { 1, 1, 1 };
|
||||
glColor3fv(afValues);
|
||||
glCallList(st_aGLSheetDisplayList.at(size_t(st_CurrentSheetIndex)));
|
||||
}
|
||||
if (stbDisplayMarkups && st_aGLSheetMarkupDisplayList.size() > 0)
|
||||
{
|
||||
glCallList(st_aGLSheetMarkupDisplayList.at(size_t(st_CurrentSheetIndex)));
|
||||
}
|
||||
}
|
||||
glPopMatrix();
|
||||
|
||||
if(stbDisplayInfos || stbDisplayHelp)
|
||||
DrawStrings();
|
||||
|
||||
glFlush();
|
||||
glFinish();
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
static bool stbTBRunning = false;
|
||||
|
||||
//######################################################################################################################
|
||||
void MouseButton(int button, int state, GLsizei x, GLsizei y)
|
||||
{
|
||||
if(button == GLUT_LEFT_BUTTON)
|
||||
{
|
||||
if(state == GLUT_DOWN)
|
||||
stbLButtonDown = true;
|
||||
else if(state == GLUT_UP)
|
||||
stbLButtonDown = false;
|
||||
}
|
||||
else if(button == GLUT_RIGHT_BUTTON)
|
||||
{
|
||||
if(state == GLUT_DOWN)
|
||||
stbRButtonDown = true;
|
||||
else if(state == GLUT_UP)
|
||||
stbRButtonDown = false;
|
||||
}
|
||||
|
||||
if(!stbLButtonDown && !stbRButtonDown)
|
||||
glutSetCursor(GLUT_CURSOR_LEFT_ARROW);
|
||||
|
||||
eMotionType = KE_NONE;
|
||||
|
||||
if(stbLButtonDown)
|
||||
{
|
||||
if(stbTBRunning)
|
||||
tbMouse(GLUT_LEFT_BUTTON, GLUT_UP, x, y);
|
||||
eMotionType = KE_PANNING;
|
||||
glutSetCursor(GLUT_CURSOR_SPRAY);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(stbRButtonDown)
|
||||
{
|
||||
eMotionType = KE_ZOOMING;
|
||||
glutSetCursor(GLUT_CURSOR_UP_DOWN);
|
||||
}
|
||||
else
|
||||
{
|
||||
tbMouse(button, state, x, y);
|
||||
stbTBRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
stiXScreen = x;
|
||||
stiYScreen = y;
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
void Motion(GLsizei x, GLsizei y)
|
||||
{
|
||||
tbMotion(x, y);
|
||||
|
||||
switch(eMotionType)
|
||||
{
|
||||
case KE_PANNING :
|
||||
{
|
||||
stdXPan -= (GLdouble)(x - stiXScreen)/(GLdouble)staiViewport[2] * 2.0 / stdZoom;
|
||||
stdYPan += (GLdouble)(y - stiYScreen)/(GLdouble)staiViewport[3] * 2.0 / stdZoom;
|
||||
break;
|
||||
}
|
||||
case KE_ZOOMING :
|
||||
{
|
||||
stdZoom += (GLdouble)(y - stiYScreen)/(GLdouble)staiViewport[3] * 10.0;
|
||||
if(stdZoom < 0.1)
|
||||
stdZoom = 0.1;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
stiXScreen = x;
|
||||
stiYScreen = y;
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
A3DInt32 CloseFile()
|
||||
{
|
||||
A3DInt32 iRet = A3D_SUCCESS;
|
||||
|
||||
size_t uiList, uiNbList = st_aGLSheetDisplayList.size();
|
||||
for(uiList = 0; uiList < uiNbList; ++uiList)
|
||||
{
|
||||
glDeleteLists(st_aGLSheetDisplayList.back(), 1);
|
||||
st_aGLSheetDisplayList.pop_back();
|
||||
|
||||
glDeleteLists(st_aGLSheetMarkupDisplayList.back(), 1);
|
||||
st_aGLSheetMarkupDisplayList.pop_back();
|
||||
}
|
||||
|
||||
st_aGLSheetSize.clear();
|
||||
|
||||
glDeleteLists(stuiModelFileDisplayList, 1);
|
||||
glDeleteLists(stuiMarkupsDisplayList, 1);
|
||||
stuiModelFileDisplayList = stuiMarkupsDisplayList = 0;
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
A3DInt32 OpenFile(const A3DUTF8Char*pcCADFileName)
|
||||
{
|
||||
if(stpHOOPSExchangeLoader == NULL)
|
||||
return A3D_ERROR;
|
||||
|
||||
A3DImport sImport(pcCADFileName);
|
||||
sImport.m_sLoadData.m_sGeneral.m_eReadingMode2D3D = kA3DRead_Drawings;
|
||||
|
||||
A3DInt32 iRet = stpHOOPSExchangeLoader->Import(sImport);
|
||||
|
||||
printf("Done.\n");
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
A3DInt32 ProcessModelFile()
|
||||
{
|
||||
if(stpHOOPSExchangeLoader == NULL || stpHOOPSExchangeLoader->m_psModelFile == NULL)
|
||||
return A3D_ERROR;
|
||||
|
||||
// Collect all DrawingModels
|
||||
std::vector<A3DDrawingModel*> apDrawingModels;
|
||||
A3DInt32 iRet = CollectDrawing(stpHOOPSExchangeLoader->m_psModelFile, apDrawingModels);
|
||||
if(iRet != A3D_SUCCESS)
|
||||
return iRet;
|
||||
|
||||
if(apDrawingModels.size() == 0)
|
||||
return A3D_ERROR;
|
||||
|
||||
// Draws and stores all the sheets in list
|
||||
st_aGLSheetDisplayList.clear();
|
||||
size_t uiModel, uiNbModel = apDrawingModels.size();
|
||||
for(uiModel = 0; uiModel < uiNbModel; ++uiModel)
|
||||
{
|
||||
iRet = A3DDrawDrawing(apDrawingModels.at(uiModel), &stsDrawCallbacksData, st_aGLSheetDisplayList,
|
||||
&st_aGLSheetSize, false);
|
||||
if(iRet != A3D_SUCCESS)
|
||||
break;
|
||||
|
||||
iRet = A3DDrawDrawing(apDrawingModels.at(uiModel), &stsDrawCallbacksData, st_aGLSheetMarkupDisplayList,
|
||||
NULL, true);
|
||||
if(iRet != A3D_SUCCESS)
|
||||
break;
|
||||
}
|
||||
|
||||
if(iRet == A3D_SUCCESS && st_aGLSheetSize.size() > 0)
|
||||
{
|
||||
st_CurrentSheetIndex = 0;
|
||||
stsInfo.sBoundingBox.m_sMin.m_dX = 0.;
|
||||
stsInfo.sBoundingBox.m_sMin.m_dY = 0.;
|
||||
stsInfo.sBoundingBox.m_sMax.m_dX = st_aGLSheetSize[st_CurrentSheetIndex].m_dX;
|
||||
stsInfo.sBoundingBox.m_sMax.m_dY = st_aGLSheetSize[st_CurrentSheetIndex].m_dY;
|
||||
stsInfo.Calculate();
|
||||
}
|
||||
|
||||
stdZoom = 1.;
|
||||
stdXPan = 0.0;
|
||||
stdYPan = 0.0;
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
A3DInt32 SaveFileAsPrc()
|
||||
{
|
||||
A3DStatus iRet = A3D_SUCCESS;
|
||||
|
||||
if(stpHOOPSExchangeLoader->m_psModelFile != NULL)
|
||||
{
|
||||
PrintString("Enter file name in console\n");
|
||||
printf("Enter file name:\n");
|
||||
|
||||
A3DUTF8Char pcPRCFileName[_MAX_PATH];
|
||||
scanf("%s", pcPRCFileName);
|
||||
|
||||
A3DRWParamsExportPrcData sParamsExportData;
|
||||
A3D_INITIALIZE_DATA(A3DRWParamsExportPrcData, sParamsExportData);
|
||||
sParamsExportData.m_bCompressBrep = false;
|
||||
sParamsExportData.m_bCompressTessellation = false;
|
||||
|
||||
CHECK_RET(A3DAsmModelFileExportToPrcFile(stpHOOPSExchangeLoader->m_psModelFile, &sParamsExportData, pcPRCFileName, NULL));
|
||||
if(iRet == A3D_SUCCESS)
|
||||
printf("Done.\n");
|
||||
else
|
||||
printf("failure [%d]\n", iRet);
|
||||
}
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
void terminate2()
|
||||
{
|
||||
CloseFile();
|
||||
|
||||
delete stpHOOPSExchangeLoader;
|
||||
stpHOOPSExchangeLoader = NULL;
|
||||
ListLeaks();
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
void stChangeViewedSheet(bool bPrevious)
|
||||
{
|
||||
bool bChange = false;
|
||||
if(bPrevious)
|
||||
{
|
||||
if(st_CurrentSheetIndex > 0)
|
||||
{
|
||||
st_CurrentSheetIndex--;
|
||||
bChange = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(st_CurrentSheetIndex + 1 < unsigned(st_aGLSheetDisplayList.size()))
|
||||
{
|
||||
st_CurrentSheetIndex++;
|
||||
bChange = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(bChange)
|
||||
{
|
||||
stsInfo.sBoundingBox.m_sMin.m_dX = 0.;
|
||||
stsInfo.sBoundingBox.m_sMin.m_dY = 0.;
|
||||
stsInfo.sBoundingBox.m_sMax.m_dX = st_aGLSheetSize[st_CurrentSheetIndex].m_dX;
|
||||
stsInfo.sBoundingBox.m_sMax.m_dY = st_aGLSheetSize[st_CurrentSheetIndex].m_dY;
|
||||
stsInfo.Calculate();
|
||||
|
||||
Reshape(staiWinSize[0], staiWinSize[1]);
|
||||
glutPostRedisplay();
|
||||
}
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
void Key(unsigned char key, int /* x */, int /* y */)
|
||||
{
|
||||
|
||||
switch(key)
|
||||
{
|
||||
case 27 :
|
||||
exit(0);
|
||||
|
||||
case GLUT_KEY_F1:
|
||||
stbDisplayHelp = !stbDisplayHelp;
|
||||
glutPostRedisplay();
|
||||
break;
|
||||
|
||||
case GLUT_KEY_F2:
|
||||
{
|
||||
A3DUTF8Char pcFilePath[_MAX_PATH];
|
||||
printf("\nFile path: ");
|
||||
scanf("%s", pcFilePath);
|
||||
|
||||
CloseFile();
|
||||
if (OpenFile(pcFilePath) == A3D_SUCCESS)
|
||||
{
|
||||
ProcessModelFile();
|
||||
Reshape(staiWinSize[0], staiWinSize[1]);
|
||||
}
|
||||
Display();
|
||||
}
|
||||
break;
|
||||
|
||||
case GLUT_KEY_F3:
|
||||
{
|
||||
SaveFileAsPrc();
|
||||
}
|
||||
break;
|
||||
|
||||
case GLUT_KEY_F4:
|
||||
stbDisplayMarkups = !stbDisplayMarkups;
|
||||
Reshape(staiWinSize[0], staiWinSize[1]);
|
||||
glutPostRedisplay();
|
||||
break;
|
||||
|
||||
case GLUT_KEY_F5:
|
||||
stbFullScreen = !stbFullScreen;
|
||||
if(stbFullScreen)
|
||||
glutFullScreen();
|
||||
else
|
||||
{
|
||||
glutPositionWindow(staiWinPosition[0], staiWinPosition[1]);
|
||||
glutReshapeWindow(staiWinSize[0], staiWinSize[1]);
|
||||
}
|
||||
break;
|
||||
|
||||
case GLUT_KEY_F6:
|
||||
{
|
||||
char pcNewColor[_MAX_PATH];
|
||||
printf("\nNew color (0xHHHHHH) : ");
|
||||
scanf("%s", pcNewColor);
|
||||
sscanf(pcNewColor, "%x", &stuiClearColor);
|
||||
glClearColor(HEX_TO_RED(stuiClearColor), HEX_TO_GREEN(stuiClearColor), HEX_TO_BLUE(stuiClearColor), 1.0f);
|
||||
glutPostRedisplay();
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case GLUT_KEY_F11:
|
||||
stbDisplayInfos = !stbDisplayInfos;
|
||||
glutPostRedisplay();
|
||||
break;
|
||||
|
||||
case GLUT_KEY_PAGE_UP:
|
||||
stChangeViewedSheet(true);
|
||||
break;
|
||||
|
||||
case GLUT_KEY_PAGE_DOWN:
|
||||
stChangeViewedSheet(false);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
void SpecialKey(int k, int x, int y)
|
||||
{
|
||||
Key((unsigned char) k, x, y);
|
||||
}
|
||||
|
||||
static MY_CHAR acSrcFileName[_MAX_PATH * 2];
|
||||
static MY_CHAR acLogFileName[_MAX_PATH * 2];
|
||||
|
||||
//######################################################################################################################
|
||||
// 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)
|
||||
{
|
||||
MY_PRINTF2("Usage:\n %s [input CATDrawing file] [Clear color value] [output LOG file]\n", ppcArgv[0]);
|
||||
MY_PRINTF(" Default output LOG file is [input CATDrawing file]_Log.txt\n\n");
|
||||
}
|
||||
|
||||
if (iArgc > 1) MY_STRCPY(acSrcFileName, ppcArgv[1]);
|
||||
else MY_STRCPY(acSrcFileName, DEFAULT_INPUT_DRAWING);
|
||||
if (iArgc > 2) MY_SSCANF(ppcArgv[2], "%x", &stuiClearColor);
|
||||
else stuiClearColor = 0xB2B2B2;
|
||||
if (iArgc > 3) MY_STRCPY(acLogFileName, ppcArgv[3]);
|
||||
else MY_SPRINTF(acLogFileName, "%s_Log.txt", acSrcFileName);
|
||||
GetLogFile(acLogFileName); // Initialize log file
|
||||
|
||||
//
|
||||
// ### INITIALIZE HOOPS EXCHANGE
|
||||
//
|
||||
|
||||
stpHOOPSExchangeLoader = new A3DSDKHOOPSExchangeLoader(_T(HOOPS_BINARY_DIRECTORY));
|
||||
if (stpHOOPSExchangeLoader->m_eSDKStatus != A3D_SUCCESS)
|
||||
{
|
||||
A3DStatus eSDKStatus = stpHOOPSExchangeLoader->m_eSDKStatus;
|
||||
delete stpHOOPSExchangeLoader;
|
||||
stpHOOPSExchangeLoader = NULL;
|
||||
return eSDKStatus;
|
||||
}
|
||||
|
||||
CHECK_RET(A3DDllSetCallbacksMemory(CheckMalloc, CheckFree));
|
||||
CHECK_RET(A3DDllSetCallbacksReport(PrintLogMessage, PrintLogWarning, PrintLogError));
|
||||
|
||||
//
|
||||
// ### PROCESS SAMPLE CODE
|
||||
//
|
||||
|
||||
A3DInt32 iRet = A3D_SUCCESS;
|
||||
glutInit((int*)(&iArgc), (char**)ppcArgv);
|
||||
GLsizei iScreenW = glutGet(GLUT_SCREEN_WIDTH);
|
||||
GLsizei iScreenH = glutGet(GLUT_SCREEN_HEIGHT);
|
||||
staiWinSize[0] = (GLsizei)((double)iScreenW * 0.7);
|
||||
staiWinSize[1] = (GLsizei)((double)iScreenH * 0.7);
|
||||
staiWinPosition[0] = (iScreenW - staiWinSize[0]) / 2;
|
||||
staiWinPosition[1] = (iScreenH - staiWinSize[1]) / 2;
|
||||
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_STENCIL); // GLUT_DEPTH
|
||||
glutInitWindowPosition(staiWinPosition[0], staiWinPosition[1]);
|
||||
glutInitWindowSize(staiWinSize[0], staiWinSize[1]);
|
||||
|
||||
glutCreateWindow("A3DPRCDrawingViewerGL");
|
||||
glViewport(0, 0, staiWinSize[0], staiWinSize[1]);
|
||||
|
||||
tbInit(GLUT_LEFT_BUTTON);
|
||||
tbAnimate(stbTrackBallAnimate);
|
||||
|
||||
stsInfo.Init();
|
||||
stsInfo3D.Init();
|
||||
stsInfoMarkups.Init();
|
||||
|
||||
CHECK_RET(OpenGL_SetAndInitCallBack(stsDrawCallbacksData));
|
||||
|
||||
A3DUTF8Char sSrcFileNameUTF8[_MAX_PATH];
|
||||
#ifdef _MSC_VER
|
||||
A3DMiscUTF16ToUTF8(acSrcFileName, sSrcFileNameUTF8);
|
||||
#else
|
||||
MY_STRCPY(sSrcFileNameUTF8, acSrcFileName);
|
||||
#endif
|
||||
CHECK_RET_TERM(OpenFile(sSrcFileNameUTF8));
|
||||
|
||||
CHECK_RET_TERM(ProcessModelFile());
|
||||
|
||||
InitGL();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutDisplayFunc(Display);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
glutMouseFunc(MouseButton);
|
||||
glutMotionFunc(Motion);
|
||||
glutIdleFunc(NULL);
|
||||
|
||||
printf("\nF1 for help\n");
|
||||
|
||||
// glut call exit(0) when closing windows, so set atexit to close properly dll
|
||||
atexit(terminate2);
|
||||
|
||||
glutMainLoop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
51
exchange/exchangesource/DrawingViewer/drawing_main.h
Normal file
51
exchange/exchangesource/DrawingViewer/drawing_main.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/***********************************************************************************************************************
|
||||
*
|
||||
* 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 drawing_main.h
|
||||
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef _A3DPRCViewerGL_H
|
||||
#define _A3DPRCViewerGL_H
|
||||
|
||||
#define _CRT_SECURE_NO_DEPRECATE 1
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <GLUT/glut.h>
|
||||
#else
|
||||
#include <GL/glut.h>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
||||
//######################################################################################################################
|
||||
#define CHECK_RET_TERM(function_call) {\
|
||||
iRet = function_call;\
|
||||
if(iRet != A3D_SUCCESS)\
|
||||
{\
|
||||
std::cout << #function_call " returned error " << iRet << std::endl;\
|
||||
terminate2();\
|
||||
return iRet;\
|
||||
}\
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
#define FOVY 30.0f
|
||||
#define Stringize(L) #L
|
||||
#define MakeString(M, L) M(L)
|
||||
#define $Line \
|
||||
MakeString(Stringize, __LINE__)
|
||||
#define Todo __FILE__ "(" $Line ") : TODO: "
|
||||
|
||||
#endif
|
||||
431
exchange/exchangesource/DrawingViewer/drawing_parse.cpp
Normal file
431
exchange/exchangesource/DrawingViewer/drawing_parse.cpp
Normal file
@@ -0,0 +1,431 @@
|
||||
/***********************************************************************************************************************
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <A3DSDKIncludes.h>
|
||||
#include "drawing_parse.h"
|
||||
|
||||
|
||||
|
||||
//######################################################################################################################
|
||||
#define CHECK(FCT) \
|
||||
if(!bExit) \
|
||||
{ \
|
||||
A3DStatus iLocRet = (FCT); \
|
||||
if(iLocRet != A3D_SUCCESS) \
|
||||
{ \
|
||||
if(iLocRet == A3D_CALLBACK_CONTINUE) \
|
||||
bExit = true; \
|
||||
else \
|
||||
{ \
|
||||
iRet = iLocRet; \
|
||||
bExit = (uiParseBehavior & A3D_PARSE_CONTINUE_EVEN_IF_ERROR) && (iLocRet != A3D_SUCCESS); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
#define A3DDRAWING_PARSE_SHEET 0x80000000 // 1000 0000 0000 0000
|
||||
#define A3DDRAWING_PARSE_VIEW 0x40000000 // 0100 0000 0000 0000
|
||||
#define A3DDRAWING_PARSE_BLOCK 0x20000000 // 0010 0000 0000 0000
|
||||
#define A3DDRAWING_PARSE_BLOCKBASIC 0x10000000 // 0001 0000 0000 0000
|
||||
#define A3DDRAWING_PARSE_BLOCKOPERATOR 0x08000000 // 0000 1000 0000 0000
|
||||
#define A3DDRAWING_PARSE_ENTITY 0x00400000 // 0000 0100 0000 0000
|
||||
|
||||
//######################################################################################################################
|
||||
#define A3DDRAWING_SET_PARSE_SHEET 0x80000000 // 1000 0000 0000 0000
|
||||
#define A3DDRAWING_SET_PARSE_VIEW 0xC0000000 // 1100 0000 0000 0000
|
||||
#define A3DDRAWING_SET_PARSE_BLOCK 0xE0000000 // 1110 0000 0000 0000
|
||||
#define A3DDRAWING_SET_PARSE_BLOCKBASIC 0xF0000000 // 1111 0000 0000 0000
|
||||
#define A3DDRAWING_SET_PARSE_BLOCKOPERATOR 0xE8000000 // 1110 1000 0000 0000
|
||||
#define A3DDRAWING_SET_PARSE_ENTITY 0xF8000000 // 1111 1000 0000 0000
|
||||
|
||||
//######################################################################################################################
|
||||
static A3DStatus stCreateAndPushCascadedAttributes(const A3DRootBaseWithGraphics* pBase,
|
||||
const A3DMiscCascadedAttributes* pFatherAttr,
|
||||
A3DMiscCascadedAttributes** ppAttr)
|
||||
{
|
||||
A3DStatus iRet = A3D_SUCCESS;
|
||||
|
||||
CHECK_RET(A3DMiscCascadedAttributesCreate(ppAttr));
|
||||
CHECK_RET(A3DMiscCascadedAttributesPush(*ppAttr, pBase, pFatherAttr));
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
static A3DStatus stFreeCascadedAttributes(A3DMiscCascadedAttributes* ppAttr)
|
||||
{
|
||||
A3DStatus iRet = A3D_SUCCESS;
|
||||
|
||||
CHECK_RET(A3DMiscCascadedAttributesDelete(ppAttr));
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
#define CREATE_AUTOCLEAN_CLASS_DATA(TYPE) \
|
||||
class AutoClean##TYPE##Data : public TYPE##Data\
|
||||
{ \
|
||||
public: \
|
||||
AutoClean##TYPE##Data() { A3D_INITIALIZE_##TYPE##Data(*this)}; \
|
||||
~AutoClean##TYPE##Data() { TYPE##Get(NULL, (TYPE##Data*)this);}; \
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
CREATE_AUTOCLEAN_CLASS_DATA(A3DDrawingBlockBasic);
|
||||
|
||||
//######################################################################################################################
|
||||
static A3DStatus stA3DParse_Block(A3DParseDrawingModelData const* const pParseData, A3DUns32 uiParseBehavior,
|
||||
A3DDrawingBlock* pBlock, A3DMiscCascadedAttributes const* pFatherAttr);
|
||||
|
||||
//######################################################################################################################
|
||||
static A3DStatus stA3DParse_BlockBasic(A3DParseDrawingModelData const* const pParseData, A3DUns32 uiParseBehavior,
|
||||
A3DDrawingBlockBasic* pBlock, A3DMiscCascadedAttributes const* pFatherAttr)
|
||||
{
|
||||
if((uiParseBehavior & A3DDRAWING_PARSE_BLOCKBASIC) == 0)
|
||||
return A3D_SUCCESS;
|
||||
|
||||
A3DStatus iRet = A3D_SUCCESS;
|
||||
A3DVoid* pFunctionData = NULL;
|
||||
A3DUns32 uiFunctionBehavior = 0;
|
||||
bool bExit = false;
|
||||
|
||||
// Compute CascadedAttributes ...
|
||||
A3DMiscCascadedAttributes* pAttr = NULL;
|
||||
CHECK(stCreateAndPushCascadedAttributes(pBlock, pFatherAttr, &pAttr));
|
||||
|
||||
if(pParseData->m_pfBlockBasic.m_pfPreProcess != NULL)
|
||||
{
|
||||
CHECK(pParseData->m_pfBlockBasic.m_pfPreProcess(pBlock, pAttr, pParseData->m_pGlobalData, &pFunctionData,
|
||||
uiFunctionBehavior));
|
||||
}
|
||||
|
||||
if(!bExit)
|
||||
{
|
||||
//A3DDrawingBlockBasicData sBlockData;
|
||||
//A3D_INITIALIZE_DATA(A3DDrawingBlockBasicData, sBlockData);
|
||||
AutoCleanA3DDrawingBlockBasicData sBlockData;
|
||||
CHECK(A3DDrawingBlockBasicGet(pBlock,&sBlockData));
|
||||
sBlockData.m_uiDrwEntitiesSize = 0;
|
||||
if(bExit)
|
||||
{
|
||||
// No need to continue
|
||||
stFreeCascadedAttributes(pAttr);
|
||||
return iRet;
|
||||
}
|
||||
|
||||
A3DUns32 uiIndex;
|
||||
|
||||
for(uiIndex = 0; uiIndex < sBlockData.m_uiDrwBlocksSize; uiIndex++)
|
||||
{
|
||||
CHECK(stA3DParse_Block(pParseData, uiParseBehavior, sBlockData.m_ppDrwBlocks[uiIndex], pAttr));
|
||||
if(bExit)
|
||||
break;
|
||||
}
|
||||
|
||||
CHECK(A3DDrawingBlockBasicGet(NULL, &sBlockData));
|
||||
}
|
||||
|
||||
if(pParseData->m_pfBlockBasic.m_pfPostProcess != NULL)
|
||||
{
|
||||
if(iRet != A3D_SUCCESS)
|
||||
uiFunctionBehavior |= A3D_PARSE_ERROR;
|
||||
CHECK(pParseData->m_pfBlockBasic.m_pfPostProcess(pBlock, pAttr, pParseData->m_pGlobalData, pFunctionData,
|
||||
uiFunctionBehavior));
|
||||
}
|
||||
|
||||
// Free local data
|
||||
stFreeCascadedAttributes(pAttr);
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
static A3DStatus stA3DParse_BlockOperator(A3DParseDrawingModelData const* const pParseData, A3DUns32 uiParseBehavior,
|
||||
A3DDrawingBlockOperator* pBlock, A3DMiscCascadedAttributes const* pFatherAttr)
|
||||
{
|
||||
if((uiParseBehavior & A3DDRAWING_PARSE_BLOCKBASIC)==0)
|
||||
return A3D_SUCCESS;
|
||||
|
||||
A3DStatus iRet = A3D_SUCCESS;
|
||||
A3DVoid *pFunctionData = NULL;
|
||||
A3DUns32 uiFunctionBehavior = 0;
|
||||
bool bExit = false;
|
||||
|
||||
|
||||
// Compute CascadedAttributes ...
|
||||
A3DMiscCascadedAttributes* pAttr = NULL;
|
||||
CHECK(stCreateAndPushCascadedAttributes(pBlock, pFatherAttr, &pAttr));
|
||||
|
||||
if(pParseData->m_pfBlockOperator.m_pfPreProcess != NULL)
|
||||
{
|
||||
CHECK(pParseData->m_pfBlockOperator.m_pfPreProcess(pBlock, pAttr, pParseData->m_pGlobalData, &pFunctionData,
|
||||
uiFunctionBehavior));
|
||||
}
|
||||
|
||||
if(!bExit)
|
||||
{
|
||||
A3DDrawingBlockOperatorData sBlockData;
|
||||
A3D_INITIALIZE_DATA(A3DDrawingBlockOperatorData, sBlockData);
|
||||
CHECK(A3DDrawingBlockOperatorGet(pBlock,&sBlockData));
|
||||
if(bExit)
|
||||
{
|
||||
// No need to continue
|
||||
stFreeCascadedAttributes(pAttr);
|
||||
return iRet;
|
||||
}
|
||||
|
||||
A3DUns32 uiIndex;
|
||||
|
||||
for(uiIndex = 0; uiIndex < sBlockData.m_uiDrwBlocksSize; uiIndex++)
|
||||
{
|
||||
CHECK(stA3DParse_Block(pParseData, uiParseBehavior, sBlockData.m_ppDrwBlocks[uiIndex], pAttr));
|
||||
if(bExit)
|
||||
break;
|
||||
}
|
||||
|
||||
CHECK(A3DDrawingBlockOperatorGet(NULL, &sBlockData));
|
||||
}
|
||||
|
||||
if(pParseData->m_pfBlockOperator.m_pfPostProcess != NULL)
|
||||
{
|
||||
if(iRet != A3D_SUCCESS)
|
||||
uiFunctionBehavior |= A3D_PARSE_ERROR;
|
||||
CHECK(pParseData->m_pfBlockOperator.m_pfPostProcess(pBlock, pAttr, pParseData->m_pGlobalData, pFunctionData,
|
||||
uiFunctionBehavior));
|
||||
}
|
||||
|
||||
// Free local data
|
||||
stFreeCascadedAttributes(pAttr);
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
static A3DStatus stA3DParse_Block(A3DParseDrawingModelData const* const pParseData, A3DUns32 uiParseBehavior,
|
||||
A3DDrawingBlock* pBlock, A3DMiscCascadedAttributes const* pFatherAttr)
|
||||
{
|
||||
A3DStatus iRet = A3D_SUCCESS;
|
||||
bool bExit = false;
|
||||
|
||||
if((uiParseBehavior & A3DDRAWING_PARSE_BLOCK) != 0)
|
||||
{
|
||||
A3DEEntityType eType = kA3DTypeUnknown;
|
||||
CHECK(A3DEntityGetType(pBlock, &eType));
|
||||
switch(eType)
|
||||
{
|
||||
case kA3DTypeDrawingBlockBasic:
|
||||
CHECK(stA3DParse_BlockBasic(pParseData, uiParseBehavior, (A3DDrawingBlockBasic*) pBlock, pFatherAttr));
|
||||
break;
|
||||
|
||||
case kA3DTypeDrawingBlockOperator:
|
||||
CHECK(stA3DParse_BlockOperator(pParseData, uiParseBehavior, (A3DDrawingBlockOperator*) pBlock, pFatherAttr));
|
||||
break;
|
||||
|
||||
default:
|
||||
return A3D_INVALID_ENTITY_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
static A3DStatus stA3DParse_View(A3DParseDrawingModelData const* const pParseData, A3DUns32 uiParseBehavior,
|
||||
A3DDrawingView* pView, A3DMiscCascadedAttributes const* pFatherAttr)
|
||||
{
|
||||
if((uiParseBehavior & A3DDRAWING_PARSE_VIEW) == 0)
|
||||
return A3D_SUCCESS;
|
||||
|
||||
A3DStatus iRet = A3D_SUCCESS;
|
||||
A3DVoid* pFunctionData = NULL;
|
||||
A3DUns32 uiFunctionBehavior = 0;
|
||||
bool bExit = false;
|
||||
|
||||
|
||||
// Compute CascadedAttributes ...
|
||||
A3DMiscCascadedAttributes* pAttr = NULL;
|
||||
CHECK(stCreateAndPushCascadedAttributes(pView, pFatherAttr, &pAttr));
|
||||
|
||||
if(pParseData->m_pfView.m_pfPreProcess != NULL)
|
||||
{
|
||||
CHECK(pParseData->m_pfView.m_pfPreProcess(pView, pAttr, pParseData->m_pGlobalData, &pFunctionData,
|
||||
uiFunctionBehavior));
|
||||
}
|
||||
|
||||
if(!bExit)
|
||||
{
|
||||
// Getting A3DDrawingView Data
|
||||
A3DDrawingViewData sViewData;
|
||||
A3D_INITIALIZE_DATA(A3DDrawingViewData, sViewData);
|
||||
CHECK(A3DDrawingViewGet(pView, &sViewData));
|
||||
if(bExit)
|
||||
{
|
||||
// No need to continue
|
||||
stFreeCascadedAttributes(pAttr);
|
||||
return iRet;
|
||||
}
|
||||
|
||||
// Parse sub-entities
|
||||
{
|
||||
if(sViewData.m_pLocalBlocks != NULL)
|
||||
{
|
||||
CHECK(stA3DParse_Block(pParseData, uiParseBehavior, sViewData.m_pLocalBlocks, pAttr));
|
||||
}
|
||||
|
||||
A3DUns32 uiIndex;
|
||||
for(uiIndex = 0; uiIndex < sViewData.m_uiDrwBlocksSize; uiIndex++)
|
||||
{
|
||||
CHECK(stA3DParse_Block(pParseData, uiParseBehavior, sViewData.m_ppDrwBlocks[uiIndex], pAttr));
|
||||
if(bExit)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CHECK(A3DDrawingViewGet(NULL, &sViewData));
|
||||
}
|
||||
|
||||
if(pParseData->m_pfView.m_pfPostProcess != NULL)
|
||||
{
|
||||
if(iRet != A3D_SUCCESS)
|
||||
uiFunctionBehavior |= A3D_PARSE_ERROR;
|
||||
CHECK(pParseData->m_pfView.m_pfPostProcess(pView, pAttr, pParseData->m_pGlobalData, pFunctionData,
|
||||
uiFunctionBehavior));
|
||||
}
|
||||
|
||||
// Free local data
|
||||
stFreeCascadedAttributes(pAttr);
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
static A3DStatus stA3DParse_Sheet(A3DParseDrawingModelData const* const pParseData, A3DUns32 uiParseBehavior,
|
||||
A3DDrawingSheet* pSheet, A3DMiscCascadedAttributes const* pFatherAttr)
|
||||
{
|
||||
if((uiParseBehavior & A3DDRAWING_PARSE_SHEET) == 0)
|
||||
return A3D_SUCCESS;
|
||||
|
||||
A3DStatus iRet = A3D_SUCCESS;
|
||||
A3DVoid* pFunctionData = NULL;
|
||||
A3DUns32 uiFunctionBehavior = 0;
|
||||
bool bExit = false;
|
||||
|
||||
// Compute CascadedAttributes ...
|
||||
A3DMiscCascadedAttributes* pAttr = NULL;
|
||||
CHECK(stCreateAndPushCascadedAttributes(pSheet, pFatherAttr, &pAttr));
|
||||
|
||||
if(pParseData->m_pfSheet.m_pfPreProcess != NULL)
|
||||
{
|
||||
CHECK(pParseData->m_pfSheet.m_pfPreProcess(pSheet, pAttr, pParseData->m_pGlobalData, &pFunctionData,
|
||||
uiFunctionBehavior));
|
||||
}
|
||||
|
||||
A3DDrawingSheetData sSheetData;
|
||||
A3D_INITIALIZE_DATA(A3DDrawingSheetData, sSheetData);
|
||||
CHECK(A3DDrawingSheetGet(pSheet, &sSheetData));
|
||||
|
||||
if(sSheetData.m_pBackgroundBlocks != NULL)
|
||||
{
|
||||
CHECK(stA3DParse_Block(pParseData, uiParseBehavior, sSheetData.m_pBackgroundBlocks, pAttr));
|
||||
}
|
||||
|
||||
A3DUns32 uiIndex;
|
||||
for(uiIndex = 0; uiIndex < sSheetData.m_uiDrwBlocksSize; uiIndex++)
|
||||
{
|
||||
CHECK(stA3DParse_Block(pParseData, uiParseBehavior, sSheetData.m_ppDrwBlocks[uiIndex], pAttr));
|
||||
if(bExit)
|
||||
break;
|
||||
}
|
||||
|
||||
for(uiIndex=0; uiIndex<sSheetData.m_uiDrwViewsSize; uiIndex++)
|
||||
{
|
||||
CHECK(stA3DParse_View(pParseData, uiParseBehavior, sSheetData.m_ppDrwViews[uiIndex], pAttr));
|
||||
if(bExit)
|
||||
break;
|
||||
}
|
||||
|
||||
if(pParseData->m_pfSheet.m_pfPostProcess != NULL)
|
||||
{
|
||||
if(iRet != A3D_SUCCESS)
|
||||
uiFunctionBehavior |= A3D_PARSE_ERROR;
|
||||
CHECK(pParseData->m_pfSheet.m_pfPostProcess(pSheet, pAttr, pParseData->m_pGlobalData, pFunctionData,
|
||||
uiFunctionBehavior));
|
||||
}
|
||||
|
||||
// Free local data
|
||||
stFreeCascadedAttributes(pAttr);
|
||||
CHECK(A3DDrawingSheetGet(nullptr, &sSheetData));
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
A3DStatus A3DParseDrawingModel(A3DParseDrawingModelData const* const pParseData)
|
||||
{
|
||||
if(pParseData == NULL ||pParseData->m_pDrawingModel == NULL)
|
||||
return A3D_ERROR;
|
||||
|
||||
// Compute ParseBehavior
|
||||
A3DUns32 uiLParseBehavior = pParseData->m_uiParseBehavior;
|
||||
if(pParseData->m_pfSheet.m_pfPreProcess || pParseData->m_pfSheet.m_pfPostProcess)
|
||||
uiLParseBehavior |= A3DDRAWING_SET_PARSE_VIEW;
|
||||
|
||||
if(pParseData->m_pfView.m_pfPreProcess || pParseData->m_pfView.m_pfPostProcess)
|
||||
uiLParseBehavior |= A3DDRAWING_SET_PARSE_SHEET;
|
||||
|
||||
if(pParseData->m_pfBlockBasic.m_pfPreProcess || pParseData->m_pfBlockBasic.m_pfPostProcess)
|
||||
uiLParseBehavior |= A3DDRAWING_SET_PARSE_BLOCKBASIC;
|
||||
|
||||
if(pParseData->m_pfBlockOperator.m_pfPreProcess || pParseData->m_pfBlockOperator.m_pfPostProcess)
|
||||
uiLParseBehavior |= A3DDRAWING_SET_PARSE_BLOCKOPERATOR;
|
||||
|
||||
if(pParseData->m_pfEntity.m_pfPreProcess || pParseData->m_pfEntity.m_pfPostProcess)
|
||||
uiLParseBehavior |= A3DDRAWING_SET_PARSE_ENTITY;
|
||||
|
||||
A3DStatus iRet;
|
||||
|
||||
A3DMiscCascadedAttributes* pCascadedAttr;
|
||||
CHECK_RET(A3DMiscCascadedAttributesCreate(&pCascadedAttr));
|
||||
|
||||
A3DDrawingModelData sDrawingModelData;
|
||||
A3D_INITIALIZE_DATA(A3DDrawingModelData, sDrawingModelData);
|
||||
iRet = A3DDrawingModelGet(pParseData->m_pDrawingModel, &sDrawingModelData);
|
||||
if(iRet == A3D_SUCCESS)
|
||||
{
|
||||
if((pParseData->m_uiParseBehavior & A3D_PARSE_DRAWING_ACTIVE_SHEET) != 0)
|
||||
{
|
||||
if(sDrawingModelData.m_uiActiveSheet < sDrawingModelData.m_uiDrwSheetsSize)
|
||||
{
|
||||
iRet = stA3DParse_Sheet(pParseData, uiLParseBehavior,
|
||||
sDrawingModelData.m_ppDrwSheets[sDrawingModelData.m_uiActiveSheet], pCascadedAttr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
A3DUns32 uiSheet, uiNbSheet = sDrawingModelData.m_uiDrwSheetsSize;
|
||||
for(uiSheet = 0; uiSheet < uiNbSheet; uiSheet++)
|
||||
{
|
||||
iRet = stA3DParse_Sheet(pParseData, uiLParseBehavior,
|
||||
sDrawingModelData.m_ppDrwSheets[uiSheet], pCascadedAttr);
|
||||
if((iRet != A3D_SUCCESS) && ((uiLParseBehavior & A3D_PARSE_CONTINUE_EVEN_IF_ERROR) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
A3DDrawingModelGet(nullptr, &sDrawingModelData);
|
||||
}
|
||||
|
||||
|
||||
CHECK_RET(A3DMiscCascadedAttributesDelete(pCascadedAttr));
|
||||
|
||||
return iRet;
|
||||
}
|
||||
67
exchange/exchangesource/DrawingViewer/drawing_parse.h
Normal file
67
exchange/exchangesource/DrawingViewer/drawing_parse.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/***********************************************************************************************************************
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef __A3DPRCDRAWINGPARSE_H__
|
||||
#define __A3DPRCDRAWINGPARSE_H__
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#define A3D_PARSE_ERROR 0x0200
|
||||
#define A3D_PARSE_CONTINUE_EVEN_IF_ERROR 0x0400
|
||||
#define A3D_PARSE_DRAWING_ACTIVE_SHEET 0x0800
|
||||
|
||||
|
||||
|
||||
//######################################################################################################################
|
||||
#define CHECK_RET(function_call) {\
|
||||
iRet = function_call; if(iRet != A3D_SUCCESS) { std::cout << "Error number=" << iRet << std::endl; return iRet; }\
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
typedef A3DStatus (*A3DCallbackParsePreProcess) (A3DEntity* psEntity,
|
||||
A3DMiscCascadedAttributes const* pAttribute,
|
||||
A3DVoid* pGlobalData,
|
||||
A3DVoid** pFunctionData,
|
||||
A3DUns32 uiFctBehavior); // entity already parsed
|
||||
|
||||
//######################################################################################################################
|
||||
typedef A3DStatus (*A3DCallbackParsePostProcess) (A3DEntity* psEntity,
|
||||
A3DMiscCascadedAttributes const* pAttribute,
|
||||
A3DVoid* pGlobalData,
|
||||
A3DVoid* pFunctionData,
|
||||
A3DUns32 uiFctBehavior); // error int process
|
||||
|
||||
//######################################################################################################################
|
||||
typedef struct
|
||||
{
|
||||
A3DCallbackParsePreProcess m_pfPreProcess;
|
||||
A3DCallbackParsePostProcess m_pfPostProcess;
|
||||
} A3DCallbackParse;
|
||||
|
||||
//######################################################################################################################
|
||||
typedef struct
|
||||
{
|
||||
A3DUns16 m_usStructSize; /*!< Reserved; must be initialized using the \ref A3D_INITIALIZE_DATA macro. */
|
||||
A3DDrawingModel* m_pDrawingModel;
|
||||
A3DUns32 m_uiParseBehavior;
|
||||
A3DVoid* m_pGlobalData;
|
||||
|
||||
A3DCallbackParse m_pfSheet;
|
||||
A3DCallbackParse m_pfView;
|
||||
A3DCallbackParse m_pfBlockBasic;
|
||||
A3DCallbackParse m_pfBlockOperator;
|
||||
A3DCallbackParse m_pfEntity;
|
||||
} A3DParseDrawingModelData;
|
||||
|
||||
//######################################################################################################################
|
||||
A3DStatus A3DParseDrawingModel(A3DParseDrawingModelData const* const pParseData);
|
||||
|
||||
#endif // __A3DPRCDRAWINGPARSE_H__
|
||||
Reference in New Issue
Block a user