EgtExecutor :
- aggiunte funzioni Exe e Lua TestBoxSurface, TestRectPrismoidSurface, TestCylSurface, TestConeSurface, TestSpheSurface, TestSurfaceSurface.
This commit is contained in:
+2
-2
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2020-2020
|
||||
//----------------------------------------------------------------------------
|
||||
// File : EXE_CDeObjClosedSurfTm.cpp Data : 09.01.20 Versione : 2.2a2
|
||||
// File : EXE_CDeObjSolid.cpp Data : 09.01.20 Versione : 2.2a2
|
||||
// Contenuto : Funzioni per verificare collisioni tra
|
||||
// Objects e Closed SurftriMesh.
|
||||
// Objects e Solidi (Closed SurftriMesh e Zmap).
|
||||
//
|
||||
//
|
||||
// Modifiche : 09.01.20 DS Creazione modulo.
|
||||
|
||||
@@ -0,0 +1,316 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2024-2024
|
||||
//----------------------------------------------------------------------------
|
||||
// File : EXE_TestObjSurface.cpp Data : 24.03.24 Versione : 2.6c2
|
||||
// Contenuto : Funzioni per verificare collisioni tra
|
||||
// Objects e Superfici (TriMesh).
|
||||
//
|
||||
//
|
||||
// Modifiche : 09.01.20 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "EXE.h"
|
||||
#include "EXE_Macro.h"
|
||||
#include "EXE_Const.h"
|
||||
#include "AuxTools.h"
|
||||
#include "GeoTools.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EXeConst.h"
|
||||
#include "/EgtDev/Include/EGkCDeBoxClosedSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkCDeRectPrismoidClosedSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkCDeCylClosedSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkCDeConeFrustumClosedSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkCDeSpheClosedSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkCDeClosedSurfTmClosedSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkSurfLocal.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
MyTestBoxSurfTm( const Frame3d& frBox, const Vector3d& vtDiag, int nSurfTmId, double dSafeDist, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, -1)
|
||||
// recupero la superficie TriMesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nSurfTmId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return -1 ;
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nSurfTmId, frSurf))
|
||||
return -1 ;
|
||||
// porto in locale alla superficie il riferimento del box (il vettore è già in questo stesso riferimento)
|
||||
Frame3d frBoxL = GetFrameLocal( pGeomDB, frBox, nRefType, frSurf) ;
|
||||
// verifico l'a collisione'interferenza
|
||||
return ( TestBoxSurfTm( frBoxL, vtDiag, *pStm, dSafeDist) ? 1 : 0) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeTestBoxSurface( const Frame3d& frBox, const Vector3d& vtDiag, int nSurfId, double dSafeDist, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
int nRes = -1 ;
|
||||
if ( pGeomDB != nullptr && pGeomDB->GetGeoType( nSurfId) == SRF_TRIMESH)
|
||||
nRes = MyTestBoxSurfTm( frBox, vtDiag, nSurfId, dSafeDist, nRefType) ;
|
||||
// è da aggiungere il test con le superfici di Bezier
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtTestBoxSurface({{" + ToString( frBox.Orig()) + "},{" +
|
||||
ToString( frBox.VersX()) + "},{" +
|
||||
ToString( frBox.VersY()) + "},{" +
|
||||
ToString( frBox.VersZ()) + "}},{" +
|
||||
ToString( vtDiag) + "}," +
|
||||
IdToString( nSurfId) + "," +
|
||||
ToString( dSafeDist) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Res=" + ToString( nRes) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultato
|
||||
return nRes ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
MyTestRectPrismoidSurfTm( const Frame3d& frPrismoid, double dBaseLenX, double dBaseLenY,
|
||||
double dTopLenX, double dTopLenY, double dHeight,
|
||||
int nSurfTmId, double dSafeDist, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, -1)
|
||||
// recupero la superficie TriMesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nSurfTmId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return -1 ;
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nSurfTmId, frSurf))
|
||||
return -1 ;
|
||||
// porto in locale alla superficie il riferimento del prismoide rettangolare
|
||||
Frame3d frPrismoidL = GetFrameLocal( pGeomDB, frPrismoid, nRefType, frSurf) ;
|
||||
// verifico l'a collisione'interferenza
|
||||
return ( TestRectPrismoidSurfTm( frPrismoidL, dBaseLenX, dBaseLenY, dTopLenX, dTopLenY, dHeight, *pStm, dSafeDist) ? 1 : 0) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeTestRectPrismoidSurface( const Frame3d& frPrismoid, double dBaseLenX, double dBaseLenY,
|
||||
double dTopLenX, double dTopLenY, double dHeight,
|
||||
int nSurfId, double dSafeDist, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
int nRes = -1 ;
|
||||
if ( pGeomDB != nullptr && pGeomDB->GetGeoType( nSurfId) == SRF_TRIMESH)
|
||||
nRes = MyTestRectPrismoidSurfTm( frPrismoid, dBaseLenX, dBaseLenY, dTopLenX, dTopLenY, dHeight, nSurfId, dSafeDist, nRefType) ;
|
||||
// è da aggiungere il test con le superfici di Bezier
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtTestRectPrismoidSurface({{" + ToString( frPrismoid.Orig()) + "},{" +
|
||||
ToString( frPrismoid.VersX()) + "},{" +
|
||||
ToString( frPrismoid.VersY()) + "},{" +
|
||||
ToString( frPrismoid.VersZ()) + "}}," +
|
||||
ToString( dBaseLenX) + "," +
|
||||
ToString( dBaseLenY) + "," +
|
||||
ToString( dTopLenX) + "," +
|
||||
ToString( dTopLenY) + "," +
|
||||
ToString( dHeight) + "," +
|
||||
IdToString( nSurfId) + "," +
|
||||
ToString( dSafeDist) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Res=" + ToString( nRes) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultato
|
||||
return nRes ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
MyTestCylSurfTm( const Frame3d& frCyl, double dR, double dH, int nSurfTmId, double dSafeDist, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, -1)
|
||||
// recupero la superficie TriMesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nSurfTmId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return -1 ;
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nSurfTmId, frSurf))
|
||||
return -1 ;
|
||||
// porto in locale alla superficie il riferimento del cilindro
|
||||
Frame3d frCylL = GetFrameLocal( pGeomDB, frCyl, nRefType, frSurf) ;
|
||||
// verifico l'interferenza
|
||||
return ( TestCylSurfTm( frCylL, dR, dH, *pStm, dSafeDist) ? 1 : 0) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeTestCylSurface( const Frame3d& frCyl, double dR, double dH, int nSurfId, double dSafeDist, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
int nRes = -1 ;
|
||||
if ( pGeomDB != nullptr && pGeomDB->GetGeoType( nSurfId) == SRF_TRIMESH)
|
||||
nRes = MyTestCylSurfTm( frCyl, dR, dH, nSurfId, dSafeDist, nRefType) ;
|
||||
// è da aggiungere il test con le superfici di Bezier
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtTestCylSurface({{" + ToString( frCyl.Orig()) + "},{" +
|
||||
ToString( frCyl.VersX()) + "},{" +
|
||||
ToString( frCyl.VersY()) + "},{" +
|
||||
ToString( frCyl.VersZ()) + "}}," +
|
||||
ToString( dR) + "," +
|
||||
ToString( dH) + "," +
|
||||
IdToString( nSurfId) + "," +
|
||||
ToString( dSafeDist) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Res=" + ToString( nRes) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultato
|
||||
return nRes ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
MyTestConeSurfTm( const Frame3d& frCone, double dR1, double dR2, double dH, int nSurfTmId, double dSafeDist, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, -1)
|
||||
// recupero la superficie TriMesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nSurfTmId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return -1 ;
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nSurfTmId, frSurf))
|
||||
return -1 ;
|
||||
// porto in locale alla superficie il riferimento del cilindro
|
||||
Frame3d frConeL = GetFrameLocal( pGeomDB, frCone, nRefType, frSurf) ;
|
||||
// verifico l'interferenza
|
||||
return ( TestConeFrustumSurfTm( frConeL, dR1, dR2, dH, *pStm, dSafeDist) ? 1 : 0) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeTestConeSurface( const Frame3d& frCone, double dR1, double dR2, double dH, int nSurfId, double dSafeDist, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
int nRes = -1 ;
|
||||
if ( pGeomDB != nullptr && pGeomDB->GetGeoType( nSurfId) == SRF_TRIMESH)
|
||||
nRes = MyTestConeSurfTm( frCone, dR1, dR2, dH, nSurfId, dSafeDist, nRefType) ;
|
||||
// è da aggiungere il test con le superfici di Bezier
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtTestConeSurface({{" + ToString( frCone.Orig()) + "},{" +
|
||||
ToString( frCone.VersX()) + "},{" +
|
||||
ToString( frCone.VersY()) + "},{" +
|
||||
ToString( frCone.VersZ()) + "}}," +
|
||||
ToString( dR1) + "," +
|
||||
ToString( dR2) + "," +
|
||||
ToString( dH) + "," +
|
||||
IdToString( nSurfId) + "," +
|
||||
ToString( dSafeDist) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Res=" + ToString( nRes) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultato
|
||||
return nRes ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
MyTestSpheSurfTm( const Point3d& ptCen, double dR, int nSurfTmId, double dSafeDist, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, -1)
|
||||
// recupero la superficie TriMesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nSurfTmId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return -1 ;
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nSurfTmId, frSurf))
|
||||
return -1 ;
|
||||
// porto in locale alla superficie il centro della sfera
|
||||
Point3d ptCenL = GetPointLocal( pGeomDB, ptCen, nRefType, frSurf) ;
|
||||
// verifico l'a collisione'interferenza
|
||||
return ( TestSpheSurfTm( ptCenL, dR, *pStm, dSafeDist) ? 1 : 0) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeTestSpheSurface( const Point3d& ptCen, double dR, int nSurfId, double dSafeDist, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
int nRes = -1 ;
|
||||
if ( pGeomDB != nullptr && pGeomDB->GetGeoType( nSurfId) == SRF_TRIMESH)
|
||||
nRes = MyTestSpheSurfTm( ptCen, dR, nSurfId, dSafeDist, nRefType) ;
|
||||
// è da aggiungere il test con le superfici di Bezier
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtTestSpheSurface({" + ToString( ptCen) + "}," +
|
||||
ToString( dR) + "," +
|
||||
IdToString( nSurfId) + "," +
|
||||
ToString( dSafeDist) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Res=" + ToString( nRes) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultato
|
||||
return nRes ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
MyTestSurfTmSurfTm( int nSurfTm1Id, int nSurfTm2Id, double dSafeDist)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, -1)
|
||||
// recupero il riferimento della seconda superficie
|
||||
Frame3d frSurf2 ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nSurfTm2Id, frSurf2))
|
||||
return -1 ;
|
||||
// recupero la prima superficie in locale alla seconda
|
||||
SurfLocal Surf1Loc( pGeomDB, nSurfTm1Id, frSurf2) ;
|
||||
const ISurfTriMesh* pStm1 = GetSurfTriMesh( Surf1Loc) ;
|
||||
if ( pStm1 == nullptr)
|
||||
return -1 ;
|
||||
// recupero la seconda superficie TriMesh
|
||||
const ISurfTriMesh* pStm2 = GetSurfTriMesh( pGeomDB->GetGeoObj( nSurfTm2Id)) ;
|
||||
if ( pStm2 == nullptr)
|
||||
return -1 ;
|
||||
// verifico l'a collisione'interferenza
|
||||
return ( TestSurfTmSurfTm( *pStm1, *pStm2, dSafeDist) ? 1 : 0) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeTestSurfaceSurface( int nSurf1Id, int nSurf2Id, double dSafeDist)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
int nRes = -1 ;
|
||||
if ( pGeomDB != nullptr) {
|
||||
if ( pGeomDB->GetGeoType( nSurf1Id) == SRF_TRIMESH && pGeomDB->GetGeoType( nSurf2Id) == SRF_TRIMESH)
|
||||
nRes = MyTestSurfTmSurfTm( nSurf1Id, nSurf2Id, dSafeDist) ;
|
||||
// è da aggiungere il test con le superfici di Bezier
|
||||
}
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtTestSurfaceSurface({" + IdToString( nSurf1Id) + "," +
|
||||
IdToString( nSurf2Id) + "," +
|
||||
ToString( dSafeDist) + ")" +
|
||||
" -- Res=" + ToString( nRes) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultato
|
||||
return nRes ;
|
||||
}
|
||||
@@ -293,6 +293,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="EXE_Picture.cpp" />
|
||||
<ClCompile Include="EXE_Scene.cpp" />
|
||||
<ClCompile Include="EXE_ShortestPath.cpp" />
|
||||
<ClCompile Include="EXE_TestObjSurface.cpp" />
|
||||
<ClCompile Include="EXE_TscExec.cpp" />
|
||||
<ClCompile Include="AuxTools.cpp" />
|
||||
<ClCompile Include="DllExchange.cpp" />
|
||||
@@ -316,6 +317,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="LUA_MaxFiller.cpp" />
|
||||
<ClCompile Include="LUA_Picture.cpp" />
|
||||
<ClCompile Include="LUA_PolynomialRoots.cpp" />
|
||||
<ClCompile Include="LUA_TestObjSurface.cpp" />
|
||||
<ClCompile Include="PictureObj.cpp" />
|
||||
<ClCompile Include="LUA_Base.cpp" />
|
||||
<ClCompile Include="LUA_GdbCreateCurve.cpp" />
|
||||
|
||||
@@ -401,6 +401,12 @@
|
||||
<ClCompile Include="LUA_GdbGetPocketing.cpp">
|
||||
<Filter>File di origine\LUA</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EXE_TestObjSurface.cpp">
|
||||
<Filter>File di origine\EXE</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LUA_TestObjSurface.cpp">
|
||||
<Filter>File di origine\LUA</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EgtExecutor.rc">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2015
|
||||
// EgalTech 2014-2024
|
||||
//----------------------------------------------------------------------------
|
||||
// File : LUA.h Data : 16.01.15 Versione : 1.6a3
|
||||
// File : LUA.h Data : 24.03.24 Versione : 2.6c2
|
||||
// Contenuto : Dichiarazioni locali per moduli LUA.
|
||||
//
|
||||
//
|
||||
@@ -93,6 +93,9 @@ bool LuaInstallGeoInters( LuaMgr& luaMgr) ;
|
||||
//-------------------------- Collision Detection -----------------------------
|
||||
bool LuaInstallCDeObjSolid( LuaMgr& luaMgr) ;
|
||||
|
||||
//-------------------------- Test Interference -------------------------------
|
||||
bool LuaInstallTestObjSurface( LuaMgr& luaMgr) ;
|
||||
|
||||
//-------------------------- MachMgr -----------------------------------------
|
||||
bool LuaInstallMachMgr( LuaMgr& luaMgr) ;
|
||||
|
||||
|
||||
@@ -130,6 +130,10 @@ LuaInstallEgtFunctions( LuaMgr& LuaMgr)
|
||||
LOG_ERROR( GetLogger(), "Error in LuaInstallCDeObjSolid (LuaInstallEgtFunctions)")
|
||||
return false ;
|
||||
}
|
||||
if ( ! LuaInstallTestObjSurface( LuaMgr)) {
|
||||
LOG_ERROR( GetLogger(), "Error in LuaInstallTestObjSurface (LuaInstallEgtFunctions)")
|
||||
return false ;
|
||||
}
|
||||
if ( ! LuaInstallMachMgr( LuaMgr)) {
|
||||
LOG_ERROR( GetLogger(), "Error in LuaInstallMachMgr (LuaInstallEgtFunctions)")
|
||||
return false ;
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2024-2024
|
||||
//----------------------------------------------------------------------------
|
||||
// File : LUA_TestObjSurface.cpp Data : 24.03.24 Versione : 2.6c2
|
||||
// Contenuto : Funzioni di verifica intersezione tra oggetti e superfici.
|
||||
// Oggetti = Box, Sfere, Cilindri, Coni, RectPrismoid, SurfTriMesh
|
||||
// Superfici = SurfTriMesh, ( Bezier).
|
||||
//
|
||||
// Modifiche : 24.03.24 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "LUA.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EXeConst.h"
|
||||
#include "/EgtDev/Include/EGkLuaAux.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTestBoxSurface( lua_State* L)
|
||||
{
|
||||
// 4 o 5 parametri : frBox, vtDiag, nSurfId, dSafeDist [, nRefType]
|
||||
Frame3d frBox ;
|
||||
LuaCheckParam( L, 1, frBox)
|
||||
Vector3d vtDiag ;
|
||||
LuaCheckParam( L, 2, vtDiag)
|
||||
int nSurfId ;
|
||||
LuaCheckParam( L, 3, nSurfId)
|
||||
double dSafeDist ;
|
||||
LuaCheckParam( L, 4, dSafeDist)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 5, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// eseguo verifica di collisione
|
||||
int nRes = ExeTestBoxSurface( frBox, vtDiag, nSurfId, dSafeDist, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( nRes >= 0)
|
||||
LuaSetParam( L, ( nRes != 0)) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTestRectPrismoidSurface( lua_State* L)
|
||||
{
|
||||
// 8 o 9 parametri : frBox, dBaseLenX, dBaseLenY, dTopLenX, dTopLenY, dHeight, nSurfId, dSafeDist [, nRefType]
|
||||
Frame3d frBox ;
|
||||
LuaCheckParam( L, 1, frBox)
|
||||
double dBaseLenX ;
|
||||
LuaCheckParam( L, 2, dBaseLenX)
|
||||
double dBaseLenY ;
|
||||
LuaCheckParam( L, 3, dBaseLenY)
|
||||
double dTopLenX ;
|
||||
LuaCheckParam( L, 4, dTopLenX)
|
||||
double dTopLenY ;
|
||||
LuaCheckParam( L, 5, dTopLenY)
|
||||
double dHeight ;
|
||||
LuaCheckParam( L, 6, dHeight)
|
||||
int nSurfId ;
|
||||
LuaCheckParam( L, 7, nSurfId)
|
||||
double dSafeDist ;
|
||||
LuaCheckParam( L, 8, dSafeDist)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 9, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// eseguo verifica di collisione
|
||||
int nRes = ExeTestRectPrismoidSurface( frBox, dBaseLenX, dBaseLenY, dTopLenX, dTopLenY, dHeight, nSurfId, dSafeDist, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( nRes >= 0)
|
||||
LuaSetParam( L, ( nRes != 0)) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTestCylSurface( lua_State* L)
|
||||
{
|
||||
// 5 o 6 parametri : frCyl, dR, dH, nSurfId, dSafeDist [, nRefType]
|
||||
Frame3d frCyl ;
|
||||
LuaCheckParam( L, 1, frCyl)
|
||||
double dR ;
|
||||
LuaCheckParam( L, 2, dR)
|
||||
double dH ;
|
||||
LuaCheckParam( L, 3, dH)
|
||||
int nSurfId ;
|
||||
LuaCheckParam( L, 4, nSurfId)
|
||||
double dSafeDist ;
|
||||
LuaCheckParam( L, 5, dSafeDist)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 6, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// eseguo verifica di collisione
|
||||
int nRes = ExeTestCylSurface( frCyl, dR, dH, nSurfId, dSafeDist, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( nRes >= 0)
|
||||
LuaSetParam( L, ( nRes != 0)) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTestConeSurface( lua_State* L)
|
||||
{
|
||||
// 6 o 7 parametri : frCone, dR1, dR2, dH, nSurfId, dSafeDist [, nRefType]
|
||||
Frame3d frCone ;
|
||||
LuaCheckParam( L, 1, frCone)
|
||||
double dR1 ;
|
||||
LuaCheckParam( L, 2, dR1)
|
||||
double dR2 ;
|
||||
LuaCheckParam( L, 3, dR2)
|
||||
double dH ;
|
||||
LuaCheckParam( L, 4, dH)
|
||||
int nSurfId ;
|
||||
LuaCheckParam( L, 5, nSurfId)
|
||||
double dSafeDist ;
|
||||
LuaCheckParam( L, 6, dSafeDist)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 7, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// eseguo verifica di collisione
|
||||
int nRes = ExeTestConeSurface( frCone, dR1, dR2, dH, nSurfId, dSafeDist, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( nRes >= 0)
|
||||
LuaSetParam( L, ( nRes != 0)) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTestSpheSurface( lua_State* L)
|
||||
{
|
||||
// 4 o 5 parametri : ptCen, dRad, nSurfId, dSafeDist [, nRefType]
|
||||
Point3d ptCen ;
|
||||
LuaCheckParam( L, 1, ptCen)
|
||||
double dR ;
|
||||
LuaCheckParam( L, 2, dR)
|
||||
int nSurfId ;
|
||||
LuaCheckParam( L, 3, nSurfId)
|
||||
double dSafeDist ;
|
||||
LuaCheckParam( L, 4, dSafeDist)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 5, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// eseguo verifica di collisione
|
||||
int nRes = ExeTestSpheSurface( ptCen, dR, nSurfId, dSafeDist, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( nRes >= 0)
|
||||
LuaSetParam( L, ( nRes != 0)) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTestSurfaceSurface( lua_State* L)
|
||||
{
|
||||
// 3 parametri : nSurf1Id, nSurf2Id, dSafeDist
|
||||
int nSurf1Id ;
|
||||
LuaCheckParam( L, 1, nSurf1Id)
|
||||
int nSurf2Id ;
|
||||
LuaCheckParam( L, 2, nSurf2Id)
|
||||
double dSafeDist ;
|
||||
LuaCheckParam( L, 3, dSafeDist)
|
||||
LuaClearStack( L) ;
|
||||
// eseguo verifica di interferenza
|
||||
int nRes = ExeTestSurfaceSurface( nSurf1Id, nSurf2Id, dSafeDist) ;
|
||||
// restituisco il risultato
|
||||
if ( nRes >= 0)
|
||||
LuaSetParam( L, ( nRes != 0)) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallTestObjSurface( LuaMgr& luaMgr)
|
||||
{
|
||||
bool bOk = ( &luaMgr != nullptr) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTestBoxSurface", LuaTestBoxSurface) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTestRectPrismoidSurface", LuaTestRectPrismoidSurface) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTestCylSurface", LuaTestCylSurface) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTestConeSurface", LuaTestConeSurface) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTestSpheSurface", LuaTestSpheSurface) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTestSurfaceSurface", LuaTestSurfaceSurface) ;
|
||||
return bOk ;
|
||||
}
|
||||
Reference in New Issue
Block a user