diff --git a/LUA_GeoSnap.cpp b/LUA_GeoSnap.cpp index f97df92..b68e29d 100644 --- a/LUA_GeoSnap.cpp +++ b/LUA_GeoSnap.cpp @@ -866,6 +866,41 @@ LuaSurfTmFacetsContact( lua_State* L) return 4 ; } +//---------------------------------------------------------------------------- +static int +LuaSurfTmLineInters( lua_State* L) +{ + // 3 o 4 parametri : Id, ptP, vtDir [, nRefId] + int nId ; + LuaCheckParam( L, 1, nId) + Point3d ptP ; + LuaCheckParam( L, 2, ptP) + Vector3d vtDir ; + LuaCheckParam( L, 3, vtDir) + int nRefType = nId ; + LuaGetParam( L, 4, nRefType) ; + LuaClearStack( L) ; + // recupero i punti di intersezione tra linea e superficie trimesh + INTDBLVECTOR vInters ; + if ( ExeSurfTmLineInters( nId, ptP, vtDir, nRefType, vInters)) { + LuaSetParam( L, true) ; + INTVECTOR vType( vInters.size()) ; + DBLVECTOR vPar( vInters.size()) ; + for ( size_t i = 0 ; i < vInters.size() ; ++ i) { + vType[i] = vInters[i].first ; + vPar[i] = vInters[i].second ; + } + LuaSetParam( L, vType) ; + LuaSetParam( L, vPar) ; + } + else { + LuaSetParam( L) ; + LuaSetParam( L) ; + LuaSetParam( L) ; + } + return 3 ; +} + //---------------------------------------------------------------------------- static int LuaVolZmapVolume( lua_State* L) @@ -1019,6 +1054,7 @@ LuaInstallGeoSnap( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetNormVersor", LuaSurfTmFacetNormVersor) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetOppositeSide", LuaSurfTmFacetOppositeSide) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetsContact", LuaSurfTmFacetsContact) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmLineInters", LuaSurfTmLineInters) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapVolume", LuaVolZmapVolume) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapPartCount", LuaVolZmapPartCount) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapPartVolume", LuaVolZmapPartVolume) ;