From 2c4de5c4f4149a6f5a94a083dc1f375fa34a667d Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Sun, 31 Aug 2014 10:24:17 +0000 Subject: [PATCH] EgtInterface 1.5h1 : - primo commit. --- EInDllMain.cpp | 68 +++++ EgtInterface.cpp | 88 ++++++ EgtInterface.rc | Bin 0 -> 11526 bytes EgtInterface.sln | 26 ++ EgtInterface.vcxproj | 205 ++++++++++++++ EgtInterface.vcxproj.filters | 47 ++++ Interface.cpp | 503 +++++++++++++++++++++++++++++++++++ resource.h | Bin 0 -> 994 bytes stdafx.cpp | 8 + stdafx.h | 35 +++ 10 files changed, 980 insertions(+) create mode 100644 EInDllMain.cpp create mode 100644 EgtInterface.cpp create mode 100644 EgtInterface.rc create mode 100644 EgtInterface.sln create mode 100644 EgtInterface.vcxproj create mode 100644 EgtInterface.vcxproj.filters create mode 100644 Interface.cpp create mode 100644 resource.h create mode 100644 stdafx.cpp create mode 100644 stdafx.h diff --git a/EInDllMain.cpp b/EInDllMain.cpp new file mode 100644 index 0000000..672141f --- /dev/null +++ b/EInDllMain.cpp @@ -0,0 +1,68 @@ +//---------------------------------------------------------------------------- +// EgalTech 2014-2014 +//---------------------------------------------------------------------------- +// File : EInDllMain.cpp Data : 26.08.14 Versione : 1.5h1 +// Contenuto : Inizializzazione della DLL. +// +// +// +// Modifiche : 26.08.14 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "/EgtDev/Include/EInDllMain.h" +#include "/EgtDev/Include/EGnGetModuleVer.h" +#include "/EgtDev/Include/EgtTrace.h" + +//--------------------------- Costanti ---------------------------------------- +#if defined( _WIN64) + #if defined( _DEBUG) + const char* EIN_STR = "EgtInterfaceD64.dll ver. " ; + #else + const char* EIN_STR = "EgtInterfaceR64.dll ver. " ; + #endif +#elif defined( _WIN32) + #if defined( _DEBUG) + const char* EIN_STR = "EgtInterfaceD32.dll ver. " ; + #else + const char* EIN_STR = "EgtInterfaceR32.dll ver. " ; + #endif +#endif +const int STR_DIM = 40 ; + +//----------------------------------------------------------------------------- +static HINSTANCE s_hModule = NULL ; +static char s_szEInNameVer[STR_DIM] ; + +//----------------------------------------------------------------------------- +BOOL APIENTRY +DllMain( HMODULE hModule, DWORD dwReason, LPVOID lpReserved) +{ + + if ( dwReason == DLL_PROCESS_ATTACH) { + s_hModule = hModule ; + EGT_TRACE( "EgtInterface.dll Initializing!\n") ; + } + else if ( dwReason == DLL_PROCESS_DETACH) { + s_hModule = NULL ; + EGT_TRACE( "EgtInterface.dll Terminating!\n") ; + } + + return 1 ; +} + +//----------------------------------------------------------------------------- +const char* +GetEInVersion( void) +{ + std::string sVer ; + + GetModuleVersion( s_hModule, sVer) ; + sprintf_s( s_szEInNameVer, STR_DIM, "%s%s", EIN_STR, sVer.c_str()) ; + + return s_szEInNameVer ; +} + diff --git a/EgtInterface.cpp b/EgtInterface.cpp new file mode 100644 index 0000000..c8161ca --- /dev/null +++ b/EgtInterface.cpp @@ -0,0 +1,88 @@ +// EgtInterface.cpp: definisce le funzioni esportate per l'applicazione DLL. +// + +#include "stdafx.h" +#include "/EgtDev/Include/EInAPI.h" +#include + +using namespace std ; + +//----------------------------------------------------------------------------- +double +__stdcall Summ( double dA, double dB) +{ + return ( dA + dB) ; +} + +//----------------------------------------------------------------------------- +int +__stdcall Summ2( double& dA, double dB) +{ + dA += dB ; + bool bOk = false ; + return ( bOk ? 1 : 0) ; +} + +//----------------------------------------------------------------------------- +int +__stdcall Append( const wchar_t* wsA, wchar_t*& wsB) +{ + wstring wsMy = wsA + wstring( L"_dalC++") ; + wsB = _wcsdup( wsMy.c_str()) ; + return (( wsB == nullptr) ? 0 : 1) ; +} + +//----------------------------------------------------------------------------- +int +__stdcall FreeMemory( void* pMem) +{ + if ( pMem == nullptr) + return 0 ; + free( pMem) ; + return 1 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall SetPoint( double ptP[3]) +{ + ptP[0] += 10 ; + ptP[1] += 20 ; + ptP[2] += 30 ; + + return 1 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall OutText( HWND hWnd, const wchar_t* wsA) +{ + SetWindowText( hWnd, wsA) ; + + return 1 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall DrawCross( HWND hWnd, int nX, int nY, int nDim) +{ + RECT rc ; + GetClientRect( hWnd, &rc) ; + + HDC hdc = GetDC( hWnd) ; + + HGDIOBJ hPen = CreatePen( PS_SOLID, 1, RGB( 255,0,0)) ; + HGDIOBJ hPenOld = SelectObject( hdc, hPen) ; + + MoveToEx( hdc, nX - nDim, nY, (LPPOINT) NULL) ; + LineTo( hdc, nX + nDim, nY); + MoveToEx( hdc, nX, nY - nDim, (LPPOINT) NULL) ; + LineTo( hdc, nX, nY + nDim); + + SelectObject( hdc, hPenOld) ; + DeleteObject( hPen) ; + + ReleaseDC( hWnd, hdc) ; + + return 1 ; +} diff --git a/EgtInterface.rc b/EgtInterface.rc new file mode 100644 index 0000000000000000000000000000000000000000..02f1ae565c02f5500c511b424d7f6320f984e1e1 GIT binary patch literal 11526 zcmeI2ZBOGy5Xa|rrG5uD+zU>vfN*zJ`|=<_QNx2sf?5d)!9lo4X+R`McTzuld%yo~ z2HU{_l0(QKD{|Ie@6OJ{e`a>Q`~QE-wrq**SkFG$wO!hft7{|b4yha3jh$GZr*-?8 zUt$+_ZUe4s>PM7k)Lm1m-wk)4xKDTzwVqwkX32iE9~fmhlnc}jc-yD-S!i3k(|^f6 zTP?I!&xO#g8~Ta%N87iSwXI_f+qOMBwgcOsw!!_bHSKR|TKw0^WXRjx^kJZys#to~)(FR%adY0No_ z=(s^wLQ)sG=fj3;-szUBbnX%?J;49^$T|!NSOnXn;DwBj1==mztx*&EOtv`YZS-i@OS!D&+&Fh$DxNB84zbTAmhyU)x)c|M z;D}_!NX1s!WHQ>x-w(0QpJ=jik4<(%JXo`LM1*LE`Nt54hv@y7{|zkM3Xyl0XK}L$ zH*erIKcXbgw)K`#+H-I$6hBP)Av*GY=}wdqc-aO!8xvzERtH-jxPIfRkK67e$sStj zfb#a#9xL=%nV`NI@VSK^cCb(jTO_pkg08!~i4uw@k4y5P4N%Dwk2bE=YL#eNSGo${Zjl=iugqPIH4 zj>@6ZL5&fVYp;l{1N#cDPk1_~Uh%0$n+t0CVCI~e%xCI`%yO=|`dr0a6p!P&Xh11D zXNoZ*JKhKl5744wNSD#$JnMjG<%5&pOG)tc#7@z0oWW%y&OChOW0vz%N6HV#U7tzT zl>b4{UXfOdq+G&_`ut|$zllzwjbzCyY$)_y!1D+?(TaE9B*d`w5K&h_Qyp~8GUncR z453`;aNFu>5MMHn72Wf9Ec4&?zBh|! z*Wa%(gU^y_USj5MRGIq~tiRK2?!KaYtt9;x!N8(WTvW3o@^w~Yp zUdkmki@CZooIKfPU-skpi;JHkDLQ!)+v((qPMQ>*Jju6kJH=BJJ|}tTe1_}Jby=>` zx$|<`sWN}BQdb?zPdk66_r<&T#V7raZg=j}y*1I$ckp?}C^}(S1Fw_k+iG^ip5PHU z&gVzf`&oiKNAKq3Xx4GEJB#^P_!zWFchf1%@4@9lZk8KKoV}ulYHxPhslfahD)r6M lE7!eq=jHdF4;6~J7*}S}`IpCf%Qy81lqLWG literal 0 HcmV?d00001 diff --git a/EgtInterface.sln b/EgtInterface.sln new file mode 100644 index 0000000..351d7a8 --- /dev/null +++ b/EgtInterface.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EgtInterface", "EgtInterface.vcxproj", "{DF654897-F85B-4108-A621-F2C4AB099A48}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DF654897-F85B-4108-A621-F2C4AB099A48}.Debug|Win32.ActiveCfg = Debug|Win32 + {DF654897-F85B-4108-A621-F2C4AB099A48}.Debug|Win32.Build.0 = Debug|Win32 + {DF654897-F85B-4108-A621-F2C4AB099A48}.Debug|x64.ActiveCfg = Debug|x64 + {DF654897-F85B-4108-A621-F2C4AB099A48}.Debug|x64.Build.0 = Debug|x64 + {DF654897-F85B-4108-A621-F2C4AB099A48}.Release|Win32.ActiveCfg = Release|Win32 + {DF654897-F85B-4108-A621-F2C4AB099A48}.Release|Win32.Build.0 = Release|Win32 + {DF654897-F85B-4108-A621-F2C4AB099A48}.Release|x64.ActiveCfg = Release|x64 + {DF654897-F85B-4108-A621-F2C4AB099A48}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/EgtInterface.vcxproj b/EgtInterface.vcxproj new file mode 100644 index 0000000..6bacb77 --- /dev/null +++ b/EgtInterface.vcxproj @@ -0,0 +1,205 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {DF654897-F85B-4108-A621-F2C4AB099A48} + Win32Proj + EgtInterface + + + + DynamicLibrary + true + Unicode + + + DynamicLibrary + true + Unicode + + + DynamicLibrary + false + true + Unicode + + + DynamicLibrary + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)$(Configuration)$(PlatformArchitecture)\ + $(Configuration)$(PlatformArchitecture)\ + $(ProjectName)D$(PlatformArchitecture) + + + true + $(SolutionDir)$(Configuration)$(PlatformArchitecture)\ + $(Configuration)$(PlatformArchitecture)\ + $(ProjectName)D$(PlatformArchitecture) + + + false + $(SolutionDir)$(Configuration)$(PlatformArchitecture)\ + $(Configuration)$(PlatformArchitecture)\ + $(ProjectName)R$(PlatformArchitecture) + + + false + $(SolutionDir)$(Configuration)$(PlatformArchitecture)\ + $(Configuration)$(PlatformArchitecture)\ + $(ProjectName)R$(PlatformArchitecture) + + + + Use + Level3 + Disabled + WIN32;I_AM_EIN;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + + + Windows + true + $(OutDir)$(TargetName)$(TargetExt) + + + copy $(TargetDir)$(TargetName).pdb \EgtDev\Lib\ +copy $(TargetDir)$(TargetName).lib \EgtDev\Lib\ +copy $(TargetPath) \EgtProg\Dll32 + + + _UNICODE;UNICODE;_DEB32;%(PreprocessorDefinitions) + + + + + Use + Level3 + Disabled + WIN32;I_AM_EIN;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + + + Windows + true + $(OutDir)$(TargetName)$(TargetExt) + + + copy $(TargetDir)$(TargetName).pdb \EgtDev\Lib\ +copy $(TargetDir)$(TargetName).lib \EgtDev\Lib\ +copy $(TargetPath) \EgtProg\Dll64 + + + _UNICODE;UNICODE;_DEB64;%(PreprocessorDefinitions) + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;I_AM_EIN;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + Speed + AnySuitable + + + Windows + true + true + true + $(OutDir)$(TargetName)$(TargetExt) + + + copy $(TargetDir)$(TargetName).lib \EgtDev\Lib\ +copy $(TargetPath) \EgtProg\Dll32 + + + _UNICODE;UNICODE;NDEB32;%(PreprocessorDefinitions) + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;I_AM_EIN;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + Speed + AnySuitable + + + Windows + true + true + true + $(OutDir)$(TargetName)$(TargetExt) + + + copy $(TargetDir)$(TargetName).lib \EgtDev\Lib\ +copy $(TargetPath) \EgtProg\Dll64 + + + _UNICODE;UNICODE;NDEB64;%(PreprocessorDefinitions) + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + \ No newline at end of file diff --git a/EgtInterface.vcxproj.filters b/EgtInterface.vcxproj.filters new file mode 100644 index 0000000..5f06da0 --- /dev/null +++ b/EgtInterface.vcxproj.filters @@ -0,0 +1,47 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + + + File di origine + + + File di origine + + + File di origine + + + File di origine + + + + + File di risorse + + + \ No newline at end of file diff --git a/Interface.cpp b/Interface.cpp new file mode 100644 index 0000000..319e672 --- /dev/null +++ b/Interface.cpp @@ -0,0 +1,503 @@ +// Interface.cpp: definisce le funzioni esportate per l'applicazione DLL. +// + +#include "stdafx.h" +#include "/EgtDev/Include/EInAPI.h" +#include "/EgtDev/Include/EInDllMain.h" +#include "/EgtDev/Include/EGkDllMain.h" +#include "/EgtDev/Include/ENkDllMain.h" +#include "/EgtDev/Include/EGnDllMain.h" +#include "/EgtDev/Include/EExDllMain.h" +#include "/EgtDev/Include/EGrDllMain.h" +#include "/EgtDev/Include/EGkGeomDB.h" +#include "/EgtDev/Include/EExImportStl.h" +#include "/EgtDev/Include/EExImportDxf.h" +#include "/EgtDev/Include/EExExportStl.h" +#include "/EgtDev/Include/EExExportDxf.h" +#include "/EgtDev/Include/EGrScene.h" +#include "/EgtDev/Include/EGnStringUtils.h" +#include "/EgtDev/Include/EGnStringConverter.h" +#include "/EgtDev/Include/EgtLogger.h" +#include "/EgtDev/Include/EgtPointerOwner.h" +#include + +using namespace std ; +using namespace egtlogger ; + + +//----------------------------------------------------------------------------- +static Logger* s_pLogGen = nullptr ; +static IGeomDB* s_pGeomDB = nullptr ; +static HWND s_hWnd = nullptr ; +static IEGrScene* s_pScene = nullptr ; +static Color s_colDef = BLACK ; + +//----------------------------------------------------------------------------- +int +__stdcall EgtSetLog( int nDebug, const wchar_t* sLogFile) +{ + // creo il logger generale + s_pLogGen = new Logger( ( nDebug > 0 ? LL_DEBUG : LL_INFO), "EgtInterface") ; + if ( s_pLogGen == nullptr) + return 0 ; + // assegno il file + s_pLogGen->AddOutputStream( new ofstream( sLogFile), true) ; + // lo passo alle DLL + SetEGnLogger( s_pLogGen) ; + SetENkLogger( s_pLogGen) ; + SetEGkLogger( s_pLogGen) ; + SetEExLogger( s_pLogGen) ; + SetEGrLogger( s_pLogGen) ; + + return 1 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtSetFont( const wchar_t* sNfeFontDir, const wchar_t* sDefaultFont) +{ + // inizializzazioni gestore font Nfe + InitFontManager( LPSTR( WtoA( sNfeFontDir)), LPSTR( WtoA( sDefaultFont))) ; + return 1 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtInit( HWND hWnd, int nDriver, int b2Buff, int nColorBits, int nDepthBits) +{ + // inizio programma + LOG_DATETIME( s_pLogGen, " Init") + // versione dell'interfaccia + LOG_INFO( s_pLogGen, GetEInVersion()) + // versione delle librerie + LOG_INFO( s_pLogGen, GetEGnVersion()) + LOG_INFO( s_pLogGen, GetENkVersion()) + LOG_INFO( s_pLogGen, GetEGkVersion()) + LOG_INFO( s_pLogGen, GetEExVersion()) + LOG_INFO( s_pLogGen, GetEGrVersion()) + + // inizializzazioni DB geometrico + s_pGeomDB = CreateGeomDB() ; + if ( s_pGeomDB == nullptr) + return 0 ; + s_pGeomDB->Init() ; + s_pGeomDB->SetDefaultMaterial( s_colDef) ; + + // inizializzazione scena OpenGL + s_pScene = CreateEGrScene() ; + if ( s_pScene == nullptr) + return 0 ; + s_hWnd = hWnd ; + HDC hdc = GetDC( hWnd) ; + if ( ! s_pScene->CreateContext( hdc, nDriver, ( b2Buff != 0), nColorBits, nDepthBits)) + return 0 ; + s_pScene->SetBackground( WHITE, WHITE) ; + s_pScene->SetShowMode( SM_SHADING) ; + s_pScene->SetShowCurveDirection( false) ; + s_pScene->SetCamera( CT_TOP) ; + s_pScene->ZoomAll() ; + s_pScene->SetWinRectAttribs( true, BLACK) ; + s_pScene->SetMark( YELLOW) ; + s_pScene->Init( s_pGeomDB) ; + // log con info sulla scena + string sSceneInfo = s_pScene->GetOpenGLInfo() + '\n' + + s_pScene->GetGLSLInfo() + '\n' + + s_pScene->GetPixelFormatInfo() ; + LOG_INFO( s_pLogGen, sSceneInfo.c_str()) + + return 1 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtExit( void) +{ + // fine programma + LOG_DATETIME( s_pLogGen, " Exit") + + // scena + if ( s_pScene != nullptr) { + s_pScene->Destroy() ; + delete s_pScene ; + s_pScene = nullptr ; + } + s_hWnd = nullptr ; + // geomDB + if ( s_pGeomDB != nullptr) { + delete s_pGeomDB ; + s_pGeomDB = nullptr ; + } + // logger + if ( s_pLogGen != nullptr) { + delete s_pLogGen ; + s_pLogGen = nullptr ; + } + + return 1 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtSetDefaultMaterial( int nRed, int nGreen, int nBlue) +{ + // verifico GeomDB + if ( s_pGeomDB == nullptr) { + LOG_ERROR( s_pLogGen, "GeomDB invalid (EgtSetDefaultMaterial)") + return 0 ; + } + // imposto il materiale di default + s_colDef.Set( nRed, nGreen, nBlue) ; + s_pGeomDB->SetDefaultMaterial( s_colDef) ; + return 1 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtSetBackground( int nTopRed, int nTopGreen, int nTopBlue, + int nBottomRed, int nBottomGreen, int nBottomBlue) +{ + // verifico GeomDB + if ( s_pGeomDB == nullptr) { + LOG_ERROR( s_pLogGen, "GeomDB invalid (EgtSetDefaultMaterial)") + return 0 ; + } + // imposto lo sfondo + s_pScene->SetBackground( Color( nTopRed, nTopGreen, nTopBlue), Color( nBottomRed, nBottomGreen, nBottomBlue)) ; + return 1 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtNewFile( void) +{ + // verifico GeomDB + if ( s_pGeomDB == nullptr) { + LOG_ERROR( s_pLogGen, "GeomDB invalid (EgtNewFile)") + return 0 ; + } + // reinizializzazione (con pulizia) del DB geometrico + s_pGeomDB->Init() ; + s_pGeomDB->SetDefaultMaterial( s_colDef) ; + return 1 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtOpenFile( const wchar_t* sFilePath) +{ + // reinizializzazione (con pulizia) del DB geometrico + if ( ! EgtNewFile()) + return 0 ; + // carico il file + if ( s_pGeomDB->Load( LPSTR( WtoA( sFilePath)))) + return 1 ; + else + return 0 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtTestImportExt( const wchar_t* sFilePath) +{ + // divido in nome e direttorio + string sFileDir, sFileName ; + SplitLast( LPSTR( WtoA( sFilePath)), "\\", sFileDir, sFileName) ; + + // recupero l'estensione + string sFileTitle, sFileExt ; + SplitLast( sFileName, ".", sFileTitle, sFileExt) ; + ToUpper( sFileExt) ; + + if ( sFileExt == "DXF") + return 1 ; + else if ( sFileExt == "STL") + return 2 ; + else { + // emetto info + string sInfo = "File type (" + sFileExt + ") not recognized" ; + LOG_INFO( s_pLogGen, sInfo.c_str()) + return 0 ; + } +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtImportDxf( const wchar_t* sFilePath) +{ + // verifico GeomDB + if ( s_pGeomDB == nullptr) { + LOG_ERROR( s_pLogGen, "GeomDB invalid (ImportFile)") + return 0 ; + } + // importo il file DXF + // aggiungo un gruppo pezzo + int nPartId = s_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; + // preparo l'importatore + PtrOwner pImpDxf( CreateImportDxf()) ; + if ( IsNull( pImpDxf)) { + LOG_ERROR( s_pLogGen, "Error : CreateImportDxf") + return 0 ; + } + // eseguo l'importazione + if ( pImpDxf->Import( LPSTR( WtoA( sFilePath)), s_pGeomDB, nPartId)) + return 1 ; + else + return 0 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtImportStl( const wchar_t* sFilePath) +{ + // verifico GeomDB + if ( s_pGeomDB == nullptr) { + LOG_ERROR( s_pLogGen, "GeomDB invalid (EgtImportStl)") + return 0 ; + } + // importo il file STL + // aggiungo un gruppo pezzo e un gruppo layer + int nPartId = s_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; + int nLayerId = s_pGeomDB->AddGroup( GDB_ID_NULL, nPartId, Frame3d()) ; + // preparo l'importatore + PtrOwner pImpStl( CreateImportStl()) ; + if ( IsNull( pImpStl)) { + LOG_ERROR( s_pLogGen, "Error : CreateImportStl") + return 0 ; + } + // eseguo l'importazione + if ( pImpStl->Import( LPSTR( WtoA( sFilePath)), s_pGeomDB, nLayerId)) + return 1 ; + else + return 0 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtDraw( void) +{ + // verifico Scena + if ( s_pScene == nullptr) { + LOG_ERROR( s_pLogGen, "Scene invalid (EgtDraw)") + return 0 ; + } + // eseguo disegno + s_pScene->Draw() ; + // valido la finestra disegnata + ValidateRgn( s_hWnd, NULL) ; + + return 1 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtResize( int nW, int nH) +{ + // verifico Scena + if ( s_pScene == nullptr) { + LOG_ERROR( s_pLogGen, "Scene invalid (EgtResize)") + return 0 ; + } + + s_pScene->Resize( nW, nH) ; + return 1 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtSetShowMode( int nShowMode) +{ + // verifico Scena + if ( s_pScene == nullptr) { + LOG_ERROR( s_pLogGen, "Scene invalid (EgtSetShowMode)") + return 0 ; + } + + if ( nShowMode >= SM_WIREFRAME && nShowMode <= SM_SHADING) { + s_pScene->SetShowMode( nShowMode) ; + return 1 ; + } + else + return 0 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtSetShowCurveDirection( int nShow) +{ + // verifico Scena + if ( s_pScene == nullptr) { + LOG_ERROR( s_pLogGen, "Scene invalid (EgtZoom)") + return 0 ; + } + + s_pScene->SetShowCurveDirection( nShow != 0) ; + return 1 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtZoom( int nZoom) +{ + // verifico Scena + if ( s_pScene == nullptr) { + LOG_ERROR( s_pLogGen, "Scene invalid (EgtZoom)") + return 0 ; + } + + const double COEFF_IN = 0.9 ; + const double COEFF_OUT = 1 / COEFF_IN ; + + switch ( nZoom) { + case 1 : + s_pScene->ZoomAll() ; + return 1 ; + break ; + case 2 : + s_pScene->ZoomChange( COEFF_IN) ; + return 1 ; + break ; + case 3 : + s_pScene->ZoomChange( COEFF_OUT) ; + return 1 ; + break ; + } + + return 0 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtZoomOnPoint( int nWinX, int nWinY, double dCoeff) +{ + // verifico Scena + if ( s_pScene == nullptr) { + LOG_ERROR( s_pLogGen, "Scene invalid (EgtZoomOnPoint)") + return 0 ; + } + + s_pScene->ZoomOnPoint( Point3d( nWinX, nWinY), dCoeff) ; + return 1 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtSetWinRect( int nPrevX, int nPrevY, int nCurrX, int nCurrY) +{ + // verifico Scena + if ( s_pScene == nullptr) { + LOG_ERROR( s_pLogGen, "Scene invalid (EgtSetWinRect)") + return 0 ; + } + // eseguo panoramica + s_pScene->SetWinRect( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ; + return 1 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtResetWinRect( void) +{ + // verifico Scena + if ( s_pScene == nullptr) { + LOG_ERROR( s_pLogGen, "Scene invalid (EgtResetWinRect)") + return 0 ; + } + // eseguo panoramica + s_pScene->ResetWinRect() ; + return 1 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtZoomWin( int nPrevX, int nPrevY, int nCurrX, int nCurrY) +{ + // verifico Scena + if ( s_pScene == nullptr) { + LOG_ERROR( s_pLogGen, "Scene invalid (EgtZoomWin)") + return 0 ; + } + // eseguo panoramica + s_pScene->ZoomWin( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ; + return 1 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtSetView( int nView) +{ + // verifico Scena + if ( s_pScene == nullptr) { + LOG_ERROR( s_pLogGen, "Scene invalid (EgtSetView)") + return 0 ; + } + + if ( nView >= CT_TOP && nView <= CT_ISO_NW) { + s_pScene->SetCamera( nView) ; + return 1 ; + } + else + return 0 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtPanCamera( int nPrevX, int nPrevY, int nCurrX, int nCurrY) +{ + // verifico Scena + if ( s_pScene == nullptr) { + LOG_ERROR( s_pLogGen, "Scene invalid (EgtPanCamera)") + return 0 ; + } + // eseguo panoramica + s_pScene->PanCamera( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ; + return 1 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtRotateCamera( int nPrevX, int nPrevY, int nCurrX, int nCurrY) +{ + // verifico Scena + if ( s_pScene == nullptr) { + LOG_ERROR( s_pLogGen, "Scene invalid (EgtRotateCamera)") + return 0 ; + } + // eseguo panoramica + s_pScene->RotateCamera( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ; + return 1 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtGetCameraDir( int* pnDir) +{ + // verifico Scena + if ( s_pScene == nullptr) { + LOG_ERROR( s_pLogGen, "Scene invalid (EgtGetCameraDir)") + return 0 ; + } + // recupero direzione di vista + if ( pnDir != nullptr) + *pnDir = s_pScene->GetCameraDir() ; + return 1 ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtUnProject( int nWinX, int nWinY, double ptP[3]) +{ + // verifico Scena + if ( s_pScene == nullptr) { + LOG_ERROR( s_pLogGen, "Scene invalid (EgtGetCameraDir)") + return 0 ; + } + // eseguo l'inverso della proiezione (considero Z punto su centro) + Point3d ptView( nWinX, nWinY, s_pScene->GetProjectedCenter().z) ; + Point3d ptWorld ; + if ( ! s_pScene->UnProject( ptView, ptWorld)) + return 0 ; + ptP[0] = ptWorld.x ; + ptP[1] = ptWorld.y ; + ptP[2] = ptWorld.z ; + return 1 ; +} \ No newline at end of file diff --git a/resource.h b/resource.h new file mode 100644 index 0000000000000000000000000000000000000000..067126829ada991e02f99eb4f3bb653c296692ec GIT binary patch literal 994 zcmb7@+e*Vg5QhJ2!FO2jQm|Hhf!anWwy7i<^eXfesgxFy#slK3tKV!|X`!T)VKWD2 z{+;<}^ZV0KLtjX!fl_r8=$;dLD^y!uyjb7JsZPjk$f>WH#>%x+!O65DmJlmcYN$D0 zTjz+=i>6v|a^frWgxHM8n5+_Sik}ggV_j_B@Ca6wJ<=yR0Z1!)S$LG3njsiglcP7C znLhKVhH3X&UomqfAVgSQrVR1Bd~dPcL1}vQ<4~IiQLjAerf)|#Q+;?IjT4)$gcIZS z%`;jOE$}k<&e1m8J9?>+Ua`mI7XLiBbMD?FzbdyVy=M>cCLR2(E&cW~3$s#w(2 zMC7)}HWqt&1|{a(*A0;#_P!0I>$_8G0zJ_~$}a3x4d^D~tpr38vU>OdQ|(Gqm)gID zeaLN4`$&u1I<>e?*C3l5haNIP +#include +#include +#include + +// in Debug riconoscimento memory leakage +#if defined( _DEBUG) + #define _CRTDBG_MAP_ALLOC + #include + #include +#endif + +// in Debug controllo iteratori +#if defined( _DEBUG) + #define _SECURE_SCL 1 +#else + #define _SECURE_SCL 0 +#endif + +#include "/EgtDev/Include/EgtLibVer.h" + +#pragma comment(lib, EGTLIBDIR "EgtGeneral" EGTLIBVER ".lib") +#pragma comment(lib, EGTLIBDIR "EgtNumKernel" EGTLIBVER ".lib") +#pragma comment(lib, EGTLIBDIR "EgtGeomKernel" EGTLIBVER ".lib") +#pragma comment(lib, EGTLIBDIR "EgtExchange" EGTLIBVER ".lib") +#pragma comment(lib, EGTLIBDIR "EgtGraphics" EGTLIBVER ".lib")